Skip to content

Commit 72193a7

Browse files
committed
Removal of tuple store code for insert-exec because we now have a complete new redesign approach implemented
1 parent 84ee727 commit 72193a7

4 files changed

Lines changed: 27 additions & 85 deletions

File tree

src/backend/access/common/attmap.c

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
#include "access/attmap.h"
2626
#include "utils/builtins.h"
2727

28-
called_from_tsql_insert_exec_hook_type called_from_tsql_insert_exec_hook = NULL;
2928
called_for_tsql_itvf_func_hook_type called_for_tsql_itvf_func_hook = NULL;
3029

3130
static bool check_attrmap_match(TupleDesc indesc,
@@ -112,10 +111,9 @@ build_attrmap_by_position(TupleDesc indesc,
112111
nincols++;
113112

114113
/* Found matching column, now check type */
115-
/* skip check type if it's tsql insert exec or if it is for tsql inline table valued function */
114+
/* skip check type if it is for tsql inline table valued function */
116115
if ((outatt->atttypid != inatt->atttypid ||
117116
(outatt->atttypmod != inatt->atttypmod && outatt->atttypmod >= 0)) &&
118-
!(called_from_tsql_insert_exec_hook && called_from_tsql_insert_exec_hook()) &&
119117
!(called_for_tsql_itvf_func_hook && called_for_tsql_itvf_func_hook()))
120118
ereport(ERROR,
121119
(errcode(ERRCODE_DATATYPE_MISMATCH),
@@ -318,10 +316,9 @@ check_attrmap_match(TupleDesc indesc,
318316
return false;
319317

320318
/**
321-
* in tsql insert exec or for tsql inline table valued function, we need a cast
319+
* for tsql inline table valued function, we need a cast
322320
*/
323-
if (((called_from_tsql_insert_exec_hook && called_from_tsql_insert_exec_hook())
324-
|| (called_for_tsql_itvf_func_hook && called_for_tsql_itvf_func_hook()))
321+
if ((called_for_tsql_itvf_func_hook && called_for_tsql_itvf_func_hook())
325322
&& (inatt_form_attributes->atttypid != outatt_form_attributes->atttypid ||
326323
inatt_form_attributes->atttypmod != outatt_form_attributes->atttypmod))
327324
return false;

src/backend/access/common/tupconvert.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -177,10 +177,9 @@ execute_attr_map_tuple(HeapTuple tuple, TupleConversionMap *map)
177177
int j = attrMap->attnums[i];
178178

179179
/**
180-
* if it's tsql insert exec or if it is for tsql inline table valued function, we'll consider value cast
180+
* if it is for tsql inline table valued function, we'll consider value cast
181181
*/
182-
if ((called_from_tsql_insert_exec_hook && called_from_tsql_insert_exec_hook())
183-
|| (called_for_tsql_itvf_func_hook && called_for_tsql_itvf_func_hook()))
182+
if (called_for_tsql_itvf_func_hook && called_for_tsql_itvf_func_hook())
184183
{
185184
Oid intypeid;
186185
Oid outtypeid;

src/backend/executor/nodeModifyTable.c

Lines changed: 22 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -4241,11 +4241,6 @@ ExecModifyTable(PlanState *pstate)
42414241
HeapTupleData oldtupdata;
42424242
HeapTuple oldtuple;
42434243
ItemPointer tupleid;
4244-
/* for INSERT ... EXECUTE */
4245-
bool tsql_insert_exec = node->callStmt != NULL;
4246-
Tuplestorestate *tss = NULL;
4247-
TupleDesc tupdesc = NULL;
4248-
DestReceiver *dest = NULL;
42494244
bool tuplock;
42504245

42514246
CHECK_FOR_INTERRUPTS();
@@ -4289,36 +4284,6 @@ ExecModifyTable(PlanState *pstate)
42894284
context.epqstate = &node->mt_epqstate;
42904285
context.estate = estate;
42914286

4292-
/*
4293-
* If we are here for INSERT ... EXECUTE, create a TuplestoreDestReceiver
4294-
* and pass it to the procedure execution. The procedure execution will send
4295-
* its result sets to the tuplestore via the receiver function.
4296-
*/
4297-
if (tsql_insert_exec)
4298-
{
4299-
tss = tuplestore_begin_heap(false, false, work_mem);
4300-
tupdesc = RelationGetDescr(resultRelInfo->ri_RelationDesc);
4301-
dest = CreateTuplestoreDestReceiver();
4302-
SetTuplestoreDestReceiverParams(dest, tss, CurrentMemoryContext, false, NULL, NULL);
4303-
dest->rStartup(dest, -1, tupdesc);
4304-
4305-
switch (nodeTag(node->callStmt))
4306-
{
4307-
case T_CallStmt:
4308-
ExecuteCallStmt((CallStmt *)node->callStmt,
4309-
pstate->state->es_param_list_info, false, dest);
4310-
break;
4311-
case T_DoStmt:
4312-
ExecuteDoStmtInsertExec((DoStmt *)node->callStmt, false, dest);
4313-
break;
4314-
default:
4315-
ereport(ERROR,
4316-
(errcode(ERRCODE_SYNTAX_ERROR),
4317-
errmsg("Unrecognized stmt in INSERT EXEC")));
4318-
break;
4319-
}
4320-
}
4321-
43224287
/*
43234288
* Fetch rows from subplan(s), and execute the required table modification
43244289
* for each row.
@@ -4348,43 +4313,35 @@ ExecModifyTable(PlanState *pstate)
43484313
break;
43494314
}
43504315

4351-
if (tsql_insert_exec)
4316+
/*
4317+
* If there is a pending MERGE ... WHEN NOT MATCHED [BY TARGET] action
4318+
* to execute, do so now --- see the comments in ExecMerge().
4319+
*/
4320+
if (node->mt_merge_pending_not_matched != NULL)
43524321
{
4353-
context.planSlot = MakeSingleTupleTableSlot(tupdesc, &TTSOpsMinimalTuple);
4354-
tuplestore_gettupleslot(tss, true, false, context.planSlot);
4355-
}
4356-
else
4357-
{
4358-
/*
4359-
* If there is a pending MERGE ... WHEN NOT MATCHED [BY TARGET] action
4360-
* to execute, do so now --- see the comments in ExecMerge().
4361-
*/
4362-
if (node->mt_merge_pending_not_matched != NULL)
4363-
{
4364-
context.planSlot = node->mt_merge_pending_not_matched;
4365-
context.cpDeletedSlot = NULL;
4366-
4367-
slot = ExecMergeNotMatched(&context, node->resultRelInfo,
4368-
node->canSetTag);
4322+
context.planSlot = node->mt_merge_pending_not_matched;
4323+
context.cpDeletedSlot = NULL;
43694324

4370-
/* Clear the pending action */
4371-
node->mt_merge_pending_not_matched = NULL;
4325+
slot = ExecMergeNotMatched(&context, node->resultRelInfo,
4326+
node->canSetTag);
43724327

4373-
/*
4374-
* If we got a RETURNING result, return it to the caller. We'll
4375-
* continue the work on next call.
4376-
*/
4377-
if (slot)
4378-
return slot;
4328+
/* Clear the pending action */
4329+
node->mt_merge_pending_not_matched = NULL;
43794330

4380-
continue; /* continue with the next tuple */
4381-
}
4331+
/*
4332+
* If we got a RETURNING result, return it to the caller. We'll
4333+
* continue the work on next call.
4334+
*/
4335+
if (slot)
4336+
return slot;
43824337

4383-
/* Fetch the next row from subplan */
4384-
context.planSlot = ExecProcNode(subplanstate);
4385-
context.cpDeletedSlot = NULL;
4338+
continue; /* continue with the next tuple */
43864339
}
43874340

4341+
/* Fetch the next row from subplan */
4342+
context.planSlot = ExecProcNode(subplanstate);
4343+
context.cpDeletedSlot = NULL;
4344+
43884345
/* No more tuples to process? */
43894346
if (TupIsNull(context.planSlot))
43904347
break;
@@ -4674,9 +4631,6 @@ ExecModifyTable(PlanState *pstate)
46744631
break;
46754632
}
46764633

4677-
if(tsql_insert_exec)
4678-
ExecDropSingleTupleTableSlot(context.planSlot);
4679-
46804634
/*
46814635
* If we got a RETURNING result, return it to caller. We'll continue
46824636
* the work on next call.
@@ -4685,12 +4639,6 @@ ExecModifyTable(PlanState *pstate)
46854639
return slot;
46864640
}
46874641

4688-
if (tsql_insert_exec && dest)
4689-
{
4690-
dest->rShutdown(dest);
4691-
dest->rDestroy(dest);
4692-
}
4693-
46944642
/*
46954643
* Insert remaining tuples for batch insert.
46964644
*/

src/include/access/attmap.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,7 @@ extern AttrMap *build_attrmap_by_name_if_req(TupleDesc indesc,
5050
extern AttrMap *build_attrmap_by_position(TupleDesc indesc,
5151
TupleDesc outdesc,
5252
const char *msg);
53-
typedef bool (*called_from_tsql_insert_exec_hook_type)();
5453
typedef bool (*called_for_tsql_itvf_func_hook_type)();
55-
extern PGDLLEXPORT called_from_tsql_insert_exec_hook_type called_from_tsql_insert_exec_hook;
5654
extern PGDLLIMPORT called_for_tsql_itvf_func_hook_type called_for_tsql_itvf_func_hook;
5755

5856
#endif /* ATTMAP_H */

0 commit comments

Comments
 (0)