---------------------------------------------------------------- * ExecInitModifyTable * ---------------------------------------------------------------- */
| 3122 | * ---------------------------------------------------------------- |
| 3123 | */ |
| 3124 | ModifyTableState * |
| 3125 | ExecInitModifyTable(ModifyTable *node, EState *estate, int eflags) |
| 3126 | { |
| 3127 | ModifyTableState *mtstate; |
| 3128 | Plan *subplan = outerPlan(node); |
| 3129 | CmdType operation = node->operation; |
| 3130 | int nrels = list_length(node->resultRelations); |
| 3131 | ResultRelInfo *resultRelInfo; |
| 3132 | List *arowmarks; |
| 3133 | ListCell *l; |
| 3134 | int i; |
| 3135 | Relation rel; |
| 3136 | HASHCTL hash_ctl; |
| 3137 | |
| 3138 | /* check for unsupported flags */ |
| 3139 | Assert(!(eflags & (EXEC_FLAG_BACKWARD | EXEC_FLAG_MARK))); |
| 3140 | |
| 3141 | /* |
| 3142 | * create state structure |
| 3143 | */ |
| 3144 | mtstate = makeNode(ModifyTableState); |
| 3145 | mtstate->ps.plan = (Plan *) node; |
| 3146 | mtstate->ps.state = estate; |
| 3147 | mtstate->ps.ExecProcNode = ExecModifyTable; |
| 3148 | |
| 3149 | MemSet(&hash_ctl, 0, sizeof(hash_ctl)); |
| 3150 | hash_ctl.keysize = sizeof(ModifiedLeafRelidsKey); |
| 3151 | hash_ctl.entrysize = sizeof(ModifiedLeafRelidsData); |
| 3152 | hash_ctl.hash = modified_leaf_hash; |
| 3153 | hash_ctl.match = modified_leaf_compare; |
| 3154 | hash_ctl.hcxt = CurrentMemoryContext; |
| 3155 | mtstate->modified_leaf_relids = hash_create("ModifiedLeafRelids", |
| 3156 | 4, |
| 3157 | &hash_ctl, |
| 3158 | HASH_ELEM | HASH_FUNCTION | HASH_COMPARE); |
| 3159 | |
| 3160 | mtstate->operation = operation; |
| 3161 | mtstate->canSetTag = node->canSetTag; |
| 3162 | mtstate->mt_done = false; |
| 3163 | |
| 3164 | mtstate->mt_nrels = nrels; |
| 3165 | mtstate->resultRelInfo = (ResultRelInfo *) |
| 3166 | palloc(nrels * sizeof(ResultRelInfo)); |
| 3167 | |
| 3168 | /*---------- |
| 3169 | * Resolve the target relation. This is the same as: |
| 3170 | * |
| 3171 | * - the relation for which we will fire FOR STATEMENT triggers, |
| 3172 | * - the relation into whose tuple format all captured transition tuples |
| 3173 | * must be converted, and |
| 3174 | * - the root partitioned table used for tuple routing. |
| 3175 | * |
| 3176 | * If it's a partitioned table, the root partition doesn't appear |
| 3177 | * elsewhere in the plan and its RT index is given explicitly in |
| 3178 | * node->rootRelation. Otherwise (i.e. table inheritance) the target |
| 3179 | * relation is the first relation in the node->resultRelations list. |
| 3180 | *---------- |
| 3181 | */ |
no test coverage detected