Fix issue with GROUP BY + DEFAULT

onder_ins_select
Marco Slot 2022-07-25 12:48:50 +02:00
parent 150205223c
commit f849487cb3
1 changed files with 6 additions and 0 deletions

View File

@ -48,6 +48,7 @@
#include "utils/builtins.h" #include "utils/builtins.h"
#include "utils/lsyscache.h" #include "utils/lsyscache.h"
#include "utils/rel.h" #include "utils/rel.h"
#include <nodes/print.h>
static void PrepareInsertSelectForCitusPlanner(Query *insertSelectQuery); static void PrepareInsertSelectForCitusPlanner(Query *insertSelectQuery);
@ -958,6 +959,7 @@ ReorderInsertSelectTargetLists(Query *originalQuery, RangeTblEntry *insertRte,
ListCell *insertTargetEntryCell; ListCell *insertTargetEntryCell;
List *newSubqueryTargetlist = NIL; List *newSubqueryTargetlist = NIL;
List *newInsertTargetlist = NIL; List *newInsertTargetlist = NIL;
List *columnNameList = NIL;
int resno = 1; int resno = 1;
Index selectTableId = 2; Index selectTableId = 2;
int targetEntryIndex = 0; int targetEntryIndex = 0;
@ -1029,6 +1031,9 @@ ReorderInsertSelectTargetLists(Query *originalQuery, RangeTblEntry *insertRte,
newSubqueryTargetEntry); newSubqueryTargetEntry);
} }
String *columnName = makeString(newSubqueryTargetEntry->resname);
columnNameList = lappend(columnNameList, columnName);
/* /*
* The newly created select target entry cannot be a junk entry since junk * The newly created select target entry cannot be a junk entry since junk
* entries are not in the final target list and we're processing the * entries are not in the final target list and we're processing the
@ -1080,6 +1085,7 @@ ReorderInsertSelectTargetLists(Query *originalQuery, RangeTblEntry *insertRte,
originalQuery->targetList = newInsertTargetlist; originalQuery->targetList = newInsertTargetlist;
subquery->targetList = newSubqueryTargetlist; subquery->targetList = newSubqueryTargetlist;
subqueryRte->eref->colnames = columnNameList;
return NULL; return NULL;
} }