diff options
author | Bruce Momjian <bruce@momjian.us> | 1998-01-06 18:53:02 +0000 |
---|---|---|
committer | Bruce Momjian <bruce@momjian.us> | 1998-01-06 18:53:02 +0000 |
commit | 9d00fbbeb008e351047161e195250743453e3c3a (patch) | |
tree | 9b8769acad7ca41d2e8caab6bbf51be0bffd3f1c /src/backend | |
parent | 42acc6e8c4fa6117b7783455200e41f8019a58b0 (diff) | |
download | postgresql-9d00fbbeb008e351047161e195250743453e3c3a.tar.gz |
Change some labels in bootparse to make ctags happy. Clean up outfunc/readfunc code and add missing fields for Query structure and new Union fields. Fix optimizer bug shown in new \do command. Change WARN to ERROR in contrib and regression stuff.
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/bootstrap/bootparse.y | 102 | ||||
-rw-r--r-- | src/backend/catalog/aclchk.c | 4 | ||||
-rw-r--r-- | src/backend/lib/stringinfo.c | 6 | ||||
-rw-r--r-- | src/backend/nodes/outfuncs.c | 639 | ||||
-rw-r--r-- | src/backend/nodes/read.c | 17 | ||||
-rw-r--r-- | src/backend/nodes/readfuncs.c | 204 | ||||
-rw-r--r-- | src/backend/optimizer/path/prune.c | 23 |
7 files changed, 490 insertions, 505 deletions
diff --git a/src/backend/bootstrap/bootparse.y b/src/backend/bootstrap/bootparse.y index d9340f2544..2c86b7826e 100644 --- a/src/backend/bootstrap/bootparse.y +++ b/src/backend/bootstrap/bootparse.y @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.11 1998/01/05 03:30:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootparse.y,v 1.12 1998/01/06 18:51:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,10 +79,10 @@ static Oid objectid; int ival; } -%type <list> arg_list -%type <ielem> index_params index_on -%type <ival> const ident -%type <ival> optbootstrap optoideq tuple tuplelist +%type <list> boot_arg_list +%type <ielem> boot_index_params boot_index_on +%type <ival> boot_const boot_ident +%type <ival> optbootstrap optoideq boot_tuple boot_tuplelist %token <ival> CONST ID %token OPEN XCLOSE XCREATE INSERT_TUPLE @@ -98,26 +98,26 @@ static Oid objectid; %% TopLevel: - Queries + Boot_Queries | ; -Queries: - A_Query - | Queries A_Query +Boot_Queries: + Boot_Query + | Boot_Queries Boot_Query ; -A_Query : - OpenStmt - | CloseStmt - | CreateStmt - | InsertStmt - | DeclareIndexStmt - | BuildIndsStmt +Boot_Query : + Boot_OpenStmt + | Boot_CloseStmt + | Boot_CreateStmt + | Boot_InsertStmt + | Boot_DeclareIndexStmt + | Boot_BuildIndsStmt ; -OpenStmt: - OPEN ident +Boot_OpenStmt: + OPEN boot_ident { DO_START; boot_openrel(LexIDStr($2)); @@ -125,8 +125,8 @@ OpenStmt: } ; -CloseStmt: - XCLOSE ident %prec low +Boot_CloseStmt: + XCLOSE boot_ident %prec low { DO_START; closerel(LexIDStr($2)); @@ -140,13 +140,13 @@ CloseStmt: } ; -CreateStmt: - XCREATE optbootstrap ident LPAREN +Boot_CreateStmt: + XCREATE optbootstrap boot_ident LPAREN { DO_START; numattr=(int)0; } - typelist + boot_typelist { if (!Quiet) putchar('\n'); @@ -192,7 +192,7 @@ CreateStmt: } ; -InsertStmt: +Boot_InsertStmt: INSERT_TUPLE optoideq { DO_START; @@ -200,7 +200,7 @@ InsertStmt: printf("tuple %d<", $2); num_tuples_read = 0; } - LPAREN tuplelist RPAREN + LPAREN boot_tuplelist RPAREN { if (num_tuples_read != numattr) elog(ABORT,"incorrect number of values for tuple"); @@ -223,8 +223,8 @@ InsertStmt: } ; -DeclareIndexStmt: - XDECLARE INDEX ident ON ident USING ident LPAREN index_params RPAREN +Boot_DeclareIndexStmt: + XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN { List *params; @@ -239,25 +239,25 @@ DeclareIndexStmt: } ; -BuildIndsStmt: +Boot_BuildIndsStmt: XBUILD INDICES { build_indices(); } -index_params: - index_on ident +boot_index_params: + boot_index_on boot_ident { IndexElem *n = (IndexElem*)$1; n->class = LexIDStr($2); $$ = n; } -index_on: - ident +boot_index_on: + boot_ident { IndexElem *n = makeNode(IndexElem); n->name = LexIDStr($1); $$ = n; } - | ident LPAREN arg_list RPAREN + | boot_ident LPAREN boot_arg_list RPAREN { IndexElem *n = makeNode(IndexElem); n->name = LexIDStr($1); @@ -265,12 +265,12 @@ index_on: $$ = n; } -arg_list: - ident +boot_arg_list: + boot_ident { $$ = lappend(NIL, makeString(LexIDStr($1))); } - | arg_list COMMA ident + | boot_arg_list COMMA boot_ident { $$ = lappend((List*)$1, makeString(LexIDStr($3))); } @@ -280,13 +280,13 @@ optbootstrap: | { $$ = 0; } ; -typelist: - typething - | typelist COMMA typething +boot_typelist: + boot_type_thing + | boot_typelist COMMA boot_type_thing ; -typething: - ident EQUALS ident +boot_type_thing: + boot_ident EQUALS boot_ident { if(++numattr > MAXATTR) elog(FATAL,"Too many attributes\n"); @@ -297,28 +297,28 @@ typething: ; optoideq: - OBJ_ID EQUALS ident { $$ = atol(LexIDStr($3)); } + OBJ_ID EQUALS boot_ident { $$ = atol(LexIDStr($3)); } | { extern Oid newoid(); $$ = newoid(); } ; -tuplelist: - tuple - | tuplelist tuple - | tuplelist COMMA tuple +boot_tuplelist: + boot_tuple + | boot_tuplelist boot_tuple + | boot_tuplelist COMMA boot_tuple ; -tuple: - ident {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } - | const {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } +boot_tuple: + boot_ident {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } + | boot_const {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } | NULLVAL { InsertOneNull(num_tuples_read++); } ; -const : +boot_const : CONST { $$=yylval.ival; } ; -ident : +boot_ident : ID { $$=yylval.ival; } ; %% diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index 752399e761..e754563286 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.1 1998/01/05 18:42:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.2 1998/01/06 18:52:03 momjian Exp $ * * NOTES * See acl.h. @@ -410,7 +410,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) * pg_database table, there is still additional permissions * checking in dbcommands.c */ - if (mode & ACL_AP) + if ((mode & ACL_WR) || (mode & ACL_AP)) return ACLCHECK_OK; } diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 5a241953da..72d8ce59d4 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.6 1998/01/05 03:31:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.7 1998/01/06 18:52:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,7 +76,9 @@ appendStringInfo(StringInfo str, char *buffer) newlen; char *s; - Assert((str != NULL)); + Assert(str != NULL); + if (buffer == NULL) + buffer = "\"\""; /* * do we have enough space to append the new string? (don't forget to diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index a7fa85d31f..7232d5a026 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.14 1997/12/27 06:40:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.15 1998/01/06 18:52:15 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -70,63 +70,71 @@ _outIntList(StringInfo str, List *list) static void _outCreateStmt(StringInfo str, CreateStmt *node) { - char buf[500]; - - sprintf(buf, "CREATE"); - appendStringInfo(str, buf); + appendStringInfo(str, "CREATE"); - sprintf(buf, " :relname %s", node->relname); - appendStringInfo(str, buf); + appendStringInfo(str, " :relname "); + appendStringInfo(str, node->relname); appendStringInfo(str, " :columns"); _outNode(str, node->tableElts); + appendStringInfo(str, " :inhRelnames"); + _outNode(str, node->inhRelnames); + appendStringInfo(str, " :constraints"); + _outNode(str, node->constraints); } /* _outCreateStmt() */ static void _outIndexStmt(StringInfo str, IndexStmt *node) { - char buf[500]; - - sprintf(buf, "INDEX"); - appendStringInfo(str, buf); - - sprintf(buf, " :idxname %s", node->idxname); - appendStringInfo(str, buf); - sprintf(buf, " :relname %s", node->relname); - appendStringInfo(str, buf); - sprintf(buf, " :method %s", node->accessMethod); - appendStringInfo(str, buf); - sprintf(buf, " :unique %s", (node->unique? "y": "n")); - appendStringInfo(str, buf); - appendStringInfo(str, " :columns"); + appendStringInfo(str, "INDEX"); + + appendStringInfo(str, " :idxname "); + appendStringInfo(str, node->idxname); + appendStringInfo(str, " :relname "); + appendStringInfo(str, node->relname); + appendStringInfo(str, " :accessMethod "); + appendStringInfo(str, node->accessMethod); + appendStringInfo(str, " :indexParams "); _outNode(str, node->indexParams); + appendStringInfo(str, " :withClause "); + _outNode(str, node->withClause); + appendStringInfo(str, " :whereClause "); + _outNode(str, node->whereClause); + appendStringInfo(str, " :rangetable "); + _outNode(str, node->rangetable); + appendStringInfo(str, " :lossy "); + appendStringInfo(str, (*node->lossy ? "y": "n")); + appendStringInfo(str, " :unique "); + appendStringInfo(str, (node->unique ? "y": "n")); } /* _outIndexStmt() */ static void _outColumnDef(StringInfo str, ColumnDef *node) { - char buf[500]; - - sprintf(buf, "COLUMNDEF"); - appendStringInfo(str, buf); + appendStringInfo(str, "COLUMNDEF"); - sprintf(buf, " :colname %s", node->colname); - appendStringInfo(str, buf); - appendStringInfo(str, " :typename"); + appendStringInfo(str, " :colname "); + appendStringInfo(str, node->colname); + appendStringInfo(str, " :typename "); _outNode(str, node->typename); + appendStringInfo(str, " :is_not_null "); + appendStringInfo(str, (node->is_not_null ? "y": "n")); + appendStringInfo(str, " :defval "); + appendStringInfo(str, node->defval); + appendStringInfo(str, " :constraints"); + _outNode(str, node->constraints); } /* _outColumnDef() */ static void _outIndexElem(StringInfo str, IndexElem *node) { - char buf[500]; - - sprintf(buf, "INDEXELEM"); - appendStringInfo(str, buf); + appendStringInfo(str, "INDEXELEM"); - sprintf(buf, " :name %s", node->name); - appendStringInfo(str, buf); - sprintf(buf, " :class %s", node->class); - appendStringInfo(str, buf); + appendStringInfo(str, " :name "); + appendStringInfo(str, node->name); + appendStringInfo(str, " :args "); + _outNode(str, node->args); + appendStringInfo(str, " :class "); + appendStringInfo(str, node->class); appendStringInfo(str, " :tname"); _outNode(str, node->tname); } /* _outIndexElem() */ @@ -135,66 +143,98 @@ static void _outQuery(StringInfo str, Query *node) { char buf[500]; + int i; + + appendStringInfo(str, "QUERY"); - sprintf(buf, "QUERY"); + appendStringInfo(str, " :command "); + sprintf(buf," %d ", node->commandType); appendStringInfo(str, buf); - sprintf(buf, " :command %d", node->commandType); - appendStringInfo(str, buf); if (node->utilityStmt) { switch (nodeTag(node->utilityStmt)) { case T_CreateStmt: - sprintf(buf, " :create %s", - ((CreateStmt *) (node->utilityStmt))->relname); - appendStringInfo(str, buf); + appendStringInfo(str, " :create "); + appendStringInfo(str, ((CreateStmt *) (node->utilityStmt))->relname); _outNode(str, node->utilityStmt); break; case T_IndexStmt: - sprintf(buf, " :index %s on %s", - ((IndexStmt *) (node->utilityStmt))->idxname, - ((IndexStmt *) (node->utilityStmt))->relname); - appendStringInfo(str, buf); + appendStringInfo(str, " :index "); + appendStringInfo(str, ((IndexStmt *) (node->utilityStmt))->idxname); + appendStringInfo(str, " on "); + appendStringInfo(str, ((IndexStmt *) (node->utilityStmt))->relname); _outNode(str, node->utilityStmt); break; case T_NotifyStmt: - sprintf(buf, " :utility %s", - ((NotifyStmt *) (node->utilityStmt))->relname); - appendStringInfo(str, buf); + appendStringInfo(str, " :utility "); + appendStringInfo(str, ((NotifyStmt *) (node->utilityStmt))->relname); break; default: - sprintf(buf, " :utility ?"); - appendStringInfo(str, buf); + appendStringInfo(str, " :utility ? "); } } else { -/* use "" to designate */ - appendStringInfo(str, " :utility \"\""); + appendStringInfo(str, " :utility "); + appendStringInfo(str, NULL); } - sprintf(buf, " :resrel %d", node->resultRelation); - appendStringInfo(str, buf); - sprintf(buf, " :rtable "); - appendStringInfo(str, buf); + appendStringInfo(str, " :resultRelation "); + sprintf(buf, " %d ", node->resultRelation); + appendStringInfo(str, buf); + appendStringInfo(str, " :into "); + appendStringInfo(str, node->into); + appendStringInfo(str, " :isPortal "); + appendStringInfo(str, (node->isPortal ? "y": "n")); + appendStringInfo(str, " :isBinary "); + appendStringInfo(str, (node->isBinary ? "y": "n")); + appendStringInfo(str, " :unionall "); + appendStringInfo(str, (node->unionall ? "y": "n")); + appendStringInfo(str, " :unique "); + appendStringInfo(str, node->uniqueFlag); + appendStringInfo(str, " :sortClause "); + _outNode(str, node->sortClause); + appendStringInfo(str, " :rtable "); _outNode(str, node->rtable); - if (node->uniqueFlag) - sprintf(buf, " :unique %s", node->uniqueFlag); - else -/* use "" to designate non-unique */ - sprintf(buf, " :unique \"\""); - appendStringInfo(str, buf); - sprintf(buf, " :targetlist "); - appendStringInfo(str, buf); + appendStringInfo(str, " :targetlist "); _outNode(str, node->targetList); - sprintf(buf, " :qual "); - appendStringInfo(str, buf); + appendStringInfo(str, " :qual "); _outNode(str, node->qual); - /* how are we handling aggregates, sort, and group by? bjm 1997/12/26 */ + appendStringInfo(str, " :groupClause "); + _outNode(str, node->groupClause); + appendStringInfo(str, " :havingQual "); + _outNode(str, node->havingQual); + appendStringInfo(str, " :qry_numAgg "); + sprintf(buf, " %d ", node->qry_numAgg); + appendStringInfo(str, buf); + appendStringInfo(str, " :qry_aggs "); + for (i=0; i < node->qry_numAgg; i++) + _outNode(str, node->qry_aggs[i]); + appendStringInfo(str, " :unionClause "); + _outNode(str, node->unionClause); +} + +static void +_outSortGroupBy(StringInfo str, SortGroupBy *node) +{ + char buf[500]; + int i; + + appendStringInfo(str, "SORTGROUPBY"); + + appendStringInfo(str, " :resno "); + sprintf(buf," %d ", node->resno); + appendStringInfo(str, " :range "); + appendStringInfo(str, node->range); + appendStringInfo(str, " :name "); + appendStringInfo(str, node->name); + appendStringInfo(str, " :useOp "); + appendStringInfo(str, node->useOp); } /* @@ -211,20 +251,15 @@ _outPlanInfo(StringInfo str, Plan *node) appendStringInfo(str, buf); sprintf(buf, " :width %d", node->plan_width); appendStringInfo(str, buf); - sprintf(buf, " :state %s", (node->state == (EState *) NULL ? - "nil" : "non-NIL")); - appendStringInfo(str, buf); - sprintf(buf, " :qptargetlist "); - appendStringInfo(str, buf); + appendStringInfo(str, " :state "); + appendStringInfo(str, (node->state == (EState *) NULL? "nil" : "non-NIL")); + appendStringInfo(str, " :qptargetlist "); _outNode(str, node->targetlist); - sprintf(buf, " :qpqual "); - appendStringInfo(str, buf); + appendStringInfo(str, " :qpqual "); _outNode(str, node->qual); - sprintf(buf, " :lefttree "); - appendStringInfo(str, buf); + appendStringInfo(str, " :lefttree "); _outNode(str, node->lefttree); - sprintf(buf, " :righttree "); - appendStringInfo(str, buf); + appendStringInfo(str, " :righttree "); _outNode(str, node->righttree); } @@ -235,25 +270,17 @@ _outPlanInfo(StringInfo str, Plan *node) static void _outPlan(StringInfo str, Plan *node) { - char buf[500]; - - sprintf(buf, "PLAN"); - appendStringInfo(str, buf); + appendStringInfo(str, "PLAN"); _outPlanInfo(str, (Plan *) node); - } static void _outResult(StringInfo str, Result *node) { - char buf[500]; - - sprintf(buf, "RESULT"); - appendStringInfo(str, buf); + appendStringInfo(str, "RESULT"); _outPlanInfo(str, (Plan *) node); - sprintf(buf, " :resconstantqual "); - appendStringInfo(str, buf); + appendStringInfo(str, " :resconstantqual "); _outNode(str, node->resconstantqual); } @@ -266,19 +293,19 @@ _outAppend(StringInfo str, Append *node) { char buf[500]; - sprintf(buf, "APPEND"); - appendStringInfo(str, buf); + appendStringInfo(str, "APPEND"); _outPlanInfo(str, (Plan *) node); - sprintf(buf, " :unionplans "); - appendStringInfo(str, buf); + appendStringInfo(str, " :unionplans "); _outNode(str, node->unionplans); + appendStringInfo(str, " :unionrts "); + _outNode(str, node->unionrts); + sprintf(buf, " :unionrelid %d", node->unionrelid); appendStringInfo(str, buf); - sprintf(buf, " :unionrtentries "); - appendStringInfo(str, buf); + appendStringInfo(str, " :unionrtentries "); _outNode(str, node->unionrtentries); } @@ -289,10 +316,7 @@ _outAppend(StringInfo str, Append *node) static void _outJoin(StringInfo str, Join *node) { - char buf[500]; - - sprintf(buf, "JOIN"); - appendStringInfo(str, buf); + appendStringInfo(str, "JOIN"); _outPlanInfo(str, (Plan *) node); } @@ -303,10 +327,7 @@ _outJoin(StringInfo str, Join *node) static void _outNestLoop(StringInfo str, NestLoop *node) { - char buf[500]; - - sprintf(buf, "NESTLOOP"); - appendStringInfo(str, buf); + appendStringInfo(str, "NESTLOOP"); _outPlanInfo(str, (Plan *) node); } @@ -318,12 +339,10 @@ _outMergeJoin(StringInfo str, MergeJoin *node) { char buf[500]; - sprintf(buf, "MERGEJOIN"); - appendStringInfo(str, buf); + appendStringInfo(str, "MERGEJOIN"); _outPlanInfo(str, (Plan *) node); - sprintf(buf, " :mergeclauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :mergeclauses "); _outNode(str, node->mergeclauses); sprintf(buf, " :mergesortop %u", node->mergesortop); @@ -344,12 +363,10 @@ _outHashJoin(StringInfo str, HashJoin *node) { char buf[500]; - sprintf(buf, "HASHJOIN"); - appendStringInfo(str, buf); + appendStringInfo(str, "HASHJOIN"); _outPlanInfo(str, (Plan *) node); - sprintf(buf, " :hashclauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :hashclauses "); _outNode(str, node->hashclauses); sprintf(buf, " :hashjoinop %u", node->hashjoinop); @@ -372,8 +389,7 @@ _outScan(StringInfo str, Scan *node) { char buf[500]; - sprintf(buf, "SCAN"); - appendStringInfo(str, buf); + appendStringInfo(str, "SCAN"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :scanrelid %d", node->scanrelid); @@ -389,8 +405,7 @@ _outSeqScan(StringInfo str, SeqScan *node) { char buf[500]; - sprintf(buf, "SEQSCAN"); - appendStringInfo(str, buf); + appendStringInfo(str, "SEQSCAN"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :scanrelid %d", node->scanrelid); @@ -407,19 +422,16 @@ _outIndexScan(StringInfo str, IndexScan *node) { char buf[500]; - sprintf(buf, "INDEXSCAN"); - appendStringInfo(str, buf); + appendStringInfo(str, "INDEXSCAN"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :scanrelid %d", node->scan.scanrelid); appendStringInfo(str, buf); - sprintf(buf, " :indxid "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indxid "); _outIntList(str, node->indxid); - sprintf(buf, " :indxqual "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indxqual "); _outNode(str, node->indxqual); } @@ -432,8 +444,7 @@ _outTemp(StringInfo str, Temp *node) { char buf[500]; - sprintf(buf, "TEMP"); - appendStringInfo(str, buf); + appendStringInfo(str, "TEMP"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :tempid %u", node->tempid); @@ -451,8 +462,7 @@ _outSort(StringInfo str, Sort *node) { char buf[500]; - sprintf(buf, "SORT"); - appendStringInfo(str, buf); + appendStringInfo(str, "SORT"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :tempid %u", node->tempid); @@ -467,8 +477,7 @@ _outAgg(StringInfo str, Agg *node) { char buf[500]; - sprintf(buf, "AGG"); - appendStringInfo(str, buf); + appendStringInfo(str, "AGG"); _outPlanInfo(str, (Plan *) node); /* the actual Agg fields */ @@ -481,19 +490,18 @@ _outGroup(StringInfo str, Group *node) { char buf[500]; - sprintf(buf, "GRP"); - appendStringInfo(str, buf); + appendStringInfo(str, "GRP"); _outPlanInfo(str, (Plan *) node); /* the actual Group fields */ sprintf(buf, " :numCols %d ", node->numCols); appendStringInfo(str, buf); - sprintf(buf, " :tuplePerGroup %s", node->tuplePerGroup ? "true" : "nil"); + appendStringInfo(str, " :tuplePerGroup "); + appendStringInfo(str, node->tuplePerGroup ? "true" : "false"); appendStringInfo(str, buf); } - /* * For some reason, unique is a subclass of Temp. */ @@ -502,8 +510,7 @@ _outUnique(StringInfo str, Unique *node) { char buf[500]; - sprintf(buf, "UNIQUE"); - appendStringInfo(str, buf); + appendStringInfo(str, "UNIQUE"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :tempid %u", node->tempid); @@ -522,12 +529,10 @@ _outHash(StringInfo str, Hash *node) { char buf[500]; - sprintf(buf, "HASH"); - appendStringInfo(str, buf); + appendStringInfo(str, "HASH"); _outPlanInfo(str, (Plan *) node); - sprintf(buf, " :hashkey "); - appendStringInfo(str, buf); + appendStringInfo(str, " :hashkey "); _outNode(str, node->hashkey); sprintf(buf, " :hashtable 0x%x", (int) (node->hashtable)); @@ -543,8 +548,7 @@ _outTee(StringInfo str, Tee *node) { char buf[500]; - sprintf(buf, "TEE"); - appendStringInfo(str, buf); + appendStringInfo(str, "TEE"); _outPlanInfo(str, (Plan *) node); sprintf(buf, " :leftParent %X", (int) (node->leftParent)); @@ -552,8 +556,7 @@ _outTee(StringInfo str, Tee *node) sprintf(buf, " :rightParent %X", (int) (node->rightParent)); appendStringInfo(str, buf); - sprintf(buf, " :rtentries "); - appendStringInfo(str, buf); + appendStringInfo(str, " :rtentries "); _outNode(str, node->rtentries); } @@ -574,16 +577,15 @@ _outResdom(StringInfo str, Resdom *node) { char buf[500]; - sprintf(buf, "RESDOM"); - appendStringInfo(str, buf); + appendStringInfo(str, "RESDOM"); sprintf(buf, " :resno %hd", node->resno); appendStringInfo(str, buf); sprintf(buf, " :restype %u", node->restype); appendStringInfo(str, buf); sprintf(buf, " :reslen %d", node->reslen); appendStringInfo(str, buf); - sprintf(buf, " :resname \"%s\"", - ((node->resname) ? ((char *) node->resname) : "null")); + appendStringInfo(str, " :resname "); + appendStringInfo(str, node->resname); appendStringInfo(str, buf); sprintf(buf, " :reskey %d", node->reskey); appendStringInfo(str, buf); @@ -600,10 +602,9 @@ _outFjoin(StringInfo str, Fjoin *node) char buf[500]; int i; - sprintf(buf, "FJOIN"); - appendStringInfo(str, buf); - sprintf(buf, " :initialized %s", node->fj_initialized ? "true" : "nil"); - appendStringInfo(str, buf); + appendStringInfo(str, "FJOIN"); + appendStringInfo(str, " :initialized "); + appendStringInfo(str, node->fj_initialized ? "true" : "false"); sprintf(buf, " :nNodes %d", node->fj_nNodes); appendStringInfo(str, buf); @@ -617,8 +618,7 @@ _outFjoin(StringInfo str, Fjoin *node) appendStringInfo(str, " :alwaysdone "); for (i = 0; i < node->fj_nNodes; i++) { - sprintf(buf, " %s ", ((node->fj_alwaysDone[i]) ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false"); } } @@ -631,8 +631,7 @@ _outExpr(StringInfo str, Expr *node) char buf[500]; char *opstr = NULL; - sprintf(buf, "EXPR"); - appendStringInfo(str, buf); + appendStringInfo(str, "EXPR"); sprintf(buf, " :typeOid %u", node->typeOid); appendStringInfo(str, buf); @@ -654,13 +653,11 @@ _outExpr(StringInfo str, Expr *node) opstr = "not"; break; } - sprintf(buf, " :opType %s", opstr); - appendStringInfo(str, buf); - sprintf(buf, " :oper "); - appendStringInfo(str, buf); + appendStringInfo(str, " :opType "); + appendStringInfo(str, opstr); + appendStringInfo(str, " :oper "); _outNode(str, node->oper); - sprintf(buf, " :args "); - appendStringInfo(str, buf); + appendStringInfo(str, " :args "); _outNode(str, node->args); } @@ -672,8 +669,7 @@ _outVar(StringInfo str, Var *node) { char buf[500]; - sprintf(buf, "VAR"); - appendStringInfo(str, buf); + appendStringInfo(str, "VAR"); sprintf(buf, " :varno %d", node->varno); appendStringInfo(str, buf); sprintf(buf, " :varattno %hd", node->varattno); @@ -694,28 +690,24 @@ _outConst(StringInfo str, Const *node) { char buf[500]; - sprintf(buf, "CONST"); - appendStringInfo(str, buf); + appendStringInfo(str, "CONST"); sprintf(buf, " :consttype %u", node->consttype); appendStringInfo(str, buf); sprintf(buf, " :constlen %hd", node->constlen); appendStringInfo(str, buf); - sprintf(buf, " :constisnull %s", (node->constisnull ? "true" : "nil")); - appendStringInfo(str, buf); - sprintf(buf, " :constvalue "); - appendStringInfo(str, buf); + appendStringInfo(str, " :constisnull "); + appendStringInfo(str, node->constisnull ? "true" : "false"); + appendStringInfo(str, " :constvalue "); if (node->constisnull) { - sprintf(buf, "NIL "); - appendStringInfo(str, buf); + appendStringInfo(str, "\"\""); } else { _outDatum(str, node->constvalue, node->consttype); } - sprintf(buf, " :constbyval %s", (node->constbyval ? "true" : "nil")); - appendStringInfo(str, buf); - + appendStringInfo(str, " :constbyval "); + appendStringInfo(str, node->constbyval ? "true" : "false"); } /* @@ -726,20 +718,20 @@ _outAggreg(StringInfo str, Aggreg *node) { char buf[500]; - sprintf(buf, "AGGREG"); - appendStringInfo(str, buf); - sprintf(buf, " :aggname \"%s\"", (char *) node->aggname); + appendStringInfo(str, "AGGREG"); + appendStringInfo(str, " :aggname "); + appendStringInfo(str, (char *) node->aggname); appendStringInfo(str, buf); sprintf(buf, " :basetype %u", node->basetype); appendStringInfo(str, buf); sprintf(buf, " :aggtype %u", node->aggtype); appendStringInfo(str, buf); + appendStringInfo(str, " :target "); + _outNode(str, node->target); sprintf(buf, " :aggno %d", node->aggno); appendStringInfo(str, buf); - - sprintf(buf, " :target "); - appendStringInfo(str, buf); - _outNode(str, node->target); + appendStringInfo(str, " :usenulls "); + appendStringInfo(str, node->usenulls ? "true" : "false"); } /* @@ -751,8 +743,7 @@ _outArray(StringInfo str, Array *node) char buf[500]; int i; - sprintf(buf, "ARRAY"); - appendStringInfo(str, buf); + appendStringInfo(str, "ARRAY"); sprintf(buf, " :arrayelemtype %u", node->arrayelemtype); appendStringInfo(str, buf); sprintf(buf, " :arrayelemlength %d", node->arrayelemlength); @@ -761,15 +752,13 @@ _outArray(StringInfo str, Array *node) appendStringInfo(str, buf); sprintf(buf, " :arrayndim %d", node->arrayndim); appendStringInfo(str, buf); - sprintf(buf, " :arraylow "); - appendStringInfo(str, buf); + appendStringInfo(str, " :arraylow "); for (i = 0; i < node->arrayndim; i++) { sprintf(buf, " %d", node->arraylow.indx[i]); appendStringInfo(str, buf); } - sprintf(buf, " :arrayhigh "); - appendStringInfo(str, buf); + appendStringInfo(str, " :arrayhigh "); for (i = 0; i < node->arrayndim; i++) { sprintf(buf, " %d", node->arrayhigh.indx[i]); @@ -787,8 +776,7 @@ _outArrayRef(StringInfo str, ArrayRef *node) { char buf[500]; - sprintf(buf, "ARRAYREF"); - appendStringInfo(str, buf); + appendStringInfo(str, "ARRAYREF"); sprintf(buf, " :refelemtype %u", node->refelemtype); appendStringInfo(str, buf); sprintf(buf, " :refattrlength %d", node->refattrlength); @@ -798,20 +786,16 @@ _outArrayRef(StringInfo str, ArrayRef *node) sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f'); appendStringInfo(str, buf); - sprintf(buf, " :refupperindex "); - appendStringInfo(str, buf); + appendStringInfo(str, " :refupperindex "); _outNode(str, node->refupperindexpr); - sprintf(buf, " :reflowerindex "); - appendStringInfo(str, buf); + appendStringInfo(str, " :reflowerindex "); _outNode(str, node->reflowerindexpr); - sprintf(buf, " :refexpr "); - appendStringInfo(str, buf); + appendStringInfo(str, " :refexpr "); _outNode(str, node->refexpr); - sprintf(buf, " :refassgnexpr "); - appendStringInfo(str, buf); + appendStringInfo(str, " :refassgnexpr "); _outNode(str, node->refassgnexpr); } @@ -823,15 +807,13 @@ _outFunc(StringInfo str, Func *node) { char buf[500]; - sprintf(buf, "FUNC"); - appendStringInfo(str, buf); + appendStringInfo(str, "FUNC"); sprintf(buf, " :funcid %u", node->funcid); appendStringInfo(str, buf); sprintf(buf, " :functype %u", node->functype); appendStringInfo(str, buf); - sprintf(buf, " :funcisindex %s", - (node->funcisindex ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, " :funcisindex "); + appendStringInfo(str, (node->funcisindex ? "true" : "false")); sprintf(buf, " :funcsize %d", node->funcsize); appendStringInfo(str, buf); sprintf(buf, " :func_fcache @ 0x%x", (int) (node->func_fcache)); @@ -852,8 +834,7 @@ _outOper(StringInfo str, Oper *node) { char buf[500]; - sprintf(buf, "OPER"); - appendStringInfo(str, buf); + appendStringInfo(str, "OPER"); sprintf(buf, " :opno %u", node->opno); appendStringInfo(str, buf); sprintf(buf, " :opid %u", node->opid); @@ -871,14 +852,13 @@ _outParam(StringInfo str, Param *node) { char buf[500]; - sprintf(buf, "PARAM"); - appendStringInfo(str, buf); + appendStringInfo(str, "PARAM"); sprintf(buf, " :paramkind %d", node->paramkind); appendStringInfo(str, buf); sprintf(buf, " :paramid %hd", node->paramid); appendStringInfo(str, buf); - sprintf(buf, " :paramname \"%s\"", node->paramname); - appendStringInfo(str, buf); + appendStringInfo(str, " :paramname "); + appendStringInfo(str, node->paramname); sprintf(buf, " :paramtype %u", node->paramtype); appendStringInfo(str, buf); @@ -898,13 +878,11 @@ _outEState(StringInfo str, EState *node) { char buf[500]; - sprintf(buf, "ESTATE"); - appendStringInfo(str, buf); + appendStringInfo(str, "ESTATE"); sprintf(buf, " :direction %d", node->es_direction); appendStringInfo(str, buf); - sprintf(buf, " :range_table "); - appendStringInfo(str, buf); + appendStringInfo(str, " :range_table "); _outNode(str, node->es_range_table); sprintf(buf, " :result_relation_info @ 0x%x", @@ -921,15 +899,13 @@ _outRel(StringInfo str, Rel *node) { char buf[500]; - sprintf(buf, "REL"); - appendStringInfo(str, buf); + appendStringInfo(str, "REL"); - sprintf(buf, " :relids "); - appendStringInfo(str, buf); + appendStringInfo(str, " :relids "); _outIntList(str, node->relids); - sprintf(buf, " :indexed %s", (node->indexed ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, " :indexed "); + appendStringInfo(str, node->indexed ? "true" : "false"); sprintf(buf, " :pages %u", node->pages); appendStringInfo(str, buf); sprintf(buf, " :tuples %u", node->tuples); @@ -939,12 +915,10 @@ _outRel(StringInfo str, Rel *node) sprintf(buf, " :width %u", node->width); appendStringInfo(str, buf); - sprintf(buf, " :targetlist "); - appendStringInfo(str, buf); + appendStringInfo(str, " :targetlist "); _outNode(str, node->targetlist); - sprintf(buf, " :pathlist "); - appendStringInfo(str, buf); + appendStringInfo(str, " :pathlist "); _outNode(str, node->pathlist); /* @@ -958,33 +932,27 @@ _outRel(StringInfo str, Rel *node) sprintf(buf, " :cheapestpath @ 0x%x", (int) (node->cheapestpath)); appendStringInfo(str, buf); - sprintf(buf, " :pruneable %s", (node->pruneable ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, " :pruneable "); + appendStringInfo(str, node->pruneable ? "true" : "false"); #if 0 - sprintf(buf, " :classlist "); - appendStringInfo(str, buf); + appendStringInfo(str, " :classlist "); _outNode(str, node->classlist); - sprintf(buf, " :indexkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indexkeys "); _outNode(str, node->indexkeys); - sprintf(buf, " :ordering "); - appendStringInfo(str, buf); + appendStringInfo(str, " :ordering "); _outNode(str, node->ordering); #endif - sprintf(buf, " :clauseinfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :clauseinfo "); _outNode(str, node->clauseinfo); - sprintf(buf, " :joininfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :joininfo "); _outNode(str, node->joininfo); - sprintf(buf, " :innerjoin "); - appendStringInfo(str, buf); + appendStringInfo(str, " :innerjoin "); _outNode(str, node->innerjoin); } @@ -995,24 +963,12 @@ _outRel(StringInfo str, Rel *node) static void _outTargetEntry(StringInfo str, TargetEntry *node) { - char buf[500]; - - sprintf(buf, "TLE"); - appendStringInfo(str, buf); - sprintf(buf, " :resdom "); - appendStringInfo(str, buf); + appendStringInfo(str, "TLE"); + appendStringInfo(str, " :resdom "); _outNode(str, node->resdom); - sprintf(buf, " :expr "); - appendStringInfo(str, buf); - if (node->expr) - { - _outNode(str, node->expr); - } - else - { - appendStringInfo(str, "nil"); - } + appendStringInfo(str, " :expr "); + _outNode(str, node->expr); } static void @@ -1020,19 +976,16 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node) { char buf[500]; - sprintf(buf, "RTE"); - appendStringInfo(str, buf); + appendStringInfo(str, "RTE"); - sprintf(buf, " :relname \"%s\"", - ((node->relname) ? ((char *) node->relname) : "null")); - appendStringInfo(str, buf); + appendStringInfo(str, " :relname "); + appendStringInfo(str, node->relname); sprintf(buf, " :inh %d ", node->inh); appendStringInfo(str, buf); - sprintf(buf, " :refname \"%s\"", - ((node->refname) ? ((char *) node->refname) : "null")); - appendStringInfo(str, buf); + appendStringInfo(str, " :refname "); + appendStringInfo(str, node->refname); sprintf(buf, " :relid %u ", node->relid); appendStringInfo(str, buf); @@ -1046,8 +999,7 @@ _outPath(StringInfo str, Path *node) { char buf[500]; - sprintf(buf, "PATH"); - appendStringInfo(str, buf); + appendStringInfo(str, "PATH"); sprintf(buf, " :pathtype %d", node->pathtype); appendStringInfo(str, buf); @@ -1055,8 +1007,7 @@ _outPath(StringInfo str, Path *node) sprintf(buf, " :cost %f", node->path_cost); appendStringInfo(str, buf); - sprintf(buf, " :keys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :keys "); _outNode(str, node->keys); } @@ -1069,8 +1020,7 @@ _outIndexPath(StringInfo str, IndexPath *node) { char buf[500]; - sprintf(buf, "INDEXPATH"); - appendStringInfo(str, buf); + appendStringInfo(str, "INDEXPATH"); sprintf(buf, " :pathtype %d", node->path.pathtype); appendStringInfo(str, buf); @@ -1084,20 +1034,16 @@ _outIndexPath(StringInfo str, IndexPath *node) appendStringInfo(str, buf); #if 0 - sprintf(buf, " :p_ordering "); - appendStringInfo(str, buf); + appendStringInfo(str, " :p_ordering "); _outNode(str, node->path.p_ordering); #endif - sprintf(buf, " :keys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :keys "); _outNode(str, node->path.keys); - sprintf(buf, " :indexid "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indexid "); _outIntList(str, node->indexid); - sprintf(buf, " :indexqual "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indexqual "); _outNode(str, node->indexqual); } @@ -1110,8 +1056,7 @@ _outJoinPath(StringInfo str, JoinPath *node) { char buf[500]; - sprintf(buf, "JOINPATH"); - appendStringInfo(str, buf); + appendStringInfo(str, "JOINPATH"); sprintf(buf, " :pathtype %d", node->path.pathtype); appendStringInfo(str, buf); @@ -1125,16 +1070,13 @@ _outJoinPath(StringInfo str, JoinPath *node) appendStringInfo(str, buf); #if 0 - sprintf(buf, " :p_ordering "); - appendStringInfo(str, buf); + appendStringInfo(str, " :p_ordering "); _outNode(str, node->path.p_ordering); #endif - sprintf(buf, " :keys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :keys "); _outNode(str, node->path.keys); - sprintf(buf, " :pathclauseinfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :pathclauseinfo "); _outNode(str, node->pathclauseinfo); /* @@ -1150,8 +1092,7 @@ _outJoinPath(StringInfo str, JoinPath *node) sprintf(buf, " :outerjoincost %f", node->path.outerjoincost); appendStringInfo(str, buf); - sprintf(buf, " :joinid "); - appendStringInfo(str, buf); + appendStringInfo(str, " :joinid "); _outIntList(str, node->path.joinid); } @@ -1164,8 +1105,7 @@ _outMergePath(StringInfo str, MergePath *node) { char buf[500]; - sprintf(buf, "MERGEPATH"); - appendStringInfo(str, buf); + appendStringInfo(str, "MERGEPATH"); sprintf(buf, " :pathtype %d", node->jpath.path.pathtype); appendStringInfo(str, buf); @@ -1173,12 +1113,10 @@ _outMergePath(StringInfo str, MergePath *node) sprintf(buf, " :cost %f", node->jpath.path.path_cost); appendStringInfo(str, buf); - sprintf(buf, " :keys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :keys "); _outNode(str, node->jpath.path.keys); - sprintf(buf, " :pathclauseinfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :pathclauseinfo "); _outNode(str, node->jpath.pathclauseinfo); /* @@ -1194,20 +1132,16 @@ _outMergePath(StringInfo str, MergePath *node) sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost); appendStringInfo(str, buf); - sprintf(buf, " :joinid "); - appendStringInfo(str, buf); + appendStringInfo(str, " :joinid "); _outIntList(str, node->jpath.path.joinid); - sprintf(buf, " :path_mergeclauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :path_mergeclauses "); _outNode(str, node->path_mergeclauses); - sprintf(buf, " :outersortkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :outersortkeys "); _outNode(str, node->outersortkeys); - sprintf(buf, " :innersortkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :innersortkeys "); _outNode(str, node->innersortkeys); } @@ -1220,8 +1154,7 @@ _outHashPath(StringInfo str, HashPath *node) { char buf[500]; - sprintf(buf, "HASHPATH"); - appendStringInfo(str, buf); + appendStringInfo(str, "HASHPATH"); sprintf(buf, " :pathtype %d", node->jpath.path.pathtype); appendStringInfo(str, buf); @@ -1229,12 +1162,10 @@ _outHashPath(StringInfo str, HashPath *node) sprintf(buf, " :cost %f", node->jpath.path.path_cost); appendStringInfo(str, buf); - sprintf(buf, " :keys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :keys "); _outNode(str, node->jpath.path.keys); - sprintf(buf, " :pathclauseinfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :pathclauseinfo "); _outNode(str, node->jpath.pathclauseinfo); /* @@ -1250,20 +1181,16 @@ _outHashPath(StringInfo str, HashPath *node) sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost); appendStringInfo(str, buf); - sprintf(buf, " :joinid "); - appendStringInfo(str, buf); + appendStringInfo(str, " :joinid "); _outIntList(str, node->jpath.path.joinid); - sprintf(buf, " :path_hashclauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :path_hashclauses "); _outNode(str, node->path_hashclauses); - sprintf(buf, " :outerhashkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :outerhashkeys "); _outNode(str, node->outerhashkeys); - sprintf(buf, " :innerhashkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :innerhashkeys "); _outNode(str, node->innerhashkeys); } @@ -1276,8 +1203,7 @@ _outOrderKey(StringInfo str, OrderKey *node) { char buf[500]; - sprintf(buf, "ORDERKEY"); - appendStringInfo(str, buf); + appendStringInfo(str, "ORDERKEY"); sprintf(buf, " :attribute_number %d", node->attribute_number); appendStringInfo(str, buf); sprintf(buf, " :array_index %d", node->array_index); @@ -1291,17 +1217,12 @@ _outOrderKey(StringInfo str, OrderKey *node) static void _outJoinKey(StringInfo str, JoinKey *node) { - char buf[500]; + appendStringInfo(str, "JOINKEY"); - sprintf(buf, "JOINKEY"); - appendStringInfo(str, buf); - - sprintf(buf, " :outer "); - appendStringInfo(str, buf); + appendStringInfo(str, " :outer "); _outNode(str, node->outer); - sprintf(buf, " :inner "); - appendStringInfo(str, buf); + appendStringInfo(str, " :inner "); _outNode(str, node->inner); } @@ -1314,8 +1235,7 @@ _outMergeOrder(StringInfo str, MergeOrder *node) { char buf[500]; - sprintf(buf, "MERGEORDER"); - appendStringInfo(str, buf); + appendStringInfo(str, "MERGEORDER"); sprintf(buf, " :join_operator %d", node->join_operator); appendStringInfo(str, buf); @@ -1338,24 +1258,20 @@ _outCInfo(StringInfo str, CInfo *node) { char buf[500]; - sprintf(buf, "CINFO"); - appendStringInfo(str, buf); + appendStringInfo(str, "CINFO"); - sprintf(buf, " :clause "); - appendStringInfo(str, buf); + appendStringInfo(str, " :clause "); _outNode(str, node->clause); sprintf(buf, " :selectivity %f", node->selectivity); appendStringInfo(str, buf); - sprintf(buf, " :notclause %s", (node->notclause ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, " :notclause "); + appendStringInfo(str, node->notclause ? "true" : "false"); - sprintf(buf, " :indexids "); - appendStringInfo(str, buf); + appendStringInfo(str, " :indexids "); _outNode(str, node->indexids); - sprintf(buf, " :mergesortorder "); - appendStringInfo(str, buf); + appendStringInfo(str, " :mergesortorder "); _outNode(str, node->mergesortorder); sprintf(buf, " :hashjoinoperator %u", node->hashjoinoperator); @@ -1369,17 +1285,12 @@ _outCInfo(StringInfo str, CInfo *node) static void _outJoinMethod(StringInfo str, JoinMethod *node) { - char buf[500]; - - sprintf(buf, "JOINMETHOD"); - appendStringInfo(str, buf); + appendStringInfo(str, "JOINMETHOD"); - sprintf(buf, " :jmkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :jmkeys "); _outNode(str, node->jmkeys); - sprintf(buf, " :clauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :clauses "); _outNode(str, node->clauses); @@ -1393,20 +1304,16 @@ _outHInfo(StringInfo str, HInfo *node) { char buf[500]; - sprintf(buf, "HASHINFO"); - appendStringInfo(str, buf); + appendStringInfo(str, "HASHINFO"); - sprintf(buf, " :hashop "); - appendStringInfo(str, buf); + appendStringInfo(str, " :hashop "); sprintf(buf, "%u", node->hashop); appendStringInfo(str, buf); - sprintf(buf, " :jmkeys "); - appendStringInfo(str, buf); + appendStringInfo(str, " :jmkeys "); _outNode(str, node->jmethod.jmkeys); - sprintf(buf, " :clauses "); - appendStringInfo(str, buf); + appendStringInfo(str, " :clauses "); _outNode(str, node->jmethod.clauses); } @@ -1417,25 +1324,18 @@ _outHInfo(StringInfo str, HInfo *node) static void _outJInfo(StringInfo str, JInfo *node) { - char buf[500]; - - sprintf(buf, "JINFO"); - appendStringInfo(str, buf); + appendStringInfo(str, "JINFO"); - sprintf(buf, " :otherrels "); - appendStringInfo(str, buf); + appendStringInfo(str, " :otherrels "); _outIntList(str, node->otherrels); - sprintf(buf, " :jinfoclauseinfo "); - appendStringInfo(str, buf); + appendStringInfo(str, " :jinfoclauseinfo "); _outNode(str, node->jinfoclauseinfo); - sprintf(buf, " :mergesortable %s", - (node->mergesortable ? "true" : "nil")); - appendStringInfo(str, buf); - sprintf(buf, " :hashjoinable %s", - (node->hashjoinable ? "true" : "nil")); - appendStringInfo(str, buf); + appendStringInfo(str, " :mergesortable "); + appendStringInfo(str, node->mergesortable ? "true" : "false"); + appendStringInfo(str, " :hashjoinable "); + appendStringInfo(str, node->hashjoinable ? "true" : "false"); } @@ -1550,10 +1450,8 @@ _outStream(StringInfo str, Stream *node) static void _outAExpr(StringInfo str, A_Expr *node) { - char buf[500]; - - sprintf(buf, "EXPR %s", node->opname); - appendStringInfo(str, buf); + appendStringInfo(str, "EXPR "); + appendStringInfo(str, node->opname); _outNode(str, node->lexpr); _outNode(str, node->rexpr); return; @@ -1589,7 +1487,7 @@ _outIdent(StringInfo str, Ident *node) { char buf[500]; - sprintf(buf, "IDENT %s", node->name); + sprintf(buf, "IDENT \"%s\"", node->name); appendStringInfo(str, buf); return; } @@ -1614,7 +1512,7 @@ _outNode(StringInfo str, void *obj) { if (obj == NULL) { - appendStringInfo(str, "nil"); + appendStringInfo(str, "\"\""); return; } @@ -1653,6 +1551,9 @@ _outNode(StringInfo str, void *obj) case T_Query: _outQuery(str, obj); break; + case T_SortGroupBy: + _outSortGroupBy(str, obj); + break; case T_Plan: _outPlan(str, obj); break; diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index 28f3f20847..ef12ecf734 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.6 1998/01/05 03:31:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.7 1998/01/06 18:52:18 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -94,7 +94,7 @@ nodeTokenType(char *token, int length) retval = (*token != '.') ? T_Integer : T_Float; } - else if (isalpha(*token)) + else if (isalpha(*token) || *token == '_') retval = ATOM_TOKEN; else if (*token == '(') retval = LEFT_PAREN; @@ -145,8 +145,12 @@ lsptok(char *string, int *length) if (*local_str == '\"') { - for (local_str++; *local_str != '\"'; (*length)++, local_str++); - (*length)++; + for (local_str++; *local_str != '\"'; (*length)++, local_str++) + ; + if (*length == 2) + *length -= 2; /* if "", return zero length */ + else + (*length)++; local_str++; } else if (*local_str == ')' || *local_str == '(' || @@ -225,12 +229,12 @@ nodeRead(bool read_car_only) case AT_SYMBOL: break; case ATOM_TOKEN: - if (!strncmp(token, "nil", 3)) + if (!strncmp(token, "\"\"", 2)) { this_value = NULL; /* - * It might be "nil" but it is an atom! + * It might be NULL but it is an atom! */ if (read_car_only) { @@ -283,6 +287,7 @@ nodeRead(bool read_car_only) List *l = makeNode(List); lfirst(l) = this_value; + if (!read_car_only) { lnext(l) = nodeRead(false); diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 7ac0e725e7..d43646c92d 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.13 1998/01/05 03:31:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.14 1998/01/06 18:52:22 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -76,16 +76,19 @@ _readQuery() Query *local_node; char *token; int length; - + int i; + local_node = makeNode(Query); token = lsptok(NULL, &length); /* skip the :command */ token = lsptok(NULL, &length); /* get the commandType */ local_node->commandType = atoi(token); - token = lsptok(NULL, &length); /* skip the :utility */ + token = lsptok(NULL, &length); /* skip :utility */ + /* we can't get create or index here, can we? */ + token = lsptok(NULL, &length); /* get the notify name if any */ - if (token[0] == '"' && token[1] == '"') + if (length == 0) local_node->utilityStmt = NULL; else { @@ -96,17 +99,35 @@ _readQuery() local_node->utilityStmt = (Node *) n; } - token = lsptok(NULL, &length); /* skip the :resrel */ + token = lsptok(NULL, &length); /* skip the :resultRelation */ token = lsptok(NULL, &length); /* get the resultRelation */ local_node->resultRelation = atoi(token); - token = lsptok(NULL, &length); /* skip :rtable */ - local_node->rtable = nodeRead(true); - - token = lsptok(NULL, &length); /* skip the :unique */ - token = lsptok(NULL, &length); /* get the uniqueFlag */ -/* local_node->uniqueFlag = (bool)atoi(token); */ - if (token[0] == '"' && token[1] == '"') /* non-unique */ + token = lsptok(NULL, &length); /* skip :into */ + token = lsptok(NULL, &length); /* get into */ + if (length == 0) + local_node->into = NULL; + else + { + local_node->into = palloc(length + 1); + StrNCpy(local_node->into, token, length+1); + } + + token = lsptok(NULL, &length); /* skip :isPortal */ + token = lsptok(NULL, &length); /* get isPortal */ + local_node->isPortal = (token[0] == 't') ? true : false; + + token = lsptok(NULL, &length); /* skip :isBinary */ + token = lsptok(NULL, &length); /* get isBinary */ + local_node->isBinary = (token[0] == 't') ? true : false; + + token = lsptok(NULL, &length); /* skip :unionall */ + token = lsptok(NULL, &length); /* get unionall */ + local_node->unionall = (token[0] == 't') ? true : false; + + token = lsptok(NULL, &length); /* skip :uniqueFlag */ + token = lsptok(NULL, &length); /* get uniqueFlag */ + if (length == 0) local_node->uniqueFlag = NULL; else { @@ -114,12 +135,90 @@ _readQuery() StrNCpy(local_node->uniqueFlag, token, length+1); } + token = lsptok(NULL, &length); /* skip :sortClause */ + local_node->sortClause = nodeRead(true); + + token = lsptok(NULL, &length); /* skip :rtable */ + local_node->rtable = nodeRead(true); + token = lsptok(NULL, &length); /* skip :targetlist */ local_node->targetList = nodeRead(true); token = lsptok(NULL, &length); /* skip :qual */ local_node->qual = nodeRead(true); - /* how are we handling aggregates, sort, and group by? bjm 1997/12/26 */ + + token = lsptok(NULL, &length); /* skip :groupClause */ + local_node->groupClause = nodeRead(true); + + token = lsptok(NULL, &length); /* skip :havingQual */ + local_node->havingQual = nodeRead(true); + + token = lsptok(NULL, &length); /* skip the :qry_numAgg */ + token = lsptok(NULL, &length); /* get qry_numAgg */ + local_node->qry_numAgg = atoi(token); + + token = lsptok(NULL, &length); /* skip the :qry_Aggs */ + if (local_node->qry_numAgg == 0) + local_node->qry_aggs = NULL; + else + { + local_node->qry_aggs = palloc(sizeof(Aggreg *) * local_node->qry_numAgg); + for (i=0; i < local_node->qry_numAgg; i++) + local_node->qry_aggs[i] = nodeRead(true); + } + + token = lsptok(NULL, &length); /* skip :unionClause */ + local_node->unionClause = nodeRead(true); + + return (local_node); +} + +/* ---------------- + * _readSortGroupBy + * ---------------- + */ +static SortGroupBy * +_readSortGroupBy() +{ + SortGroupBy *local_node; + char *token; + int length; + + local_node = makeNode(SortGroupBy); + + token = lsptok(NULL, &length); /* skip the :resno */ + token = lsptok(NULL, &length); /* get resno */ + local_node->resno = atoi(token); + + token = lsptok(NULL, &length); /* skip :range */ + token = lsptok(NULL, &length); /* get range */ + if (length == 0) + local_node->range = NULL; + else + { + local_node->range = palloc(length + 1); + StrNCpy(local_node->range, token, length+1); + } + + token = lsptok(NULL, &length); /* skip :name */ + token = lsptok(NULL, &length); /* get name */ + if (length == 0) + local_node->name = NULL; + else + { + local_node->name = palloc(length + 1); + StrNCpy(local_node->name, token, length+1); + } + + token = lsptok(NULL, &length); /* skip :useOp */ + token = lsptok(NULL, &length); /* get useOp */ + if (length == 0) + local_node->useOp = NULL; + else + { + local_node->useOp = palloc(length + 1); + StrNCpy(local_node->useOp, token, length+1); + } return (local_node); } @@ -239,6 +338,9 @@ _readAppend() token = lsptok(NULL, &length); /* eat :unionplans */ local_node->unionplans = nodeRead(true); /* now read it */ + token = lsptok(NULL, &length); /* eat :unionrts */ + local_node->unionrts = nodeRead(true); /* now read it */ + token = lsptok(NULL, &length); /* eat :unionrelid */ token = lsptok(NULL, &length); /* get unionrelid */ local_node->unionrelid = atoi(token); @@ -623,23 +725,12 @@ _readResdom() token = lsptok(NULL, &length); /* eat :resname */ token = lsptok(NULL, &length); /* get the name */ - if (!strncmp(token, "\"null\"", 5)) - { + if (length == 0) local_node->resname = NULL; - } else { - - /* - * Peel off ""'s, then make a true copy. - */ - - token++; - token[length - 2] = '\0'; - - local_node->resname = palloc(length); - strcpy(local_node->resname, token); - token[length - 2] = '\"'; + local_node->resname = (char *) palloc(length + 1); + StrNCpy(local_node->resname, token, length+1); } token = lsptok(NULL, &length); /* eat :reskey */ @@ -1016,11 +1107,13 @@ _readParam() token = lsptok(NULL, &length); /* get :paramname */ token = lsptok(NULL, &length); /* now read it */ - token++; /* skip the first `"' */ - token[length - 2] = '\0'; /* this is the 2nd `"' */ - - local_node->paramname = pstrdup(token); - token[length - 2] = '\"'; /* restore the 2nd `"' */ + if (length == 0) + local_node->paramname = NULL; + else + { + local_node->paramname = (char *) palloc(length + 1); + StrNCpy(local_node->paramname, token, length+1); + } token = lsptok(NULL, &length); /* get :paramtype */ token = lsptok(NULL, &length); /* now read it */ @@ -1060,12 +1153,16 @@ _readAggreg() token = lsptok(NULL, &length); /* get aggtype */ local_node->aggtype = (Oid) atol(token); + token = lsptok(NULL, &length); /* eat :target */ + local_node->target = nodeRead(true); /* now read it */ + token = lsptok(NULL, &length); /* eat :aggno */ token = lsptok(NULL, &length); /* get aggno */ local_node->aggno = atoi(token); - token = lsptok(NULL, &length); /* eat :target */ - local_node->target = nodeRead(true); /* now read it */ + token = lsptok(NULL, &length); /* eat :usenulls */ + token = lsptok(NULL, &length); /* get usenulls */ + local_node->usenulls = (token[0] == 't') ? true : false; return (local_node); } @@ -1216,7 +1313,7 @@ _readTargetEntry() } /* ---------------- - * _readTargetEntry + * _readRangeTblEntry * ---------------- */ static RangeTblEntry * @@ -1230,23 +1327,12 @@ _readRangeTblEntry() token = lsptok(NULL, &length); /* eat :relname */ token = lsptok(NULL, &length); /* get :relname */ - if (!strncmp(token, "\"null\"", 5)) - { + if (length == 0) local_node->relname = NULL; - } else { - - /* - * Peel off ""'s, then make a true copy. - */ - - token++; - token[length - 2] = '\0'; - - local_node->relname = (char *) palloc(NAMEDATALEN); - strcpy(local_node->relname, token); - token[length - 2] = '\"'; + local_node->relname = (char *) palloc(length + 1); + StrNCpy(local_node->relname, token, length+1); } token = lsptok(NULL, &length); /* eat :inh */ @@ -1255,22 +1341,12 @@ _readRangeTblEntry() token = lsptok(NULL, &length); /* eat :refname */ token = lsptok(NULL, &length); /* get :refname */ - if (!strncmp(token, "\"null\"", 5)) - { + if (length == 0) local_node->refname = NULL; - } else { - - /* - * Peel off ""'s, then make a true copy. - */ - - token++; - token[length - 2] = '\0'; - - local_node->refname = (char *) pstrdup(token); - token[length - 2] = '\"'; + local_node->refname = (char *) palloc(length + 1); + StrNCpy(local_node->refname, token, length+1); } token = lsptok(NULL, &length); /* eat :relid */ @@ -2032,6 +2108,10 @@ parsePlanString(void) { return_value = _readQuery(); } + else if (!strncmp(token, "SORTGROUPBY", 11)) + { + return_value = _readSortGroupBy(); + } else { elog(ABORT, "badly formatted planstring \"%.10s\"...\n", token); diff --git a/src/backend/optimizer/path/prune.c b/src/backend/optimizer/path/prune.c index 4358f19150..2a8c49e624 100644 --- a/src/backend/optimizer/path/prune.c +++ b/src/backend/optimizer/path/prune.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.9 1998/01/05 03:31:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.10 1998/01/06 18:52:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -76,21 +76,18 @@ prune_joinrel(Rel *rel, List *other_rels) return_list = cur; /* remove relations that do match, we use lnext so we can remove easily */ - if (cur != NIL) + while (cur != NIL && lnext(cur) != NIL) { - while (lnext(cur) != NIL) - { - Rel *other_rel = (Rel *) lfirst(lnext(cur)); + Rel *other_rel = (Rel *) lfirst(lnext(cur)); - if (same(rel->relids, other_rel->relids)) - { - rel->pathlist = add_pathlist(rel, - rel->pathlist, - other_rel->pathlist); - lnext(cur) = lnext(lnext(cur)); /* delete it */ - } - cur = lnext(cur); + if (same(rel->relids, other_rel->relids)) + { + rel->pathlist = add_pathlist(rel, + rel->pathlist, + other_rel->pathlist); + lnext(cur) = lnext(lnext(cur)); /* delete it */ } + cur = lnext(cur); } return return_list; } |