---------------------------------------------------------------- * ExecBatchInsert * * Insert multiple tuples in an efficient way. * Currently, this handles inserting into a foreign table without * RETURNING clause. * ---------------------------------------------------------------- */
| 1160 | * ---------------------------------------------------------------- |
| 1161 | */ |
| 1162 | static void |
| 1163 | ExecBatchInsert(ModifyTableState *mtstate, |
| 1164 | ResultRelInfo *resultRelInfo, |
| 1165 | TupleTableSlot **slots, |
| 1166 | TupleTableSlot **planSlots, |
| 1167 | int numSlots, |
| 1168 | EState *estate, |
| 1169 | bool canSetTag) |
| 1170 | { |
| 1171 | int i; |
| 1172 | int numInserted = numSlots; |
| 1173 | TupleTableSlot *slot = NULL; |
| 1174 | TupleTableSlot **rslots; |
| 1175 | |
| 1176 | /* |
| 1177 | * insert into foreign table: let the FDW do it |
| 1178 | */ |
| 1179 | rslots = resultRelInfo->ri_FdwRoutine->ExecForeignBatchInsert(estate, |
| 1180 | resultRelInfo, |
| 1181 | slots, |
| 1182 | planSlots, |
| 1183 | &numInserted); |
| 1184 | |
| 1185 | for (i = 0; i < numInserted; i++) |
| 1186 | { |
| 1187 | slot = rslots[i]; |
| 1188 | |
| 1189 | /* |
| 1190 | * AFTER ROW Triggers or RETURNING expressions might reference the |
| 1191 | * tableoid column, so (re-)initialize tts_tableOid before evaluating |
| 1192 | * them. |
| 1193 | */ |
| 1194 | slot->tts_tableOid = RelationGetRelid(resultRelInfo->ri_RelationDesc); |
| 1195 | |
| 1196 | /* AFTER ROW INSERT Triggers */ |
| 1197 | ExecARInsertTriggers(estate, resultRelInfo, slot, NIL, |
| 1198 | mtstate->mt_transition_capture); |
| 1199 | |
| 1200 | /* |
| 1201 | * Check any WITH CHECK OPTION constraints from parent views. See the |
| 1202 | * comment in ExecInsert. |
| 1203 | */ |
| 1204 | if (resultRelInfo->ri_WithCheckOptions != NIL) |
| 1205 | ExecWithCheckOptions(WCO_VIEW_CHECK, resultRelInfo, slot, estate); |
| 1206 | } |
| 1207 | |
| 1208 | if (canSetTag && numInserted > 0) |
| 1209 | estate->es_processed += numInserted; |
| 1210 | } |
| 1211 | |
| 1212 | /* ---------------------------------------------------------------- |
| 1213 | * ExecDelete |
no test coverage detected