-
-
Save krk/bd331cdc0c994708e444a86db2432ce8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* Returns a subquery selecting outputColumns from main_arg. | |
* main_arg is modified and returned. | |
*/ | |
static SelectStmt * | |
createSubqueryForCorresponding(List* outputColumns, SelectStmt* main_arg) | |
{ | |
ColumnRef *cr; | |
ResTarget *rt; | |
SelectStmt *n; | |
RangeSubselect * rss; | |
ListCell* mctl; | |
n = makeNode(SelectStmt); | |
n->targetList = NIL; | |
foreach(mctl, outputColumns) | |
{ | |
TargetEntry *mctle = (TargetEntry *) lfirst(mctl); | |
cr = makeNode(ColumnRef); | |
cr->fields = list_make1(makeString(mctle->resname)); | |
cr->location = -1; | |
rt = makeNode(ResTarget); | |
rt->name = NULL; | |
rt->indirection = NIL; | |
rt->val = (Node *)cr; | |
rt->location = -1; | |
n->targetList = lappend(n->targetList, rt); | |
} | |
rss = makeNode(RangeSubselect); | |
// XXX makeAlias alias name should be empty?? | |
rss->alias = makeAlias("", NULL); | |
rss->subquery = (Node *)main_arg; | |
n->fromClause = list_make1(rss); | |
main_arg = n; | |
return main_arg; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment