---------------------------------------------------------------- * DefineExternalRelation * Creates a new external relation. * * In here we first dispatch a normal DefineRelation() (with relstorage * external) in order to create the external relation entries in pg_class * pg_type etc. Then once this is done we dispatch ourselves (DefineExternalRelation) * in order to create the pg_foreign_tabl
| 73 | * ---------------------------------------------------------------- |
| 74 | */ |
| 75 | void |
| 76 | DefineExternalRelation(CreateExternalStmt *createExtStmt) |
| 77 | { |
| 78 | CreateForeignTableStmt *createForeignTableStmt; |
| 79 | CreateStmt *createStmt; |
| 80 | ExtTableTypeDesc *exttypeDesc = (ExtTableTypeDesc *) createExtStmt->exttypedesc; |
| 81 | SingleRowErrorDesc *singlerowerrorDesc = NULL; |
| 82 | DefElem *dencoding = NULL; |
| 83 | ListCell *option; |
| 84 | ObjectAddress objAddr; |
| 85 | Oid userid; |
| 86 | Oid reloid = 0; |
| 87 | List *formatOpts = NIL; |
| 88 | List *entryOptions = NIL; |
| 89 | char *locationUris = NULL; |
| 90 | char *locationExec = NULL; |
| 91 | char *commandString = NULL; |
| 92 | char rejectlimittype = '\0'; |
| 93 | char formattype; |
| 94 | int rejectlimit = -1; |
| 95 | int encoding = -1; |
| 96 | bool issreh = false; /* is single row error handling requested? */ |
| 97 | char logerrors = LOG_ERRORS_DISABLE; |
| 98 | bool log_persistent_option = false; |
| 99 | bool iswritable = createExtStmt->iswritable; |
| 100 | bool isweb = createExtStmt->isweb; |
| 101 | bool shouldDispatch = (Gp_role == GP_ROLE_DISPATCH && |
| 102 | IsNormalProcessingMode()); |
| 103 | |
| 104 | /* Identify user ID that will own the table */ |
| 105 | userid = GetUserId(); |
| 106 | |
| 107 | /* |
| 108 | * now set the parameters for keys/inheritance etc. Most of these are |
| 109 | * uninteresting for external relations... |
| 110 | */ |
| 111 | createForeignTableStmt = makeNode(CreateForeignTableStmt); |
| 112 | createStmt = &createForeignTableStmt->base; |
| 113 | createStmt->relation = createExtStmt->relation; |
| 114 | createStmt->tableElts = createExtStmt->tableElts; |
| 115 | createStmt->inhRelations = NIL; |
| 116 | createStmt->constraints = NIL; |
| 117 | createStmt->oncommit = ONCOMMIT_NOOP; |
| 118 | createStmt->tablespacename = NULL; |
| 119 | createStmt->distributedBy = createExtStmt->distributedBy; /* policy was set in transform */ |
| 120 | createStmt->ownerid = userid; |
| 121 | createStmt->tags = createExtStmt->tags; |
| 122 | createStmt->origin = ORIGIN_NO_GEN; |
| 123 | |
| 124 | switch (exttypeDesc->exttabletype) |
| 125 | { |
| 126 | case EXTTBL_TYPE_LOCATION: |
| 127 | /* Parse and validate URI strings (LOCATION clause) */ |
| 128 | locationExec = transformExecOnClause(exttypeDesc->on_clause); |
| 129 | locationUris = transformLocationUris(exttypeDesc->location_list, |
| 130 | isweb, iswritable); |
| 131 | break; |
| 132 |
no test coverage detected