Skip to content

Commit 11637f5

Browse files
committed
This fixes coordinator planner to geenrate operator to go to
datanodes. Submitted by Abbas But.
1 parent fac6a27 commit 11637f5

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

src/backend/nodes/copyfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1048,7 +1048,8 @@ _copyRemoteQuery(const RemoteQuery *from)
10481048
COPY_SCALAR_FIELD(has_row_marks);
10491049
COPY_SCALAR_FIELD(rq_save_command_id);
10501050
COPY_SCALAR_FIELD(rq_params_internal);
1051-
COPY_SCALAR_FIELD(rq_save_command_id);
1051+
COPY_SCALAR_FIELD(rq_use_pk_for_rep_change);
1052+
COPY_SCALAR_FIELD(rq_max_param_num);
10521053

10531054
return newnode;
10541055
}

src/backend/nodes/outfuncs.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,8 @@ _outRemoteQuery(StringInfo str, const RemoteQuery *node)
492492
WRITE_NODE_FIELD(query_var_tlist);
493493
WRITE_BOOL_FIELD(rq_save_command_id);
494494
WRITE_BOOL_FIELD(rq_params_internal);
495-
WRITE_BOOL_FIELD(rq_save_command_id);
495+
WRITE_BOOL_FIELD(rq_use_pk_for_rep_change);
496+
WRITE_BOOL_FIELD(rq_max_param_num);
496497
}
497498

498499
static void

src/backend/optimizer/plan/pgxcplan.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1334,6 +1334,18 @@ pgxc_build_dml_statement(PlannerInfo *root, CmdType cmdtype,
13341334
pgxc_dml_add_qual_to_query(query_to_deparse, col_att,
13351335
pkattno, resultRelationIndex);
13361336
}
1337+
1338+
/*
1339+
* Save the maximum number of parameters that should be sent down
1340+
* to the datanode while executing this delete. Sending extra
1341+
* parametrs causes problems in case those extra contain composite
1342+
* types, because input of annon composite types is not implemented
1343+
* For example see the delete query in JDBC regression
1344+
* File : XC_02_AbsenteesTest.java
1345+
* Function : testDeletePersonnel_3
1346+
*/
1347+
if (cmdtype == CMD_DELETE)
1348+
rqplan->rq_max_param_num = col_att;
13371349
}
13381350
query_to_deparse->jointree->quals = (Node *)make_andclause(
13391351
(List *)query_to_deparse->jointree->quals);

src/backend/pgxc/pool/execRemote.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4967,11 +4967,14 @@ SetDataRowForIntParams(JunkFilter *junkfilter,
49674967
{
49684968
StringInfoData buf;
49694969
uint16 numparams = 0;
4970+
RemoteQuery *step = (RemoteQuery *) rq_state->ss.ps.plan;
49704971

49714972
Assert(sourceSlot);
49724973

49734974
/* Calculate the total number of parameters */
4974-
if (dataSlot)
4975+
if (step->rq_max_param_num > 0)
4976+
numparams = step->rq_max_param_num;
4977+
else if (dataSlot)
49754978
numparams = dataSlot->tts_tupleDescriptor->natts;
49764979
/* Add number of junk attributes */
49774980
if (junkfilter)
@@ -5009,6 +5012,10 @@ SetDataRowForIntParams(JunkFilter *junkfilter,
50095012
{
50105013
TupleDesc tdesc = dataSlot->tts_tupleDescriptor;
50115014
int numatts = tdesc->natts;
5015+
5016+
if (step->rq_max_param_num > 0)
5017+
numatts = step->rq_max_param_num;
5018+
50125019
for (attindex = 0; attindex < numatts; attindex++)
50135020
{
50145021
rq_state->rqs_param_types[attindex] =
@@ -5057,12 +5064,16 @@ SetDataRowForIntParams(JunkFilter *junkfilter,
50575064
{
50585065
TupleDesc tdesc = dataSlot->tts_tupleDescriptor;
50595066
int attindex;
5067+
int numatts = tdesc->natts;
50605068

50615069
/* Append the data attributes */
50625070

5071+
if (step->rq_max_param_num > 0)
5072+
numatts = step->rq_max_param_num;
5073+
50635074
/* ensure we have all values */
50645075
slot_getallattrs(dataSlot);
5065-
for (attindex = 0; attindex < tdesc->natts; attindex++)
5076+
for (attindex = 0; attindex < numatts; attindex++)
50665077
{
50675078
uint32 n32;
50685079
Assert(attindex < numparams);

src/include/optimizer/pgxcplan.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,18 @@ typedef struct
126126
* the replicated table to
127127
* perform update/delete?
128128
*/
129+
int rq_max_param_num; /* Upto which number are parameters
130+
* added in an delete on a replicated
131+
* tablke. This is required to make
132+
* sure that extra parameters are not
133+
* sent to the datanode while
134+
* executing. The problem in sending
135+
* extra parameters is that those extra
136+
* parameters may contain a composite
137+
* type which makes the query fail
138+
* because input of annon. composite
139+
* types is not implemented.
140+
*/
129141
} RemoteQuery;
130142

131143
extern PlannedStmt *pgxc_planner(Query *query, int cursorOptions,

0 commit comments

Comments
 (0)