Commit 9d00fbbe authored by Bruce Momjian's avatar Bruce Momjian

Change some labels in bootparse to make ctags happy. Clean up...

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.
parent 42acc6e8
...@@ -56,7 +56,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -56,7 +56,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
/* Lookup element type information */ /* Lookup element type information */
typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype),0,0,0); typ_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(elemtype),0,0,0);
if (!HeapTupleIsValid(typ_tuple)) { if (!HeapTupleIsValid(typ_tuple)) {
elog(WARN,"array_iterator: cache lookup failed for type %d", elemtype); elog(ERROR,"array_iterator: cache lookup failed for type %d", elemtype);
return 0; return 0;
} }
typ_struct = (TypeTupleForm) GETSTRUCT(typ_tuple); typ_struct = (TypeTupleForm) GETSTRUCT(typ_tuple);
...@@ -67,7 +67,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value) ...@@ -67,7 +67,7 @@ array_iterator(Oid elemtype, Oid proc, int and, ArrayType *array, Datum value)
proc_fn = (func_ptr) NULL; proc_fn = (func_ptr) NULL;
fmgr_info(proc, &proc_fn, &pronargs); fmgr_info(proc, &proc_fn, &pronargs);
if ((proc_fn == NULL) || (pronargs != 2)) { if ((proc_fn == NULL) || (pronargs != 2)) {
elog(WARN, "array_iterator: fmgr_info lookup failed for oid %d", proc); elog(ERROR, "array_iterator: fmgr_info lookup failed for oid %d", proc);
return (0); return (0);
} }
......
...@@ -47,23 +47,23 @@ hhmm_in(char *str) ...@@ -47,23 +47,23 @@ hhmm_in(char *str)
int ftype[MAXDATEFIELDS]; int ftype[MAXDATEFIELDS];
if (!PointerIsValid(str)) if (!PointerIsValid(str))
elog(WARN,"Bad (null) time external representation",NULL); elog(ERROR,"Bad (null) time external representation",NULL);
if ((ParseDateTime( str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0) if ((ParseDateTime( str, lowstr, field, ftype, MAXDATEFIELDS, &nf) != 0)
|| (DecodeTimeOnly( field, ftype, nf, &dtype, tm, &fsec) != 0)) || (DecodeTimeOnly( field, ftype, nf, &dtype, tm, &fsec) != 0))
elog(WARN,"Bad time external representation '%s'",str); elog(ERROR,"Bad time external representation '%s'",str);
if (tm->tm_hour<0 || tm->tm_hour>24 || if (tm->tm_hour<0 || tm->tm_hour>24 ||
(tm->tm_hour==24 && (tm->tm_min!=0 || tm->tm_sec!=0 || fsec!= 0))) { (tm->tm_hour==24 && (tm->tm_min!=0 || tm->tm_sec!=0 || fsec!= 0))) {
elog(WARN, elog(ERROR,
"time_in: hour must be limited to values 0 through 24:00 " "time_in: hour must be limited to values 0 through 24:00 "
"in \"%s\"", "in \"%s\"",
str); str);
} }
if ((tm->tm_min < 0) || (tm->tm_min > 59)) if ((tm->tm_min < 0) || (tm->tm_min > 59))
elog(WARN,"Minute must be limited to values 0 through 59 in '%s'",str); elog(ERROR,"Minute must be limited to values 0 through 59 in '%s'",str);
if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60)) if ((tm->tm_sec < 0) || ((tm->tm_sec + fsec) >= 60))
elog(WARN,"Second must be limited to values 0 through < 60 in '%s'", elog(ERROR,"Second must be limited to values 0 through < 60 in '%s'",
str); str);
time = PALLOCTYPE(TimeADT); time = PALLOCTYPE(TimeADT);
......
...@@ -110,13 +110,13 @@ int8in(char *str) ...@@ -110,13 +110,13 @@ int8in(char *str)
#if HAVE_64BIT_INTS #if HAVE_64BIT_INTS
if (!PointerIsValid(str)) if (!PointerIsValid(str))
elog(WARN, "Bad (null) int8 external representation", NULL); elog(ERROR, "Bad (null) int8 external representation", NULL);
if (sscanf(str, INT64_FORMAT, result) != 1) if (sscanf(str, INT64_FORMAT, result) != 1)
elog(WARN, "Bad int8 external representation '%s'", str); elog(ERROR, "Bad int8 external representation '%s'", str);
#else #else
elog(WARN, "64-bit integers are not supported", NULL); elog(ERROR, "64-bit integers are not supported", NULL);
result = NULL; result = NULL;
#endif #endif
...@@ -139,14 +139,14 @@ int8out(int64 * val) ...@@ -139,14 +139,14 @@ int8out(int64 * val)
return (NULL); return (NULL);
if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, *val)) < 0) if ((len = snprintf(buf, MAXINT8LEN, INT64_FORMAT, *val)) < 0)
elog(WARN, "Unable to format int8", NULL); elog(ERROR, "Unable to format int8", NULL);
result = PALLOC(len + 1); result = PALLOC(len + 1);
strcpy(result, buf); strcpy(result, buf);
#else #else
elog(WARN, "64-bit integers are not supported", NULL); elog(ERROR, "64-bit integers are not supported", NULL);
result = NULL; result = NULL;
#endif #endif
...@@ -328,10 +328,10 @@ int84(int64 * val) ...@@ -328,10 +328,10 @@ int84(int64 * val)
int32 result; int32 result;
if (!PointerIsValid(val)) if (!PointerIsValid(val))
elog(WARN, "Invalid (null) int64, can't convert int8 to int4", NULL); elog(ERROR, "Invalid (null) int64, can't convert int8 to int4", NULL);
if ((*val < INT_MIN) || (*val > INT_MAX)) if ((*val < INT_MIN) || (*val > INT_MAX))
elog(WARN, "int8 conversion to int4 is out of range", NULL); elog(ERROR, "int8 conversion to int4 is out of range", NULL);
result = *val; result = *val;
...@@ -345,7 +345,7 @@ int28 (int16 val) ...@@ -345,7 +345,7 @@ int28 (int16 val)
int64 *result; int64 *result;
if (!PointerIsValid(result = PALLOCTYPE(int64))) if (!PointerIsValid(result = PALLOCTYPE(int64)))
elog(WARN, "Memory allocation failed, can't convert int8 to int2", NULL); elog(ERROR, "Memory allocation failed, can't convert int8 to int2", NULL);
*result = val; *result = val;
...@@ -358,7 +358,7 @@ int82(int64 * val) ...@@ -358,7 +358,7 @@ int82(int64 * val)
int16 result; int16 result;
if (!PointerIsValid(val)) if (!PointerIsValid(val))
elog(WARN, "Invalid (null) int8, can't convert to int2", NULL); elog(ERROR, "Invalid (null) int8, can't convert to int2", NULL);
result = *val; result = *val;
...@@ -383,7 +383,7 @@ dtoi8(float64 val) ...@@ -383,7 +383,7 @@ dtoi8(float64 val)
int64 *result = PALLOCTYPE(int64); int64 *result = PALLOCTYPE(int64);
if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1))) if ((*val < (-pow(2, 64) + 1)) || (*val > (pow(2, 64) - 1)))
elog(WARN, "Floating point conversion to int64 is out of range", NULL); elog(ERROR, "Floating point conversion to int64 is out of range", NULL);
*result = *val; *result = *val;
......
...@@ -23,18 +23,18 @@ autoinc() ...@@ -23,18 +23,18 @@ autoinc()
int i; int i;
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(WARN, "autoinc: triggers are not initialized"); elog(ERROR, "autoinc: triggers are not initialized");
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
elog(WARN, "autoinc: can't process STATEMENT events"); elog(ERROR, "autoinc: can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event))
elog(WARN, "autoinc: must be fired before event"); elog(ERROR, "autoinc: must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
rettuple = CurrentTriggerData->tg_trigtuple; rettuple = CurrentTriggerData->tg_trigtuple;
else if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) else if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
rettuple = CurrentTriggerData->tg_newtuple; rettuple = CurrentTriggerData->tg_newtuple;
else else
elog(WARN, "autoinc: can't process DELETE events"); elog(ERROR, "autoinc: can't process DELETE events");
rel = CurrentTriggerData->tg_relation; rel = CurrentTriggerData->tg_relation;
relname = SPI_getrelname(rel); relname = SPI_getrelname(rel);
...@@ -43,7 +43,7 @@ autoinc() ...@@ -43,7 +43,7 @@ autoinc()
nargs = trigger->tgnargs; nargs = trigger->tgnargs;
if (nargs <= 0 || nargs % 2 != 0) if (nargs <= 0 || nargs % 2 != 0)
elog(WARN, "autoinc (%s): even number gt 0 of arguments was expected", relname); elog(ERROR, "autoinc (%s): even number gt 0 of arguments was expected", relname);
args = trigger->tgargs; args = trigger->tgargs;
tupdesc = rel->rd_att; tupdesc = rel->rd_att;
...@@ -60,9 +60,9 @@ autoinc() ...@@ -60,9 +60,9 @@ autoinc()
int32 val; int32 val;
if ( attnum < 0 ) if ( attnum < 0 )
elog(WARN, "autoinc (%s): there is no attribute %s", relname, args[i]); elog(ERROR, "autoinc (%s): there is no attribute %s", relname, args[i]);
if (SPI_gettypeid (tupdesc, attnum) != INT4OID) if (SPI_gettypeid (tupdesc, attnum) != INT4OID)
elog(WARN, "autoinc (%s): attribute %s must be of INT4 type", elog(ERROR, "autoinc (%s): attribute %s must be of INT4 type",
relname, args[i]); relname, args[i]);
val = DatumGetInt32 (SPI_getbinval (rettuple, tupdesc, attnum, &isnull)); val = DatumGetInt32 (SPI_getbinval (rettuple, tupdesc, attnum, &isnull));
...@@ -88,7 +88,7 @@ autoinc() ...@@ -88,7 +88,7 @@ autoinc()
{ {
rettuple = SPI_modifytuple (rel, rettuple, chnattrs, chattrs, newvals, NULL); rettuple = SPI_modifytuple (rel, rettuple, chnattrs, chattrs, newvals, NULL);
if ( rettuple == NULL ) if ( rettuple == NULL )
elog (WARN, "autoinc (%s): %d returned by SPI_modifytuple", elog (ERROR, "autoinc (%s): %d returned by SPI_modifytuple",
relname, SPI_result); relname, SPI_result);
} }
......
...@@ -27,18 +27,18 @@ insert_username () ...@@ -27,18 +27,18 @@ insert_username ()
/* sanity checks from autoinc.c */ /* sanity checks from autoinc.c */
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(WARN, "insert_username: triggers are not initialized"); elog(ERROR, "insert_username: triggers are not initialized");
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
elog(WARN, "insert_username: can't process STATEMENT events"); elog(ERROR, "insert_username: can't process STATEMENT events");
if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event))
elog(WARN, "insert_username: must be fired before event"); elog(ERROR, "insert_username: must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
rettuple = CurrentTriggerData->tg_trigtuple; rettuple = CurrentTriggerData->tg_trigtuple;
else if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) else if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
rettuple = CurrentTriggerData->tg_newtuple; rettuple = CurrentTriggerData->tg_newtuple;
else else
elog(WARN, "insert_username: can't process DELETE events"); elog(ERROR, "insert_username: can't process DELETE events");
rel = CurrentTriggerData->tg_relation; rel = CurrentTriggerData->tg_relation;
relname = SPI_getrelname(rel); relname = SPI_getrelname(rel);
...@@ -47,7 +47,7 @@ insert_username () ...@@ -47,7 +47,7 @@ insert_username ()
nargs = trigger->tgnargs; nargs = trigger->tgnargs;
if (nargs != 1) if (nargs != 1)
elog(WARN, "insert_username (%s): one argument was expected", relname); elog(ERROR, "insert_username (%s): one argument was expected", relname);
args = trigger->tgargs; args = trigger->tgargs;
tupdesc = rel->rd_att; tupdesc = rel->rd_att;
...@@ -57,9 +57,9 @@ insert_username () ...@@ -57,9 +57,9 @@ insert_username ()
attnum = SPI_fnumber (tupdesc, args[0]); attnum = SPI_fnumber (tupdesc, args[0]);
if ( attnum < 0 ) if ( attnum < 0 )
elog(WARN, "insert_username (%s): there is no attribute %s", relname, args[0]); elog(ERROR, "insert_username (%s): there is no attribute %s", relname, args[0]);
if (SPI_gettypeid (tupdesc, attnum) != TEXTOID) if (SPI_gettypeid (tupdesc, attnum) != TEXTOID)
elog(WARN, "insert_username (%s): attribute %s must be of TEXT type", elog(ERROR, "insert_username (%s): attribute %s must be of TEXT type",
relname, args[0]); relname, args[0]);
/* create fields containing name */ /* create fields containing name */
...@@ -68,7 +68,7 @@ insert_username () ...@@ -68,7 +68,7 @@ insert_username ()
/* construct new tuple */ /* construct new tuple */
rettuple = SPI_modifytuple (rel, rettuple, 1, &attnum, &newval, NULL); rettuple = SPI_modifytuple (rel, rettuple, 1, &attnum, &newval, NULL);
if ( rettuple == NULL ) if ( rettuple == NULL )
elog (WARN, "insert_username (%s): %d returned by SPI_modifytuple", elog (ERROR, "insert_username (%s): %d returned by SPI_modifytuple",
relname, SPI_result); relname, SPI_result);
pfree (relname); pfree (relname);
......
...@@ -60,11 +60,11 @@ check_primary_key() ...@@ -60,11 +60,11 @@ check_primary_key()
/* Called by trigger manager ? */ /* Called by trigger manager ? */
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(WARN, "check_primary_key: triggers are not initialized"); elog(ERROR, "check_primary_key: triggers are not initialized");
/* Should be called for ROW trigger */ /* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
elog(WARN, "check_primary_key: can't process STATEMENT events"); elog(ERROR, "check_primary_key: can't process STATEMENT events");
/* If INSERTion then must check Tuple to being inserted */ /* If INSERTion then must check Tuple to being inserted */
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
...@@ -74,7 +74,7 @@ check_primary_key() ...@@ -74,7 +74,7 @@ check_primary_key()
/* Not should be called for DELETE */ /* Not should be called for DELETE */
else if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event)) else if (TRIGGER_FIRED_BY_DELETE(CurrentTriggerData->tg_event))
elog(WARN, "check_primary_key: can't process DELETE events"); elog(ERROR, "check_primary_key: can't process DELETE events");
/* If UPDATion the must check new Tuple, not old one */ /* If UPDATion the must check new Tuple, not old one */
else else
...@@ -85,7 +85,7 @@ check_primary_key() ...@@ -85,7 +85,7 @@ check_primary_key()
args = trigger->tgargs; args = trigger->tgargs;
if (nargs % 2 != 1) /* odd number of arguments! */ if (nargs % 2 != 1) /* odd number of arguments! */
elog(WARN, "check_primary_key: odd number of arguments should be specified"); elog(ERROR, "check_primary_key: odd number of arguments should be specified");
nkeys = nargs / 2; nkeys = nargs / 2;
relname = args[nkeys]; relname = args[nkeys];
...@@ -101,7 +101,7 @@ check_primary_key() ...@@ -101,7 +101,7 @@ check_primary_key()
/* Connect to SPI manager */ /* Connect to SPI manager */
if ((ret = SPI_connect()) < 0) if ((ret = SPI_connect()) < 0)
elog(WARN, "check_primary_key: SPI_connect returned %d", ret); elog(ERROR, "check_primary_key: SPI_connect returned %d", ret);
/* /*
* We use SPI plan preparation feature, so allocate space to place key * We use SPI plan preparation feature, so allocate space to place key
...@@ -128,7 +128,7 @@ check_primary_key() ...@@ -128,7 +128,7 @@ check_primary_key()
/* Bad guys may give us un-existing column in CREATE TRIGGER */ /* Bad guys may give us un-existing column in CREATE TRIGGER */
if (fnumber < 0) if (fnumber < 0)
elog(WARN, "check_primary_key: there is no attribute %s in relation %s", elog(ERROR, "check_primary_key: there is no attribute %s in relation %s",
args[i], SPI_getrelname(rel)); args[i], SPI_getrelname(rel));
/* Well, get binary (in internal format) value of column */ /* Well, get binary (in internal format) value of column */
...@@ -171,7 +171,7 @@ check_primary_key() ...@@ -171,7 +171,7 @@ check_primary_key()
/* Prepare plan for query */ /* Prepare plan for query */
pplan = SPI_prepare(sql, nkeys, argtypes); pplan = SPI_prepare(sql, nkeys, argtypes);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "check_primary_key: SPI_prepare returned %d", SPI_result); elog(ERROR, "check_primary_key: SPI_prepare returned %d", SPI_result);
/* /*
* Remember that SPI_prepare places plan in current memory context * Remember that SPI_prepare places plan in current memory context
...@@ -180,7 +180,7 @@ check_primary_key() ...@@ -180,7 +180,7 @@ check_primary_key()
*/ */
pplan = SPI_saveplan(pplan); pplan = SPI_saveplan(pplan);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "check_primary_key: SPI_saveplan returned %d", SPI_result); elog(ERROR, "check_primary_key: SPI_saveplan returned %d", SPI_result);
plan->splan = (void **) malloc(sizeof(void *)); plan->splan = (void **) malloc(sizeof(void *));
*(plan->splan) = pplan; *(plan->splan) = pplan;
plan->nplans = 1; plan->nplans = 1;
...@@ -193,13 +193,13 @@ check_primary_key() ...@@ -193,13 +193,13 @@ check_primary_key()
/* we have no NULLs - so we pass ^^^^ here */ /* we have no NULLs - so we pass ^^^^ here */
if (ret < 0) if (ret < 0)
elog(WARN, "check_primary_key: SPI_execp returned %d", ret); elog(ERROR, "check_primary_key: SPI_execp returned %d", ret);
/* /*
* If there are no tuples returned by SELECT then ... * If there are no tuples returned by SELECT then ...
*/ */
if (SPI_processed == 0) if (SPI_processed == 0)
elog(WARN, "%s: tuple references non-existing key in %s", elog(ERROR, "%s: tuple references non-existing key in %s",
trigger->tgname, relname); trigger->tgname, relname);
SPI_finish(); SPI_finish();
...@@ -250,16 +250,16 @@ check_foreign_key() ...@@ -250,16 +250,16 @@ check_foreign_key()
/* Called by trigger manager ? */ /* Called by trigger manager ? */
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(WARN, "check_foreign_key: triggers are not initialized"); elog(ERROR, "check_foreign_key: triggers are not initialized");
/* Should be called for ROW trigger */ /* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
elog(WARN, "check_foreign_key: can't process STATEMENT events"); elog(ERROR, "check_foreign_key: can't process STATEMENT events");
/* Not should be called for INSERT */ /* Not should be called for INSERT */
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
elog(WARN, "check_foreign_key: can't process INSERT events"); elog(ERROR, "check_foreign_key: can't process INSERT events");
/* Have to check tg_trigtuple - tuple being deleted */ /* Have to check tg_trigtuple - tuple being deleted */
trigtuple = CurrentTriggerData->tg_trigtuple; trigtuple = CurrentTriggerData->tg_trigtuple;
...@@ -278,18 +278,18 @@ check_foreign_key() ...@@ -278,18 +278,18 @@ check_foreign_key()
if (nargs < 5) /* nrefs, action, key, Relation, key - at if (nargs < 5) /* nrefs, action, key, Relation, key - at
* least */ * least */
elog(WARN, "check_foreign_key: too short %d (< 5) list of arguments", nargs); elog(ERROR, "check_foreign_key: too short %d (< 5) list of arguments", nargs);
nrefs = pg_atoi(args[0], sizeof(int), 0); nrefs = pg_atoi(args[0], sizeof(int), 0);
if (nrefs < 1) if (nrefs < 1)
elog(WARN, "check_foreign_key: %d (< 1) number of references specified", nrefs); elog(ERROR, "check_foreign_key: %d (< 1) number of references specified", nrefs);
action = tolower(*(args[1])); action = tolower(*(args[1]));
if (action != 'r' && action != 'c' && action != 's') if (action != 'r' && action != 'c' && action != 's')
elog(WARN, "check_foreign_key: invalid action %s", args[1]); elog(ERROR, "check_foreign_key: invalid action %s", args[1]);
nargs -= 2; nargs -= 2;
args += 2; args += 2;
nkeys = (nargs - nrefs) / (nrefs + 1); nkeys = (nargs - nrefs) / (nrefs + 1);
if (nkeys <= 0 || nargs != (nrefs + nkeys * (nrefs + 1))) if (nkeys <= 0 || nargs != (nrefs + nkeys * (nrefs + 1)))
elog(WARN, "check_foreign_key: invalid number of arguments %d for %d references", elog(ERROR, "check_foreign_key: invalid number of arguments %d for %d references",
nargs + 2, nrefs); nargs + 2, nrefs);
rel = CurrentTriggerData->tg_relation; rel = CurrentTriggerData->tg_relation;
...@@ -304,7 +304,7 @@ check_foreign_key() ...@@ -304,7 +304,7 @@ check_foreign_key()
/* Connect to SPI manager */ /* Connect to SPI manager */
if ((ret = SPI_connect()) < 0) if ((ret = SPI_connect()) < 0)
elog(WARN, "check_foreign_key: SPI_connect returned %d", ret); elog(ERROR, "check_foreign_key: SPI_connect returned %d", ret);
/* /*
* We use SPI plan preparation feature, so allocate space to place key * We use SPI plan preparation feature, so allocate space to place key
...@@ -327,7 +327,7 @@ check_foreign_key() ...@@ -327,7 +327,7 @@ check_foreign_key()
* else - check that we have exactly nrefs plan(s) ready * else - check that we have exactly nrefs plan(s) ready
*/ */
else if (plan->nplans != nrefs) else if (plan->nplans != nrefs)
elog(WARN, "%s: check_foreign_key: # of plans changed in meantime", elog(ERROR, "%s: check_foreign_key: # of plans changed in meantime",
trigger->tgname); trigger->tgname);
/* For each column in key ... */ /* For each column in key ... */
...@@ -338,7 +338,7 @@ check_foreign_key() ...@@ -338,7 +338,7 @@ check_foreign_key()
/* Bad guys may give us un-existing column in CREATE TRIGGER */ /* Bad guys may give us un-existing column in CREATE TRIGGER */
if (fnumber < 0) if (fnumber < 0)
elog(WARN, "check_foreign_key: there is no attribute %s in relation %s", elog(ERROR, "check_foreign_key: there is no attribute %s in relation %s",
args[i], SPI_getrelname(rel)); args[i], SPI_getrelname(rel));
/* Well, get binary (in internal format) value of column */ /* Well, get binary (in internal format) value of column */
...@@ -367,7 +367,7 @@ check_foreign_key() ...@@ -367,7 +367,7 @@ check_foreign_key()
/* this shouldn't happen! SPI_ERROR_NOOUTFUNC ? */ /* this shouldn't happen! SPI_ERROR_NOOUTFUNC ? */
if (oldval == NULL) if (oldval == NULL)
elog(WARN, "check_foreign_key: SPI_getvalue returned %d", SPI_result); elog(ERROR, "check_foreign_key: SPI_getvalue returned %d", SPI_result);
newval = SPI_getvalue(newtuple, tupdesc, fnumber); newval = SPI_getvalue(newtuple, tupdesc, fnumber);
if (newval == NULL || strcmp(oldval, newval) != 0) if (newval == NULL || strcmp(oldval, newval) != 0)
isequal = false; isequal = false;
...@@ -439,7 +439,7 @@ check_foreign_key() ...@@ -439,7 +439,7 @@ check_foreign_key()
/* Prepare plan for query */ /* Prepare plan for query */
pplan = SPI_prepare(sql, nkeys, argtypes); pplan = SPI_prepare(sql, nkeys, argtypes);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "check_foreign_key: SPI_prepare returned %d", SPI_result); elog(ERROR, "check_foreign_key: SPI_prepare returned %d", SPI_result);
/* /*
* Remember that SPI_prepare places plan in current memory * Remember that SPI_prepare places plan in current memory
...@@ -448,7 +448,7 @@ check_foreign_key() ...@@ -448,7 +448,7 @@ check_foreign_key()
*/ */
pplan = SPI_saveplan(pplan); pplan = SPI_saveplan(pplan);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "check_foreign_key: SPI_saveplan returned %d", SPI_result); elog(ERROR, "check_foreign_key: SPI_saveplan returned %d", SPI_result);
plan->splan[r] = pplan; plan->splan[r] = pplan;
...@@ -484,14 +484,14 @@ check_foreign_key() ...@@ -484,14 +484,14 @@ check_foreign_key()
/* we have no NULLs - so we pass ^^^^ here */ /* we have no NULLs - so we pass ^^^^ here */
if (ret < 0) if (ret < 0)
elog(WARN, "check_foreign_key: SPI_execp returned %d", ret); elog(ERROR, "check_foreign_key: SPI_execp returned %d", ret);
/* If action is 'R'estrict ... */ /* If action is 'R'estrict ... */
if (action == 'r') if (action == 'r')
{ {
/* If there is tuple returned by SELECT then ... */ /* If there is tuple returned by SELECT then ... */
if (SPI_processed > 0) if (SPI_processed > 0)
elog(WARN, "%s: tuple referenced in %s", elog(ERROR, "%s: tuple referenced in %s",
trigger->tgname, relname); trigger->tgname, relname);
} }
#ifdef REFINT_VERBOSE #ifdef REFINT_VERBOSE
......
...@@ -77,15 +77,15 @@ timetravel() ...@@ -77,15 +77,15 @@ timetravel()
/* Called by trigger manager ? */ /* Called by trigger manager ? */
if (!CurrentTriggerData) if (!CurrentTriggerData)
elog(WARN, "timetravel: triggers are not initialized"); elog(ERROR, "timetravel: triggers are not initialized");
/* Should be called for ROW trigger */ /* Should be called for ROW trigger */
if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_FOR_STATEMENT(CurrentTriggerData->tg_event))
elog(WARN, "timetravel: can't process STATEMENT events"); elog(ERROR, "timetravel: can't process STATEMENT events");
/* Should be called BEFORE */ /* Should be called BEFORE */
if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event))
elog(WARN, "timetravel: must be fired before event"); elog(ERROR, "timetravel: must be fired before event");
/* INSERT ? */ /* INSERT ? */
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
...@@ -112,7 +112,7 @@ timetravel() ...@@ -112,7 +112,7 @@ timetravel()
trigger = CurrentTriggerData->tg_trigger; trigger = CurrentTriggerData->tg_trigger;
if (trigger->tgnargs != 2) if (trigger->tgnargs != 2)
elog(WARN, "timetravel (%s): invalid (!= 2) number of arguments %d", elog(ERROR, "timetravel (%s): invalid (!= 2) number of arguments %d",
relname, trigger->tgnargs); relname, trigger->tgnargs);
args = trigger->tgargs; args = trigger->tgargs;
...@@ -130,9 +130,9 @@ timetravel() ...@@ -130,9 +130,9 @@ timetravel()
{ {
attnum[i] = SPI_fnumber (tupdesc, args[i]); attnum[i] = SPI_fnumber (tupdesc, args[i]);
if ( attnum[i] < 0 ) if ( attnum[i] < 0 )
elog(WARN, "timetravel (%s): there is no attribute %s", relname, args[i]); elog(ERROR, "timetravel (%s): there is no attribute %s", relname, args[i]);
if (SPI_gettypeid (tupdesc, attnum[i]) != ABSTIMEOID) if (SPI_gettypeid (tupdesc, attnum[i]) != ABSTIMEOID)
elog(WARN, "timetravel (%s): attributes %s and %s must be of abstime type", elog(ERROR, "timetravel (%s): attributes %s and %s must be of abstime type",
relname, args[0], args[1]); relname, args[0], args[1]);
} }
...@@ -155,7 +155,7 @@ timetravel() ...@@ -155,7 +155,7 @@ timetravel()
{ {
if ((chnattrs == 0 && DatumGetInt32 (oldon) >= NOEND_ABSTIME) || if ((chnattrs == 0 && DatumGetInt32 (oldon) >= NOEND_ABSTIME) ||
(chnattrs > 0 && DatumGetInt32 (newvals[0]) >= NOEND_ABSTIME)) (chnattrs > 0 && DatumGetInt32 (newvals[0]) >= NOEND_ABSTIME))
elog (WARN, "timetravel (%s): %s ge %s", elog (ERROR, "timetravel (%s): %s ge %s",
relname, args[0], args[1]); relname, args[0], args[1]);
newvals[chnattrs] = NOEND_ABSTIME; newvals[chnattrs] = NOEND_ABSTIME;
chattrs[chnattrs] = attnum[1]; chattrs[chnattrs] = attnum[1];
...@@ -167,7 +167,7 @@ timetravel() ...@@ -167,7 +167,7 @@ timetravel()
DatumGetInt32 (oldoff)) || DatumGetInt32 (oldoff)) ||
(chnattrs > 0 && DatumGetInt32 (newvals[0]) >= (chnattrs > 0 && DatumGetInt32 (newvals[0]) >=
DatumGetInt32 (oldoff))) DatumGetInt32 (oldoff)))
elog (WARN, "timetravel (%s): %s ge %s", elog (ERROR, "timetravel (%s): %s ge %s",
relname, args[0], args[1]); relname, args[0], args[1]);
} }
...@@ -182,11 +182,11 @@ timetravel() ...@@ -182,11 +182,11 @@ timetravel()
oldon = SPI_getbinval (trigtuple, tupdesc, attnum[0], &isnull); oldon = SPI_getbinval (trigtuple, tupdesc, attnum[0], &isnull);
if (isnull) if (isnull)
elog(WARN, "timetravel (%s): %s must be NOT NULL", relname, args[0]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
oldoff = SPI_getbinval (trigtuple, tupdesc, attnum[1], &isnull); oldoff = SPI_getbinval (trigtuple, tupdesc, attnum[1], &isnull);
if (isnull) if (isnull)
elog(WARN, "timetravel (%s): %s must be NOT NULL", relname, args[1]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
/* /*
* If DELETE/UPDATE of tuple with stop_date neq INFINITY * If DELETE/UPDATE of tuple with stop_date neq INFINITY
* then say upper Executor to skip operation for this tuple * then say upper Executor to skip operation for this tuple
...@@ -195,13 +195,13 @@ timetravel() ...@@ -195,13 +195,13 @@ timetravel()
{ {
newon = SPI_getbinval (newtuple, tupdesc, attnum[0], &isnull); newon = SPI_getbinval (newtuple, tupdesc, attnum[0], &isnull);
if (isnull) if (isnull)
elog(WARN, "timetravel (%s): %s must be NOT NULL", relname, args[0]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[0]);
newoff = SPI_getbinval (newtuple, tupdesc, attnum[1], &isnull); newoff = SPI_getbinval (newtuple, tupdesc, attnum[1], &isnull);
if (isnull) if (isnull)
elog(WARN, "timetravel (%s): %s must be NOT NULL", relname, args[1]); elog(ERROR, "timetravel (%s): %s must be NOT NULL", relname, args[1]);
if ( oldon != newon || oldoff != newoff ) if ( oldon != newon || oldoff != newoff )
elog (WARN, "timetravel (%s): you can't change %s and/or %s columns (use set_timetravel)", elog (ERROR, "timetravel (%s): you can't change %s and/or %s columns (use set_timetravel)",
relname, args[0], args[1]); relname, args[0], args[1]);
if ( newoff != NOEND_ABSTIME ) if ( newoff != NOEND_ABSTIME )
...@@ -220,7 +220,7 @@ timetravel() ...@@ -220,7 +220,7 @@ timetravel()
/* Connect to SPI manager */ /* Connect to SPI manager */
if ((ret = SPI_connect()) < 0) if ((ret = SPI_connect()) < 0)
elog(WARN, "timetravel (%s): SPI_connect returned %d", relname, ret); elog(ERROR, "timetravel (%s): SPI_connect returned %d", relname, ret);
/* Fetch tuple values and nulls */ /* Fetch tuple values and nulls */
cvals = (Datum *) palloc (natts * sizeof (Datum)); cvals = (Datum *) palloc (natts * sizeof (Datum));
...@@ -278,7 +278,7 @@ timetravel() ...@@ -278,7 +278,7 @@ timetravel()
/* Prepare plan for query */ /* Prepare plan for query */
pplan = SPI_prepare(sql, natts, ctypes); pplan = SPI_prepare(sql, natts, ctypes);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "timetravel (%s): SPI_prepare returned %d", relname, SPI_result); elog(ERROR, "timetravel (%s): SPI_prepare returned %d", relname, SPI_result);
/* /*
* Remember that SPI_prepare places plan in current memory context * Remember that SPI_prepare places plan in current memory context
...@@ -287,7 +287,7 @@ timetravel() ...@@ -287,7 +287,7 @@ timetravel()
*/ */
pplan = SPI_saveplan(pplan); pplan = SPI_saveplan(pplan);
if (pplan == NULL) if (pplan == NULL)
elog(WARN, "timetravel (%s): SPI_saveplan returned %d", relname, SPI_result); elog(ERROR, "timetravel (%s): SPI_saveplan returned %d", relname, SPI_result);
plan->splan = pplan; plan->splan = pplan;
} }
...@@ -298,7 +298,7 @@ timetravel() ...@@ -298,7 +298,7 @@ timetravel()
ret = SPI_execp(plan->splan, cvals, cnulls, 0); ret = SPI_execp(plan->splan, cvals, cnulls, 0);
if (ret < 0) if (ret < 0)
elog(WARN, "timetravel (%s): SPI_execp returned %d", relname, ret); elog(ERROR, "timetravel (%s): SPI_execp returned %d", relname, ret);
/* Tuple to return to upper Executor ... */ /* Tuple to return to upper Executor ... */
if (newtuple) /* UPDATE */ if (newtuple) /* UPDATE */
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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; ...@@ -79,10 +79,10 @@ static Oid objectid;
int ival; int ival;
} }
%type <list> arg_list %type <list> boot_arg_list
%type <ielem> index_params index_on %type <ielem> boot_index_params boot_index_on
%type <ival> const ident %type <ival> boot_const boot_ident
%type <ival> optbootstrap optoideq tuple tuplelist %type <ival> optbootstrap optoideq boot_tuple boot_tuplelist
%token <ival> CONST ID %token <ival> CONST ID
%token OPEN XCLOSE XCREATE INSERT_TUPLE %token OPEN XCLOSE XCREATE INSERT_TUPLE
...@@ -98,26 +98,26 @@ static Oid objectid; ...@@ -98,26 +98,26 @@ static Oid objectid;
%% %%
TopLevel: TopLevel:
Queries Boot_Queries
| |
; ;
Queries: Boot_Queries:
A_Query Boot_Query
| Queries A_Query | Boot_Queries Boot_Query
; ;
A_Query : Boot_Query :
OpenStmt Boot_OpenStmt
| CloseStmt | Boot_CloseStmt
| CreateStmt | Boot_CreateStmt
| InsertStmt | Boot_InsertStmt
| DeclareIndexStmt | Boot_DeclareIndexStmt
| BuildIndsStmt | Boot_BuildIndsStmt
; ;
OpenStmt: Boot_OpenStmt:
OPEN ident OPEN boot_ident
{ {
DO_START; DO_START;
boot_openrel(LexIDStr($2)); boot_openrel(LexIDStr($2));
...@@ -125,8 +125,8 @@ OpenStmt: ...@@ -125,8 +125,8 @@ OpenStmt:
} }
; ;
CloseStmt: Boot_CloseStmt:
XCLOSE ident %prec low XCLOSE boot_ident %prec low
{ {
DO_START; DO_START;
closerel(LexIDStr($2)); closerel(LexIDStr($2));
...@@ -140,13 +140,13 @@ CloseStmt: ...@@ -140,13 +140,13 @@ CloseStmt:
} }
; ;
CreateStmt: Boot_CreateStmt:
XCREATE optbootstrap ident LPAREN XCREATE optbootstrap boot_ident LPAREN
{ {
DO_START; DO_START;
numattr=(int)0; numattr=(int)0;
} }
typelist boot_typelist
{ {
if (!Quiet) if (!Quiet)
putchar('\n'); putchar('\n');
...@@ -192,7 +192,7 @@ CreateStmt: ...@@ -192,7 +192,7 @@ CreateStmt:
} }
; ;
InsertStmt: Boot_InsertStmt:
INSERT_TUPLE optoideq INSERT_TUPLE optoideq
{ {
DO_START; DO_START;
...@@ -200,7 +200,7 @@ InsertStmt: ...@@ -200,7 +200,7 @@ InsertStmt:
printf("tuple %d<", $2); printf("tuple %d<", $2);
num_tuples_read = 0; num_tuples_read = 0;
} }
LPAREN tuplelist RPAREN LPAREN boot_tuplelist RPAREN
{ {
if (num_tuples_read != numattr) if (num_tuples_read != numattr)
elog(ABORT,"incorrect number of values for tuple"); elog(ABORT,"incorrect number of values for tuple");
...@@ -223,8 +223,8 @@ InsertStmt: ...@@ -223,8 +223,8 @@ InsertStmt:
} }
; ;
DeclareIndexStmt: Boot_DeclareIndexStmt:
XDECLARE INDEX ident ON ident USING ident LPAREN index_params RPAREN XDECLARE INDEX boot_ident ON boot_ident USING boot_ident LPAREN boot_index_params RPAREN
{ {
List *params; List *params;
...@@ -239,25 +239,25 @@ DeclareIndexStmt: ...@@ -239,25 +239,25 @@ DeclareIndexStmt:
} }
; ;
BuildIndsStmt: Boot_BuildIndsStmt:
XBUILD INDICES { build_indices(); } XBUILD INDICES { build_indices(); }
index_params: boot_index_params:
index_on ident boot_index_on boot_ident
{ {
IndexElem *n = (IndexElem*)$1; IndexElem *n = (IndexElem*)$1;
n->class = LexIDStr($2); n->class = LexIDStr($2);
$$ = n; $$ = n;
} }
index_on: boot_index_on:
ident boot_ident
{ {
IndexElem *n = makeNode(IndexElem); IndexElem *n = makeNode(IndexElem);
n->name = LexIDStr($1); n->name = LexIDStr($1);
$$ = n; $$ = n;
} }
| ident LPAREN arg_list RPAREN | boot_ident LPAREN boot_arg_list RPAREN
{ {
IndexElem *n = makeNode(IndexElem); IndexElem *n = makeNode(IndexElem);
n->name = LexIDStr($1); n->name = LexIDStr($1);
...@@ -265,12 +265,12 @@ index_on: ...@@ -265,12 +265,12 @@ index_on:
$$ = n; $$ = n;
} }
arg_list: boot_arg_list:
ident boot_ident
{ {
$$ = lappend(NIL, makeString(LexIDStr($1))); $$ = lappend(NIL, makeString(LexIDStr($1)));
} }
| arg_list COMMA ident | boot_arg_list COMMA boot_ident
{ {
$$ = lappend((List*)$1, makeString(LexIDStr($3))); $$ = lappend((List*)$1, makeString(LexIDStr($3)));
} }
...@@ -280,13 +280,13 @@ optbootstrap: ...@@ -280,13 +280,13 @@ optbootstrap:
| { $$ = 0; } | { $$ = 0; }
; ;
typelist: boot_typelist:
typething boot_type_thing
| typelist COMMA typething | boot_typelist COMMA boot_type_thing
; ;
typething: boot_type_thing:
ident EQUALS ident boot_ident EQUALS boot_ident
{ {
if(++numattr > MAXATTR) if(++numattr > MAXATTR)
elog(FATAL,"Too many attributes\n"); elog(FATAL,"Too many attributes\n");
...@@ -297,28 +297,28 @@ typething: ...@@ -297,28 +297,28 @@ typething:
; ;
optoideq: optoideq:
OBJ_ID EQUALS ident { $$ = atol(LexIDStr($3)); } OBJ_ID EQUALS boot_ident { $$ = atol(LexIDStr($3)); }
| { extern Oid newoid(); $$ = newoid(); } | { extern Oid newoid(); $$ = newoid(); }
; ;
tuplelist: boot_tuplelist:
tuple boot_tuple
| tuplelist tuple | boot_tuplelist boot_tuple
| tuplelist COMMA tuple | boot_tuplelist COMMA boot_tuple
; ;
tuple: boot_tuple:
ident {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } boot_ident {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); }
| const {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); } | boot_const {InsertOneValue(objectid, LexIDStr($1), num_tuples_read++); }
| NULLVAL | NULLVAL
{ InsertOneNull(num_tuples_read++); } { InsertOneNull(num_tuples_read++); }
; ;
const : boot_const :
CONST { $$=yylval.ival; } CONST { $$=yylval.ival; }
; ;
ident : boot_ident :
ID { $$=yylval.ival; } ID { $$=yylval.ival; }
; ;
%% %%
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* See acl.h. * See acl.h.
...@@ -410,7 +410,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) ...@@ -410,7 +410,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode)
* pg_database table, there is still additional permissions * pg_database table, there is still additional permissions
* checking in dbcommands.c * checking in dbcommands.c
*/ */
if (mode & ACL_AP) if ((mode & ACL_WR) || (mode & ACL_AP))
return ACLCHECK_OK; return ACLCHECK_OK;
} }
......
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -76,7 +76,9 @@ appendStringInfo(StringInfo str, char *buffer)
newlen; newlen;
char *s; 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 * do we have enough space to append the new string? (don't forget to
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* Every (plan) node in POSTGRES has an associated "out" routine which * Every (plan) node in POSTGRES has an associated "out" routine which
...@@ -70,63 +70,71 @@ _outIntList(StringInfo str, List *list) ...@@ -70,63 +70,71 @@ _outIntList(StringInfo str, List *list)
static void static void
_outCreateStmt(StringInfo str, CreateStmt *node) _outCreateStmt(StringInfo str, CreateStmt *node)
{ {
char buf[500]; appendStringInfo(str, "CREATE");
sprintf(buf, "CREATE");
appendStringInfo(str, buf);
sprintf(buf, " :relname %s", node->relname); appendStringInfo(str, " :relname ");
appendStringInfo(str, buf); appendStringInfo(str, node->relname);
appendStringInfo(str, " :columns"); appendStringInfo(str, " :columns");
_outNode(str, node->tableElts); _outNode(str, node->tableElts);
appendStringInfo(str, " :inhRelnames");
_outNode(str, node->inhRelnames);
appendStringInfo(str, " :constraints");
_outNode(str, node->constraints);
} /* _outCreateStmt() */ } /* _outCreateStmt() */
static void static void
_outIndexStmt(StringInfo str, IndexStmt *node) _outIndexStmt(StringInfo str, IndexStmt *node)
{ {
char buf[500]; appendStringInfo(str, "INDEX");
sprintf(buf, "INDEX"); appendStringInfo(str, " :idxname ");
appendStringInfo(str, buf); appendStringInfo(str, node->idxname);
appendStringInfo(str, " :relname ");
sprintf(buf, " :idxname %s", node->idxname); appendStringInfo(str, node->relname);
appendStringInfo(str, buf); appendStringInfo(str, " :accessMethod ");
sprintf(buf, " :relname %s", node->relname); appendStringInfo(str, node->accessMethod);
appendStringInfo(str, buf); appendStringInfo(str, " :indexParams ");
sprintf(buf, " :method %s", node->accessMethod);
appendStringInfo(str, buf);
sprintf(buf, " :unique %s", (node->unique? "y": "n"));
appendStringInfo(str, buf);
appendStringInfo(str, " :columns");
_outNode(str, node->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() */ } /* _outIndexStmt() */
static void static void
_outColumnDef(StringInfo str, ColumnDef *node) _outColumnDef(StringInfo str, ColumnDef *node)
{ {
char buf[500]; appendStringInfo(str, "COLUMNDEF");
sprintf(buf, "COLUMNDEF");
appendStringInfo(str, buf);
sprintf(buf, " :colname %s", node->colname); appendStringInfo(str, " :colname ");
appendStringInfo(str, buf); appendStringInfo(str, node->colname);
appendStringInfo(str, " :typename"); appendStringInfo(str, " :typename ");
_outNode(str, node->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() */ } /* _outColumnDef() */
static void static void
_outIndexElem(StringInfo str, IndexElem *node) _outIndexElem(StringInfo str, IndexElem *node)
{ {
char buf[500]; appendStringInfo(str, "INDEXELEM");
sprintf(buf, "INDEXELEM");
appendStringInfo(str, buf);
sprintf(buf, " :name %s", node->name); appendStringInfo(str, " :name ");
appendStringInfo(str, buf); appendStringInfo(str, node->name);
sprintf(buf, " :class %s", node->class); appendStringInfo(str, " :args ");
appendStringInfo(str, buf); _outNode(str, node->args);
appendStringInfo(str, " :class ");
appendStringInfo(str, node->class);
appendStringInfo(str, " :tname"); appendStringInfo(str, " :tname");
_outNode(str, node->tname); _outNode(str, node->tname);
} /* _outIndexElem() */ } /* _outIndexElem() */
...@@ -135,66 +143,98 @@ static void ...@@ -135,66 +143,98 @@ static void
_outQuery(StringInfo str, Query *node) _outQuery(StringInfo str, Query *node)
{ {
char buf[500]; char buf[500];
int i;
appendStringInfo(str, "QUERY");
sprintf(buf, "QUERY"); appendStringInfo(str, " :command ");
sprintf(buf," %d ", node->commandType);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :command %d", node->commandType);
appendStringInfo(str, buf);
if (node->utilityStmt) if (node->utilityStmt)
{ {
switch (nodeTag(node->utilityStmt)) switch (nodeTag(node->utilityStmt))
{ {
case T_CreateStmt: case T_CreateStmt:
sprintf(buf, " :create %s", appendStringInfo(str, " :create ");
((CreateStmt *) (node->utilityStmt))->relname); appendStringInfo(str, ((CreateStmt *) (node->utilityStmt))->relname);
appendStringInfo(str, buf);
_outNode(str, node->utilityStmt); _outNode(str, node->utilityStmt);
break; break;
case T_IndexStmt: case T_IndexStmt:
sprintf(buf, " :index %s on %s", appendStringInfo(str, " :index ");
((IndexStmt *) (node->utilityStmt))->idxname, appendStringInfo(str, ((IndexStmt *) (node->utilityStmt))->idxname);
((IndexStmt *) (node->utilityStmt))->relname); appendStringInfo(str, " on ");
appendStringInfo(str, buf); appendStringInfo(str, ((IndexStmt *) (node->utilityStmt))->relname);
_outNode(str, node->utilityStmt); _outNode(str, node->utilityStmt);
break; break;
case T_NotifyStmt: case T_NotifyStmt:
sprintf(buf, " :utility %s", appendStringInfo(str, " :utility ");
((NotifyStmt *) (node->utilityStmt))->relname); appendStringInfo(str, ((NotifyStmt *) (node->utilityStmt))->relname);
appendStringInfo(str, buf);
break; break;
default: default:
sprintf(buf, " :utility ?"); appendStringInfo(str, " :utility ? ");
appendStringInfo(str, buf);
} }
} }
else else
{ {
/* use "" to designate */ appendStringInfo(str, " :utility ");
appendStringInfo(str, " :utility \"\""); appendStringInfo(str, NULL);
} }
sprintf(buf, " :resrel %d", node->resultRelation); appendStringInfo(str, " :resultRelation ");
appendStringInfo(str, buf); sprintf(buf, " %d ", node->resultRelation);
sprintf(buf, " :rtable "); appendStringInfo(str, buf);
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); _outNode(str, node->rtable);
if (node->uniqueFlag) appendStringInfo(str, " :targetlist ");
sprintf(buf, " :unique %s", node->uniqueFlag);
else
/* use "" to designate non-unique */
sprintf(buf, " :unique \"\"");
appendStringInfo(str, buf);
sprintf(buf, " :targetlist ");
appendStringInfo(str, buf);
_outNode(str, node->targetList); _outNode(str, node->targetList);
sprintf(buf, " :qual "); appendStringInfo(str, " :qual ");
appendStringInfo(str, buf);
_outNode(str, node->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) ...@@ -211,20 +251,15 @@ _outPlanInfo(StringInfo str, Plan *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :width %d", node->plan_width); sprintf(buf, " :width %d", node->plan_width);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :state %s", (node->state == (EState *) NULL ? appendStringInfo(str, " :state ");
"nil" : "non-NIL")); appendStringInfo(str, (node->state == (EState *) NULL? "nil" : "non-NIL"));
appendStringInfo(str, buf); appendStringInfo(str, " :qptargetlist ");
sprintf(buf, " :qptargetlist ");
appendStringInfo(str, buf);
_outNode(str, node->targetlist); _outNode(str, node->targetlist);
sprintf(buf, " :qpqual "); appendStringInfo(str, " :qpqual ");
appendStringInfo(str, buf);
_outNode(str, node->qual); _outNode(str, node->qual);
sprintf(buf, " :lefttree "); appendStringInfo(str, " :lefttree ");
appendStringInfo(str, buf);
_outNode(str, node->lefttree); _outNode(str, node->lefttree);
sprintf(buf, " :righttree "); appendStringInfo(str, " :righttree ");
appendStringInfo(str, buf);
_outNode(str, node->righttree); _outNode(str, node->righttree);
} }
...@@ -235,25 +270,17 @@ _outPlanInfo(StringInfo str, Plan *node) ...@@ -235,25 +270,17 @@ _outPlanInfo(StringInfo str, Plan *node)
static void static void
_outPlan(StringInfo str, Plan *node) _outPlan(StringInfo str, Plan *node)
{ {
char buf[500]; appendStringInfo(str, "PLAN");
sprintf(buf, "PLAN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
} }
static void static void
_outResult(StringInfo str, Result *node) _outResult(StringInfo str, Result *node)
{ {
char buf[500]; appendStringInfo(str, "RESULT");
sprintf(buf, "RESULT");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :resconstantqual "); appendStringInfo(str, " :resconstantqual ");
appendStringInfo(str, buf);
_outNode(str, node->resconstantqual); _outNode(str, node->resconstantqual);
} }
...@@ -266,19 +293,19 @@ _outAppend(StringInfo str, Append *node) ...@@ -266,19 +293,19 @@ _outAppend(StringInfo str, Append *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "APPEND"); appendStringInfo(str, "APPEND");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :unionplans "); appendStringInfo(str, " :unionplans ");
appendStringInfo(str, buf);
_outNode(str, node->unionplans); _outNode(str, node->unionplans);
appendStringInfo(str, " :unionrts ");
_outNode(str, node->unionrts);
sprintf(buf, " :unionrelid %d", node->unionrelid); sprintf(buf, " :unionrelid %d", node->unionrelid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :unionrtentries "); appendStringInfo(str, " :unionrtentries ");
appendStringInfo(str, buf);
_outNode(str, node->unionrtentries); _outNode(str, node->unionrtentries);
} }
...@@ -289,10 +316,7 @@ _outAppend(StringInfo str, Append *node) ...@@ -289,10 +316,7 @@ _outAppend(StringInfo str, Append *node)
static void static void
_outJoin(StringInfo str, Join *node) _outJoin(StringInfo str, Join *node)
{ {
char buf[500]; appendStringInfo(str, "JOIN");
sprintf(buf, "JOIN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
} }
...@@ -303,10 +327,7 @@ _outJoin(StringInfo str, Join *node) ...@@ -303,10 +327,7 @@ _outJoin(StringInfo str, Join *node)
static void static void
_outNestLoop(StringInfo str, NestLoop *node) _outNestLoop(StringInfo str, NestLoop *node)
{ {
char buf[500]; appendStringInfo(str, "NESTLOOP");
sprintf(buf, "NESTLOOP");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
} }
...@@ -318,12 +339,10 @@ _outMergeJoin(StringInfo str, MergeJoin *node) ...@@ -318,12 +339,10 @@ _outMergeJoin(StringInfo str, MergeJoin *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "MERGEJOIN"); appendStringInfo(str, "MERGEJOIN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :mergeclauses "); appendStringInfo(str, " :mergeclauses ");
appendStringInfo(str, buf);
_outNode(str, node->mergeclauses); _outNode(str, node->mergeclauses);
sprintf(buf, " :mergesortop %u", node->mergesortop); sprintf(buf, " :mergesortop %u", node->mergesortop);
...@@ -344,12 +363,10 @@ _outHashJoin(StringInfo str, HashJoin *node) ...@@ -344,12 +363,10 @@ _outHashJoin(StringInfo str, HashJoin *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "HASHJOIN"); appendStringInfo(str, "HASHJOIN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :hashclauses "); appendStringInfo(str, " :hashclauses ");
appendStringInfo(str, buf);
_outNode(str, node->hashclauses); _outNode(str, node->hashclauses);
sprintf(buf, " :hashjoinop %u", node->hashjoinop); sprintf(buf, " :hashjoinop %u", node->hashjoinop);
...@@ -372,8 +389,7 @@ _outScan(StringInfo str, Scan *node) ...@@ -372,8 +389,7 @@ _outScan(StringInfo str, Scan *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "SCAN"); appendStringInfo(str, "SCAN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :scanrelid %d", node->scanrelid); sprintf(buf, " :scanrelid %d", node->scanrelid);
...@@ -389,8 +405,7 @@ _outSeqScan(StringInfo str, SeqScan *node) ...@@ -389,8 +405,7 @@ _outSeqScan(StringInfo str, SeqScan *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "SEQSCAN"); appendStringInfo(str, "SEQSCAN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :scanrelid %d", node->scanrelid); sprintf(buf, " :scanrelid %d", node->scanrelid);
...@@ -407,19 +422,16 @@ _outIndexScan(StringInfo str, IndexScan *node) ...@@ -407,19 +422,16 @@ _outIndexScan(StringInfo str, IndexScan *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "INDEXSCAN"); appendStringInfo(str, "INDEXSCAN");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :scanrelid %d", node->scan.scanrelid); sprintf(buf, " :scanrelid %d", node->scan.scanrelid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :indxid "); appendStringInfo(str, " :indxid ");
appendStringInfo(str, buf);
_outIntList(str, node->indxid); _outIntList(str, node->indxid);
sprintf(buf, " :indxqual "); appendStringInfo(str, " :indxqual ");
appendStringInfo(str, buf);
_outNode(str, node->indxqual); _outNode(str, node->indxqual);
} }
...@@ -432,8 +444,7 @@ _outTemp(StringInfo str, Temp *node) ...@@ -432,8 +444,7 @@ _outTemp(StringInfo str, Temp *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "TEMP"); appendStringInfo(str, "TEMP");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :tempid %u", node->tempid); sprintf(buf, " :tempid %u", node->tempid);
...@@ -451,8 +462,7 @@ _outSort(StringInfo str, Sort *node) ...@@ -451,8 +462,7 @@ _outSort(StringInfo str, Sort *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "SORT"); appendStringInfo(str, "SORT");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :tempid %u", node->tempid); sprintf(buf, " :tempid %u", node->tempid);
...@@ -467,8 +477,7 @@ _outAgg(StringInfo str, Agg *node) ...@@ -467,8 +477,7 @@ _outAgg(StringInfo str, Agg *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "AGG"); appendStringInfo(str, "AGG");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
/* the actual Agg fields */ /* the actual Agg fields */
...@@ -481,19 +490,18 @@ _outGroup(StringInfo str, Group *node) ...@@ -481,19 +490,18 @@ _outGroup(StringInfo str, Group *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "GRP"); appendStringInfo(str, "GRP");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
/* the actual Group fields */ /* the actual Group fields */
sprintf(buf, " :numCols %d ", node->numCols); sprintf(buf, " :numCols %d ", node->numCols);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :tuplePerGroup %s", node->tuplePerGroup ? "true" : "nil"); appendStringInfo(str, " :tuplePerGroup ");
appendStringInfo(str, node->tuplePerGroup ? "true" : "false");
appendStringInfo(str, buf); appendStringInfo(str, buf);
} }
/* /*
* For some reason, unique is a subclass of Temp. * For some reason, unique is a subclass of Temp.
*/ */
...@@ -502,8 +510,7 @@ _outUnique(StringInfo str, Unique *node) ...@@ -502,8 +510,7 @@ _outUnique(StringInfo str, Unique *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "UNIQUE"); appendStringInfo(str, "UNIQUE");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :tempid %u", node->tempid); sprintf(buf, " :tempid %u", node->tempid);
...@@ -522,12 +529,10 @@ _outHash(StringInfo str, Hash *node) ...@@ -522,12 +529,10 @@ _outHash(StringInfo str, Hash *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "HASH"); appendStringInfo(str, "HASH");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :hashkey "); appendStringInfo(str, " :hashkey ");
appendStringInfo(str, buf);
_outNode(str, node->hashkey); _outNode(str, node->hashkey);
sprintf(buf, " :hashtable 0x%x", (int) (node->hashtable)); sprintf(buf, " :hashtable 0x%x", (int) (node->hashtable));
...@@ -543,8 +548,7 @@ _outTee(StringInfo str, Tee *node) ...@@ -543,8 +548,7 @@ _outTee(StringInfo str, Tee *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "TEE"); appendStringInfo(str, "TEE");
appendStringInfo(str, buf);
_outPlanInfo(str, (Plan *) node); _outPlanInfo(str, (Plan *) node);
sprintf(buf, " :leftParent %X", (int) (node->leftParent)); sprintf(buf, " :leftParent %X", (int) (node->leftParent));
...@@ -552,8 +556,7 @@ _outTee(StringInfo str, Tee *node) ...@@ -552,8 +556,7 @@ _outTee(StringInfo str, Tee *node)
sprintf(buf, " :rightParent %X", (int) (node->rightParent)); sprintf(buf, " :rightParent %X", (int) (node->rightParent));
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :rtentries "); appendStringInfo(str, " :rtentries ");
appendStringInfo(str, buf);
_outNode(str, node->rtentries); _outNode(str, node->rtentries);
} }
...@@ -574,16 +577,15 @@ _outResdom(StringInfo str, Resdom *node) ...@@ -574,16 +577,15 @@ _outResdom(StringInfo str, Resdom *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "RESDOM"); appendStringInfo(str, "RESDOM");
appendStringInfo(str, buf);
sprintf(buf, " :resno %hd", node->resno); sprintf(buf, " :resno %hd", node->resno);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :restype %u", node->restype); sprintf(buf, " :restype %u", node->restype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :reslen %d", node->reslen); sprintf(buf, " :reslen %d", node->reslen);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :resname \"%s\"", appendStringInfo(str, " :resname ");
((node->resname) ? ((char *) node->resname) : "null")); appendStringInfo(str, node->resname);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :reskey %d", node->reskey); sprintf(buf, " :reskey %d", node->reskey);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -600,10 +602,9 @@ _outFjoin(StringInfo str, Fjoin *node) ...@@ -600,10 +602,9 @@ _outFjoin(StringInfo str, Fjoin *node)
char buf[500]; char buf[500];
int i; int i;
sprintf(buf, "FJOIN"); appendStringInfo(str, "FJOIN");
appendStringInfo(str, buf); appendStringInfo(str, " :initialized ");
sprintf(buf, " :initialized %s", node->fj_initialized ? "true" : "nil"); appendStringInfo(str, node->fj_initialized ? "true" : "false");
appendStringInfo(str, buf);
sprintf(buf, " :nNodes %d", node->fj_nNodes); sprintf(buf, " :nNodes %d", node->fj_nNodes);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -617,8 +618,7 @@ _outFjoin(StringInfo str, Fjoin *node) ...@@ -617,8 +618,7 @@ _outFjoin(StringInfo str, Fjoin *node)
appendStringInfo(str, " :alwaysdone "); appendStringInfo(str, " :alwaysdone ");
for (i = 0; i < node->fj_nNodes; i++) for (i = 0; i < node->fj_nNodes; i++)
{ {
sprintf(buf, " %s ", ((node->fj_alwaysDone[i]) ? "true" : "nil")); appendStringInfo(str, (node->fj_alwaysDone[i]) ? "true" : "false");
appendStringInfo(str, buf);
} }
} }
...@@ -631,8 +631,7 @@ _outExpr(StringInfo str, Expr *node) ...@@ -631,8 +631,7 @@ _outExpr(StringInfo str, Expr *node)
char buf[500]; char buf[500];
char *opstr = NULL; char *opstr = NULL;
sprintf(buf, "EXPR"); appendStringInfo(str, "EXPR");
appendStringInfo(str, buf);
sprintf(buf, " :typeOid %u", node->typeOid); sprintf(buf, " :typeOid %u", node->typeOid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -654,13 +653,11 @@ _outExpr(StringInfo str, Expr *node) ...@@ -654,13 +653,11 @@ _outExpr(StringInfo str, Expr *node)
opstr = "not"; opstr = "not";
break; break;
} }
sprintf(buf, " :opType %s", opstr); appendStringInfo(str, " :opType ");
appendStringInfo(str, buf); appendStringInfo(str, opstr);
sprintf(buf, " :oper "); appendStringInfo(str, " :oper ");
appendStringInfo(str, buf);
_outNode(str, node->oper); _outNode(str, node->oper);
sprintf(buf, " :args "); appendStringInfo(str, " :args ");
appendStringInfo(str, buf);
_outNode(str, node->args); _outNode(str, node->args);
} }
...@@ -672,8 +669,7 @@ _outVar(StringInfo str, Var *node) ...@@ -672,8 +669,7 @@ _outVar(StringInfo str, Var *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "VAR"); appendStringInfo(str, "VAR");
appendStringInfo(str, buf);
sprintf(buf, " :varno %d", node->varno); sprintf(buf, " :varno %d", node->varno);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :varattno %hd", node->varattno); sprintf(buf, " :varattno %hd", node->varattno);
...@@ -694,28 +690,24 @@ _outConst(StringInfo str, Const *node) ...@@ -694,28 +690,24 @@ _outConst(StringInfo str, Const *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "CONST"); appendStringInfo(str, "CONST");
appendStringInfo(str, buf);
sprintf(buf, " :consttype %u", node->consttype); sprintf(buf, " :consttype %u", node->consttype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :constlen %hd", node->constlen); sprintf(buf, " :constlen %hd", node->constlen);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :constisnull %s", (node->constisnull ? "true" : "nil")); appendStringInfo(str, " :constisnull ");
appendStringInfo(str, buf); appendStringInfo(str, node->constisnull ? "true" : "false");
sprintf(buf, " :constvalue "); appendStringInfo(str, " :constvalue ");
appendStringInfo(str, buf);
if (node->constisnull) if (node->constisnull)
{ {
sprintf(buf, "NIL "); appendStringInfo(str, "\"\"");
appendStringInfo(str, buf);
} }
else else
{ {
_outDatum(str, node->constvalue, node->consttype); _outDatum(str, node->constvalue, node->consttype);
} }
sprintf(buf, " :constbyval %s", (node->constbyval ? "true" : "nil")); appendStringInfo(str, " :constbyval ");
appendStringInfo(str, buf); appendStringInfo(str, node->constbyval ? "true" : "false");
} }
/* /*
...@@ -726,20 +718,20 @@ _outAggreg(StringInfo str, Aggreg *node) ...@@ -726,20 +718,20 @@ _outAggreg(StringInfo str, Aggreg *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "AGGREG"); appendStringInfo(str, "AGGREG");
appendStringInfo(str, buf); appendStringInfo(str, " :aggname ");
sprintf(buf, " :aggname \"%s\"", (char *) node->aggname); appendStringInfo(str, (char *) node->aggname);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :basetype %u", node->basetype); sprintf(buf, " :basetype %u", node->basetype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :aggtype %u", node->aggtype); sprintf(buf, " :aggtype %u", node->aggtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
appendStringInfo(str, " :target ");
_outNode(str, node->target);
sprintf(buf, " :aggno %d", node->aggno); sprintf(buf, " :aggno %d", node->aggno);
appendStringInfo(str, buf); appendStringInfo(str, buf);
appendStringInfo(str, " :usenulls ");
sprintf(buf, " :target "); appendStringInfo(str, node->usenulls ? "true" : "false");
appendStringInfo(str, buf);
_outNode(str, node->target);
} }
/* /*
...@@ -751,8 +743,7 @@ _outArray(StringInfo str, Array *node) ...@@ -751,8 +743,7 @@ _outArray(StringInfo str, Array *node)
char buf[500]; char buf[500];
int i; int i;
sprintf(buf, "ARRAY"); appendStringInfo(str, "ARRAY");
appendStringInfo(str, buf);
sprintf(buf, " :arrayelemtype %u", node->arrayelemtype); sprintf(buf, " :arrayelemtype %u", node->arrayelemtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :arrayelemlength %d", node->arrayelemlength); sprintf(buf, " :arrayelemlength %d", node->arrayelemlength);
...@@ -761,15 +752,13 @@ _outArray(StringInfo str, Array *node) ...@@ -761,15 +752,13 @@ _outArray(StringInfo str, Array *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :arrayndim %d", node->arrayndim); sprintf(buf, " :arrayndim %d", node->arrayndim);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :arraylow "); appendStringInfo(str, " :arraylow ");
appendStringInfo(str, buf);
for (i = 0; i < node->arrayndim; i++) for (i = 0; i < node->arrayndim; i++)
{ {
sprintf(buf, " %d", node->arraylow.indx[i]); sprintf(buf, " %d", node->arraylow.indx[i]);
appendStringInfo(str, buf); appendStringInfo(str, buf);
} }
sprintf(buf, " :arrayhigh "); appendStringInfo(str, " :arrayhigh ");
appendStringInfo(str, buf);
for (i = 0; i < node->arrayndim; i++) for (i = 0; i < node->arrayndim; i++)
{ {
sprintf(buf, " %d", node->arrayhigh.indx[i]); sprintf(buf, " %d", node->arrayhigh.indx[i]);
...@@ -787,8 +776,7 @@ _outArrayRef(StringInfo str, ArrayRef *node) ...@@ -787,8 +776,7 @@ _outArrayRef(StringInfo str, ArrayRef *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "ARRAYREF"); appendStringInfo(str, "ARRAYREF");
appendStringInfo(str, buf);
sprintf(buf, " :refelemtype %u", node->refelemtype); sprintf(buf, " :refelemtype %u", node->refelemtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :refattrlength %d", node->refattrlength); sprintf(buf, " :refattrlength %d", node->refattrlength);
...@@ -798,20 +786,16 @@ _outArrayRef(StringInfo str, ArrayRef *node) ...@@ -798,20 +786,16 @@ _outArrayRef(StringInfo str, ArrayRef *node)
sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f'); sprintf(buf, " :refelembyval %c", (node->refelembyval) ? 't' : 'f');
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :refupperindex "); appendStringInfo(str, " :refupperindex ");
appendStringInfo(str, buf);
_outNode(str, node->refupperindexpr); _outNode(str, node->refupperindexpr);
sprintf(buf, " :reflowerindex "); appendStringInfo(str, " :reflowerindex ");
appendStringInfo(str, buf);
_outNode(str, node->reflowerindexpr); _outNode(str, node->reflowerindexpr);
sprintf(buf, " :refexpr "); appendStringInfo(str, " :refexpr ");
appendStringInfo(str, buf);
_outNode(str, node->refexpr); _outNode(str, node->refexpr);
sprintf(buf, " :refassgnexpr "); appendStringInfo(str, " :refassgnexpr ");
appendStringInfo(str, buf);
_outNode(str, node->refassgnexpr); _outNode(str, node->refassgnexpr);
} }
...@@ -823,15 +807,13 @@ _outFunc(StringInfo str, Func *node) ...@@ -823,15 +807,13 @@ _outFunc(StringInfo str, Func *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "FUNC"); appendStringInfo(str, "FUNC");
appendStringInfo(str, buf);
sprintf(buf, " :funcid %u", node->funcid); sprintf(buf, " :funcid %u", node->funcid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :functype %u", node->functype); sprintf(buf, " :functype %u", node->functype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :funcisindex %s", appendStringInfo(str, " :funcisindex ");
(node->funcisindex ? "true" : "nil")); appendStringInfo(str, (node->funcisindex ? "true" : "false"));
appendStringInfo(str, buf);
sprintf(buf, " :funcsize %d", node->funcsize); sprintf(buf, " :funcsize %d", node->funcsize);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :func_fcache @ 0x%x", (int) (node->func_fcache)); sprintf(buf, " :func_fcache @ 0x%x", (int) (node->func_fcache));
...@@ -852,8 +834,7 @@ _outOper(StringInfo str, Oper *node) ...@@ -852,8 +834,7 @@ _outOper(StringInfo str, Oper *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "OPER"); appendStringInfo(str, "OPER");
appendStringInfo(str, buf);
sprintf(buf, " :opno %u", node->opno); sprintf(buf, " :opno %u", node->opno);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :opid %u", node->opid); sprintf(buf, " :opid %u", node->opid);
...@@ -871,14 +852,13 @@ _outParam(StringInfo str, Param *node) ...@@ -871,14 +852,13 @@ _outParam(StringInfo str, Param *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "PARAM"); appendStringInfo(str, "PARAM");
appendStringInfo(str, buf);
sprintf(buf, " :paramkind %d", node->paramkind); sprintf(buf, " :paramkind %d", node->paramkind);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :paramid %hd", node->paramid); sprintf(buf, " :paramid %hd", node->paramid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :paramname \"%s\"", node->paramname); appendStringInfo(str, " :paramname ");
appendStringInfo(str, buf); appendStringInfo(str, node->paramname);
sprintf(buf, " :paramtype %u", node->paramtype); sprintf(buf, " :paramtype %u", node->paramtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -898,13 +878,11 @@ _outEState(StringInfo str, EState *node) ...@@ -898,13 +878,11 @@ _outEState(StringInfo str, EState *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "ESTATE"); appendStringInfo(str, "ESTATE");
appendStringInfo(str, buf);
sprintf(buf, " :direction %d", node->es_direction); sprintf(buf, " :direction %d", node->es_direction);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :range_table "); appendStringInfo(str, " :range_table ");
appendStringInfo(str, buf);
_outNode(str, node->es_range_table); _outNode(str, node->es_range_table);
sprintf(buf, " :result_relation_info @ 0x%x", sprintf(buf, " :result_relation_info @ 0x%x",
...@@ -921,15 +899,13 @@ _outRel(StringInfo str, Rel *node) ...@@ -921,15 +899,13 @@ _outRel(StringInfo str, Rel *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "REL"); appendStringInfo(str, "REL");
appendStringInfo(str, buf);
sprintf(buf, " :relids "); appendStringInfo(str, " :relids ");
appendStringInfo(str, buf);
_outIntList(str, node->relids); _outIntList(str, node->relids);
sprintf(buf, " :indexed %s", (node->indexed ? "true" : "nil")); appendStringInfo(str, " :indexed ");
appendStringInfo(str, buf); appendStringInfo(str, node->indexed ? "true" : "false");
sprintf(buf, " :pages %u", node->pages); sprintf(buf, " :pages %u", node->pages);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :tuples %u", node->tuples); sprintf(buf, " :tuples %u", node->tuples);
...@@ -939,12 +915,10 @@ _outRel(StringInfo str, Rel *node) ...@@ -939,12 +915,10 @@ _outRel(StringInfo str, Rel *node)
sprintf(buf, " :width %u", node->width); sprintf(buf, " :width %u", node->width);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :targetlist "); appendStringInfo(str, " :targetlist ");
appendStringInfo(str, buf);
_outNode(str, node->targetlist); _outNode(str, node->targetlist);
sprintf(buf, " :pathlist "); appendStringInfo(str, " :pathlist ");
appendStringInfo(str, buf);
_outNode(str, node->pathlist); _outNode(str, node->pathlist);
/* /*
...@@ -958,33 +932,27 @@ _outRel(StringInfo str, Rel *node) ...@@ -958,33 +932,27 @@ _outRel(StringInfo str, Rel *node)
sprintf(buf, " :cheapestpath @ 0x%x", (int) (node->cheapestpath)); sprintf(buf, " :cheapestpath @ 0x%x", (int) (node->cheapestpath));
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :pruneable %s", (node->pruneable ? "true" : "nil")); appendStringInfo(str, " :pruneable ");
appendStringInfo(str, buf); appendStringInfo(str, node->pruneable ? "true" : "false");
#if 0 #if 0
sprintf(buf, " :classlist "); appendStringInfo(str, " :classlist ");
appendStringInfo(str, buf);
_outNode(str, node->classlist); _outNode(str, node->classlist);
sprintf(buf, " :indexkeys "); appendStringInfo(str, " :indexkeys ");
appendStringInfo(str, buf);
_outNode(str, node->indexkeys); _outNode(str, node->indexkeys);
sprintf(buf, " :ordering "); appendStringInfo(str, " :ordering ");
appendStringInfo(str, buf);
_outNode(str, node->ordering); _outNode(str, node->ordering);
#endif #endif
sprintf(buf, " :clauseinfo "); appendStringInfo(str, " :clauseinfo ");
appendStringInfo(str, buf);
_outNode(str, node->clauseinfo); _outNode(str, node->clauseinfo);
sprintf(buf, " :joininfo "); appendStringInfo(str, " :joininfo ");
appendStringInfo(str, buf);
_outNode(str, node->joininfo); _outNode(str, node->joininfo);
sprintf(buf, " :innerjoin "); appendStringInfo(str, " :innerjoin ");
appendStringInfo(str, buf);
_outNode(str, node->innerjoin); _outNode(str, node->innerjoin);
} }
...@@ -995,24 +963,12 @@ _outRel(StringInfo str, Rel *node) ...@@ -995,24 +963,12 @@ _outRel(StringInfo str, Rel *node)
static void static void
_outTargetEntry(StringInfo str, TargetEntry *node) _outTargetEntry(StringInfo str, TargetEntry *node)
{ {
char buf[500]; appendStringInfo(str, "TLE");
appendStringInfo(str, " :resdom ");
sprintf(buf, "TLE");
appendStringInfo(str, buf);
sprintf(buf, " :resdom ");
appendStringInfo(str, buf);
_outNode(str, node->resdom); _outNode(str, node->resdom);
sprintf(buf, " :expr "); appendStringInfo(str, " :expr ");
appendStringInfo(str, buf); _outNode(str, node->expr);
if (node->expr)
{
_outNode(str, node->expr);
}
else
{
appendStringInfo(str, "nil");
}
} }
static void static void
...@@ -1020,19 +976,16 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node) ...@@ -1020,19 +976,16 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "RTE"); appendStringInfo(str, "RTE");
appendStringInfo(str, buf);
sprintf(buf, " :relname \"%s\"", appendStringInfo(str, " :relname ");
((node->relname) ? ((char *) node->relname) : "null")); appendStringInfo(str, node->relname);
appendStringInfo(str, buf);
sprintf(buf, " :inh %d ", node->inh); sprintf(buf, " :inh %d ", node->inh);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :refname \"%s\"", appendStringInfo(str, " :refname ");
((node->refname) ? ((char *) node->refname) : "null")); appendStringInfo(str, node->refname);
appendStringInfo(str, buf);
sprintf(buf, " :relid %u ", node->relid); sprintf(buf, " :relid %u ", node->relid);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1046,8 +999,7 @@ _outPath(StringInfo str, Path *node) ...@@ -1046,8 +999,7 @@ _outPath(StringInfo str, Path *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "PATH"); appendStringInfo(str, "PATH");
appendStringInfo(str, buf);
sprintf(buf, " :pathtype %d", node->pathtype); sprintf(buf, " :pathtype %d", node->pathtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1055,8 +1007,7 @@ _outPath(StringInfo str, Path *node) ...@@ -1055,8 +1007,7 @@ _outPath(StringInfo str, Path *node)
sprintf(buf, " :cost %f", node->path_cost); sprintf(buf, " :cost %f", node->path_cost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :keys "); appendStringInfo(str, " :keys ");
appendStringInfo(str, buf);
_outNode(str, node->keys); _outNode(str, node->keys);
} }
...@@ -1069,8 +1020,7 @@ _outIndexPath(StringInfo str, IndexPath *node) ...@@ -1069,8 +1020,7 @@ _outIndexPath(StringInfo str, IndexPath *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "INDEXPATH"); appendStringInfo(str, "INDEXPATH");
appendStringInfo(str, buf);
sprintf(buf, " :pathtype %d", node->path.pathtype); sprintf(buf, " :pathtype %d", node->path.pathtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1084,20 +1034,16 @@ _outIndexPath(StringInfo str, IndexPath *node) ...@@ -1084,20 +1034,16 @@ _outIndexPath(StringInfo str, IndexPath *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
#if 0 #if 0
sprintf(buf, " :p_ordering "); appendStringInfo(str, " :p_ordering ");
appendStringInfo(str, buf);
_outNode(str, node->path.p_ordering); _outNode(str, node->path.p_ordering);
#endif #endif
sprintf(buf, " :keys "); appendStringInfo(str, " :keys ");
appendStringInfo(str, buf);
_outNode(str, node->path.keys); _outNode(str, node->path.keys);
sprintf(buf, " :indexid "); appendStringInfo(str, " :indexid ");
appendStringInfo(str, buf);
_outIntList(str, node->indexid); _outIntList(str, node->indexid);
sprintf(buf, " :indexqual "); appendStringInfo(str, " :indexqual ");
appendStringInfo(str, buf);
_outNode(str, node->indexqual); _outNode(str, node->indexqual);
} }
...@@ -1110,8 +1056,7 @@ _outJoinPath(StringInfo str, JoinPath *node) ...@@ -1110,8 +1056,7 @@ _outJoinPath(StringInfo str, JoinPath *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "JOINPATH"); appendStringInfo(str, "JOINPATH");
appendStringInfo(str, buf);
sprintf(buf, " :pathtype %d", node->path.pathtype); sprintf(buf, " :pathtype %d", node->path.pathtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1125,16 +1070,13 @@ _outJoinPath(StringInfo str, JoinPath *node) ...@@ -1125,16 +1070,13 @@ _outJoinPath(StringInfo str, JoinPath *node)
appendStringInfo(str, buf); appendStringInfo(str, buf);
#if 0 #if 0
sprintf(buf, " :p_ordering "); appendStringInfo(str, " :p_ordering ");
appendStringInfo(str, buf);
_outNode(str, node->path.p_ordering); _outNode(str, node->path.p_ordering);
#endif #endif
sprintf(buf, " :keys "); appendStringInfo(str, " :keys ");
appendStringInfo(str, buf);
_outNode(str, node->path.keys); _outNode(str, node->path.keys);
sprintf(buf, " :pathclauseinfo "); appendStringInfo(str, " :pathclauseinfo ");
appendStringInfo(str, buf);
_outNode(str, node->pathclauseinfo); _outNode(str, node->pathclauseinfo);
/* /*
...@@ -1150,8 +1092,7 @@ _outJoinPath(StringInfo str, JoinPath *node) ...@@ -1150,8 +1092,7 @@ _outJoinPath(StringInfo str, JoinPath *node)
sprintf(buf, " :outerjoincost %f", node->path.outerjoincost); sprintf(buf, " :outerjoincost %f", node->path.outerjoincost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :joinid "); appendStringInfo(str, " :joinid ");
appendStringInfo(str, buf);
_outIntList(str, node->path.joinid); _outIntList(str, node->path.joinid);
} }
...@@ -1164,8 +1105,7 @@ _outMergePath(StringInfo str, MergePath *node) ...@@ -1164,8 +1105,7 @@ _outMergePath(StringInfo str, MergePath *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "MERGEPATH"); appendStringInfo(str, "MERGEPATH");
appendStringInfo(str, buf);
sprintf(buf, " :pathtype %d", node->jpath.path.pathtype); sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1173,12 +1113,10 @@ _outMergePath(StringInfo str, MergePath *node) ...@@ -1173,12 +1113,10 @@ _outMergePath(StringInfo str, MergePath *node)
sprintf(buf, " :cost %f", node->jpath.path.path_cost); sprintf(buf, " :cost %f", node->jpath.path.path_cost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :keys "); appendStringInfo(str, " :keys ");
appendStringInfo(str, buf);
_outNode(str, node->jpath.path.keys); _outNode(str, node->jpath.path.keys);
sprintf(buf, " :pathclauseinfo "); appendStringInfo(str, " :pathclauseinfo ");
appendStringInfo(str, buf);
_outNode(str, node->jpath.pathclauseinfo); _outNode(str, node->jpath.pathclauseinfo);
/* /*
...@@ -1194,20 +1132,16 @@ _outMergePath(StringInfo str, MergePath *node) ...@@ -1194,20 +1132,16 @@ _outMergePath(StringInfo str, MergePath *node)
sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost); sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :joinid "); appendStringInfo(str, " :joinid ");
appendStringInfo(str, buf);
_outIntList(str, node->jpath.path.joinid); _outIntList(str, node->jpath.path.joinid);
sprintf(buf, " :path_mergeclauses "); appendStringInfo(str, " :path_mergeclauses ");
appendStringInfo(str, buf);
_outNode(str, node->path_mergeclauses); _outNode(str, node->path_mergeclauses);
sprintf(buf, " :outersortkeys "); appendStringInfo(str, " :outersortkeys ");
appendStringInfo(str, buf);
_outNode(str, node->outersortkeys); _outNode(str, node->outersortkeys);
sprintf(buf, " :innersortkeys "); appendStringInfo(str, " :innersortkeys ");
appendStringInfo(str, buf);
_outNode(str, node->innersortkeys); _outNode(str, node->innersortkeys);
} }
...@@ -1220,8 +1154,7 @@ _outHashPath(StringInfo str, HashPath *node) ...@@ -1220,8 +1154,7 @@ _outHashPath(StringInfo str, HashPath *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "HASHPATH"); appendStringInfo(str, "HASHPATH");
appendStringInfo(str, buf);
sprintf(buf, " :pathtype %d", node->jpath.path.pathtype); sprintf(buf, " :pathtype %d", node->jpath.path.pathtype);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1229,12 +1162,10 @@ _outHashPath(StringInfo str, HashPath *node) ...@@ -1229,12 +1162,10 @@ _outHashPath(StringInfo str, HashPath *node)
sprintf(buf, " :cost %f", node->jpath.path.path_cost); sprintf(buf, " :cost %f", node->jpath.path.path_cost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :keys "); appendStringInfo(str, " :keys ");
appendStringInfo(str, buf);
_outNode(str, node->jpath.path.keys); _outNode(str, node->jpath.path.keys);
sprintf(buf, " :pathclauseinfo "); appendStringInfo(str, " :pathclauseinfo ");
appendStringInfo(str, buf);
_outNode(str, node->jpath.pathclauseinfo); _outNode(str, node->jpath.pathclauseinfo);
/* /*
...@@ -1250,20 +1181,16 @@ _outHashPath(StringInfo str, HashPath *node) ...@@ -1250,20 +1181,16 @@ _outHashPath(StringInfo str, HashPath *node)
sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost); sprintf(buf, " :outerjoincost %f", node->jpath.path.outerjoincost);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :joinid "); appendStringInfo(str, " :joinid ");
appendStringInfo(str, buf);
_outIntList(str, node->jpath.path.joinid); _outIntList(str, node->jpath.path.joinid);
sprintf(buf, " :path_hashclauses "); appendStringInfo(str, " :path_hashclauses ");
appendStringInfo(str, buf);
_outNode(str, node->path_hashclauses); _outNode(str, node->path_hashclauses);
sprintf(buf, " :outerhashkeys "); appendStringInfo(str, " :outerhashkeys ");
appendStringInfo(str, buf);
_outNode(str, node->outerhashkeys); _outNode(str, node->outerhashkeys);
sprintf(buf, " :innerhashkeys "); appendStringInfo(str, " :innerhashkeys ");
appendStringInfo(str, buf);
_outNode(str, node->innerhashkeys); _outNode(str, node->innerhashkeys);
} }
...@@ -1276,8 +1203,7 @@ _outOrderKey(StringInfo str, OrderKey *node) ...@@ -1276,8 +1203,7 @@ _outOrderKey(StringInfo str, OrderKey *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "ORDERKEY"); appendStringInfo(str, "ORDERKEY");
appendStringInfo(str, buf);
sprintf(buf, " :attribute_number %d", node->attribute_number); sprintf(buf, " :attribute_number %d", node->attribute_number);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :array_index %d", node->array_index); sprintf(buf, " :array_index %d", node->array_index);
...@@ -1291,17 +1217,12 @@ _outOrderKey(StringInfo str, OrderKey *node) ...@@ -1291,17 +1217,12 @@ _outOrderKey(StringInfo str, OrderKey *node)
static void static void
_outJoinKey(StringInfo str, JoinKey *node) _outJoinKey(StringInfo str, JoinKey *node)
{ {
char buf[500]; appendStringInfo(str, "JOINKEY");
sprintf(buf, "JOINKEY"); appendStringInfo(str, " :outer ");
appendStringInfo(str, buf);
sprintf(buf, " :outer ");
appendStringInfo(str, buf);
_outNode(str, node->outer); _outNode(str, node->outer);
sprintf(buf, " :inner "); appendStringInfo(str, " :inner ");
appendStringInfo(str, buf);
_outNode(str, node->inner); _outNode(str, node->inner);
} }
...@@ -1314,8 +1235,7 @@ _outMergeOrder(StringInfo str, MergeOrder *node) ...@@ -1314,8 +1235,7 @@ _outMergeOrder(StringInfo str, MergeOrder *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "MERGEORDER"); appendStringInfo(str, "MERGEORDER");
appendStringInfo(str, buf);
sprintf(buf, " :join_operator %d", node->join_operator); sprintf(buf, " :join_operator %d", node->join_operator);
appendStringInfo(str, buf); appendStringInfo(str, buf);
...@@ -1338,24 +1258,20 @@ _outCInfo(StringInfo str, CInfo *node) ...@@ -1338,24 +1258,20 @@ _outCInfo(StringInfo str, CInfo *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "CINFO"); appendStringInfo(str, "CINFO");
appendStringInfo(str, buf);
sprintf(buf, " :clause "); appendStringInfo(str, " :clause ");
appendStringInfo(str, buf);
_outNode(str, node->clause); _outNode(str, node->clause);
sprintf(buf, " :selectivity %f", node->selectivity); sprintf(buf, " :selectivity %f", node->selectivity);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :notclause %s", (node->notclause ? "true" : "nil")); appendStringInfo(str, " :notclause ");
appendStringInfo(str, buf); appendStringInfo(str, node->notclause ? "true" : "false");
sprintf(buf, " :indexids "); appendStringInfo(str, " :indexids ");
appendStringInfo(str, buf);
_outNode(str, node->indexids); _outNode(str, node->indexids);
sprintf(buf, " :mergesortorder "); appendStringInfo(str, " :mergesortorder ");
appendStringInfo(str, buf);
_outNode(str, node->mergesortorder); _outNode(str, node->mergesortorder);
sprintf(buf, " :hashjoinoperator %u", node->hashjoinoperator); sprintf(buf, " :hashjoinoperator %u", node->hashjoinoperator);
...@@ -1369,17 +1285,12 @@ _outCInfo(StringInfo str, CInfo *node) ...@@ -1369,17 +1285,12 @@ _outCInfo(StringInfo str, CInfo *node)
static void static void
_outJoinMethod(StringInfo str, JoinMethod *node) _outJoinMethod(StringInfo str, JoinMethod *node)
{ {
char buf[500]; appendStringInfo(str, "JOINMETHOD");
sprintf(buf, "JOINMETHOD");
appendStringInfo(str, buf);
sprintf(buf, " :jmkeys "); appendStringInfo(str, " :jmkeys ");
appendStringInfo(str, buf);
_outNode(str, node->jmkeys); _outNode(str, node->jmkeys);
sprintf(buf, " :clauses "); appendStringInfo(str, " :clauses ");
appendStringInfo(str, buf);
_outNode(str, node->clauses); _outNode(str, node->clauses);
...@@ -1393,20 +1304,16 @@ _outHInfo(StringInfo str, HInfo *node) ...@@ -1393,20 +1304,16 @@ _outHInfo(StringInfo str, HInfo *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "HASHINFO"); appendStringInfo(str, "HASHINFO");
appendStringInfo(str, buf);
sprintf(buf, " :hashop "); appendStringInfo(str, " :hashop ");
appendStringInfo(str, buf);
sprintf(buf, "%u", node->hashop); sprintf(buf, "%u", node->hashop);
appendStringInfo(str, buf); appendStringInfo(str, buf);
sprintf(buf, " :jmkeys "); appendStringInfo(str, " :jmkeys ");
appendStringInfo(str, buf);
_outNode(str, node->jmethod.jmkeys); _outNode(str, node->jmethod.jmkeys);
sprintf(buf, " :clauses "); appendStringInfo(str, " :clauses ");
appendStringInfo(str, buf);
_outNode(str, node->jmethod.clauses); _outNode(str, node->jmethod.clauses);
} }
...@@ -1417,25 +1324,18 @@ _outHInfo(StringInfo str, HInfo *node) ...@@ -1417,25 +1324,18 @@ _outHInfo(StringInfo str, HInfo *node)
static void static void
_outJInfo(StringInfo str, JInfo *node) _outJInfo(StringInfo str, JInfo *node)
{ {
char buf[500]; appendStringInfo(str, "JINFO");
sprintf(buf, "JINFO");
appendStringInfo(str, buf);
sprintf(buf, " :otherrels "); appendStringInfo(str, " :otherrels ");
appendStringInfo(str, buf);
_outIntList(str, node->otherrels); _outIntList(str, node->otherrels);
sprintf(buf, " :jinfoclauseinfo "); appendStringInfo(str, " :jinfoclauseinfo ");
appendStringInfo(str, buf);
_outNode(str, node->jinfoclauseinfo); _outNode(str, node->jinfoclauseinfo);
sprintf(buf, " :mergesortable %s", appendStringInfo(str, " :mergesortable ");
(node->mergesortable ? "true" : "nil")); appendStringInfo(str, node->mergesortable ? "true" : "false");
appendStringInfo(str, buf); appendStringInfo(str, " :hashjoinable ");
sprintf(buf, " :hashjoinable %s", appendStringInfo(str, node->hashjoinable ? "true" : "false");
(node->hashjoinable ? "true" : "nil"));
appendStringInfo(str, buf);
} }
...@@ -1550,10 +1450,8 @@ _outStream(StringInfo str, Stream *node) ...@@ -1550,10 +1450,8 @@ _outStream(StringInfo str, Stream *node)
static void static void
_outAExpr(StringInfo str, A_Expr *node) _outAExpr(StringInfo str, A_Expr *node)
{ {
char buf[500]; appendStringInfo(str, "EXPR ");
appendStringInfo(str, node->opname);
sprintf(buf, "EXPR %s", node->opname);
appendStringInfo(str, buf);
_outNode(str, node->lexpr); _outNode(str, node->lexpr);
_outNode(str, node->rexpr); _outNode(str, node->rexpr);
return; return;
...@@ -1589,7 +1487,7 @@ _outIdent(StringInfo str, Ident *node) ...@@ -1589,7 +1487,7 @@ _outIdent(StringInfo str, Ident *node)
{ {
char buf[500]; char buf[500];
sprintf(buf, "IDENT %s", node->name); sprintf(buf, "IDENT \"%s\"", node->name);
appendStringInfo(str, buf); appendStringInfo(str, buf);
return; return;
} }
...@@ -1614,7 +1512,7 @@ _outNode(StringInfo str, void *obj) ...@@ -1614,7 +1512,7 @@ _outNode(StringInfo str, void *obj)
{ {
if (obj == NULL) if (obj == NULL)
{ {
appendStringInfo(str, "nil"); appendStringInfo(str, "\"\"");
return; return;
} }
...@@ -1653,6 +1551,9 @@ _outNode(StringInfo str, void *obj) ...@@ -1653,6 +1551,9 @@ _outNode(StringInfo str, void *obj)
case T_Query: case T_Query:
_outQuery(str, obj); _outQuery(str, obj);
break; break;
case T_SortGroupBy:
_outSortGroupBy(str, obj);
break;
case T_Plan: case T_Plan:
_outPlan(str, obj); _outPlan(str, obj);
break; break;
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
* *
* *
* IDENTIFICATION * 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 * HISTORY
* AUTHOR DATE MAJOR EVENT * AUTHOR DATE MAJOR EVENT
...@@ -94,7 +94,7 @@ nodeTokenType(char *token, int length) ...@@ -94,7 +94,7 @@ nodeTokenType(char *token, int length)
retval = (*token != '.') ? T_Integer : T_Float; retval = (*token != '.') ? T_Integer : T_Float;
} }
else if (isalpha(*token)) else if (isalpha(*token) || *token == '_')
retval = ATOM_TOKEN; retval = ATOM_TOKEN;
else if (*token == '(') else if (*token == '(')
retval = LEFT_PAREN; retval = LEFT_PAREN;
...@@ -145,8 +145,12 @@ lsptok(char *string, int *length) ...@@ -145,8 +145,12 @@ lsptok(char *string, int *length)
if (*local_str == '\"') if (*local_str == '\"')
{ {
for (local_str++; *local_str != '\"'; (*length)++, local_str++); for (local_str++; *local_str != '\"'; (*length)++, local_str++)
(*length)++; ;
if (*length == 2)
*length -= 2; /* if "", return zero length */
else
(*length)++;
local_str++; local_str++;
} }
else if (*local_str == ')' || *local_str == '(' || else if (*local_str == ')' || *local_str == '(' ||
...@@ -225,12 +229,12 @@ nodeRead(bool read_car_only) ...@@ -225,12 +229,12 @@ nodeRead(bool read_car_only)
case AT_SYMBOL: case AT_SYMBOL:
break; break;
case ATOM_TOKEN: case ATOM_TOKEN:
if (!strncmp(token, "nil", 3)) if (!strncmp(token, "\"\"", 2))
{ {
this_value = NULL; 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) if (read_car_only)
{ {
...@@ -283,6 +287,7 @@ nodeRead(bool read_car_only) ...@@ -283,6 +287,7 @@ nodeRead(bool read_car_only)
List *l = makeNode(List); List *l = makeNode(List);
lfirst(l) = this_value; lfirst(l) = this_value;
if (!read_car_only) if (!read_car_only)
{ {
lnext(l) = nodeRead(false); lnext(l) = nodeRead(false);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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 * NOTES
* Most of the read functions for plan nodes are tested. (In fact, they * Most of the read functions for plan nodes are tested. (In fact, they
...@@ -76,16 +76,19 @@ _readQuery() ...@@ -76,16 +76,19 @@ _readQuery()
Query *local_node; Query *local_node;
char *token; char *token;
int length; int length;
int i;
local_node = makeNode(Query); local_node = makeNode(Query);
token = lsptok(NULL, &length); /* skip the :command */ token = lsptok(NULL, &length); /* skip the :command */
token = lsptok(NULL, &length); /* get the commandType */ token = lsptok(NULL, &length); /* get the commandType */
local_node->commandType = atoi(token); 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 */ token = lsptok(NULL, &length); /* get the notify name if any */
if (token[0] == '"' && token[1] == '"') if (length == 0)
local_node->utilityStmt = NULL; local_node->utilityStmt = NULL;
else else
{ {
...@@ -96,17 +99,35 @@ _readQuery() ...@@ -96,17 +99,35 @@ _readQuery()
local_node->utilityStmt = (Node *) n; 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 */ token = lsptok(NULL, &length); /* get the resultRelation */
local_node->resultRelation = atoi(token); local_node->resultRelation = atoi(token);
token = lsptok(NULL, &length); /* skip :rtable */ token = lsptok(NULL, &length); /* skip :into */
local_node->rtable = nodeRead(true); token = lsptok(NULL, &length); /* get into */
if (length == 0)
token = lsptok(NULL, &length); /* skip the :unique */ local_node->into = NULL;
token = lsptok(NULL, &length); /* get the uniqueFlag */ else
/* local_node->uniqueFlag = (bool)atoi(token); */ {
if (token[0] == '"' && token[1] == '"') /* non-unique */ 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; local_node->uniqueFlag = NULL;
else else
{ {
...@@ -114,12 +135,90 @@ _readQuery() ...@@ -114,12 +135,90 @@ _readQuery()
StrNCpy(local_node->uniqueFlag, token, length+1); 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 */ token = lsptok(NULL, &length); /* skip :targetlist */
local_node->targetList = nodeRead(true); local_node->targetList = nodeRead(true);
token = lsptok(NULL, &length); /* skip :qual */ token = lsptok(NULL, &length); /* skip :qual */
local_node->qual = nodeRead(true); 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); return (local_node);
} }
...@@ -239,6 +338,9 @@ _readAppend() ...@@ -239,6 +338,9 @@ _readAppend()
token = lsptok(NULL, &length); /* eat :unionplans */ token = lsptok(NULL, &length); /* eat :unionplans */
local_node->unionplans = nodeRead(true); /* now read it */ 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); /* eat :unionrelid */
token = lsptok(NULL, &length); /* get unionrelid */ token = lsptok(NULL, &length); /* get unionrelid */
local_node->unionrelid = atoi(token); local_node->unionrelid = atoi(token);
...@@ -623,23 +725,12 @@ _readResdom() ...@@ -623,23 +725,12 @@ _readResdom()
token = lsptok(NULL, &length); /* eat :resname */ token = lsptok(NULL, &length); /* eat :resname */
token = lsptok(NULL, &length); /* get the name */ token = lsptok(NULL, &length); /* get the name */
if (!strncmp(token, "\"null\"", 5)) if (length == 0)
{
local_node->resname = NULL; local_node->resname = NULL;
}
else else
{ {
local_node->resname = (char *) palloc(length + 1);
/* StrNCpy(local_node->resname, token, length+1);
* 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] = '\"';
} }
token = lsptok(NULL, &length); /* eat :reskey */ token = lsptok(NULL, &length); /* eat :reskey */
...@@ -1016,11 +1107,13 @@ _readParam() ...@@ -1016,11 +1107,13 @@ _readParam()
token = lsptok(NULL, &length); /* get :paramname */ token = lsptok(NULL, &length); /* get :paramname */
token = lsptok(NULL, &length); /* now read it */ token = lsptok(NULL, &length); /* now read it */
token++; /* skip the first `"' */ if (length == 0)
token[length - 2] = '\0'; /* this is the 2nd `"' */ local_node->paramname = NULL;
else
local_node->paramname = pstrdup(token); {
token[length - 2] = '\"'; /* restore the 2nd `"' */ local_node->paramname = (char *) palloc(length + 1);
StrNCpy(local_node->paramname, token, length+1);
}
token = lsptok(NULL, &length); /* get :paramtype */ token = lsptok(NULL, &length); /* get :paramtype */
token = lsptok(NULL, &length); /* now read it */ token = lsptok(NULL, &length); /* now read it */
...@@ -1060,12 +1153,16 @@ _readAggreg() ...@@ -1060,12 +1153,16 @@ _readAggreg()
token = lsptok(NULL, &length); /* get aggtype */ token = lsptok(NULL, &length); /* get aggtype */
local_node->aggtype = (Oid) atol(token); 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); /* eat :aggno */
token = lsptok(NULL, &length); /* get aggno */ token = lsptok(NULL, &length); /* get aggno */
local_node->aggno = atoi(token); local_node->aggno = atoi(token);
token = lsptok(NULL, &length); /* eat :target */ token = lsptok(NULL, &length); /* eat :usenulls */
local_node->target = nodeRead(true); /* now read it */ token = lsptok(NULL, &length); /* get usenulls */
local_node->usenulls = (token[0] == 't') ? true : false;
return (local_node); return (local_node);
} }
...@@ -1216,7 +1313,7 @@ _readTargetEntry() ...@@ -1216,7 +1313,7 @@ _readTargetEntry()
} }
/* ---------------- /* ----------------
* _readTargetEntry * _readRangeTblEntry
* ---------------- * ----------------
*/ */
static RangeTblEntry * static RangeTblEntry *
...@@ -1230,23 +1327,12 @@ _readRangeTblEntry() ...@@ -1230,23 +1327,12 @@ _readRangeTblEntry()
token = lsptok(NULL, &length); /* eat :relname */ token = lsptok(NULL, &length); /* eat :relname */
token = lsptok(NULL, &length); /* get :relname */ token = lsptok(NULL, &length); /* get :relname */
if (!strncmp(token, "\"null\"", 5)) if (length == 0)
{
local_node->relname = NULL; local_node->relname = NULL;
}
else else
{ {
local_node->relname = (char *) palloc(length + 1);
/* StrNCpy(local_node->relname, token, length+1);
* 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] = '\"';
} }
token = lsptok(NULL, &length); /* eat :inh */ token = lsptok(NULL, &length); /* eat :inh */
...@@ -1255,22 +1341,12 @@ _readRangeTblEntry() ...@@ -1255,22 +1341,12 @@ _readRangeTblEntry()
token = lsptok(NULL, &length); /* eat :refname */ token = lsptok(NULL, &length); /* eat :refname */
token = lsptok(NULL, &length); /* get :refname */ token = lsptok(NULL, &length); /* get :refname */
if (!strncmp(token, "\"null\"", 5)) if (length == 0)
{
local_node->refname = NULL; local_node->refname = NULL;
}
else else
{ {
local_node->refname = (char *) palloc(length + 1);
/* StrNCpy(local_node->refname, token, length+1);
* Peel off ""'s, then make a true copy.
*/
token++;
token[length - 2] = '\0';
local_node->refname = (char *) pstrdup(token);
token[length - 2] = '\"';
} }
token = lsptok(NULL, &length); /* eat :relid */ token = lsptok(NULL, &length); /* eat :relid */
...@@ -2032,6 +2108,10 @@ parsePlanString(void) ...@@ -2032,6 +2108,10 @@ parsePlanString(void)
{ {
return_value = _readQuery(); return_value = _readQuery();
} }
else if (!strncmp(token, "SORTGROUPBY", 11))
{
return_value = _readSortGroupBy();
}
else else
{ {
elog(ABORT, "badly formatted planstring \"%.10s\"...\n", token); elog(ABORT, "badly formatted planstring \"%.10s\"...\n", token);
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
* *
* *
* IDENTIFICATION * 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) ...@@ -76,21 +76,18 @@ prune_joinrel(Rel *rel, List *other_rels)
return_list = cur; return_list = cur;
/* remove relations that do match, we use lnext so we can remove easily */ /* 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)) if (same(rel->relids, other_rel->relids))
{ {
rel->pathlist = add_pathlist(rel, rel->pathlist = add_pathlist(rel,
rel->pathlist, rel->pathlist,
other_rel->pathlist); other_rel->pathlist);
lnext(cur) = lnext(lnext(cur)); /* delete it */ lnext(cur) = lnext(lnext(cur)); /* delete it */
}
cur = lnext(cur);
} }
cur = lnext(cur);
} }
return return_list; return return_list;
} }
......
/* /*
* $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.18 1998/01/05 03:35:14 momjian Exp $ * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.19 1998/01/06 18:53:02 momjian Exp $
*/ */
#include <float.h> /* faked on sunos */ #include <float.h> /* faked on sunos */
...@@ -450,7 +450,7 @@ ttdummy() ...@@ -450,7 +450,7 @@ ttdummy()
if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_AFTER(CurrentTriggerData->tg_event))
elog(ABORT, "ttdummy: must be fired before event"); elog(ABORT, "ttdummy: must be fired before event");
if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_INSERT(CurrentTriggerData->tg_event))
elog (WARN, "ttdummy: can't process INSERT event"); elog (ABORT, "ttdummy: can't process INSERT event");
if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event)) if (TRIGGER_FIRED_BY_UPDATE(CurrentTriggerData->tg_event))
newtuple = CurrentTriggerData->tg_newtuple; newtuple = CurrentTriggerData->tg_newtuple;
...@@ -506,7 +506,7 @@ ttdummy() ...@@ -506,7 +506,7 @@ ttdummy()
elog(ABORT, "ttdummy (%s): %s must be NOT NULL", relname, args[1]); elog(ABORT, "ttdummy (%s): %s must be NOT NULL", relname, args[1]);
if ( oldon != newon || oldoff != newoff ) if ( oldon != newon || oldoff != newoff )
elog (WARN, "ttdummy (%s): you can't change %s and/or %s columns (use set_ttdummy)", elog (ABORT, "ttdummy (%s): you can't change %s and/or %s columns (use set_ttdummy)",
relname, args[0], args[1]); relname, args[0], args[1]);
if ( newoff != TTDUMMY_INFINITY ) if ( newoff != TTDUMMY_INFINITY )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment