diff options
Diffstat (limited to 'src')
620 files changed, 28025 insertions, 27951 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 17257690303..9ce59d8165c 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.22 1997/09/07 04:37:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.23 1997/09/08 02:19:47 momjian Exp $ * * NOTES * The old interface functions have been converted to macros @@ -53,9 +53,9 @@ ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]) { - uint32 data_length; - int i; - int numberOfAttributes = tupleDesc->natts; + uint32 data_length; + int i; + int numberOfAttributes = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; for (data_length = 0, i = 0; i < numberOfAttributes; i++) @@ -65,41 +65,41 @@ ComputeDataSize(TupleDesc tupleDesc, switch (att[i]->attlen) { - case -1: + case -1: - /* - * This is the size of the disk representation and so must - * include the additional sizeof long. - */ - if (att[i]->attalign == 'd') - { - data_length = DOUBLEALIGN(data_length) - + VARSIZE(DatumGetPointer(value[i])); - } - else - { - data_length = INTALIGN(data_length) - + VARSIZE(DatumGetPointer(value[i])); - } - break; - case sizeof(char): - data_length++; - break; - case sizeof(short): - data_length = SHORTALIGN(data_length + sizeof(short)); - break; - case sizeof(int32): - data_length = INTALIGN(data_length + sizeof(int32)); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, "ComputeDataSize: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - data_length = DOUBLEALIGN(data_length) + att[i]->attlen; - else - data_length = LONGALIGN(data_length) + att[i]->attlen; - break; + /* + * This is the size of the disk representation and so must + * include the additional sizeof long. + */ + if (att[i]->attalign == 'd') + { + data_length = DOUBLEALIGN(data_length) + + VARSIZE(DatumGetPointer(value[i])); + } + else + { + data_length = INTALIGN(data_length) + + VARSIZE(DatumGetPointer(value[i])); + } + break; + case sizeof(char): + data_length++; + break; + case sizeof(short): + data_length = SHORTALIGN(data_length + sizeof(short)); + break; + case sizeof(int32): + data_length = INTALIGN(data_length + sizeof(int32)); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, "ComputeDataSize: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + data_length = DOUBLEALIGN(data_length) + att[i]->attlen; + else + data_length = LONGALIGN(data_length) + att[i]->attlen; + break; } } @@ -118,11 +118,11 @@ DataFill(char *data, char *infomask, bits8 * bit) { - bits8 *bitP = 0; - int bitmask = 0; - uint32 data_length; - int i; - int numberOfAttributes = tupleDesc->natts; + bits8 *bitP = 0; + int bitmask = 0; + uint32 data_length; + int i; + int numberOfAttributes = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; if (bit != NULL) @@ -159,58 +159,58 @@ DataFill(char *data, switch (att[i]->attlen) { - case -1: - *infomask |= HEAP_HASVARLENA; - if (att[i]->attalign == 'd') - { - data = (char *) DOUBLEALIGN(data); - } - else - { + case -1: + *infomask |= HEAP_HASVARLENA; + if (att[i]->attalign == 'd') + { + data = (char *) DOUBLEALIGN(data); + } + else + { + data = (char *) INTALIGN(data); + } + data_length = VARSIZE(DatumGetPointer(value[i])); + memmove(data, DatumGetPointer(value[i]), data_length); + data += data_length; + break; + case sizeof(char): + *data = att[i]->attbyval ? + DatumGetChar(value[i]) : *((char *) value[i]); + data += sizeof(char); + break; + case sizeof(int16): + data = (char *) SHORTALIGN(data); + *(short *) data = (att[i]->attbyval ? + DatumGetInt16(value[i]) : + *((short *) value[i])); + data += sizeof(short); + break; + case sizeof(int32): data = (char *) INTALIGN(data); - } - data_length = VARSIZE(DatumGetPointer(value[i])); - memmove(data, DatumGetPointer(value[i]), data_length); - data += data_length; - break; - case sizeof(char): - *data = att[i]->attbyval ? - DatumGetChar(value[i]) : *((char *) value[i]); - data += sizeof(char); - break; - case sizeof(int16): - data = (char *) SHORTALIGN(data); - *(short *) data = (att[i]->attbyval ? - DatumGetInt16(value[i]) : - *((short *) value[i])); - data += sizeof(short); - break; - case sizeof(int32): - data = (char *) INTALIGN(data); - *(int32 *) data = (att[i]->attbyval ? - DatumGetInt32(value[i]) : - *((int32 *) value[i])); - data += sizeof(int32); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, "DataFill: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - { - data = (char *) DOUBLEALIGN(data); - memmove(data, DatumGetPointer(value[i]), - att[i]->attlen); - data += att[i]->attlen; - } - else - { - data = (char *) LONGALIGN(data); - memmove(data, DatumGetPointer(value[i]), - att[i]->attlen); - data += att[i]->attlen; - } - break; + *(int32 *) data = (att[i]->attbyval ? + DatumGetInt32(value[i]) : + *((int32 *) value[i])); + data += sizeof(int32); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, "DataFill: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + { + data = (char *) DOUBLEALIGN(data); + memmove(data, DatumGetPointer(value[i]), + att[i]->attlen); + data += att[i]->attlen; + } + else + { + data = (char *) LONGALIGN(data); + memmove(data, DatumGetPointer(value[i]), + att[i]->attlen); + data += att[i]->attlen; + } + break; } } } @@ -240,24 +240,24 @@ heap_attisnull(HeapTuple tup, int attnum) else switch (attnum) { - case SelfItemPointerAttributeNumber: - case ObjectIdAttributeNumber: - case MinTransactionIdAttributeNumber: - case MinCommandIdAttributeNumber: - case MaxTransactionIdAttributeNumber: - case MaxCommandIdAttributeNumber: - case ChainItemPointerAttributeNumber: - case AnchorItemPointerAttributeNumber: - case MinAbsoluteTimeAttributeNumber: - case MaxAbsoluteTimeAttributeNumber: - case VersionTypeAttributeNumber: - break; + case SelfItemPointerAttributeNumber: + case ObjectIdAttributeNumber: + case MinTransactionIdAttributeNumber: + case MinCommandIdAttributeNumber: + case MaxTransactionIdAttributeNumber: + case MaxCommandIdAttributeNumber: + case ChainItemPointerAttributeNumber: + case AnchorItemPointerAttributeNumber: + case MinAbsoluteTimeAttributeNumber: + case MaxAbsoluteTimeAttributeNumber: + case VersionTypeAttributeNumber: + break; - case 0: - elog(WARN, "heap_attisnull: zero attnum disallowed"); + case 0: + elog(WARN, "heap_attisnull: zero attnum disallowed"); - default: - elog(WARN, "heap_attisnull: undefined negative attnum"); + default: + elog(WARN, "heap_attisnull: undefined negative attnum"); } return (0); @@ -277,38 +277,38 @@ heap_attisnull(HeapTuple tup, int attnum) int heap_sysattrlen(AttrNumber attno) { - HeapTupleData *f = NULL; + HeapTupleData *f = NULL; switch (attno) { - case SelfItemPointerAttributeNumber: - return sizeof f->t_ctid; - case ObjectIdAttributeNumber: - return sizeof f->t_oid; - case MinTransactionIdAttributeNumber: - return sizeof f->t_xmin; - case MinCommandIdAttributeNumber: - return sizeof f->t_cmin; - case MaxTransactionIdAttributeNumber: - return sizeof f->t_xmax; - case MaxCommandIdAttributeNumber: - return sizeof f->t_cmax; - case ChainItemPointerAttributeNumber: - return sizeof f->t_chain; - case MinAbsoluteTimeAttributeNumber: - return sizeof f->t_tmin; - case MaxAbsoluteTimeAttributeNumber: - return sizeof f->t_tmax; - case VersionTypeAttributeNumber: - return sizeof f->t_vtype; - - case AnchorItemPointerAttributeNumber: - elog(WARN, "heap_sysattrlen: field t_anchor does not exist!"); - return 0; - - default: - elog(WARN, "sysattrlen: System attribute number %d unknown.", attno); - return 0; + case SelfItemPointerAttributeNumber: + return sizeof f->t_ctid; + case ObjectIdAttributeNumber: + return sizeof f->t_oid; + case MinTransactionIdAttributeNumber: + return sizeof f->t_xmin; + case MinCommandIdAttributeNumber: + return sizeof f->t_cmin; + case MaxTransactionIdAttributeNumber: + return sizeof f->t_xmax; + case MaxCommandIdAttributeNumber: + return sizeof f->t_cmax; + case ChainItemPointerAttributeNumber: + return sizeof f->t_chain; + case MinAbsoluteTimeAttributeNumber: + return sizeof f->t_tmin; + case MaxAbsoluteTimeAttributeNumber: + return sizeof f->t_tmax; + case VersionTypeAttributeNumber: + return sizeof f->t_vtype; + + case AnchorItemPointerAttributeNumber: + elog(WARN, "heap_sysattrlen: field t_anchor does not exist!"); + return 0; + + default: + elog(WARN, "sysattrlen: System attribute number %d unknown.", attno); + return 0; } } @@ -321,48 +321,48 @@ heap_sysattrlen(AttrNumber attno) bool heap_sysattrbyval(AttrNumber attno) { - bool byval; + bool byval; switch (attno) { - case SelfItemPointerAttributeNumber: - byval = false; - break; - case ObjectIdAttributeNumber: - byval = true; - break; - case MinTransactionIdAttributeNumber: - byval = true; - break; - case MinCommandIdAttributeNumber: - byval = true; - break; - case MaxTransactionIdAttributeNumber: - byval = true; - break; - case MaxCommandIdAttributeNumber: - byval = true; - break; - case ChainItemPointerAttributeNumber: - byval = false; - break; - case AnchorItemPointerAttributeNumber: - byval = false; - break; - case MinAbsoluteTimeAttributeNumber: - byval = true; - break; - case MaxAbsoluteTimeAttributeNumber: - byval = true; - break; - case VersionTypeAttributeNumber: - byval = true; - break; - default: - byval = true; - elog(WARN, "sysattrbyval: System attribute number %d unknown.", - attno); - break; + case SelfItemPointerAttributeNumber: + byval = false; + break; + case ObjectIdAttributeNumber: + byval = true; + break; + case MinTransactionIdAttributeNumber: + byval = true; + break; + case MinCommandIdAttributeNumber: + byval = true; + break; + case MaxTransactionIdAttributeNumber: + byval = true; + break; + case MaxCommandIdAttributeNumber: + byval = true; + break; + case ChainItemPointerAttributeNumber: + byval = false; + break; + case AnchorItemPointerAttributeNumber: + byval = false; + break; + case MinAbsoluteTimeAttributeNumber: + byval = true; + break; + case MaxAbsoluteTimeAttributeNumber: + byval = true; + break; + case VersionTypeAttributeNumber: + byval = true; + break; + default: + byval = true; + elog(WARN, "sysattrbyval: System attribute number %d unknown.", + attno); + break; } return byval; @@ -372,57 +372,57 @@ heap_sysattrbyval(AttrNumber attno) * heap_getsysattr * ---------------- */ -char * +char * heap_getsysattr(HeapTuple tup, Buffer b, int attnum) { switch (attnum) { - case SelfItemPointerAttributeNumber: - return ((char *) &tup->t_ctid); - case ObjectIdAttributeNumber: - return ((char *) (long) tup->t_oid); - case MinTransactionIdAttributeNumber: - return ((char *) (long) tup->t_xmin); - case MinCommandIdAttributeNumber: - return ((char *) (long) tup->t_cmin); - case MaxTransactionIdAttributeNumber: - return ((char *) (long) tup->t_xmax); - case MaxCommandIdAttributeNumber: - return ((char *) (long) tup->t_cmax); - case ChainItemPointerAttributeNumber: - return ((char *) &tup->t_chain); - case AnchorItemPointerAttributeNumber: - elog(WARN, "heap_getsysattr: t_anchor does not exist!"); - break; + case SelfItemPointerAttributeNumber: + return ((char *) &tup->t_ctid); + case ObjectIdAttributeNumber: + return ((char *) (long) tup->t_oid); + case MinTransactionIdAttributeNumber: + return ((char *) (long) tup->t_xmin); + case MinCommandIdAttributeNumber: + return ((char *) (long) tup->t_cmin); + case MaxTransactionIdAttributeNumber: + return ((char *) (long) tup->t_xmax); + case MaxCommandIdAttributeNumber: + return ((char *) (long) tup->t_cmax); + case ChainItemPointerAttributeNumber: + return ((char *) &tup->t_chain); + case AnchorItemPointerAttributeNumber: + elog(WARN, "heap_getsysattr: t_anchor does not exist!"); + break; - /* - * For tmin and tmax, we need to do some extra work. These don't - * get filled in until the vacuum cleaner runs (or we manage to - * flush a page after setting the value correctly below). If the - * vacuum cleaner hasn't run yet, then the times stored in the - * tuple are wrong, and we need to look up the commit time of the - * transaction. We cache this value in the tuple to avoid doing - * the work more than once. - */ + /* + * For tmin and tmax, we need to do some extra work. These + * don't get filled in until the vacuum cleaner runs (or we + * manage to flush a page after setting the value correctly + * below). If the vacuum cleaner hasn't run yet, then the + * times stored in the tuple are wrong, and we need to look up + * the commit time of the transaction. We cache this value in + * the tuple to avoid doing the work more than once. + */ - case MinAbsoluteTimeAttributeNumber: - if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) && - TransactionIdDidCommit(tup->t_xmin)) - tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin); - return ((char *) (long) tup->t_tmin); - case MaxAbsoluteTimeAttributeNumber: - if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax)) - { - if (TransactionIdDidCommit(tup->t_xmax)) - tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax); - else - tup->t_tmax = CURRENT_ABSTIME; - } - return ((char *) (long) tup->t_tmax); - case VersionTypeAttributeNumber: - return ((char *) (long) tup->t_vtype); - default: - elog(WARN, "heap_getsysattr: undefined attnum %d", attnum); + case MinAbsoluteTimeAttributeNumber: + if (!AbsoluteTimeIsBackwardCompatiblyValid(tup->t_tmin) && + TransactionIdDidCommit(tup->t_xmin)) + tup->t_tmin = TransactionIdGetCommitTime(tup->t_xmin); + return ((char *) (long) tup->t_tmin); + case MaxAbsoluteTimeAttributeNumber: + if (!AbsoluteTimeIsBackwardCompatiblyReal(tup->t_tmax)) + { + if (TransactionIdDidCommit(tup->t_xmax)) + tup->t_tmax = TransactionIdGetCommitTime(tup->t_xmax); + else + tup->t_tmax = CURRENT_ABSTIME; + } + return ((char *) (long) tup->t_tmax); + case VersionTypeAttributeNumber: + return ((char *) (long) tup->t_vtype); + default: + elog(WARN, "heap_getsysattr: undefined attnum %d", attnum); } return (NULL); } @@ -444,15 +444,15 @@ heap_getsysattr(HeapTuple tup, Buffer b, int attnum) * the same attribute descriptor will go much quicker. -cim 5/4/91 * ---------------- */ -char * +char * fastgetattr(HeapTuple tup, int attnum, TupleDesc tupleDesc, bool * isnull) { - char *tp; /* ptr to att in tuple */ - bits8 *bp = NULL; /* ptr to att in tuple */ - int slow; /* do we have to walk nulls? */ + char *tp; /* ptr to att in tuple */ + bits8 *bp = NULL; /* ptr to att in tuple */ + int slow; /* do we have to walk nulls? */ AttributeTupleForm *att = tupleDesc->attrs; /* ---------------- @@ -526,7 +526,7 @@ fastgetattr(HeapTuple tup, */ { - register int i = 0; /* current offset in bp */ + register int i = 0; /* current offset in bp */ for (i = 0; i < attnum && !slow; i++) { @@ -554,7 +554,7 @@ fastgetattr(HeapTuple tup, } else if (!HeapTupleAllFixed(tup)) { - register int j = 0; + register int j = 0; for (j = 0; j < attnum && !slow; j++) if (att[j]->attlen < 1) @@ -569,8 +569,8 @@ fastgetattr(HeapTuple tup, */ if (!slow) { - register int j = 1; - register long off; + register int j = 1; + register long off; /* * need to set cache for some atts @@ -587,30 +587,30 @@ fastgetattr(HeapTuple tup, { switch (att[j]->attlen) { - case -1: - off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[j]->attlen < sizeof(int32)) - { - elog(WARN, - "fastgetattr: attribute %d has len %d", - j, att[j]->attlen); - } - if (att[j]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[j]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[j]->attlen < sizeof(int32)) + { + elog(WARN, + "fastgetattr: attribute %d has len %d", + j, att[j]->attlen); + } + if (att[j]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } att[j]->attcacheoff = off; @@ -622,9 +622,9 @@ fastgetattr(HeapTuple tup, } else { - register bool usecache = true; - register int off = 0; - register int i; + register bool usecache = true; + register int off = 0; + register int i; /* * Now we know that we have to walk the tuple CAREFULLY. @@ -648,28 +648,28 @@ fastgetattr(HeapTuple tup, } switch (att[i]->attlen) { - case -1: - off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[i]->attlen < sizeof(int32)) - elog(WARN, - "fastgetattr2: attribute %d has len %d", - i, att[i]->attlen); - if (att[i]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[i]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[i]->attlen < sizeof(int32)) + elog(WARN, + "fastgetattr2: attribute %d has len %d", + i, att[i]->attlen); + if (att[i]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } if (usecache && att[i]->attcacheoff > 0) { @@ -687,47 +687,47 @@ fastgetattr(HeapTuple tup, switch (att[i]->attlen) { + case sizeof(char): + off++; + break; + case sizeof(int16): + off += sizeof(int16); + break; + case sizeof(int32): + off += sizeof(int32); + break; + case -1: + usecache = false; + off += VARSIZE(tp + off); + break; + default: + off += att[i]->attlen; + break; + } + } + switch (att[attnum]->attlen) + { + case -1: + off = (att[attnum]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; case sizeof(char): - off++; break; - case sizeof(int16): - off += sizeof(int16); + case sizeof(short): + off = SHORTALIGN(off); break; case sizeof(int32): - off += sizeof(int32); - break; - case -1: - usecache = false; - off += VARSIZE(tp + off); + off = INTALIGN(off); break; default: - off += att[i]->attlen; + if (att[attnum]->attlen < sizeof(int32)) + elog(WARN, "fastgetattr3: attribute %d has len %d", + attnum, att[attnum]->attlen); + if (att[attnum]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); break; - } - } - switch (att[attnum]->attlen) - { - case -1: - off = (att[attnum]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[attnum]->attlen < sizeof(int32)) - elog(WARN, "fastgetattr3: attribute %d has len %d", - attnum, att[attnum]->attlen); - if (att[attnum]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; } return ((char *) fetchatt(&(att[attnum]), tp + off)); } @@ -742,7 +742,7 @@ fastgetattr(HeapTuple tup, HeapTuple heap_copytuple(HeapTuple tuple) { - HeapTuple newTuple; + HeapTuple newTuple; if (!HeapTupleIsValid(tuple)) return (NULL); @@ -772,15 +772,15 @@ heap_deformtuple(HeapTuple tuple, Datum values[], char nulls[]) { - int i; - int natts; + int i; + int natts; Assert(HeapTupleIsValid(tuple)); natts = tuple->t_natts; for (i = 0; i < natts; i++) { - bool isnull; + bool isnull; values[i] = (Datum) heap_getattr(tuple, InvalidBuffer, @@ -819,14 +819,14 @@ heap_formtuple(TupleDesc tupleDescriptor, Datum value[], char nulls[]) { - char *tp; /* tuple pointer */ - HeapTuple tuple; /* return tuple */ - int bitmaplen; - long len; - int hoff; - bool hasnull = false; - int i; - int numberOfAttributes = tupleDescriptor->natts; + char *tp; /* tuple pointer */ + HeapTuple tuple; /* return tuple */ + int bitmaplen; + long len; + int hoff; + bool hasnull = false; + int i; + int numberOfAttributes = tupleDescriptor->natts; len = sizeof *tuple - sizeof tuple->t_bits; @@ -885,14 +885,14 @@ heap_modifytuple(HeapTuple tuple, char replNull[], char repl[]) { - int attoff; - int numberOfAttributes; - Datum *value; - char *nulls; - bool isNull; - HeapTuple newTuple; - int madecopy; - uint8 infomask; + int attoff; + int numberOfAttributes; + Datum *value; + char *nulls; + bool isNull; + HeapTuple newTuple; + int madecopy; + uint8 infomask; /* ---------------- * sanity checks @@ -936,7 +936,7 @@ heap_modifytuple(HeapTuple tuple, if (repl[attoff] == ' ') { - char *attr; + char *attr; attr = heap_getattr(tuple, @@ -1001,10 +1001,10 @@ heap_addheader(uint32 natts, /* max domain index */ int structlen, /* its length */ char *structure) /* pointer to the struct */ { - register char *tp; /* tuple data pointer */ - HeapTuple tup; - long len; - int hoff; + register char *tp; /* tuple data pointer */ + HeapTuple tup; + long len; + int hoff; AssertArg(natts > 0); diff --git a/src/backend/access/common/heapvalid.c b/src/backend/access/common/heapvalid.c index 0caeb54e17c..ce0cb58d7dc 100644 --- a/src/backend/access/common/heapvalid.c +++ b/src/backend/access/common/heapvalid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.17 1997/09/07 04:37:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/heapvalid.c,v 1.18 1997/09/08 02:19:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,9 +36,9 @@ heap_keytest(HeapTuple t, int nkeys, ScanKey keys) { - bool isnull; - Datum atp; - int test; + bool isnull; + Datum atp; + int test; for (; nkeys--; keys++) { @@ -101,11 +101,11 @@ heap_tuple_satisfies(ItemId itemId, int nKeys, ScanKey key) { - HeapTuple tuple, - result; - bool res; - TransactionId old_tmin, - old_tmax; + HeapTuple tuple, + result; + bool res; + TransactionId old_tmin, + old_tmax; if (!ItemIdIsUsed(itemId)) return NULL; diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index c133693801b..e0a6e2ba5ca 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.16 1997/09/07 04:37:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.17 1997/09/08 02:19:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,8 +26,8 @@ #include <string.h> #endif -static Size IndexInfoFindDataOffset(unsigned short t_info); -static char * +static Size IndexInfoFindDataOffset(unsigned short t_info); +static char * fastgetiattr(IndexTuple tup, int attnum, TupleDesc att, bool * isnull); @@ -45,15 +45,15 @@ index_formtuple(TupleDesc tupleDescriptor, Datum value[], char null[]) { - register char *tp; /* tuple pointer */ - IndexTuple tuple; /* return tuple */ - Size size, - hoff; - int i; - unsigned short infomask = 0; - bool hasnull = false; - char tupmask = 0; - int numberOfAttributes = tupleDescriptor->natts; + register char *tp; /* tuple pointer */ + IndexTuple tuple; /* return tuple */ + Size size, + hoff; + int i; + unsigned short infomask = 0; + bool hasnull = false; + char tupmask = 0; + int numberOfAttributes = tupleDescriptor->natts; if (numberOfAttributes > MaxIndexAttributeNumber) elog(WARN, "index_formtuple: numberOfAttributes of %d > %d", @@ -133,16 +133,16 @@ index_formtuple(TupleDesc tupleDescriptor, * the same attribute descriptor will go much quicker. -cim 5/4/91 * ---------------- */ -static char * +static char * fastgetiattr(IndexTuple tup, int attnum, TupleDesc tupleDesc, bool * isnull) { - register char *tp; /* ptr to att in tuple */ - register char *bp = NULL; /* ptr to att in tuple */ - int slow; /* do we have to walk nulls? */ - register int data_off; /* tuple data offset */ + register char *tp; /* ptr to att in tuple */ + register char *bp = NULL; /* ptr to att in tuple */ + int slow; /* do we have to walk nulls? */ + register int data_off; /* tuple data offset */ AttributeTupleForm *att = tupleDesc->attrs; /* ---------------- @@ -212,11 +212,11 @@ fastgetiattr(IndexTuple tup, * ---------------- */ { - register int i = 0; /* current offset in bp */ - register int mask; /* bit in byte we're looking at */ - register char n; /* current byte in bp */ - register int byte, - finalbit; + register int i = 0; /* current offset in bp */ + register int mask; /* bit in byte we're looking at */ + register char n; /* current byte in bp */ + register int byte, + finalbit; byte = attnum >> 3; finalbit = attnum & 0x07; @@ -256,7 +256,7 @@ fastgetiattr(IndexTuple tup, } else if (!IndexTupleAllFixed(tup)) { - register int j = 0; + register int j = 0; for (j = 0; j < attnum && !slow; j++) if (att[j]->attlen < 1) @@ -272,8 +272,8 @@ fastgetiattr(IndexTuple tup, if (!slow) { - register int j = 1; - register long off; + register int j = 1; + register long off; /* * need to set cache for some atts @@ -297,26 +297,26 @@ fastgetiattr(IndexTuple tup, switch (att[j]->attlen) { - case -1: - off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[j]->attlen > sizeof(int32)) + case -1: off = (att[j]->attalign == 'd') ? - DOUBLEALIGN(off) : LONGALIGN(off); - else - elog(WARN, "fastgetiattr: attribute %d has len %d", - j, att[j]->attlen); - break; + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[j]->attlen > sizeof(int32)) + off = (att[j]->attalign == 'd') ? + DOUBLEALIGN(off) : LONGALIGN(off); + else + elog(WARN, "fastgetiattr: attribute %d has len %d", + j, att[j]->attlen); + break; } @@ -329,9 +329,9 @@ fastgetiattr(IndexTuple tup, } else { - register bool usecache = true; - register int off = 0; - register int i; + register bool usecache = true; + register int off = 0; + register int i; /* * Now we know that we have to walk the tuple CAREFULLY. @@ -361,31 +361,31 @@ fastgetiattr(IndexTuple tup, att[i]->attcacheoff = off; switch (att[i]->attlen) { - case sizeof(char): - off++; - break; - case sizeof(short): - off = SHORTALIGN(off) +sizeof(short); - break; - case sizeof(int32): - off = INTALIGN(off) + sizeof(int32); - break; - case -1: - usecache = false; - off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - off += VARSIZE(tp + off); - break; - default: - if (att[i]->attlen > sizeof(int32)) + case sizeof(char): + off++; + break; + case sizeof(short): + off = SHORTALIGN(off) +sizeof(short); + break; + case sizeof(int32): + off = INTALIGN(off) + sizeof(int32); + break; + case -1: + usecache = false; off = (att[i]->attalign == 'd') ? - DOUBLEALIGN(off) + att[i]->attlen : - LONGALIGN(off) + att[i]->attlen; - else - elog(WARN, "fastgetiattr2: attribute %d has len %d", - i, att[i]->attlen); - - break; + DOUBLEALIGN(off) : INTALIGN(off); + off += VARSIZE(tp + off); + break; + default: + if (att[i]->attlen > sizeof(int32)) + off = (att[i]->attalign == 'd') ? + DOUBLEALIGN(off) + att[i]->attlen : + LONGALIGN(off) + att[i]->attlen; + else + elog(WARN, "fastgetiattr2: attribute %d has len %d", + i, att[i]->attlen); + + break; } } @@ -395,27 +395,27 @@ fastgetiattr(IndexTuple tup, */ switch (att[attnum]->attlen) { - case -1: - off = (att[attnum]->attalign == 'd') ? - DOUBLEALIGN(off) : INTALIGN(off); - break; - case sizeof(char): - break; - case sizeof(short): - off = SHORTALIGN(off); - break; - case sizeof(int32): - off = INTALIGN(off); - break; - default: - if (att[attnum]->attlen < sizeof(int32)) - elog(WARN, "fastgetattr3: attribute %d has len %d", - attnum, att[attnum]->attlen); - if (att[attnum]->attalign == 'd') - off = DOUBLEALIGN(off); - else - off = LONGALIGN(off); - break; + case -1: + off = (att[attnum]->attalign == 'd') ? + DOUBLEALIGN(off) : INTALIGN(off); + break; + case sizeof(char): + break; + case sizeof(short): + off = SHORTALIGN(off); + break; + case sizeof(int32): + off = INTALIGN(off); + break; + default: + if (att[attnum]->attlen < sizeof(int32)) + elog(WARN, "fastgetattr3: attribute %d has len %d", + attnum, att[attnum]->attlen); + if (att[attnum]->attalign == 'd') + off = DOUBLEALIGN(off); + else + off = LONGALIGN(off); + break; } return (fetchatt(&att[attnum], tp + off)); @@ -461,14 +461,14 @@ FormRetrieveIndexResult(ItemPointer indexItemPointer, * * Change me if adding an attribute to IndexTuples!!!!!!!!!!! */ -static Size +static Size IndexInfoFindDataOffset(unsigned short t_info) { if (!(t_info & INDEX_NULL_MASK)) return ((Size) sizeof(IndexTupleData)); else { - Size size = sizeof(IndexTupleData); + Size size = sizeof(IndexTupleData); if (t_info & INDEX_NULL_MASK) { @@ -485,8 +485,8 @@ IndexInfoFindDataOffset(unsigned short t_info) void CopyIndexTuple(IndexTuple source, IndexTuple * target) { - Size size; - IndexTuple ret; + Size size; + IndexTuple ret; size = IndexTupleSize(source); if (*target == NULL) diff --git a/src/backend/access/common/indexvalid.c b/src/backend/access/common/indexvalid.c index 9f8501beb2e..5a9f351568c 100644 --- a/src/backend/access/common/indexvalid.c +++ b/src/backend/access/common/indexvalid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.15 1997/09/07 04:37:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/Attic/indexvalid.c,v 1.16 1997/09/08 02:19:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ * index scan key qualification code * ---------------------------------------------------------------- */ -int NIndexTupleProcessed; +int NIndexTupleProcessed; /* ---------------- * index_keytest @@ -40,9 +40,9 @@ index_keytest(IndexTuple tuple, int scanKeySize, ScanKey key) { - bool isNull; - Datum datum; - int test; + bool isNull; + Datum datum; + int test; IncrIndexProcessed(); diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index 599ac59a455..f8ff685e387 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.16 1997/09/07 04:37:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.17 1997/09/08 02:19:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ Oid typtoout(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -52,7 +52,7 @@ typtoout(Oid type) Oid gettypelem(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -73,13 +73,13 @@ gettypelem(Oid type) void printtup(HeapTuple tuple, TupleDesc typeinfo) { - int i, - j, - k; - char *outputstr, - *attr; - bool isnull; - Oid typoutput; + int i, + j, + k; + char *outputstr, + *attr; + bool isnull; + Oid typoutput; /* ---------------- * tell the frontend to expect new tuple data @@ -158,8 +158,8 @@ printatt(unsigned attributeId, void showatts(char *name, TupleDesc tupleDesc) { - int i; - int natts = tupleDesc->natts; + int i; + int natts = tupleDesc->natts; AttributeTupleForm *attinfo = tupleDesc->attrs; puts(name); @@ -175,11 +175,11 @@ showatts(char *name, TupleDesc tupleDesc) void debugtup(HeapTuple tuple, TupleDesc typeinfo) { - register int i; - char *attr, - *value; - bool isnull; - Oid typoutput; + register int i; + char *attr, + *value; + bool isnull; + Oid typoutput; for (i = 0; i < tuple->t_natts; ++i) { @@ -209,11 +209,11 @@ debugtup(HeapTuple tuple, TupleDesc typeinfo) void printtup_internal(HeapTuple tuple, TupleDesc typeinfo) { - int i, - j, - k; - char *attr; - bool isnull; + int i, + j, + k; + char *attr; + bool isnull; /* ---------------- * tell the frontend to expect new tuple data @@ -254,7 +254,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) #endif for (i = 0; i < tuple->t_natts; ++i) { - int32 len = typeinfo->attrs[i]->attlen; + int32 len = typeinfo->attrs[i]->attlen; attr = heap_getattr(tuple, InvalidBuffer, i + 1, typeinfo, &isnull); if (!isnull) @@ -269,7 +269,7 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) pq_putnchar(VARDATA(attr), len); #ifdef IPORTAL_DEBUG { - char *d = VARDATA(attr); + char *d = VARDATA(attr); fprintf(stderr, "length %d data %x%x%x%x\n", len, *d, *(d + 1), *(d + 2), *(d + 3)); @@ -281,25 +281,25 @@ printtup_internal(HeapTuple tuple, TupleDesc typeinfo) /* fixed size */ if (typeinfo->attrs[i]->attbyval) { - int8 i8; - int16 i16; - int32 i32; + int8 i8; + int16 i16; + int32 i32; pq_putint(len, sizeof(int32)); switch (len) { - case sizeof(int8): - i8 = DatumGetChar(attr); - pq_putnchar((char *) &i8, len); - break; - case sizeof(int16): - i16 = DatumGetInt16(attr); - pq_putnchar((char *) &i16, len); - break; - case sizeof(int32): - i32 = DatumGetInt32(attr); - pq_putnchar((char *) &i32, len); - break; + case sizeof(int8): + i8 = DatumGetChar(attr); + pq_putnchar((char *) &i8, len); + break; + case sizeof(int16): + i16 = DatumGetInt16(attr); + pq_putnchar((char *) &i16, len); + break; + case sizeof(int32): + i32 = DatumGetInt32(attr); + pq_putnchar((char *) &i32, len); + break; } #ifdef IPORTAL_DEBUG fprintf(stderr, "byval length %d data %d\n", len, attr); diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index e616702a8ea..d4b5e893bdd 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.20 1997/09/07 04:37:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.21 1997/09/08 02:19:56 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -42,8 +42,8 @@ TupleDesc CreateTemplateTupleDesc(int natts) { - uint32 size; - TupleDesc desc; + uint32 size; + TupleDesc desc; /* ---------------- * sanity checks @@ -77,7 +77,7 @@ CreateTemplateTupleDesc(int natts) TupleDesc CreateTupleDesc(int natts, AttributeTupleForm * attrs) { - TupleDesc desc; + TupleDesc desc; /* ---------------- * sanity checks @@ -105,9 +105,9 @@ CreateTupleDesc(int natts, AttributeTupleForm * attrs) TupleDesc CreateTupleDescCopy(TupleDesc tupdesc) { - TupleDesc desc; - int i, - size; + TupleDesc desc; + int i, + size; desc = (TupleDesc) palloc(sizeof(struct tupleDesc)); desc->natts = tupdesc->natts; @@ -139,10 +139,10 @@ CreateTupleDescCopy(TupleDesc tupdesc) TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc) { - TupleDesc desc; - TupleConstr *constr = tupdesc->constr; - int i, - size; + TupleDesc desc; + TupleConstr *constr = tupdesc->constr; + int i, + size; desc = (TupleDesc) palloc(sizeof(struct tupleDesc)); desc->natts = tupdesc->natts; @@ -158,7 +158,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) } if (constr) { - TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr)); + TupleConstr *cpy = (TupleConstr *) palloc(sizeof(TupleConstr)); cpy->has_not_null = constr->has_not_null; @@ -201,7 +201,7 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) void FreeTupleDesc(TupleDesc tupdesc) { - int i; + int i; for (i = 0; i < tupdesc->natts; i++) pfree(tupdesc->attrs[i]); @@ -210,7 +210,7 @@ FreeTupleDesc(TupleDesc tupdesc) { if (tupdesc->constr->num_defval > 0) { - AttrDefault *attrdef = tupdesc->constr->defval; + AttrDefault *attrdef = tupdesc->constr->defval; for (i = tupdesc->constr->num_defval - 1; i >= 0; i--) { @@ -223,7 +223,7 @@ FreeTupleDesc(TupleDesc tupdesc) } if (tupdesc->constr->num_check > 0) { - ConstrCheck *check = tupdesc->constr->check; + ConstrCheck *check = tupdesc->constr->check; for (i = tupdesc->constr->num_check - 1; i >= 0; i--) { @@ -258,8 +258,8 @@ TupleDescInitEntry(TupleDesc desc, int attdim, bool attisset) { - HeapTuple tuple; - TypeTupleForm typeForm; + HeapTuple tuple; + TypeTupleForm typeForm; AttributeTupleForm att; /* ---------------- @@ -378,7 +378,7 @@ TupleDescInitEntry(TupleDesc desc, */ if (attisset) { - Type t = type("oid"); + Type t = type("oid"); att->attlen = tlen(t); att->attbyval = tbyval(t); @@ -411,7 +411,7 @@ TupleDescMakeSelfReference(TupleDesc desc, char *relname) { AttributeTupleForm att; - Type t = type("oid"); + Type t = type("oid"); att = desc->attrs[attnum - 1]; att->atttypid = TypeShellMake(relname); @@ -439,17 +439,17 @@ TupleDescMakeSelfReference(TupleDesc desc, TupleDesc BuildDescForRelation(List * schema, char *relname) { - int natts; - AttrNumber attnum; - List *p; - TupleDesc desc; - AttrDefault *attrdef = NULL; - TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); - char *attname; - char *typename; - int attdim; - int ndef = 0; - bool attisset; + int natts; + AttrNumber attnum; + List *p; + TupleDesc desc; + AttrDefault *attrdef = NULL; + TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); + char *attname; + char *typename; + int attdim; + int ndef = 0; + bool attisset; /* ---------------- * allocate a new tuple descriptor @@ -465,8 +465,8 @@ BuildDescForRelation(List * schema, char *relname) foreach(p, schema) { - ColumnDef *entry; - List *arry; + ColumnDef *entry; + List *arry; /* ---------------- * for each entry in the list, get the name and type diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 598f9ed8f02..d12e4e5c6ea 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -55,7 +55,7 @@ gistSplit(Relation r, Buffer buffer, static void gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt); -static void GISTInitBuffer(Buffer b, uint32 f); +static void GISTInitBuffer(Buffer b, uint32 f); static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, int level, GISTSTATE * giststate, @@ -63,13 +63,13 @@ gistChooseSubtree(Relation r, IndexTuple itup, int level, static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, GISTSTATE * giststate); -static int gistnospace(Page p, IndexTuple it); -void gistdelete(Relation r, ItemPointer tid); +static int gistnospace(Page p, IndexTuple it); +void gistdelete(Relation r, ItemPointer tid); static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t); static void gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l); -static char *int_range_out(INTRANGE * r); +static char *int_range_out(INTRANGE * r); /* ** routine to build an index. Basically calls insert over and over @@ -85,33 +85,33 @@ gistbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc scan; - Buffer buffer; - AttrNumber i; - HeapTuple htup; - IndexTuple itup; - TupleDesc hd, - id; + HeapScanDesc scan; + Buffer buffer; + AttrNumber i; + HeapTuple htup; + IndexTuple itup; + TupleDesc hd, + id; InsertIndexResult res; - Datum *d; - bool *nulls; - int nb, - nh, - ni; + Datum *d; + bool *nulls; + int nb, + nh, + ni; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - GISTSTATE giststate; - GISTENTRY tmpcentry; - bool *compvec; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + GISTSTATE giststate; + GISTENTRY tmpcentry; + bool *compvec; /* GiSTs only know how to do stupid locking now */ RelationSetLockForWrite(index); @@ -220,8 +220,8 @@ gistbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -331,11 +331,11 @@ InsertIndexResult gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { InsertIndexResult res; - IndexTuple itup; - GISTSTATE giststate; - GISTENTRY tmpentry; - int i; - bool *compvec; + IndexTuple itup; + GISTSTATE giststate; + GISTENTRY tmpentry; + int i; + bool *compvec; initGISTstate(&giststate, r); @@ -373,7 +373,7 @@ gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation ** that knowledge (some compression routines may want to fish around ** on the page, for example, or do something special for leaf nodes.) */ -static OffsetNumber +static OffsetNumber gistPageAddItem(GISTSTATE * giststate, Relation r, Page page, @@ -384,8 +384,8 @@ gistPageAddItem(GISTSTATE * giststate, GISTENTRY * dentry, IndexTuple * newtup) { - GISTENTRY tmpcentry; - IndexTuple itup = (IndexTuple) item; + GISTENTRY tmpcentry; + IndexTuple itup = (IndexTuple) item; /* * recompress the item given that we now know the exact page and @@ -408,20 +408,20 @@ gistPageAddItem(GISTSTATE * giststate, } -static InsertIndexResult +static InsertIndexResult gistdoinsert(Relation r, IndexTuple itup, /* itup contains compressed entry */ GISTSTATE * giststate) { - GISTENTRY tmpdentry; + GISTENTRY tmpdentry; InsertIndexResult res; - OffsetNumber l; - GISTSTACK *stack; - Buffer buffer; - BlockNumber blk; - Page page; - OffsetNumber off; - IndexTuple newtup; + OffsetNumber l; + GISTSTACK *stack; + Buffer buffer; + BlockNumber blk; + Page page; + OffsetNumber off; + IndexTuple newtup; /* 3rd arg is ignored for now */ blk = gistChooseSubtree(r, itup, 0, giststate, &stack, &buffer); @@ -464,7 +464,7 @@ gistdoinsert(Relation r, } -static BlockNumber +static BlockNumber gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed * entry */ int level, @@ -472,12 +472,12 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed GISTSTACK ** retstack /* out */ , Buffer * leafbuf /* out */ ) { - Buffer buffer; - BlockNumber blk; - GISTSTACK *stack; - Page page; - GISTPageOpaque opaque; - IndexTuple which; + Buffer buffer; + BlockNumber blk; + GISTSTACK *stack; + Page page; + GISTPageOpaque opaque; + IndexTuple which; blk = GISTP_ROOT; buffer = InvalidBuffer; @@ -496,8 +496,8 @@ gistChooseSubtree(Relation r, IndexTuple itup, /* itup has compressed opaque = (GISTPageOpaque) PageGetSpecialPointer(page); if (!(opaque->flags & F_LEAF)) { - GISTSTACK *n; - ItemId iid; + GISTSTACK *n; + ItemId iid; n = (GISTSTACK *) palloc(sizeof(GISTSTACK)); n->gs_parent = stack; @@ -526,17 +526,17 @@ gistAdjustKeys(Relation r, int att_size, GISTSTATE * giststate) { - char *oldud; - Page p; - Buffer b; - bool result; - bytea *evec; - GISTENTRY centry, - *ev0p, - *ev1p; - int size, - datumsize; - IndexTuple tid; + char *oldud; + Page p; + Buffer b; + bool result; + bytea *evec; + GISTENTRY centry, + *ev0p, + *ev1p; + int size, + datumsize; + IndexTuple tid; if (stk == (GISTSTACK *) NULL) return; @@ -570,7 +570,7 @@ gistAdjustKeys(Relation r, (giststate->equalFn) (ev0p->pred, datum, &result); if (!result) { - TupleDesc td = RelationGetTupleDescriptor(r); + TupleDesc td = RelationGetTupleDescriptor(r); /* compress datum for storage on page */ gistcentryinit(giststate, ¢ry, datum, ev0p->rel, ev0p->page, @@ -595,10 +595,10 @@ gistAdjustKeys(Relation r, * delete the old entry and insert the new * one. Note that * this may cause a split here! */ - IndexTuple newtup; + IndexTuple newtup; ItemPointerData oldtid; - char *isnull; - TupleDesc tupDesc; + char *isnull; + TupleDesc tupDesc; InsertIndexResult res; /* delete old tuple */ @@ -641,41 +641,41 @@ gistAdjustKeys(Relation r, * gistSplit -- split a page in the tree. * */ -static InsertIndexResult +static InsertIndexResult gistSplit(Relation r, Buffer buffer, GISTSTACK * stack, IndexTuple itup, /* contains compressed entry */ GISTSTATE * giststate) { - Page p; - Buffer leftbuf, - rightbuf; - Page left, - right; - ItemId itemid; - IndexTuple item; - IndexTuple ltup, - rtup, - newtup; - OffsetNumber maxoff; - OffsetNumber i; - OffsetNumber leftoff, - rightoff; - BlockNumber lbknum, - rbknum; - BlockNumber bufblock; - GISTPageOpaque opaque; - int blank; + Page p; + Buffer leftbuf, + rightbuf; + Page left, + right; + ItemId itemid; + IndexTuple item; + IndexTuple ltup, + rtup, + newtup; + OffsetNumber maxoff; + OffsetNumber i; + OffsetNumber leftoff, + rightoff; + BlockNumber lbknum, + rbknum; + BlockNumber bufblock; + GISTPageOpaque opaque; + int blank; InsertIndexResult res; - char *isnull; - GIST_SPLITVEC v; - TupleDesc tupDesc; - bytea *entryvec; - bool *decompvec; - IndexTuple item_1; - GISTENTRY tmpdentry, - tmpentry; + char *isnull; + GIST_SPLITVEC v; + TupleDesc tupDesc; + bytea *entryvec; + bool *decompvec; + IndexTuple item_1; + GISTENTRY tmpdentry, + tmpentry; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -911,11 +911,11 @@ static void gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup, IndexTuple rtup, GISTSTATE * giststate) { - Buffer b; - Page p; + Buffer b; + Page p; InsertIndexResult res; - GISTENTRY tmpentry; - IndexTuple newtup; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, stk->gs_blk); p = BufferGetPage(b); @@ -949,16 +949,16 @@ gistentryinserttwo(Relation r, GISTSTACK * stk, IndexTuple ltup, /* ** Insert an entry onto a page */ -static InsertIndexResult +static InsertIndexResult gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup, GISTSTATE * giststate) { - Buffer b; - Page p; + Buffer b; + Page p; InsertIndexResult res; - OffsetNumber off; - GISTENTRY tmpentry; - IndexTuple newtup; + OffsetNumber off; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, stk->gs_blk); p = BufferGetPage(b); @@ -992,10 +992,10 @@ gistentryinsert(Relation r, GISTSTACK * stk, IndexTuple tup, static void gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt) { - Buffer b; - Page p; - GISTENTRY tmpentry; - IndexTuple newtup; + Buffer b; + Page p; + GISTENTRY tmpentry; + IndexTuple newtup; b = ReadBuffer(r, GISTP_ROOT); GISTInitBuffer(b, 0); @@ -1022,9 +1022,9 @@ gistnewroot(GISTSTATE * giststate, Relation r, IndexTuple lt, IndexTuple rt) static void GISTInitBuffer(Buffer b, uint32 f) { - GISTPageOpaque opaque; - Page page; - Size pageSize; + GISTPageOpaque opaque; + Page page; + Size pageSize; pageSize = BufferGetPageSize(b); @@ -1040,21 +1040,21 @@ GISTInitBuffer(Buffer b, uint32 f) /* ** find entry with lowest penalty */ -static OffsetNumber +static OffsetNumber gistchoose(Relation r, Page p, IndexTuple it, /* it has compressed entry */ GISTSTATE * giststate) { - OffsetNumber maxoff; - OffsetNumber i; - char *id; - char *datum; - float usize; - OffsetNumber which; - float which_grow; - GISTENTRY entry, - identry; - int size, - idsize; + OffsetNumber maxoff; + OffsetNumber i; + char *id; + char *datum; + float usize; + OffsetNumber which; + float which_grow; + GISTENTRY entry, + identry; + int size, + idsize; idsize = IndexTupleSize(it) - sizeof(IndexTupleData); id = ((char *) it) + sizeof(IndexTupleData); @@ -1097,7 +1097,7 @@ gistnospace(Page p, IndexTuple it) void gistfreestack(GISTSTACK * s) { - GISTSTACK *p; + GISTSTACK *p; while (s != (GISTSTACK *) NULL) { @@ -1114,10 +1114,10 @@ gistfreestack(GISTSTACK * s) void gistdelete(Relation r, ItemPointer tid) { - BlockNumber blkno; - OffsetNumber offnum; - Buffer buf; - Page page; + BlockNumber blkno; + OffsetNumber offnum; + Buffer buf; + Page page; /* must write-lock on delete */ RelationSetLockForWrite(r); @@ -1142,17 +1142,17 @@ gistdelete(Relation r, ItemPointer tid) void initGISTstate(GISTSTATE * giststate, Relation index) { - RegProcedure consistent_proc, - union_proc, - compress_proc, - decompress_proc; - RegProcedure penalty_proc, - picksplit_proc, - equal_proc; - func_ptr user_fn; - int pronargs; - HeapTuple htup; - IndexTupleForm itupform; + RegProcedure consistent_proc, + union_proc, + compress_proc, + decompress_proc; + RegProcedure penalty_proc, + picksplit_proc, + equal_proc; + func_ptr user_fn; + int pronargs; + HeapTuple htup; + IndexTupleForm itupform; consistent_proc = index_getprocid(index, 1, GIST_CONSISTENT_PROC); union_proc = index_getprocid(index, 1, GIST_UNION_PROC); @@ -1209,10 +1209,10 @@ initGISTstate(GISTSTATE * giststate, Relation index) ** the key with another key, which may involve generating a new IndexTuple ** if the sizes don't match */ -static IndexTuple +static IndexTuple gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t) { - char *datum = (((char *) t) + sizeof(IndexTupleData)); + char *datum = (((char *) t) + sizeof(IndexTupleData)); /* if new entry fits in index tuple, copy it in */ if (entry.bytes < IndexTupleSize(t) - sizeof(IndexTupleData)) @@ -1228,10 +1228,10 @@ gist_tuple_replacekey(Relation r, GISTENTRY entry, IndexTuple t) else { /* generate a new index tuple for the compressed entry */ - TupleDesc tupDesc = r->rd_att; - IndexTuple newtup; - char *isnull; - int blank; + TupleDesc tupDesc = r->rd_att; + IndexTuple newtup; + char *isnull; + int blank; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -1253,7 +1253,7 @@ void gistdentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l) { - GISTENTRY *dep; + GISTENTRY *dep; gistentryinit(*e, pr, r, pg, o, b, l); if (giststate->haskeytype) @@ -1274,7 +1274,7 @@ static void gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l) { - GISTENTRY *cep; + GISTENTRY *cep; gistentryinit(*e, pr, r, pg, o, b, l); if (giststate->haskeytype) @@ -1299,18 +1299,18 @@ gistcentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, void _gistdump(Relation r) { - Buffer buf; - Page page; - OffsetNumber offnum, - maxoff; - BlockNumber blkno; - BlockNumber nblocks; - GISTPageOpaque po; - IndexTuple itup; - BlockNumber itblkno; - OffsetNumber itoffno; - char *datum; - char *itkey; + Buffer buf; + Page page; + OffsetNumber offnum, + maxoff; + BlockNumber blkno; + BlockNumber nblocks; + GISTPageOpaque po; + IndexTuple itup; + BlockNumber itblkno; + OffsetNumber itoffno; + char *datum; + char *itkey; nblocks = RelationGetNumberOfBlocks(r); for (blkno = 0; blkno < nblocks; blkno++) @@ -1350,12 +1350,12 @@ _gistdump(Relation r) } #ifdef NOT_USED -static char * +static char * text_range_out(TXTRANGE * r) { - char *result; - char *lower, - *upper; + char *result; + char *lower, + *upper; if (r == NULL) return (NULL); @@ -1377,10 +1377,10 @@ text_range_out(TXTRANGE * r) #endif -static char * +static char * int_range_out(INTRANGE * r) { - char *result; + char *result; if (r == NULL) return (NULL); diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index cad4cef267e..0820389ff43 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -62,19 +62,19 @@ gistgettuple(IndexScanDesc s, ScanDirection dir) return (res); } -static RetrieveIndexResult +static RetrieveIndexResult gistfirst(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTACK *stk; - BlockNumber blk; - IndexTuple it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTACK *stk; + BlockNumber blk; + IndexTuple it; b = ReadBuffer(s->relation, GISTP_ROOT); p = BufferGetPage(b); @@ -145,19 +145,19 @@ gistfirst(IndexScanDesc s, ScanDirection dir) } } -static RetrieveIndexResult +static RetrieveIndexResult gistnext(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTACK *stk; - BlockNumber blk; - IndexTuple it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTACK *stk; + BlockNumber blk; + IndexTuple it; blk = ItemPointerGetBlockNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -247,7 +247,7 @@ gistnext(IndexScanDesc s, ScanDirection dir) } /* Similar to index_keytest, but decompresses the key in the IndexTuple */ -static bool +static bool gistindex_keytest(IndexTuple tuple, TupleDesc tupdesc, int scanKeySize, @@ -257,10 +257,10 @@ gistindex_keytest(IndexTuple tuple, Page p, OffsetNumber offset) { - bool isNull; - Datum datum; - int test; - GISTENTRY de; + bool isNull; + Datum datum; + int test; + GISTENTRY de; IncrIndexProcessed(); @@ -308,14 +308,14 @@ gistindex_keytest(IndexTuple tuple, } -static OffsetNumber +static OffsetNumber gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) { - OffsetNumber maxoff; - char *it; - GISTPageOpaque po; - GISTScanOpaque so; - GISTSTATE *giststate; + OffsetNumber maxoff; + char *it; + GISTPageOpaque po; + GISTScanOpaque so; + GISTSTATE *giststate; maxoff = PageGetMaxOffsetNumber(p); po = (GISTPageOpaque) PageGetSpecialPointer(p); @@ -355,11 +355,11 @@ gistfindnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) return (n); } -static RetrieveIndexResult +static RetrieveIndexResult gistscancache(IndexScanDesc s, ScanDirection dir) { RetrieveIndexResult res; - ItemPointer ip; + ItemPointer ip; if (!(ScanDirectionIsNoMovement(dir) && ItemPointerIsValid(&(s->currentItemData)))) @@ -384,14 +384,14 @@ gistscancache(IndexScanDesc s, ScanDirection dir) * gistheapptr returns the item pointer to the tuple in the heap relation * for which itemp is the index relation item pointer. */ -static ItemPointer +static ItemPointer gistheapptr(Relation r, ItemPointer itemp) { - Buffer b; - Page p; - IndexTuple it; - ItemPointer ip; - OffsetNumber n; + Buffer b; + Page p; + IndexTuple it; + ItemPointer ip; + OffsetNumber n; ip = (ItemPointer) palloc(sizeof(ItemPointerData)); if (ItemPointerIsValid(itemp)) diff --git a/src/backend/access/gist/gistscan.c b/src/backend/access/gist/gistscan.c index ec680558d88..67070997754 100644 --- a/src/backend/access/gist/gistscan.c +++ b/src/backend/access/gist/gistscan.c @@ -27,8 +27,8 @@ #endif /* routines defined and used here */ -static void gistregscan(IndexScanDesc s); -static void gistdropscan(IndexScanDesc s); +static void gistregscan(IndexScanDesc s); +static void gistdropscan(IndexScanDesc s); static void gistadjone(IndexScanDesc s, int op, BlockNumber blkno, OffsetNumber offnum); @@ -51,9 +51,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct GISTScanListData { - IndexScanDesc gsl_scan; + IndexScanDesc gsl_scan; struct GISTScanListData *gsl_next; -} GISTScanListData; +} GISTScanListData; typedef GISTScanListData *GISTScanList; @@ -66,7 +66,7 @@ gistbeginscan(Relation r, uint16 nkeys, ScanKey key) { - IndexScanDesc s; + IndexScanDesc s; RelationSetLockForRead(r); s = RelationGetIndexScan(r, fromEnd, nkeys, key); @@ -78,8 +78,8 @@ gistbeginscan(Relation r, void gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key) { - GISTScanOpaque p; - int i; + GISTScanOpaque p; + int i; if (!IndexScanIsValid(s)) { @@ -173,10 +173,10 @@ gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key) void gistmarkpos(IndexScanDesc s) { - GISTScanOpaque p; - GISTSTACK *o, - *n, - *tmp; + GISTScanOpaque p; + GISTSTACK *o, + *n, + *tmp; s->currentMarkData = s->currentItemData; p = (GISTScanOpaque) s->opaque; @@ -206,10 +206,10 @@ gistmarkpos(IndexScanDesc s) void gistrestrpos(IndexScanDesc s) { - GISTScanOpaque p; - GISTSTACK *o, - *n, - *tmp; + GISTScanOpaque p; + GISTSTACK *o, + *n, + *tmp; s->currentItemData = s->currentMarkData; p = (GISTScanOpaque) s->opaque; @@ -239,7 +239,7 @@ gistrestrpos(IndexScanDesc s) void gistendscan(IndexScanDesc s) { - GISTScanOpaque p; + GISTScanOpaque p; p = (GISTScanOpaque) s->opaque; @@ -257,7 +257,7 @@ gistendscan(IndexScanDesc s) static void gistregscan(IndexScanDesc s) { - GISTScanList l; + GISTScanList l; l = (GISTScanList) palloc(sizeof(GISTScanListData)); l->gsl_scan = s; @@ -268,8 +268,8 @@ gistregscan(IndexScanDesc s) static void gistdropscan(IndexScanDesc s) { - GISTScanList l; - GISTScanList prev; + GISTScanList l; + GISTScanList prev; prev = (GISTScanList) NULL; @@ -294,8 +294,8 @@ gistdropscan(IndexScanDesc s) void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) { - GISTScanList l; - Oid relid; + GISTScanList l; + Oid relid; relid = r->rd_id; for (l = GISTScans; l != (GISTScanList) NULL; l = l->gsl_next) @@ -321,7 +321,7 @@ gistadjone(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - GISTScanOpaque so; + GISTScanOpaque so; adjustiptr(s, &(s->currentItemData), op, blkno, offnum); adjustiptr(s, &(s->currentMarkData), op, blkno, offnum); @@ -349,8 +349,8 @@ adjustiptr(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - OffsetNumber curoff; - GISTScanOpaque so; + OffsetNumber curoff; + GISTScanOpaque so; if (ItemPointerIsValid(iptr)) { @@ -361,39 +361,43 @@ adjustiptr(IndexScanDesc s, switch (op) { - case GISTOP_DEL: - /* back up one if we need to */ - if (curoff >= offnum) - { - - if (curoff > FirstOffsetNumber) - { - /* just adjust the item pointer */ - ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); - } - else + case GISTOP_DEL: + /* back up one if we need to */ + if (curoff >= offnum) { - /* remember that we're before the current tuple */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags |= GS_CURBEFORE; + + if (curoff > FirstOffsetNumber) + { + /* just adjust the item pointer */ + ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); + } else - so->s_flags |= GS_MRKBEFORE; + { + + /* + * remember that we're before the current + * tuple + */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags |= GS_CURBEFORE; + else + so->s_flags |= GS_MRKBEFORE; + } } - } - break; - - case GISTOP_SPLIT: - /* back to start of page on split */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags &= ~GS_CURBEFORE; - else - so->s_flags &= ~GS_MRKBEFORE; - break; - - default: - elog(WARN, "Bad operation in GiST scan adjust: %d", op); + break; + + case GISTOP_SPLIT: + /* back to start of page on split */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags &= ~GS_CURBEFORE; + else + so->s_flags &= ~GS_MRKBEFORE; + break; + + default: + elog(WARN, "Bad operation in GiST scan adjust: %d", op); } } } diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index e13539c4ad9..97e1a631a1e 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.13 1997/09/07 04:37:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.14 1997/09/08 02:20:10 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -31,7 +31,7 @@ #include <string.h> #endif -bool BuildingHash = false; +bool BuildingHash = false; /* * hashbuild() -- build a new hash index. @@ -52,30 +52,30 @@ hashbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc hscan; - Buffer buffer; - HeapTuple htup; - IndexTuple itup; - TupleDesc htupdesc, - itupdesc; - Datum *attdata; - bool *nulls; + HeapScanDesc hscan; + Buffer buffer; + HeapTuple htup; + IndexTuple itup; + TupleDesc htupdesc, + itupdesc; + Datum *attdata; + bool *nulls; InsertIndexResult res; - int nhtups, - nitups; - int i; - HashItem hitem; + int nhtups, + nitups; + int i; + HashItem hitem; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; + Oid hrelid, + irelid; + Node *pred, + *oldPred; /* note that this is a new btree */ BuildingHash = true; @@ -171,8 +171,8 @@ hashbuild(Relation heap, */ for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -280,8 +280,8 @@ hashbuild(Relation heap, InsertIndexResult hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { - HashItem hitem; - IndexTuple itup; + HashItem hitem; + IndexTuple itup; InsertIndexResult res; @@ -306,7 +306,7 @@ hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relati /* * hashgettuple() -- Get the next tuple in the scan. */ -char * +char * hashgettuple(IndexScanDesc scan, ScanDirection dir) { RetrieveIndexResult res; @@ -329,14 +329,14 @@ hashgettuple(IndexScanDesc scan, ScanDirection dir) /* * hashbeginscan() -- start a scan on a hash index */ -char * +char * hashbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) { - IndexScanDesc scan; - HashScanOpaque so; + IndexScanDesc scan; + HashScanOpaque so; scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey); so = (HashScanOpaque) palloc(sizeof(HashScanOpaqueData)); @@ -356,8 +356,8 @@ hashbeginscan(Relation rel, void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; so = (HashScanOpaque) scan->opaque; @@ -391,8 +391,8 @@ void hashendscan(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; so = (HashScanOpaque) scan->opaque; @@ -426,8 +426,8 @@ hashendscan(IndexScanDesc scan) void hashmarkpos(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; /* * see if we ever call this code. if we do, then so_mrkbuf a useful @@ -463,8 +463,8 @@ hashmarkpos(IndexScanDesc scan) void hashrestrpos(IndexScanDesc scan) { - ItemPointer iptr; - HashScanOpaque so; + ItemPointer iptr; + HashScanOpaque so; /* * see if we ever call this code. if we do, then so_mrkbuf a useful diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index a3cbaa1a94c..11785867691 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.4 1997/09/07 04:37:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.5 1997/09/08 02:20:13 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -36,10 +36,10 @@ hashint4(uint32 key) uint32 hashfloat4(float32 keyp) { - int len; - int loop; - uint32 h; - char *kp = (char *) keyp; + int len; + int loop; + uint32 h; + char *kp = (char *) keyp; len = sizeof(float32data); @@ -55,25 +55,25 @@ hashfloat4(float32 keyp) switch (len & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASH4; - case 7: - HASH4; - case 6: - HASH4; - case 5: - HASH4; - case 4: - HASH4; - case 3: - HASH4; - case 2: - HASH4; - case 1: - HASH4; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASH4; + case 7: + HASH4; + case 6: + HASH4; + case 5: + HASH4; + case 4: + HASH4; + case 3: + HASH4; + case 2: + HASH4; + case 1: + HASH4; + } while (--loop); } } return (h); @@ -83,10 +83,10 @@ hashfloat4(float32 keyp) uint32 hashfloat8(float64 keyp) { - int len; - int loop; - uint32 h; - char *kp = (char *) keyp; + int len; + int loop; + uint32 h; + char *kp = (char *) keyp; len = sizeof(float64data); @@ -102,25 +102,25 @@ hashfloat8(float64 keyp) switch (len & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASH4; - case 7: - HASH4; - case 6: - HASH4; - case 5: - HASH4; - case 4: - HASH4; - case 3: - HASH4; - case 2: - HASH4; - case 1: - HASH4; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASH4; + case 7: + HASH4; + case 6: + HASH4; + case 5: + HASH4; + case 4: + HASH4; + case 3: + HASH4; + case 2: + HASH4; + case 1: + HASH4; + } while (--loop); } } return (h); @@ -137,8 +137,8 @@ hashoid(Oid key) uint32 hashchar(char key) { - int len; - uint32 h; + int len; + uint32 h; len = sizeof(char); @@ -156,9 +156,9 @@ hashchar(char key) uint32 hashchar2(uint16 intkey) { - uint32 h; - int len; - char *key = (char *) &intkey; + uint32 h; + int len; + char *key = (char *) &intkey; h = 0; len = sizeof(uint16); @@ -173,9 +173,9 @@ hashchar2(uint16 intkey) uint32 hashchar4(uint32 intkey) { - uint32 h; - int len; - char *key = (char *) &intkey; + uint32 h; + int len; + char *key = (char *) &intkey; h = 0; len = sizeof(uint32); @@ -190,8 +190,8 @@ hashchar4(uint32 intkey) uint32 hashchar8(char *key) { - uint32 h; - int len; + uint32 h; + int len; h = 0; len = sizeof(char8); @@ -206,9 +206,9 @@ hashchar8(char *key) uint32 hashname(NameData * n) { - uint32 h; - int len; - char *key; + uint32 h; + int len; + char *key; key = n->data; @@ -226,8 +226,8 @@ hashname(NameData * n) uint32 hashchar16(char *key) { - uint32 h; - int len; + uint32 h; + int len; h = 0; len = sizeof(char16); @@ -254,10 +254,10 @@ hashchar16(char *key) uint32 hashtext(struct varlena * key) { - int keylen; - char *keydata; - uint32 n; - int loop; + int keylen; + char *keydata; + uint32 n; + int loop; keydata = VARDATA(key); keylen = VARSIZE(key); @@ -274,25 +274,25 @@ hashtext(struct varlena * key) switch (keylen & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASHC; + case 7: + HASHC; + case 6: + HASHC; + case 5: + HASHC; + case 4: + HASHC; + case 3: + HASHC; + case 2: + HASHC; + case 1: + HASHC; + } while (--loop); } } return (n); diff --git a/src/backend/access/hash/hashinsert.c b/src/backend/access/hash/hashinsert.c index 4829093589a..f76aba41794 100644 --- a/src/backend/access/hash/hashinsert.c +++ b/src/backend/access/hash/hashinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.9 1997/09/07 04:37:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashinsert.c,v 1.10 1997/09/08 02:20:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,15 +32,15 @@ static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem) { - Buffer buf; - Buffer metabuf; - BlockNumber blkno; - HashMetaPage metap; - IndexTuple itup; + Buffer buf; + Buffer metabuf; + BlockNumber blkno; + HashMetaPage metap; + IndexTuple itup; InsertIndexResult res; - ScanKey itup_scankey; - int natts; - Page page; + ScanKey itup_scankey; + int natts; + Page page; metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_READ); metap = (HashMetaPage) BufferGetPage(metabuf); @@ -101,7 +101,7 @@ _hash_doinsert(Relation rel, HashItem hitem) * we will have dropped both the pin and the write lock on the buffer. * */ -static InsertIndexResult +static InsertIndexResult _hash_insertonpg(Relation rel, Buffer buf, int keysz, @@ -110,15 +110,15 @@ _hash_insertonpg(Relation rel, Buffer metabuf) { InsertIndexResult res; - Page page; - BlockNumber itup_blkno; - OffsetNumber itup_off; - int itemsz; - HashPageOpaque pageopaque; - bool do_expand = false; - Buffer ovflbuf; - HashMetaPage metap; - Bucket bucket; + Page page; + BlockNumber itup_blkno; + OffsetNumber itup_off; + int itemsz; + HashPageOpaque pageopaque; + bool do_expand = false; + Buffer ovflbuf; + HashMetaPage metap; + Bucket bucket; metap = (HashMetaPage) BufferGetPage(metabuf); _hash_checkpage((Page) metap, LH_META_PAGE); @@ -218,7 +218,7 @@ _hash_insertonpg(Relation rel, * write lock and reference associated with the page's buffer. It is * an error to call pgaddtup() without a write lock and reference. */ -static OffsetNumber +static OffsetNumber _hash_pgaddtup(Relation rel, Buffer buf, int keysz, @@ -226,8 +226,8 @@ _hash_pgaddtup(Relation rel, Size itemsize, HashItem hitem) { - OffsetNumber itup_off; - Page page; + OffsetNumber itup_off; + Page page; page = BufferGetPage(buf); _hash_checkpage(page, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); diff --git a/src/backend/access/hash/hashovfl.c b/src/backend/access/hash/hashovfl.c index b6882d4d3e1..5d764b34724 100644 --- a/src/backend/access/hash/hashovfl.c +++ b/src/backend/access/hash/hashovfl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.10 1997/09/07 04:37:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashovfl.c,v 1.11 1997/09/08 02:20:17 momjian Exp $ * * NOTES * Overflow pages look like ordinary relation pages. @@ -27,7 +27,7 @@ #endif static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp); -static uint32 _hash_firstfreebit(uint32 map); +static uint32 _hash_firstfreebit(uint32 map); /* * _hash_addovflpage @@ -44,13 +44,13 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf) { OverflowPageAddress oaddr; - BlockNumber ovflblkno; - Buffer ovflbuf; - HashMetaPage metap; - HashPageOpaque ovflopaque; - HashPageOpaque pageopaque; - Page page; - Page ovflpage; + BlockNumber ovflblkno; + Buffer ovflbuf; + HashMetaPage metap; + HashPageOpaque ovflopaque; + HashPageOpaque pageopaque; + Page page; + Page ovflpage; /* this had better be the last page in a bucket chain */ page = BufferGetPage(buf); @@ -99,24 +99,24 @@ _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf) * is exchanged for a read lock. * */ -static OverflowPageAddress +static OverflowPageAddress _hash_getovfladdr(Relation rel, Buffer * metabufp) { - HashMetaPage metap; - Buffer mapbuf = 0; - BlockNumber blkno; - PageOffset offset; + HashMetaPage metap; + Buffer mapbuf = 0; + BlockNumber blkno; + PageOffset offset; OverflowPageAddress oaddr; - SplitNumber splitnum; - uint32 *freep = NULL; - uint32 max_free; - uint32 bit; - uint32 first_page; - uint32 free_bit; - uint32 free_page; - uint32 in_use_bits; - uint32 i, - j; + SplitNumber splitnum; + uint32 *freep = NULL; + uint32 max_free; + uint32 bit; + uint32 first_page; + uint32 free_bit; + uint32 free_page; + uint32 in_use_bits; + uint32 i, + j; metap = (HashMetaPage) _hash_chgbufaccess(rel, metabufp, HASH_READ, HASH_WRITE); @@ -130,7 +130,7 @@ _hash_getovfladdr(Relation rel, Buffer * metabufp) first_page = metap->LAST_FREED >> (metap->BSHIFT + BYTE_TO_BIT); for (i = first_page; i <= free_page; i++) { - Page mappage; + Page mappage; blkno = metap->hashm_mapp[i]; mapbuf = _hash_getbuf(rel, blkno, HASH_WRITE); @@ -279,11 +279,11 @@ found: * splitnumber. * */ -static uint32 +static uint32 _hash_firstfreebit(uint32 map) { - uint32 i, - mask; + uint32 i, + mask; mask = 0x1; for (i = 0; i < BITS_PER_MAP; i++) @@ -306,22 +306,22 @@ _hash_firstfreebit(uint32 map) Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf) { - HashMetaPage metap; - Buffer metabuf; - Buffer mapbuf; - BlockNumber prevblkno; - BlockNumber blkno; - BlockNumber nextblkno; - HashPageOpaque ovflopaque; - Page ovflpage; - Page mappage; + HashMetaPage metap; + Buffer metabuf; + Buffer mapbuf; + BlockNumber prevblkno; + BlockNumber blkno; + BlockNumber nextblkno; + HashPageOpaque ovflopaque; + Page ovflpage; + Page mappage; OverflowPageAddress addr; - SplitNumber splitnum; - uint32 *freep; - uint32 ovflpgno; - int32 bitmappage, - bitmapbit; - Bucket bucket; + SplitNumber splitnum; + uint32 *freep; + uint32 ovflpgno; + int32 bitmappage, + bitmapbit; + Bucket bucket; metabuf = _hash_getbuf(rel, HASH_METAPAGE, HASH_WRITE); metap = (HashMetaPage) BufferGetPage(metabuf); @@ -348,9 +348,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf) */ if (BlockNumberIsValid(prevblkno)) { - Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE); - Page prevpage = BufferGetPage(prevbuf); - HashPageOpaque prevopaque = + Buffer prevbuf = _hash_getbuf(rel, prevblkno, HASH_WRITE); + Page prevpage = BufferGetPage(prevbuf); + HashPageOpaque prevopaque = (HashPageOpaque) PageGetSpecialPointer(prevpage); _hash_checkpage(prevpage, LH_BUCKET_PAGE | LH_OVERFLOW_PAGE); @@ -360,9 +360,9 @@ _hash_freeovflpage(Relation rel, Buffer ovflbuf) } if (BlockNumberIsValid(nextblkno)) { - Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE); - Page nextpage = BufferGetPage(nextbuf); - HashPageOpaque nextopaque = + Buffer nextbuf = _hash_getbuf(rel, nextblkno, HASH_WRITE); + Page nextpage = BufferGetPage(nextbuf); + HashPageOpaque nextopaque = (HashPageOpaque) PageGetSpecialPointer(nextpage); _hash_checkpage(nextpage, LH_OVERFLOW_PAGE); @@ -436,13 +436,13 @@ _hash_initbitmap(Relation rel, int32 nbits, int32 ndx) { - Buffer buf; - BlockNumber blkno; - Page pg; - HashPageOpaque op; - uint32 *freep; - int clearbytes, - clearints; + Buffer buf; + BlockNumber blkno; + Page pg; + HashPageOpaque op; + uint32 *freep; + int clearbytes, + clearints; blkno = OADDR_TO_BLKNO(pnum); buf = _hash_getbuf(rel, blkno, HASH_WRITE); @@ -496,18 +496,18 @@ _hash_squeezebucket(Relation rel, HashMetaPage metap, Bucket bucket) { - Buffer wbuf; - Buffer rbuf = 0; - BlockNumber wblkno; - BlockNumber rblkno; - Page wpage; - Page rpage; - HashPageOpaque wopaque; - HashPageOpaque ropaque; - OffsetNumber woffnum; - OffsetNumber roffnum; - HashItem hitem; - int itemsz; + Buffer wbuf; + Buffer rbuf = 0; + BlockNumber wblkno; + BlockNumber rblkno; + Page wpage; + Page rpage; + HashPageOpaque wopaque; + HashPageOpaque ropaque; + OffsetNumber woffnum; + OffsetNumber roffnum; + HashItem hitem; + int itemsz; /* elog(DEBUG, "_hash_squeezebucket: squeezing bucket %d", bucket); */ diff --git a/src/backend/access/hash/hashpage.c b/src/backend/access/hash/hashpage.c index 6c819b652d2..17fdaab37fd 100644 --- a/src/backend/access/hash/hashpage.c +++ b/src/backend/access/hash/hashpage.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.10 1997/09/07 04:38:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashpage.c,v 1.11 1997/09/08 02:20:18 momjian Exp $ * * NOTES * Postgres hash pages look like ordinary relation pages. The opaque @@ -38,9 +38,9 @@ #include <string.h> #endif -static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access); -static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access); -static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket); +static void _hash_setpagelock(Relation rel, BlockNumber blkno, int access); +static void _hash_unsetpagelock(Relation rel, BlockNumber blkno, int access); +static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucket nbucket); /* * We use high-concurrency locking on hash indices. There are two cases in @@ -68,16 +68,16 @@ static void _hash_splitpage(Relation rel, Buffer metabuf, Bucket obucket, Bucke void _hash_metapinit(Relation rel) { - HashMetaPage metap; - HashPageOpaque pageopaque; - Buffer metabuf; - Buffer buf; - Page pg; - int nbuckets; - uint32 nelem; /* number elements */ - uint32 lg2nelem; /* _hash_log2(nelem) */ - uint32 nblocks; - uint16 i; + HashMetaPage metap; + HashPageOpaque pageopaque; + Buffer metabuf; + Buffer buf; + Page pg; + int nbuckets; + uint32 nelem; /* number elements */ + uint32 lg2nelem; /* _hash_log2(nelem) */ + uint32 nblocks; + uint16 i; /* can't be sharing this with anyone, now... */ if (USELOCKING) @@ -188,7 +188,7 @@ _hash_metapinit(Relation rel) Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access) { - Buffer buf; + Buffer buf; if (blkno == P_NEW) { @@ -196,14 +196,14 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access) } switch (access) { - case HASH_WRITE: - case HASH_READ: - _hash_setpagelock(rel, blkno, access); - break; - default: - elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s", - access, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + case HASH_READ: + _hash_setpagelock(rel, blkno, access); + break; + default: + elog(WARN, "_hash_getbuf: invalid access (%d) on new blk: %s", + access, RelationGetRelationName(rel)); + break; } buf = ReadBuffer(rel, blkno); @@ -217,19 +217,19 @@ _hash_getbuf(Relation rel, BlockNumber blkno, int access) void _hash_relbuf(Relation rel, Buffer buf, int access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); switch (access) { - case HASH_WRITE: - case HASH_READ: - _hash_unsetpagelock(rel, blkno, access); - break; - default: - elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); + case HASH_WRITE: + case HASH_READ: + _hash_unsetpagelock(rel, blkno, access); + break; + default: + elog(WARN, "_hash_relbuf: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); } ReleaseBuffer(buf); @@ -245,7 +245,7 @@ _hash_relbuf(Relation rel, Buffer buf, int access) void _hash_wrtbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteBuffer(buf); @@ -262,7 +262,7 @@ _hash_wrtbuf(Relation rel, Buffer buf) void _hash_wrtnorelbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteNoReleaseBuffer(buf); @@ -274,22 +274,22 @@ _hash_chgbufaccess(Relation rel, int from_access, int to_access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(*bufp); switch (from_access) { - case HASH_WRITE: - _hash_wrtbuf(rel, *bufp); - break; - case HASH_READ: - _hash_relbuf(rel, *bufp, from_access); - break; - default: - elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s", - from_access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + _hash_wrtbuf(rel, *bufp); + break; + case HASH_READ: + _hash_relbuf(rel, *bufp, from_access); + break; + default: + elog(WARN, "_hash_chgbufaccess: invalid access (%d) on blk %x: %s", + from_access, blkno, RelationGetRelationName(rel)); + break; } *bufp = _hash_getbuf(rel, blkno, to_access); return (BufferGetPage(*bufp)); @@ -328,16 +328,16 @@ _hash_setpagelock(Relation rel, switch (access) { - case HASH_WRITE: - RelationSetSingleWLockPage(rel, &iptr); - break; - case HASH_READ: - RelationSetSingleRLockPage(rel, &iptr); - break; - default: - elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + RelationSetSingleWLockPage(rel, &iptr); + break; + case HASH_READ: + RelationSetSingleRLockPage(rel, &iptr); + break; + default: + elog(WARN, "_hash_setpagelock: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); + break; } } } @@ -355,16 +355,16 @@ _hash_unsetpagelock(Relation rel, switch (access) { - case HASH_WRITE: - RelationUnsetSingleWLockPage(rel, &iptr); - break; - case HASH_READ: - RelationUnsetSingleRLockPage(rel, &iptr); - break; - default: - elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s", - access, blkno, RelationGetRelationName(rel)); - break; + case HASH_WRITE: + RelationUnsetSingleWLockPage(rel, &iptr); + break; + case HASH_READ: + RelationUnsetSingleRLockPage(rel, &iptr); + break; + default: + elog(WARN, "_hash_unsetpagelock: invalid access (%d) on blk %x: %s", + access, blkno, RelationGetRelationName(rel)); + break; } } } @@ -372,13 +372,13 @@ _hash_unsetpagelock(Relation rel, void _hash_pagedel(Relation rel, ItemPointer tid) { - Buffer buf; - Buffer metabuf; - Page page; - BlockNumber blkno; - OffsetNumber offno; - HashMetaPage metap; - HashPageOpaque opaque; + Buffer buf; + Buffer metabuf; + Page page; + BlockNumber blkno; + OffsetNumber offno; + HashMetaPage metap; + HashPageOpaque opaque; blkno = ItemPointerGetBlockNumber(tid); offno = ItemPointerGetOffsetNumber(tid); @@ -414,10 +414,10 @@ _hash_pagedel(Relation rel, ItemPointer tid) void _hash_expandtable(Relation rel, Buffer metabuf) { - HashMetaPage metap; - Bucket old_bucket; - Bucket new_bucket; - uint32 spare_ndx; + HashMetaPage metap; + Bucket old_bucket; + Bucket new_bucket; + uint32 spare_ndx; /* elog(DEBUG, "_hash_expandtable: expanding..."); */ @@ -472,26 +472,26 @@ _hash_splitpage(Relation rel, Bucket obucket, Bucket nbucket) { - Bucket bucket; - Buffer obuf; - Buffer nbuf; - Buffer ovflbuf; - BlockNumber oblkno; - BlockNumber nblkno; - bool null; - Datum datum; - HashItem hitem; - HashPageOpaque oopaque; - HashPageOpaque nopaque; - HashMetaPage metap; - IndexTuple itup; - int itemsz; - OffsetNumber ooffnum; - OffsetNumber noffnum; - OffsetNumber omaxoffnum; - Page opage; - Page npage; - TupleDesc itupdesc; + Bucket bucket; + Buffer obuf; + Buffer nbuf; + Buffer ovflbuf; + BlockNumber oblkno; + BlockNumber nblkno; + bool null; + Datum datum; + HashItem hitem; + HashPageOpaque oopaque; + HashPageOpaque nopaque; + HashMetaPage metap; + IndexTuple itup; + int itemsz; + OffsetNumber ooffnum; + OffsetNumber noffnum; + OffsetNumber omaxoffnum; + Page opage; + Page npage; + TupleDesc itupdesc; /* elog(DEBUG, "_hash_splitpage: splitting %d into %d,%d", obucket, obucket, nbucket); diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c index 79fa33f747c..de64ebdd061 100644 --- a/src/backend/access/hash/hashscan.c +++ b/src/backend/access/hash/hashscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.9 1997/09/07 04:38:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.10 1997/09/08 02:20:20 momjian Exp $ * * NOTES * Because we can be doing an index scan on a relation while we @@ -31,14 +31,14 @@ #include <access/hash.h> -static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); -static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); typedef struct HashScanListData { - IndexScanDesc hashsl_scan; + IndexScanDesc hashsl_scan; struct HashScanListData *hashsl_next; -} HashScanListData; +} HashScanListData; typedef HashScanListData *HashScanList; @@ -50,7 +50,7 @@ static HashScanList HashScans = (HashScanList) NULL; void _hash_regscan(IndexScanDesc scan) { - HashScanList new_el; + HashScanList new_el; new_el = (HashScanList) palloc(sizeof(HashScanListData)); new_el->hashsl_scan = scan; @@ -64,8 +64,8 @@ _hash_regscan(IndexScanDesc scan) void _hash_dropscan(IndexScanDesc scan) { - HashScanList chk, - last; + HashScanList chk, + last; last = (HashScanList) NULL; for (chk = HashScans; @@ -89,8 +89,8 @@ _hash_dropscan(IndexScanDesc scan) void _hash_adjscans(Relation rel, ItemPointer tid) { - HashScanList l; - Oid relid; + HashScanList l; + Oid relid; relid = rel->rd_id; for (l = HashScans; l != (HashScanList) NULL; l = l->hashsl_next) @@ -104,10 +104,10 @@ _hash_adjscans(Relation rel, ItemPointer tid) static void _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; - Buffer buf; - Buffer metabuf; - HashScanOpaque so; + ItemPointer current; + Buffer buf; + Buffer metabuf; + HashScanOpaque so; if (!_hash_scantouched(scan, blkno, offno)) return; @@ -144,12 +144,12 @@ _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) } } -static bool +static bool _hash_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; + ItemPointer current; current = &(scan->currentItemData); if (ItemPointerIsValid(current) diff --git a/src/backend/access/hash/hashsearch.c b/src/backend/access/hash/hashsearch.c index 0a42ad05065..7c3b91b9c0c 100644 --- a/src/backend/access/hash/hashsearch.c +++ b/src/backend/access/hash/hashsearch.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.11 1997/09/07 04:38:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashsearch.c,v 1.12 1997/09/08 02:20:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ _hash_search(Relation rel, Buffer * bufP, HashMetaPage metap) { - BlockNumber blkno; - Datum keyDatum; - Bucket bucket; + BlockNumber blkno; + Datum keyDatum; + Bucket bucket; if (scankey == (ScanKey) NULL || (keyDatum = scankey[0].sk_argument) == (Datum) NULL) @@ -70,16 +70,16 @@ _hash_search(Relation rel, RetrieveIndexResult _hash_next(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Buffer metabuf; - Page page; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Buffer metabuf; + Page page; + OffsetNumber offnum; RetrieveIndexResult res; - ItemPointer current; - HashItem hitem; - IndexTuple itup; - HashScanOpaque so; + ItemPointer current; + HashItem hitem; + IndexTuple itup; + HashScanOpaque so; rel = scan->relation; so = (HashScanOpaque) scan->opaque; @@ -129,7 +129,7 @@ static void _hash_readnext(Relation rel, Buffer * bufp, Page * pagep, HashPageOpaque * opaquep) { - BlockNumber blkno; + BlockNumber blkno; blkno = (*opaquep)->hasho_nextblkno; _hash_relbuf(rel, *bufp, HASH_READ); @@ -148,7 +148,7 @@ static void _hash_readprev(Relation rel, Buffer * bufp, Page * pagep, HashPageOpaque * opaquep) { - BlockNumber blkno; + BlockNumber blkno; blkno = (*opaquep)->hasho_prevblkno; _hash_relbuf(rel, *bufp, HASH_READ); @@ -180,18 +180,18 @@ _hash_readprev(Relation rel, RetrieveIndexResult _hash_first(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Buffer metabuf; - Page page; - HashPageOpaque opaque; - HashMetaPage metap; - HashItem hitem; - IndexTuple itup; - ItemPointer current; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Buffer metabuf; + Page page; + HashPageOpaque opaque; + HashMetaPage metap; + HashItem hitem; + IndexTuple itup; + ItemPointer current; + OffsetNumber offnum; RetrieveIndexResult res; - HashScanOpaque so; + HashScanOpaque so; rel = scan->relation; so = (HashScanOpaque) scan->opaque; @@ -286,20 +286,20 @@ _hash_first(IndexScanDesc scan, ScanDirection dir) bool _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf) { - Relation rel; - ItemPointer current; - HashScanOpaque so; - int allbuckets; - HashMetaPage metap; - Buffer buf; - Page page; - HashPageOpaque opaque; - OffsetNumber maxoff; - OffsetNumber offnum; - Bucket bucket; - BlockNumber blkno; - HashItem hitem; - IndexTuple itup; + Relation rel; + ItemPointer current; + HashScanOpaque so; + int allbuckets; + HashMetaPage metap; + Buffer buf; + Page page; + HashPageOpaque opaque; + OffsetNumber maxoff; + OffsetNumber offnum; + Bucket bucket; + BlockNumber blkno; + HashItem hitem; + IndexTuple itup; rel = scan->relation; current = &(scan->currentItemData); @@ -341,107 +341,107 @@ _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf) switch (dir) { - case ForwardScanDirection: - if (offnum != InvalidOffsetNumber) - { - offnum = OffsetNumberNext(offnum); /* move forward */ - } - else - { - offnum = FirstOffsetNumber; /* new page */ - } - while (offnum > maxoff) - { + case ForwardScanDirection: + if (offnum != InvalidOffsetNumber) + { + offnum = OffsetNumberNext(offnum); /* move forward */ + } + else + { + offnum = FirstOffsetNumber; /* new page */ + } + while (offnum > maxoff) + { - /* - * either this page is empty (maxoff == - * InvalidOffsetNumber) or we ran off the end. - */ - _hash_readnext(rel, &buf, &page, &opaque); - if (BufferIsInvalid(buf)) - { /* end of chain */ - if (allbuckets && bucket < metap->hashm_maxbucket) - { - ++bucket; - blkno = BUCKET_TO_BLKNO(bucket); - buf = _hash_getbuf(rel, blkno, HASH_READ); - page = BufferGetPage(buf); - _hash_checkpage(page, LH_BUCKET_PAGE); - opaque = (HashPageOpaque) PageGetSpecialPointer(page); - Assert(opaque->hasho_bucket == bucket); - while (PageIsEmpty(page) && + /* + * either this page is empty (maxoff == + * InvalidOffsetNumber) or we ran off the end. + */ + _hash_readnext(rel, &buf, &page, &opaque); + if (BufferIsInvalid(buf)) + { /* end of chain */ + if (allbuckets && bucket < metap->hashm_maxbucket) + { + ++bucket; + blkno = BUCKET_TO_BLKNO(bucket); + buf = _hash_getbuf(rel, blkno, HASH_READ); + page = BufferGetPage(buf); + _hash_checkpage(page, LH_BUCKET_PAGE); + opaque = (HashPageOpaque) PageGetSpecialPointer(page); + Assert(opaque->hasho_bucket == bucket); + while (PageIsEmpty(page) && BlockNumberIsValid(opaque->hasho_nextblkno)) + { + _hash_readnext(rel, &buf, &page, &opaque); + } + maxoff = PageGetMaxOffsetNumber(page); + offnum = FirstOffsetNumber; + } + else { - _hash_readnext(rel, &buf, &page, &opaque); + maxoff = offnum = InvalidOffsetNumber; + break; /* while */ } - maxoff = PageGetMaxOffsetNumber(page); - offnum = FirstOffsetNumber; } else { - maxoff = offnum = InvalidOffsetNumber; - break; /* while */ + /* _hash_readnext never returns an empty page */ + maxoff = PageGetMaxOffsetNumber(page); + offnum = FirstOffsetNumber; } } + break; + case BackwardScanDirection: + if (offnum != InvalidOffsetNumber) + { + offnum = OffsetNumberPrev(offnum); /* move back */ + } else { - /* _hash_readnext never returns an empty page */ - maxoff = PageGetMaxOffsetNumber(page); - offnum = FirstOffsetNumber; + offnum = maxoff; /* new page */ } - } - break; - case BackwardScanDirection: - if (offnum != InvalidOffsetNumber) - { - offnum = OffsetNumberPrev(offnum); /* move back */ - } - else - { - offnum = maxoff;/* new page */ - } - while (offnum < FirstOffsetNumber) - { + while (offnum < FirstOffsetNumber) + { - /* - * either this page is empty (offnum == - * InvalidOffsetNumber) or we ran off the end. - */ - _hash_readprev(rel, &buf, &page, &opaque); - if (BufferIsInvalid(buf)) - { /* end of chain */ - if (allbuckets && bucket > 0) - { - --bucket; - blkno = BUCKET_TO_BLKNO(bucket); - buf = _hash_getbuf(rel, blkno, HASH_READ); - page = BufferGetPage(buf); - _hash_checkpage(page, LH_BUCKET_PAGE); - opaque = (HashPageOpaque) PageGetSpecialPointer(page); - Assert(opaque->hasho_bucket == bucket); - while (BlockNumberIsValid(opaque->hasho_nextblkno)) + /* + * either this page is empty (offnum == + * InvalidOffsetNumber) or we ran off the end. + */ + _hash_readprev(rel, &buf, &page, &opaque); + if (BufferIsInvalid(buf)) + { /* end of chain */ + if (allbuckets && bucket > 0) { - _hash_readnext(rel, &buf, &page, &opaque); + --bucket; + blkno = BUCKET_TO_BLKNO(bucket); + buf = _hash_getbuf(rel, blkno, HASH_READ); + page = BufferGetPage(buf); + _hash_checkpage(page, LH_BUCKET_PAGE); + opaque = (HashPageOpaque) PageGetSpecialPointer(page); + Assert(opaque->hasho_bucket == bucket); + while (BlockNumberIsValid(opaque->hasho_nextblkno)) + { + _hash_readnext(rel, &buf, &page, &opaque); + } + maxoff = offnum = PageGetMaxOffsetNumber(page); + } + else + { + maxoff = offnum = InvalidOffsetNumber; + break; /* while */ } - maxoff = offnum = PageGetMaxOffsetNumber(page); } else { - maxoff = offnum = InvalidOffsetNumber; - break; /* while */ + /* _hash_readprev never returns an empty page */ + maxoff = offnum = PageGetMaxOffsetNumber(page); } } - else - { - /* _hash_readprev never returns an empty page */ - maxoff = offnum = PageGetMaxOffsetNumber(page); - } - } - break; - default: - /* NoMovementScanDirection */ - /* this should not be reached */ - break; + break; + default: + /* NoMovementScanDirection */ + /* this should not be reached */ + break; } /* we ran off the end of the world without finding a match */ diff --git a/src/backend/access/hash/hashstrat.c b/src/backend/access/hash/hashstrat.c index f1bdbdb8a3a..a3a3656d76f 100644 --- a/src/backend/access/hash/hashstrat.c +++ b/src/backend/access/hash/hashstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.10 1997/09/07 04:38:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/Attic/hashstrat.c,v 1.11 1997/09/08 02:20:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,12 +52,12 @@ static StrategyEvaluationData HTEvaluationData = { */ #ifdef NOT_USED -static StrategyNumber +static StrategyNumber _hash_getstrat(Relation rel, AttrNumber attno, RegProcedure proc) { - StrategyNumber strat; + StrategyNumber strat; strat = RelationGetStrategy(rel, attno, &HTEvaluationData, proc); @@ -69,7 +69,7 @@ _hash_getstrat(Relation rel, #endif #ifdef NOT_USED -static bool +static bool _hash_invokestrat(Relation rel, AttrNumber attno, StrategyNumber strat, diff --git a/src/backend/access/hash/hashutil.c b/src/backend/access/hash/hashutil.c index f9fbe0e2d17..573c6c2dd4f 100644 --- a/src/backend/access/hash/hashutil.c +++ b/src/backend/access/hash/hashutil.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.10 1997/09/07 04:38:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashutil.c,v 1.11 1997/09/08 02:20:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ ScanKey _hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap) { - ScanKey skey; - TupleDesc itupdesc; - int natts; - AttrNumber i; - Datum arg; - RegProcedure proc; - bool null; + ScanKey skey; + TupleDesc itupdesc; + int natts; + AttrNumber i; + Datum arg; + RegProcedure proc; + bool null; natts = rel->rd_rel->relnatts; itupdesc = RelationGetTupleDescriptor(rel); @@ -73,9 +73,9 @@ _hash_checkqual(IndexScanDesc scan, IndexTuple itup) HashItem _hash_formitem(IndexTuple itup) { - int nbytes_hitem; - HashItem hitem; - Size tuplen; + int nbytes_hitem; + HashItem hitem; + Size tuplen; /* disallow nulls in hash keys */ if (itup->t_info & INDEX_NULL_MASK) @@ -95,9 +95,9 @@ _hash_formitem(IndexTuple itup) Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key) { - uint32 n; - Bucket bucket; - RegProcedure proc; + uint32 n; + Bucket bucket; + RegProcedure proc; proc = metap->hashm_procid; n = (uint32) fmgr(proc, key); @@ -113,8 +113,8 @@ _hash_call(Relation rel, HashMetaPage metap, Datum key) uint32 _hash_log2(uint32 num) { - uint32 i, - limit; + uint32 i, + limit; limit = 1; for (i = 0; limit < num; limit = limit << 1, i++) @@ -128,7 +128,7 @@ _hash_log2(uint32 num) void _hash_checkpage(Page page, int flags) { - HashPageOpaque opaque; + HashPageOpaque opaque; Assert(page); Assert(((PageHeader) (page))->pd_lower >= (sizeof(PageHeaderData) - sizeof(ItemIdData))); diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index b7ab8625140..fa4dbae7ae1 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.16 1997/09/07 04:38:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.17 1997/09/08 02:20:28 momjian Exp $ * * * INTERFACE ROUTINES @@ -96,7 +96,7 @@ #include <string.h> #endif -static bool ImmediateInvalidation; +static bool ImmediateInvalidation; /* ---------------------------------------------------------------- * heap support routines @@ -210,7 +210,7 @@ nextpage(int page, int dir) * real work in scanning tuples. * ---------------- */ -static HeapTuple +static HeapTuple heapgettup(Relation relation, ItemPointer tid, int dir, @@ -219,14 +219,14 @@ heapgettup(Relation relation, int nkeys, ScanKey key) { - ItemId lpp; - Page dp; - int page; - int pages; - int lines; - HeapTuple rtup; - OffsetNumber lineoff; - int linesleft; + ItemId lpp; + Page dp; + int page; + int pages; + int lines; + HeapTuple rtup; + OffsetNumber lineoff; + int linesleft; /* ---------------- * increment access statistics @@ -432,7 +432,7 @@ heapgettup(Relation relation, if ((rtup = heap_tuple_satisfies(lpp, relation, *b, (PageHeader) dp, timeQual, nkeys, key)) != NULL) { - ItemPointer iptr = &(rtup->t_ctid); + ItemPointer iptr = &(rtup->t_ctid); if (ItemPointerGetBlockNumber(iptr) != page) { @@ -541,7 +541,7 @@ SetHeapAccessMethodImmediateInvalidation(bool on) Relation heap_open(Oid relationId) { - Relation r; + Relation r; /* ---------------- * increment access statistics @@ -570,7 +570,7 @@ heap_open(Oid relationId) Relation heap_openr(char *relationName) { - Relation r; + Relation r; /* ---------------- * increment access statistics @@ -621,7 +621,7 @@ heap_beginscan(Relation relation, unsigned nkeys, ScanKey key) { - HeapScanDesc sdesc; + HeapScanDesc sdesc; /* ---------------- * increment access statistics @@ -808,7 +808,7 @@ heap_getnext(HeapScanDesc scandesc, Buffer * b) { register HeapScanDesc sdesc = scandesc; - Buffer localb; + Buffer localb; /* ---------------- * increment access statistics @@ -880,7 +880,7 @@ heap_getnext(HeapScanDesc scandesc, } else { /* NONTUP */ - ItemPointer iptr; + ItemPointer iptr; iptr = (sdesc->rs_ctup != NULL) ? &(sdesc->rs_ctup->t_ctid) : (ItemPointer) NULL; @@ -967,7 +967,7 @@ heap_getnext(HeapScanDesc scandesc, } else { /* NONTUP */ - ItemPointer iptr; + ItemPointer iptr; iptr = (sdesc->rs_ctup != NULL) ? &sdesc->rs_ctup->t_ctid : (ItemPointer) NULL; @@ -1035,11 +1035,11 @@ heap_fetch(Relation relation, ItemPointer tid, Buffer * b) { - ItemId lp; - Buffer buffer; - PageHeader dp; - HeapTuple tuple; - OffsetNumber offnum; + ItemId lp; + Buffer buffer; + PageHeader dp; + HeapTuple tuple; + OffsetNumber offnum; /* ---------------- * increment access statistics @@ -1203,10 +1203,10 @@ heap_insert(Relation relation, HeapTuple tup) int heap_delete(Relation relation, ItemPointer tid) { - ItemId lp; - HeapTuple tp; - PageHeader dp; - Buffer b; + ItemId lp; + HeapTuple tp; + PageHeader dp; + Buffer b; /* ---------------- * increment access statistics @@ -1313,10 +1313,10 @@ heap_delete(Relation relation, ItemPointer tid) int heap_replace(Relation relation, ItemPointer otid, HeapTuple tup) { - ItemId lp; - HeapTuple tp; - Page dp; - Buffer buffer; + ItemId lp; + HeapTuple tp; + Page dp; + Buffer buffer; /* ---------------- * increment access statistics diff --git a/src/backend/access/heap/hio.c b/src/backend/access/heap/hio.c index 0854b69bf0b..21202b15376 100644 --- a/src/backend/access/heap/hio.c +++ b/src/backend/access/heap/hio.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Id: hio.c,v 1.10 1997/09/07 04:38:11 momjian Exp $ + * $Id: hio.c,v 1.11 1997/09/08 02:20:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,13 +35,13 @@ RelationPutHeapTuple(Relation relation, BlockNumber blockIndex, HeapTuple tuple) { - Buffer buffer; - Page pageHeader; - BlockNumber numberOfBlocks; - OffsetNumber offnum; - unsigned int len; - ItemId itemId; - Item item; + Buffer buffer; + Page pageHeader; + BlockNumber numberOfBlocks; + OffsetNumber offnum; + unsigned int len; + ItemId itemId; + Item item; /* ---------------- * increment access statistics @@ -108,13 +108,13 @@ RelationPutHeapTuple(Relation relation, void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple) { - Buffer buffer; - Page pageHeader; - BlockNumber lastblock; - OffsetNumber offnum; - unsigned int len; - ItemId itemId; - Item item; + Buffer buffer; + Page pageHeader; + BlockNumber lastblock; + OffsetNumber offnum; + unsigned int len; + ItemId itemId; + Item item; Assert(RelationIsValid(relation)); Assert(HeapTupleIsValid(tuple)); diff --git a/src/backend/access/heap/stats.c b/src/backend/access/heap/stats.c index aa16803779c..2bebfd9b0be 100644 --- a/src/backend/access/heap/stats.c +++ b/src/backend/access/heap/stats.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.12 1997/09/07 04:38:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/Attic/stats.c,v 1.13 1997/09/08 02:20:31 momjian Exp $ * * NOTES * initam should be moved someplace else. @@ -28,7 +28,7 @@ #include <string.h> #endif -static void InitHeapAccessStatistics(void); +static void InitHeapAccessStatistics(void); /* ---------------- * InitHeapAccessStatistics @@ -39,7 +39,7 @@ HeapAccessStatistics heap_access_stats = (HeapAccessStatistics) NULL; static void InitHeapAccessStatistics() { - MemoryContext oldContext; + MemoryContext oldContext; HeapAccessStatistics stats; /* ---------------- diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index da7fc0dc09f..83655b7d618 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.8 1997/09/07 04:38:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.9 1997/09/08 02:20:33 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -98,7 +98,7 @@ RelationGetIndexScan(Relation relation, uint16 numberOfKeys, ScanKey key) { - IndexScanDesc scan; + IndexScanDesc scan; if (!RelationIsValid(relation)) elog(WARN, "RelationGetIndexScan: relation invalid"); diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index 6841899fa39..9d0eee39b64 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.14 1997/09/07 04:38:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.15 1997/09/08 02:20:37 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relationId @@ -167,7 +167,7 @@ index_insert(Relation relation, ItemPointer heap_t_ctid, Relation heapRel) { - RegProcedure procedure; + RegProcedure procedure; InsertIndexResult specificResult; RELATION_CHECKS; @@ -207,7 +207,7 @@ index_insert(Relation relation, void index_delete(Relation relation, ItemPointer indexItem) { - RegProcedure procedure; + RegProcedure procedure; RELATION_CHECKS; GET_REL_PROCEDURE(delete, amdelete); @@ -225,8 +225,8 @@ index_beginscan(Relation relation, uint16 numberOfKeys, ScanKey key) { - IndexScanDesc scandesc; - RegProcedure procedure; + IndexScanDesc scandesc; + RegProcedure procedure; RELATION_CHECKS; GET_REL_PROCEDURE(beginscan, ambeginscan); @@ -246,7 +246,7 @@ index_beginscan(Relation relation, void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(rescan, amrescan); @@ -261,7 +261,7 @@ index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key) void index_endscan(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(endscan, amendscan); @@ -279,7 +279,7 @@ index_endscan(IndexScanDesc scan) void index_markpos(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(markpos, ammarkpos); @@ -297,7 +297,7 @@ index_markpos(IndexScanDesc scan) void index_restrpos(IndexScanDesc scan) { - RegProcedure procedure; + RegProcedure procedure; SCAN_CHECKS; GET_SCAN_PROCEDURE(restrpos, amrestrpos); @@ -317,7 +317,7 @@ RetrieveIndexResult index_getnext(IndexScanDesc scan, ScanDirection direction) { - RegProcedure procedure; + RegProcedure procedure; RetrieveIndexResult result; SCAN_CHECKS; @@ -354,8 +354,8 @@ index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum) { - RegProcedure *loc; - int natts; + RegProcedure *loc; + int natts; natts = irel->rd_rel->relnatts; @@ -375,13 +375,13 @@ GetIndexValue(HeapTuple tuple, bool * attNull, Buffer buffer) { - Datum returnVal; - bool isNull; + Datum returnVal; + bool isNull; if (PointerIsValid(fInfo) && FIgetProcOid(fInfo) != InvalidOid) { - int i; - Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum)); + int i; + Datum *attData = (Datum *) palloc(FIgetnArgs(fInfo) * sizeof(Datum)); for (i = 0; i < FIgetnArgs(fInfo); i++) { diff --git a/src/backend/access/index/istrat.c b/src/backend/access/index/istrat.c index 35158c22170..9cc9c06e98f 100644 --- a/src/backend/access/index/istrat.c +++ b/src/backend/access/index/istrat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.10 1997/09/07 04:38:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/Attic/istrat.c,v 1.11 1997/09/08 02:20:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ #include <fmgr.h> #ifndef NO_ASSERT_CHECKING -static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); +static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation); static bool StrategyExpressionIsValid(StrategyExpression expression, StrategyNumber maxStrategy); @@ -68,7 +68,7 @@ StrategyTermIsValid(StrategyTerm term, * Assumes that the index strategy number is valid. * Bounds checking should be done outside this routine. */ -static ScanKey +static ScanKey StrategyMapGetScanKeyEntry(StrategyMap map, StrategyNumber strategyNumber) { @@ -122,7 +122,7 @@ AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber, * StrategyOperatorIsValid * ---------------- */ -static bool +static bool StrategyOperatorIsValid(StrategyOperator operator, StrategyNumber maxStrategy) { @@ -136,11 +136,11 @@ StrategyOperatorIsValid(StrategyOperator operator, * StrategyTermIsValid * ---------------- */ -static bool +static bool StrategyTermIsValid(StrategyTerm term, StrategyNumber maxStrategy) { - Index index; + Index index; if (!PointerIsValid(term) || term->degree == 0) return false; @@ -162,11 +162,11 @@ StrategyTermIsValid(StrategyTerm term, * StrategyExpressionIsValid * ---------------- */ -static bool +static bool StrategyExpressionIsValid(StrategyExpression expression, StrategyNumber maxStrategy) { - StrategyTerm *termP; + StrategyTerm *termP; if (!PointerIsValid(expression)) return true; @@ -186,10 +186,10 @@ StrategyExpressionIsValid(StrategyExpression expression, * StrategyEvaluationIsValid * ---------------- */ -static bool +static bool StrategyEvaluationIsValid(StrategyEvaluation evaluation) { - Index index; + Index index; if (!PointerIsValid(evaluation) || !StrategyNumberIsValid(evaluation->maxStrategy) || @@ -219,17 +219,17 @@ StrategyEvaluationIsValid(StrategyEvaluation evaluation) * StrategyTermEvaluate * ---------------- */ -static bool +static bool StrategyTermEvaluate(StrategyTerm term, StrategyMap map, Datum left, Datum right) { - Index index; - long tmpres = 0; - bool result = 0; + Index index; + long tmpres = 0; + bool result = 0; StrategyOperator operator; - ScanKey entry; + ScanKey entry; for (index = 0, operator = &term->operatorData[0]; index < term->degree; index += 1, operator += 1) @@ -241,29 +241,29 @@ StrategyTermEvaluate(StrategyTerm term, switch (operator->flags ^ entry->sk_flags) { - case 0x0: - tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, - left, right); - break; - - case SK_NEGATE: - tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, - left, right); - break; - - case SK_COMMUTE: - tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, - right, left); - break; - - case SK_NEGATE | SK_COMMUTE: - tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, - right, left); - break; - - default: - elog(FATAL, "StrategyTermEvaluate: impossible case %d", - operator->flags ^ entry->sk_flags); + case 0x0: + tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, + left, right); + break; + + case SK_NEGATE: + tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, + left, right); + break; + + case SK_COMMUTE: + tmpres = (long) FMGR_PTR2(entry->sk_func, entry->sk_procedure, + right, left); + break; + + case SK_NEGATE | SK_COMMUTE: + tmpres = (long) !FMGR_PTR2(entry->sk_func, entry->sk_procedure, + right, left); + break; + + default: + elog(FATAL, "StrategyTermEvaluate: impossible case %d", + operator->flags ^ entry->sk_flags); } result = (bool) tmpres; @@ -285,11 +285,11 @@ RelationGetStrategy(Relation relation, StrategyEvaluation evaluation, RegProcedure procedure) { - StrategyNumber strategy; - StrategyMap strategyMap; - ScanKey entry; - Index index; - int numattrs; + StrategyNumber strategy; + StrategyMap strategyMap; + ScanKey entry; + Index index; + int numattrs; Assert(RelationIsValid(relation)); numattrs = RelationGetNumberOfAttributes(relation); @@ -325,23 +325,23 @@ RelationGetStrategy(Relation relation, switch (entry->sk_flags & (SK_NEGATE | SK_COMMUTE)) { - case 0x0: - return strategy; + case 0x0: + return strategy; - case SK_NEGATE: - strategy = evaluation->negateTransform->strategy[strategy - 1]; - break; + case SK_NEGATE: + strategy = evaluation->negateTransform->strategy[strategy - 1]; + break; - case SK_COMMUTE: - strategy = evaluation->commuteTransform->strategy[strategy - 1]; - break; + case SK_COMMUTE: + strategy = evaluation->commuteTransform->strategy[strategy - 1]; + break; - case SK_NEGATE | SK_COMMUTE: - strategy = evaluation->negateCommuteTransform->strategy[strategy - 1]; - break; + case SK_NEGATE | SK_COMMUTE: + strategy = evaluation->negateCommuteTransform->strategy[strategy - 1]; + break; - default: - elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags); + default: + elog(FATAL, "RelationGetStrategy: impossible case %d", entry->sk_flags); } @@ -368,11 +368,11 @@ RelationInvokeStrategy(Relation relation, Datum left, Datum right) { - StrategyNumber newStrategy; - StrategyMap strategyMap; - ScanKey entry; + StrategyNumber newStrategy; + StrategyMap strategyMap; + ScanKey entry; StrategyTermData termData; - int numattrs; + int numattrs; Assert(RelationIsValid(relation)); Assert(relation->rd_rel->relkind == RELKIND_INDEX); /* XXX use accessor */ @@ -453,12 +453,12 @@ RelationInvokeStrategy(Relation relation, if (PointerIsValid(evaluation->expression[strategy - 1])) { - StrategyTerm *termP; + StrategyTerm *termP; termP = &evaluation->expression[strategy - 1]->term[0]; while (PointerIsValid(*termP)) { - Index index; + Index index; for (index = 0; index < (*termP)->degree; index += 1) { @@ -499,9 +499,9 @@ OperatorRelationFillScanKeyEntry(Relation operatorRelation, Oid operatorObjectId, ScanKey entry) { - HeapScanDesc scan; - ScanKeyData scanKeyData; - HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData scanKeyData; + HeapTuple tuple; ScanKeyEntryInitialize(&scanKeyData, 0, ObjectIdAttributeNumber, @@ -547,15 +547,15 @@ IndexSupportInitialize(IndexStrategy indexStrategy, StrategyNumber maxSupportNumber, AttrNumber maxAttributeNumber) { - Relation relation; - Relation operatorRelation; - HeapScanDesc scan; - HeapTuple tuple; - ScanKeyData entry[2]; - StrategyMap map; - AttrNumber attributeNumber; - int attributeIndex; - Oid operatorClassObjectId[MaxIndexAttributeNumber]; + Relation relation; + Relation operatorRelation; + HeapScanDesc scan; + HeapTuple tuple; + ScanKeyData entry[2]; + StrategyMap map; + AttrNumber attributeNumber; + int attributeIndex; + Oid operatorClassObjectId[MaxIndexAttributeNumber]; maxStrategyNumber = AMStrategies(maxStrategyNumber); @@ -575,7 +575,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, */ for (attributeIndex = 0; attributeIndex < maxAttributeNumber; attributeIndex++) { - IndexTupleForm iform; + IndexTupleForm iform; iform = (IndexTupleForm) GETSTRUCT(tuple); @@ -614,9 +614,9 @@ IndexSupportInitialize(IndexStrategy indexStrategy, attributeNumber--) { - int16 support; - Form_pg_amproc form; - RegProcedure *loc; + int16 support; + Form_pg_amproc form; + RegProcedure *loc; loc = &indexSupport[((attributeNumber - 1) * maxSupportNumber)]; @@ -659,7 +659,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, attributeNumber--) { - StrategyNumber strategy; + StrategyNumber strategy; entry[1].sk_argument = ObjectIdGetDatum(operatorClassObjectId[attributeNumber - 1]); @@ -676,7 +676,7 @@ IndexSupportInitialize(IndexStrategy indexStrategy, while (tuple = heap_getnext(scan, 0, (Buffer *) NULL), HeapTupleIsValid(tuple)) { - Form_pg_amop form; + Form_pg_amop form; form = (Form_pg_amop) GETSTRUCT(tuple); @@ -702,9 +702,9 @@ IndexStrategyDisplay(IndexStrategy indexStrategy, StrategyNumber numberOfStrategies, int numberOfAttributes) { - StrategyMap strategyMap; - AttrNumber attributeNumber; - StrategyNumber strategyNumber; + StrategyMap strategyMap; + AttrNumber attributeNumber; + StrategyNumber strategyNumber; for (attributeNumber = 1; attributeNumber <= numberOfAttributes; attributeNumber += 1) diff --git a/src/backend/access/nbtree/nbtcompare.c b/src/backend/access/nbtree/nbtcompare.c index 0312bbb69d7..f107e2138a1 100644 --- a/src/backend/access/nbtree/nbtcompare.c +++ b/src/backend/access/nbtree/nbtcompare.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.11 1997/09/07 04:38:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtcompare.c,v 1.12 1997/09/08 02:20:44 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -134,13 +134,13 @@ btnamecmp(NameData * a, NameData * b) int32 bttextcmp(struct varlena * a, struct varlena * b) { - int res; - unsigned char *ap, - *bp; + int res; + unsigned char *ap, + *bp; #ifdef USE_LOCALE - int la = VARSIZE(a) - VARHDRSZ; - int lb = VARSIZE(b) - VARHDRSZ; + int la = VARSIZE(a) - VARHDRSZ; + int lb = VARSIZE(b) - VARHDRSZ; ap = (unsigned char *) palloc(la + 1); bp = (unsigned char *) palloc(lb + 1); @@ -156,7 +156,7 @@ bttextcmp(struct varlena * a, struct varlena * b) pfree(bp); #else - int len = VARSIZE(a); + int len = VARSIZE(a); /* len is the length of the shorter of the two strings */ if (len > VARSIZE(b)) diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 4bafbc2ddbb..53c56d43ec5 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.18 1997/09/07 04:38:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.19 1997/09/08 02:20:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ #endif static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem afteritem); -static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright); +static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright); static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit); -static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf); +static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf); static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, ScanKey itup_scankey, Size itemsize, BTItem btitem, BTItem afteritem); -static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem); -static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem); -static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey); +static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem); +static void _bt_updateitem(Relation rel, Size keysz, Buffer buf, BTItem oldItem, BTItem newItem); +static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey); /* * _bt_doinsert() -- Handle insertion of a single btitem in the tree. @@ -46,12 +46,12 @@ static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int InsertIndexResult _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel) { - ScanKey itup_scankey; - IndexTuple itup; - BTStack stack; - Buffer buf; - BlockNumber blkno; - int natts = rel->rd_rel->relnatts; + ScanKey itup_scankey; + IndexTuple itup; + BTStack stack; + Buffer buf; + BlockNumber blkno; + int natts = rel->rd_rel->relnatts; InsertIndexResult res; itup = &(btitem->bti_itup); @@ -82,9 +82,9 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel /* already in the node */ if (index_is_unique) { - OffsetNumber offset, - maxoff; - Page page; + OffsetNumber offset, + maxoff; + Page page; page = BufferGetPage(buf); maxoff = PageGetMaxOffsetNumber(page); @@ -95,13 +95,13 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel /* key on the page before trying to compare it */ if (!PageIsEmpty(page) && offset <= maxoff) { - TupleDesc itupdesc; - BTItem btitem; - IndexTuple itup; - HeapTuple htup; - BTPageOpaque opaque; - Buffer nbuf; - BlockNumber blkno; + TupleDesc itupdesc; + BTItem btitem; + IndexTuple itup; + HeapTuple htup; + BTPageOpaque opaque; + Buffer nbuf; + BlockNumber blkno; itupdesc = RelationGetTupleDescriptor(rel); nbuf = InvalidBuffer; @@ -213,7 +213,7 @@ _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel * 'afteritem' parameter to position ourselves correctly for the * insertion on internal pages. */ -static InsertIndexResult +static InsertIndexResult _bt_insertonpg(Relation rel, Buffer buf, BTStack stack, @@ -223,14 +223,14 @@ _bt_insertonpg(Relation rel, BTItem afteritem) { InsertIndexResult res; - Page page; - BTPageOpaque lpageop; - BlockNumber itup_blkno; - OffsetNumber itup_off; - OffsetNumber firstright = InvalidOffsetNumber; - int itemsz; - bool do_split = false; - bool keys_equal = false; + Page page; + BTPageOpaque lpageop; + BlockNumber itup_blkno; + OffsetNumber itup_off; + OffsetNumber firstright = InvalidOffsetNumber; + int itemsz; + bool do_split = false; + bool keys_equal = false; page = BufferGetPage(buf); lpageop = (BTPageOpaque) PageGetSpecialPointer(page); @@ -251,9 +251,9 @@ _bt_insertonpg(Relation rel, */ if (lpageop->btpo_flags & BTP_CHAIN) { - OffsetNumber maxoff = PageGetMaxOffsetNumber(page); - ItemId hitemid; - BTItem hitem; + OffsetNumber maxoff = PageGetMaxOffsetNumber(page); + ItemId hitemid; + BTItem hitem; Assert(!P_RIGHTMOST(lpageop)); hitemid = PageGetItemId(page, P_HIKEY); @@ -280,8 +280,8 @@ _bt_insertonpg(Relation rel, else /* "eat" page */ { - Buffer pbuf; - Page ppage; + Buffer pbuf; + Page ppage; itup_blkno = BufferGetBlockNumber(buf); itup_off = PageAddItem(page, (Item) btitem, itemsz, @@ -315,13 +315,13 @@ _bt_insertonpg(Relation rel, do_split = true; else if (PageGetFreeSpace(page) < 3 * itemsz + 2 * sizeof(ItemIdData)) { - OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; - OffsetNumber maxoff = PageGetMaxOffsetNumber(page); - ItemId itid; - BTItem previtem, - chkitem; - Size maxsize; - Size currsize; + OffsetNumber offnum = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; + OffsetNumber maxoff = PageGetMaxOffsetNumber(page); + ItemId itid; + BTItem previtem, + chkitem; + Size maxsize; + Size currsize; itid = PageGetItemId(page, offnum); previtem = (BTItem) PageGetItem(page, itid); @@ -351,19 +351,19 @@ _bt_insertonpg(Relation rel, if (do_split) { - Buffer rbuf; - Page rpage; - BTItem ritem; - BlockNumber rbknum; - BTPageOpaque rpageop; - Buffer pbuf; - Page ppage; - BTPageOpaque ppageop; - BlockNumber bknum = BufferGetBlockNumber(buf); - BTItem lowLeftItem; - OffsetNumber maxoff; - bool shifted = false; - bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false; + Buffer rbuf; + Page rpage; + BTItem ritem; + BlockNumber rbknum; + BTPageOpaque rpageop; + Buffer pbuf; + Page ppage; + BTPageOpaque ppageop; + BlockNumber bknum = BufferGetBlockNumber(buf); + BTItem lowLeftItem; + OffsetNumber maxoff; + bool shifted = false; + bool left_chained = (lpageop->btpo_flags & BTP_CHAIN) ? true : false; /* * If we have to split leaf page in the chain of duplicates by new @@ -372,7 +372,7 @@ _bt_insertonpg(Relation rel, if ((lpageop->btpo_flags & BTP_CHAIN) && (lpageop->btpo_flags & BTP_LEAF) && keys_equal) { - bool use_left = true; + bool use_left = true; rbuf = _bt_getbuf(rel, lpageop->btpo_next, BT_WRITE); rpage = BufferGetPage(rbuf); @@ -429,8 +429,8 @@ _bt_insertonpg(Relation rel, */ else if (!(lpageop->btpo_flags & BTP_CHAIN)) { - OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; - Size llimit; + OffsetNumber start = (P_RIGHTMOST(lpageop)) ? P_HIKEY : P_FIRSTKEY; + Size llimit; maxoff = PageGetMaxOffsetNumber(page); llimit = PageGetPageSize(page) - sizeof(PageHeaderData) - @@ -547,13 +547,13 @@ _bt_insertonpg(Relation rel, } else { - ScanKey newskey; + ScanKey newskey; InsertIndexResult newres; - BTItem new_item; - OffsetNumber upditem_offset = P_HIKEY; - bool do_update = false; - bool update_in_place = true; - bool parent_chained; + BTItem new_item; + OffsetNumber upditem_offset = P_HIKEY; + bool do_update = false; + bool update_in_place = true; + bool parent_chained; /* form a index tuple that points at the new right page */ rbknum = BufferGetBlockNumber(rbuf); @@ -790,27 +790,27 @@ _bt_insertonpg(Relation rel, * Returns the new right sibling of buf, pinned and write-locked. The * pin and lock on buf are maintained. */ -static Buffer +static Buffer _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) { - Buffer rbuf; - Page origpage; - Page leftpage, - rightpage; - BTPageOpaque ropaque, - lopaque, - oopaque; - Buffer sbuf; - Page spage; - BTPageOpaque sopaque; - Size itemsz; - ItemId itemid; - BTItem item; - OffsetNumber leftoff, - rightoff; - OffsetNumber start; - OffsetNumber maxoff; - OffsetNumber i; + Buffer rbuf; + Page origpage; + Page leftpage, + rightpage; + BTPageOpaque ropaque, + lopaque, + oopaque; + Buffer sbuf; + Page spage; + BTPageOpaque sopaque; + Size itemsz; + ItemId itemid; + BTItem item; + OffsetNumber leftoff, + rightoff; + OffsetNumber start; + OffsetNumber maxoff; + OffsetNumber i; rbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); origpage = BufferGetPage(buf); @@ -871,7 +871,7 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) maxoff = PageGetMaxOffsetNumber(origpage); if (firstright == InvalidOffsetNumber) { - Size llimit = PageGetFreeSpace(leftpage) / 2; + Size llimit = PageGetFreeSpace(leftpage) / 2; firstright = _bt_findsplitloc(rel, origpage, start, maxoff, llimit); } @@ -987,21 +987,21 @@ _bt_split(Relation rel, Buffer buf, OffsetNumber firstright) * may be split as * [2 2 2 2] [2 3 4]. */ -static OffsetNumber +static OffsetNumber _bt_findsplitloc(Relation rel, Page page, OffsetNumber start, OffsetNumber maxoff, Size llimit) { - OffsetNumber i; - OffsetNumber saferight; - ItemId nxtitemid, - safeitemid; - BTItem safeitem, - nxtitem; - Size nbytes; - int natts; + OffsetNumber i; + OffsetNumber saferight; + ItemId nxtitemid, + safeitemid; + BTItem safeitem, + nxtitem; + Size nbytes; + int natts; if (start >= maxoff) elog(FATAL, "btree: cannot split if start (%d) >= maxoff (%d)", @@ -1072,18 +1072,18 @@ _bt_findsplitloc(Relation rel, static void _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) { - Buffer rootbuf; - Page lpage, - rpage, - rootpage; - BlockNumber lbkno, - rbkno; - BlockNumber rootbknum; - BTPageOpaque rootopaque; - ItemId itemid; - BTItem item; - Size itemsz; - BTItem new_item; + Buffer rootbuf; + Page lpage, + rpage, + rootpage; + BlockNumber lbkno, + rbkno; + BlockNumber rootbknum; + BTPageOpaque rootopaque; + ItemId itemid; + BTItem item; + Size itemsz; + BTItem new_item; /* get a new root page */ rootbuf = _bt_getbuf(rel, P_NEW, BT_WRITE); @@ -1158,7 +1158,7 @@ _bt_newroot(Relation rel, Buffer lbuf, Buffer rbuf) * to follow. Otherwise, we do a binary search for the correct place * and insert the new item there. */ -static OffsetNumber +static OffsetNumber _bt_pgaddtup(Relation rel, Buffer buf, int keysz, @@ -1167,11 +1167,11 @@ _bt_pgaddtup(Relation rel, BTItem btitem, BTItem afteritem) { - OffsetNumber itup_off; - OffsetNumber first; - Page page; - BTPageOpaque opaque; - BTItem chkitem; + OffsetNumber itup_off; + OffsetNumber first; + Page page; + BTPageOpaque opaque; + BTItem chkitem; page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -1213,20 +1213,20 @@ _bt_pgaddtup(Relation rel, * + the item it is to follow ("afteritem") appears on this * page. */ -static bool +static bool _bt_goesonpg(Relation rel, Buffer buf, Size keysz, ScanKey scankey, BTItem afteritem) { - Page page; - ItemId hikey; - BTPageOpaque opaque; - BTItem chkitem; - OffsetNumber offnum, - maxoff; - bool found; + Page page; + ItemId hikey; + BTPageOpaque opaque; + BTItem chkitem; + OffsetNumber offnum, + maxoff; + bool found; page = BufferGetPage(buf); @@ -1314,16 +1314,16 @@ _bt_itemcmp(Relation rel, BTItem item2, StrategyNumber strat) { - TupleDesc tupDes; - IndexTuple indexTuple1, - indexTuple2; - Datum attrDatum1, - attrDatum2; - int i; - bool isFirstNull, - isSecondNull; - bool compare; - bool useEqual = false; + TupleDesc tupDes; + IndexTuple indexTuple1, + indexTuple2; + Datum attrDatum1, + attrDatum2; + int i; + bool isFirstNull, + isSecondNull; + bool compare; + bool useEqual = false; if (strat == BTLessEqualStrategyNumber) { @@ -1406,14 +1406,14 @@ _bt_updateitem(Relation rel, BTItem oldItem, BTItem newItem) { - Page page; - OffsetNumber maxoff; - OffsetNumber i; + Page page; + OffsetNumber maxoff; + OffsetNumber i; ItemPointerData itemPtrData; - BTItem item; - IndexTuple oldIndexTuple, - newIndexTuple; - int first; + BTItem item; + IndexTuple oldIndexTuple, + newIndexTuple; + int first; page = BufferGetPage(buf); maxoff = PageGetMaxOffsetNumber(page); @@ -1460,18 +1460,18 @@ _bt_updateitem(Relation rel, * * Rule is simple: NOT_NULL not equal NULL, NULL not_equal NULL too. */ -static bool +static bool _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, int keysz, ScanKey scankey) { - Datum datum; - BTItem btitem; - IndexTuple itup; - ScanKey entry; - AttrNumber attno; - long result; - int i; - bool null; + Datum datum; + BTItem btitem; + IndexTuple itup; + ScanKey entry; + AttrNumber attno; + long result; + int i; + bool null; btitem = (BTItem) PageGetItem(page, PageGetItemId(page, offnum)); itup = &(btitem->bti_itup); @@ -1504,27 +1504,27 @@ _bt_isequal(TupleDesc itupdesc, Page page, OffsetNumber offnum, * * NOTE: tested for shifting leftmost page only, having btitem < hikey. */ -static InsertIndexResult +static InsertIndexResult _bt_shift(Relation rel, Buffer buf, BTStack stack, int keysz, ScanKey scankey, BTItem btitem, BTItem hikey) { InsertIndexResult res; - int itemsz; - Page page; - BlockNumber bknum; - BTPageOpaque pageop; - Buffer rbuf; - Page rpage; - BTPageOpaque rpageop; - Buffer pbuf; - Page ppage; - BTPageOpaque ppageop; - Buffer nbuf; - Page npage; - BTPageOpaque npageop; - BlockNumber nbknum; - BTItem nitem; - OffsetNumber afteroff; + int itemsz; + Page page; + BlockNumber bknum; + BTPageOpaque pageop; + Buffer rbuf; + Page rpage; + BTPageOpaque rpageop; + Buffer pbuf; + Page ppage; + BTPageOpaque ppageop; + Buffer nbuf; + Page npage; + BTPageOpaque npageop; + BlockNumber nbknum; + BTItem nitem; + OffsetNumber afteroff; btitem = _bt_formitem(&(btitem->bti_itup)); hikey = _bt_formitem(&(hikey->bti_itup)); diff --git a/src/backend/access/nbtree/nbtpage.c b/src/backend/access/nbtree/nbtpage.c index 6551af4c17c..fe3bebbccdf 100644 --- a/src/backend/access/nbtree/nbtpage.c +++ b/src/backend/access/nbtree/nbtpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.10 1997/09/07 04:38:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtpage.c,v 1.11 1997/09/08 02:20:49 momjian Exp $ * * NOTES * Postgres btree pages look like ordinary relation pages. The opaque @@ -36,8 +36,8 @@ #include <string.h> #endif -static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access); -static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); +static void _bt_setpagelock(Relation rel, BlockNumber blkno, int access); +static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); #define BTREE_METAPAGE 0 #define BTREE_MAGIC 0x053162 @@ -50,18 +50,18 @@ static void _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access); typedef struct BTMetaPageData { - uint32 btm_magic; - uint32 btm_version; - BlockNumber btm_root; + uint32 btm_magic; + uint32 btm_version; + BlockNumber btm_root; #ifdef BTREE_VERSION_1 - int32 btm_level; + int32 btm_level; #endif -} BTMetaPageData; +} BTMetaPageData; #define BTPageGetMeta(p) \ ((BTMetaPageData *) &((PageHeader) p)->pd_linp[0]) -extern bool BuildingBtree; +extern bool BuildingBtree; /* * We use high-concurrency locking on btrees. There are two cases in @@ -85,11 +85,11 @@ extern bool BuildingBtree; void _bt_metapinit(Relation rel) { - Buffer buf; - Page pg; - int nblocks; - BTMetaPageData metad; - BTPageOpaque op; + Buffer buf; + Page pg; + int nblocks; + BTMetaPageData metad; + BTPageOpaque op; /* can't be sharing this with anyone, now... */ if (USELOCKING) @@ -131,11 +131,11 @@ _bt_metapinit(Relation rel) void _bt_checkmeta(Relation rel) { - Buffer metabuf; - Page metap; + Buffer metabuf; + Page metap; BTMetaPageData *metad; - BTPageOpaque op; - int nblocks; + BTPageOpaque op; + int nblocks; /* if the relation is empty, this is init time; don't complain */ if ((nblocks = RelationGetNumberOfBlocks(rel)) == 0) @@ -187,13 +187,13 @@ _bt_checkmeta(Relation rel) Buffer _bt_getroot(Relation rel, int access) { - Buffer metabuf; - Page metapg; - BTPageOpaque metaopaque; - Buffer rootbuf; - Page rootpg; - BTPageOpaque rootopaque; - BlockNumber rootblkno; + Buffer metabuf; + Page metapg; + BTPageOpaque metaopaque; + Buffer rootbuf; + Page rootpg; + BTPageOpaque rootopaque; + BlockNumber rootblkno; BTMetaPageData *metad; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_READ); @@ -319,8 +319,8 @@ _bt_getroot(Relation rel, int access) Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access) { - Buffer buf; - Page page; + Buffer buf; + Page page; /* * If we want a new block, we can't set a lock of the appropriate type @@ -359,7 +359,7 @@ _bt_getbuf(Relation rel, BlockNumber blkno, int access) void _bt_relbuf(Relation rel, Buffer buf, int access) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); @@ -382,7 +382,7 @@ _bt_relbuf(Relation rel, Buffer buf, int access) void _bt_wrtbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteBuffer(buf); @@ -399,7 +399,7 @@ _bt_wrtbuf(Relation rel, Buffer buf) void _bt_wrtnorelbuf(Relation rel, Buffer buf) { - BlockNumber blkno; + BlockNumber blkno; blkno = BufferGetBlockNumber(buf); WriteNoReleaseBuffer(buf); @@ -439,9 +439,9 @@ _bt_pageinit(Page page, Size size) void _bt_metaproot(Relation rel, BlockNumber rootbknum, int level) { - Buffer metabuf; - Page metap; - BTPageOpaque metaopaque; + Buffer metabuf; + Page metap; + BTPageOpaque metaopaque; BTMetaPageData *metad; metabuf = _bt_getbuf(rel, BTREE_METAPAGE, BT_WRITE); @@ -473,18 +473,18 @@ _bt_metaproot(Relation rel, BlockNumber rootbknum, int level) Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access) { - Buffer buf; - BlockNumber blkno; - OffsetNumber start, - offnum, - maxoff; - OffsetNumber i; - Page page; - ItemId itemid; - BTItem item; - BTPageOpaque opaque; - BTItem item_save; - int item_nbytes; + Buffer buf; + BlockNumber blkno; + OffsetNumber start, + offnum, + maxoff; + OffsetNumber i; + Page page; + ItemId itemid; + BTItem item; + BTPageOpaque opaque; + BTItem item_save; + int item_nbytes; blkno = stack->bts_blkno; buf = _bt_getbuf(rel, blkno, access); @@ -603,10 +603,10 @@ _bt_unsetpagelock(Relation rel, BlockNumber blkno, int access) void _bt_pagedel(Relation rel, ItemPointer tid) { - Buffer buf; - Page page; - BlockNumber blkno; - OffsetNumber offno; + Buffer buf; + Page page; + BlockNumber blkno; + OffsetNumber offno; blkno = ItemPointerGetBlockNumber(tid); offno = ItemPointerGetOffsetNumber(tid); diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index dccbd77b355..9f7b59327a9 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.20 1997/09/07 04:38:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.21 1997/09/08 02:20:50 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -35,14 +35,14 @@ #ifdef BTREE_BUILD_STATS #include <tcop/tcopprot.h> -extern int ShowExecutorStats; +extern int ShowExecutorStats; #endif -bool BuildingBtree = false; /* see comment in btbuild() */ -bool FastBuild = true; /* use sort/build instead of - * insertion build */ +bool BuildingBtree = false; /* see comment in btbuild() */ +bool FastBuild = true; /* use sort/build instead of insertion + * build */ /* * btbuild() -- build a new btree index. @@ -63,33 +63,33 @@ btbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc hscan; - Buffer buffer; - HeapTuple htup; - IndexTuple itup; - TupleDesc htupdesc, - itupdesc; - Datum *attdata; - bool *nulls; + HeapScanDesc hscan; + Buffer buffer; + HeapTuple htup; + IndexTuple itup; + TupleDesc htupdesc, + itupdesc; + Datum *attdata; + bool *nulls; InsertIndexResult res = 0; - int nhtups, - nitups; - int i; - BTItem btitem; + int nhtups, + nitups; + int i; + BTItem btitem; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext = (ExprContext *) NULL; - TupleTable tupleTable = (TupleTable) NULL; + ExprContext *econtext = (ExprContext *) NULL; + TupleTable tupleTable = (TupleTable) NULL; TupleTableSlot *slot = (TupleTableSlot *) NULL; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - void *spool = (void *) NULL; - bool isunique; - bool usefast; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + void *spool = (void *) NULL; + bool isunique; + bool usefast; /* note that this is a new btree */ BuildingBtree = true; @@ -211,8 +211,8 @@ btbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -358,8 +358,8 @@ btbuild(Relation heap, InsertIndexResult btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { - BTItem btitem; - IndexTuple itup; + BTItem btitem; + IndexTuple itup; InsertIndexResult res; /* generate an index tuple */ @@ -389,7 +389,7 @@ btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation /* * btgettuple() -- Get the next tuple in the scan. */ -char * +char * btgettuple(IndexScanDesc scan, ScanDirection dir) { RetrieveIndexResult res; @@ -411,10 +411,10 @@ btgettuple(IndexScanDesc scan, ScanDirection dir) /* * btbeginscan() -- start a scan on a btree index */ -char * +char * btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) { - IndexScanDesc scan; + IndexScanDesc scan; /* get the scan */ scan = RelationGetIndexScan(rel, fromEnd, keysz, scankey); @@ -431,8 +431,8 @@ btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey) void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -483,8 +483,8 @@ btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey) void btmovescan(IndexScanDesc scan, Datum v) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -506,8 +506,8 @@ btmovescan(IndexScanDesc scan, Datum v) void btendscan(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -541,8 +541,8 @@ btendscan(IndexScanDesc scan) void btmarkpos(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; @@ -570,8 +570,8 @@ btmarkpos(IndexScanDesc scan) void btrestrpos(IndexScanDesc scan) { - ItemPointer iptr; - BTScanOpaque so; + ItemPointer iptr; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; diff --git a/src/backend/access/nbtree/nbtscan.c b/src/backend/access/nbtree/nbtscan.c index 8a2042403ad..4f3ee1ffe62 100644 --- a/src/backend/access/nbtree/nbtscan.c +++ b/src/backend/access/nbtree/nbtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.8 1997/09/07 04:38:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtscan.c,v 1.9 1997/09/08 02:20:52 momjian Exp $ * * * NOTES @@ -34,16 +34,16 @@ typedef struct BTScanListData { - IndexScanDesc btsl_scan; + IndexScanDesc btsl_scan; struct BTScanListData *btsl_next; -} BTScanListData; +} BTScanListData; typedef BTScanListData *BTScanList; static BTScanList BTScans = (BTScanList) NULL; -static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno); -static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); +static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno); +static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno); /* * _bt_regscan() -- register a new scan. @@ -51,7 +51,7 @@ static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber void _bt_regscan(IndexScanDesc scan) { - BTScanList new_el; + BTScanList new_el; new_el = (BTScanList) palloc(sizeof(BTScanListData)); new_el->btsl_scan = scan; @@ -65,8 +65,8 @@ _bt_regscan(IndexScanDesc scan) void _bt_dropscan(IndexScanDesc scan) { - BTScanList chk, - last; + BTScanList chk, + last; last = (BTScanList) NULL; for (chk = BTScans; @@ -94,8 +94,8 @@ _bt_dropscan(IndexScanDesc scan) void _bt_adjscans(Relation rel, ItemPointer tid, int op) { - BTScanList l; - Oid relid; + BTScanList l; + Oid relid; relid = rel->rd_id; for (l = BTScans; l != (BTScanList) NULL; l = l->btsl_next) @@ -130,9 +130,9 @@ _bt_adjscans(Relation rel, ItemPointer tid, int op) static void _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; - Buffer buf; - BTScanOpaque so; + ItemPointer current; + Buffer buf; + BTScanOpaque so; if (!_bt_scantouched(scan, blkno, offno)) return; @@ -147,15 +147,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) { switch (op) { - case BT_INSERT: - _bt_step(scan, &buf, ForwardScanDirection); - break; - case BT_DELETE: - _bt_step(scan, &buf, BackwardScanDirection); - break; - default: - elog(WARN, "_bt_scandel: bad operation '%d'", op); - /* NOTREACHED */ + case BT_INSERT: + _bt_step(scan, &buf, ForwardScanDirection); + break; + case BT_DELETE: + _bt_step(scan, &buf, BackwardScanDirection); + break; + default: + elog(WARN, "_bt_scandel: bad operation '%d'", op); + /* NOTREACHED */ } so->btso_curbuf = buf; } @@ -172,15 +172,15 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) scan->currentItemData = tmp; switch (op) { - case BT_INSERT: - _bt_step(scan, &buf, ForwardScanDirection); - break; - case BT_DELETE: - _bt_step(scan, &buf, BackwardScanDirection); - break; - default: - elog(WARN, "_bt_scandel: bad operation '%d'", op); - /* NOTREACHED */ + case BT_INSERT: + _bt_step(scan, &buf, ForwardScanDirection); + break; + case BT_DELETE: + _bt_step(scan, &buf, BackwardScanDirection); + break; + default: + elog(WARN, "_bt_scandel: bad operation '%d'", op); + /* NOTREACHED */ } so->btso_mrkbuf = buf; tmp = *current; @@ -193,10 +193,10 @@ _bt_scandel(IndexScanDesc scan, int op, BlockNumber blkno, OffsetNumber offno) * _bt_scantouched() -- check to see if a scan is affected by a given * change to the index */ -static bool +static bool _bt_scantouched(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) { - ItemPointer current; + ItemPointer current; current = &(scan->currentItemData); if (ItemPointerIsValid(current) diff --git a/src/backend/access/nbtree/nbtsearch.c b/src/backend/access/nbtree/nbtsearch.c index 8b1f75b7533..50f2031779f 100644 --- a/src/backend/access/nbtree/nbtsearch.c +++ b/src/backend/access/nbtree/nbtsearch.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.24 1997/09/07 04:38:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtsearch.c,v 1.25 1997/09/08 02:20:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,19 +28,19 @@ #endif -static BTStack +static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey, Buffer * bufP, BTStack stack_in); -static OffsetNumber +static OffsetNumber _bt_firsteq(Relation rel, TupleDesc itupdesc, Page page, Size keysz, ScanKey scankey, OffsetNumber offnum); static int _bt_compare(Relation rel, TupleDesc itupdesc, Page page, int keysz, ScanKey scankey, OffsetNumber offnum); -static bool - _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); -static RetrieveIndexResult - _bt_endpoint(IndexScanDesc scan, ScanDirection dir); +static bool + _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); +static RetrieveIndexResult + _bt_endpoint(IndexScanDesc scan, ScanDirection dir); /* * _bt_search() -- Search for a scan key in the index. @@ -58,24 +58,24 @@ _bt_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP) /* * _bt_searchr() -- Search the tree recursively for a particular scankey. */ -static BTStack +static BTStack _bt_searchr(Relation rel, int keysz, ScanKey scankey, Buffer * bufP, BTStack stack_in) { - BTStack stack; - OffsetNumber offnum; - Page page; - BTPageOpaque opaque; - BlockNumber par_blkno; - BlockNumber blkno; - ItemId itemid; - BTItem btitem; - BTItem item_save; - int item_nbytes; - IndexTuple itup; + BTStack stack; + OffsetNumber offnum; + Page page; + BTPageOpaque opaque; + BlockNumber par_blkno; + BlockNumber blkno; + ItemId itemid; + BTItem btitem; + BTItem item_save; + int item_nbytes; + IndexTuple itup; /* if this is a leaf page, we're done */ page = BufferGetPage(*bufP); @@ -155,11 +155,11 @@ _bt_moveright(Relation rel, ScanKey scankey, int access) { - Page page; - BTPageOpaque opaque; - ItemId hikey; - BlockNumber rblkno; - int natts = rel->rd_rel->relnatts; + Page page; + BTPageOpaque opaque; + ItemId hikey; + BlockNumber rblkno; + int natts = rel->rd_rel->relnatts; page = BufferGetPage(buf); opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -183,7 +183,7 @@ _bt_moveright(Relation rel, /* move right as long as we need to */ do { - OffsetNumber offmax = PageGetMaxOffsetNumber(page); + OffsetNumber offmax = PageGetMaxOffsetNumber(page); /* * If this page consists of all duplicate keys (hikey and @@ -197,8 +197,8 @@ _bt_moveright(Relation rel, * if number of attrs > keysize. Example: (2,0) - last items * on this page, (2,1) - first item on next page (hikey), our * scankey is x = 2. Scankey == (2,1) because of we compare - * first attrs only, but we shouldn't to move right of here. - * - vadim 04/15/97 + * first attrs only, but we shouldn't to move right of here. - + * vadim 04/15/97 */ if (_bt_skeycmp(rel, keysz, scankey, page, hikey, @@ -268,17 +268,17 @@ _bt_skeycmp(Relation rel, ItemId itemid, StrategyNumber strat) { - BTItem item; - IndexTuple indexTuple; - TupleDesc tupDes; - ScanKey entry; - int i; - Datum attrDatum; - Datum keyDatum; - bool compare; - bool isNull; - bool useEqual = false; - bool keyNull; + BTItem item; + IndexTuple indexTuple; + TupleDesc tupDes; + ScanKey entry; + int i; + Datum attrDatum; + Datum keyDatum; + bool compare; + bool isNull; + bool useEqual = false; + bool keyNull; if (strat == BTLessEqualStrategyNumber) { @@ -382,14 +382,14 @@ _bt_binsrch(Relation rel, ScanKey scankey, int srchtype) { - TupleDesc itupdesc; - Page page; - BTPageOpaque opaque; - OffsetNumber low, - mid, - high; - int natts = rel->rd_rel->relnatts; - int result; + TupleDesc itupdesc; + Page page; + BTPageOpaque opaque; + OffsetNumber low, + mid, + high; + int natts = rel->rd_rel->relnatts; + int result; itupdesc = RelationGetTupleDescriptor(rel); page = BufferGetPage(buf); @@ -515,7 +515,7 @@ _bt_binsrch(Relation rel, } } -static OffsetNumber +static OffsetNumber _bt_firsteq(Relation rel, TupleDesc itupdesc, Page page, @@ -523,8 +523,8 @@ _bt_firsteq(Relation rel, ScanKey scankey, OffsetNumber offnum) { - BTPageOpaque opaque; - OffsetNumber limit; + BTPageOpaque opaque; + OffsetNumber limit; opaque = (BTPageOpaque) PageGetSpecialPointer(page); @@ -572,16 +572,16 @@ _bt_compare(Relation rel, ScanKey scankey, OffsetNumber offnum) { - Datum datum; - BTItem btitem; - ItemId itemid; - IndexTuple itup; - BTPageOpaque opaque; - ScanKey entry; - AttrNumber attno; - int result; - int i; - bool null; + Datum datum; + BTItem btitem; + ItemId itemid; + IndexTuple itup; + BTPageOpaque opaque; + ScanKey entry; + AttrNumber attno; + int result; + int i; + bool null; /* * If this is a leftmost internal page, and if our comparison is with @@ -650,7 +650,7 @@ _bt_compare(Relation rel, for (i = 1; i <= keysz; i++) { - long tmpres; + long tmpres; entry = &scankey[i - 1]; attno = entry->sk_attno; @@ -697,16 +697,16 @@ _bt_compare(Relation rel, RetrieveIndexResult _bt_next(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Page page; - OffsetNumber offnum; + Relation rel; + Buffer buf; + Page page; + OffsetNumber offnum; RetrieveIndexResult res; - ItemPointer current; - BTItem btitem; - IndexTuple itup; - BTScanOpaque so; - Size keysok; + ItemPointer current; + BTItem btitem; + IndexTuple itup; + BTScanOpaque so; + Size keysok; rel = scan->relation; so = (BTScanOpaque) scan->opaque; @@ -769,26 +769,26 @@ _bt_next(IndexScanDesc scan, ScanDirection dir) RetrieveIndexResult _bt_first(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - TupleDesc itupdesc; - Buffer buf; - Page page; - BTPageOpaque pop; - BTStack stack; - OffsetNumber offnum, - maxoff; - bool offGmax = false; - BTItem btitem; - IndexTuple itup; - ItemPointer current; - BlockNumber blkno; - StrategyNumber strat; + Relation rel; + TupleDesc itupdesc; + Buffer buf; + Page page; + BTPageOpaque pop; + BTStack stack; + OffsetNumber offnum, + maxoff; + bool offGmax = false; + BTItem btitem; + IndexTuple itup; + ItemPointer current; + BlockNumber blkno; + StrategyNumber strat; RetrieveIndexResult res; - RegProcedure proc; - int result; - BTScanOpaque so; - ScanKeyData skdata; - Size keysok; + RegProcedure proc; + int result; + BTScanOpaque so; + ScanKeyData skdata; + Size keysok; rel = scan->relation; so = (BTScanOpaque) scan->opaque; @@ -915,69 +915,69 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) switch (strat) { - case BTLessStrategyNumber: - if (result <= 0) - { - do + case BTLessStrategyNumber: + if (result <= 0) { - if (!_bt_twostep(scan, &buf, BackwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, BackwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result <= 0); + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result <= 0); - /* if this is true, the key we just looked at is gone */ - if (result > 0) - _bt_twostep(scan, &buf, ForwardScanDirection); - } - break; + /* if this is true, the key we just looked at is gone */ + if (result > 0) + _bt_twostep(scan, &buf, ForwardScanDirection); + } + break; - case BTLessEqualStrategyNumber: - if (result >= 0) - { - do + case BTLessEqualStrategyNumber: + if (result >= 0) { - if (!_bt_twostep(scan, &buf, ForwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, ForwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result >= 0); + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result >= 0); - if (result < 0) - _bt_twostep(scan, &buf, BackwardScanDirection); - } - break; + if (result < 0) + _bt_twostep(scan, &buf, BackwardScanDirection); + } + break; - case BTEqualStrategyNumber: - if (result != 0) - { - _bt_relbuf(scan->relation, buf, BT_READ); - so->btso_curbuf = InvalidBuffer; - ItemPointerSetInvalid(&(scan->currentItemData)); - return ((RetrieveIndexResult) NULL); - } - break; + case BTEqualStrategyNumber: + if (result != 0) + { + _bt_relbuf(scan->relation, buf, BT_READ); + so->btso_curbuf = InvalidBuffer; + ItemPointerSetInvalid(&(scan->currentItemData)); + return ((RetrieveIndexResult) NULL); + } + break; - case BTGreaterEqualStrategyNumber: - if (offGmax) - { - if (result < 0) + case BTGreaterEqualStrategyNumber: + if (offGmax) { - Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY); - if (!_bt_step(scan, &buf, ForwardScanDirection)) + if (result < 0) { - _bt_relbuf(scan->relation, buf, BT_READ); - so->btso_curbuf = InvalidBuffer; - ItemPointerSetInvalid(&(scan->currentItemData)); - return ((RetrieveIndexResult) NULL); + Assert(!P_RIGHTMOST(pop) && maxoff == P_HIKEY); + if (!_bt_step(scan, &buf, ForwardScanDirection)) + { + _bt_relbuf(scan->relation, buf, BT_READ); + so->btso_curbuf = InvalidBuffer; + ItemPointerSetInvalid(&(scan->currentItemData)); + return ((RetrieveIndexResult) NULL); + } } - } - else if (result > 0) - { /* Just remember: _bt_binsrch() returns + else if (result > 0) + { /* Just remember: _bt_binsrch() returns * the OffsetNumber of the first matching * key on the page, or the OffsetNumber at * which the matching key WOULD APPEAR IF @@ -985,41 +985,41 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) * page, but offnum from _bt_binsrch() * greater maxoff - have to move right. - * vadim 12/06/96 */ - _bt_twostep(scan, &buf, ForwardScanDirection); + _bt_twostep(scan, &buf, ForwardScanDirection); + } } - } - else if (result < 0) - { - do + else if (result < 0) { - if (!_bt_twostep(scan, &buf, BackwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, BackwardScanDirection)) + break; - page = BufferGetPage(buf); - offnum = ItemPointerGetOffsetNumber(current); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result < 0); + page = BufferGetPage(buf); + offnum = ItemPointerGetOffsetNumber(current); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result < 0); - if (result > 0) - _bt_twostep(scan, &buf, ForwardScanDirection); - } - break; + if (result > 0) + _bt_twostep(scan, &buf, ForwardScanDirection); + } + break; - case BTGreaterStrategyNumber: - /* offGmax helps as above */ - if (result >= 0 || offGmax) - { - do + case BTGreaterStrategyNumber: + /* offGmax helps as above */ + if (result >= 0 || offGmax) { - if (!_bt_twostep(scan, &buf, ForwardScanDirection)) - break; + do + { + if (!_bt_twostep(scan, &buf, ForwardScanDirection)) + break; - offnum = ItemPointerGetOffsetNumber(current); - page = BufferGetPage(buf); - result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); - } while (result >= 0); - } - break; + offnum = ItemPointerGetOffsetNumber(current); + page = BufferGetPage(buf); + result = _bt_compare(rel, itupdesc, page, 1, &skdata, offnum); + } while (result >= 0); + } + break; } /* okay, current item pointer for the scan is right */ @@ -1062,16 +1062,16 @@ _bt_first(IndexScanDesc scan, ScanDirection dir) bool _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) { - Page page; - BTPageOpaque opaque; - OffsetNumber offnum, - maxoff; - OffsetNumber start; - BlockNumber blkno; - BlockNumber obknum; - BTScanOpaque so; - ItemPointer current; - Relation rel; + Page page; + BTPageOpaque opaque; + OffsetNumber offnum, + maxoff; + OffsetNumber start; + BlockNumber blkno; + BlockNumber obknum; + BTScanOpaque so; + ItemPointer current; + Relation rel; rel = scan->relation; current = &(scan->currentItemData); @@ -1235,20 +1235,20 @@ _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) * proper state and acquires a lock and pin on *bufP. If the twostep * succeeded, we return true; otherwise, we return false. */ -static bool +static bool _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) { - Page page; - BTPageOpaque opaque; - OffsetNumber offnum, - maxoff; - OffsetNumber start; - ItemPointer current; - ItemId itemid; - int itemsz; - BTItem btitem; - BTItem svitem; - BlockNumber blkno; + Page page; + BTPageOpaque opaque; + OffsetNumber offnum, + maxoff; + OffsetNumber start; + ItemPointer current; + ItemId itemid; + int itemsz; + BTItem btitem; + BTItem svitem; + BlockNumber blkno; blkno = BufferGetBlockNumber(*bufP); page = BufferGetPage(*bufP); @@ -1333,23 +1333,23 @@ _bt_twostep(IndexScanDesc scan, Buffer * bufP, ScanDirection dir) /* * _bt_endpoint() -- Find the first or last key in the index. */ -static RetrieveIndexResult +static RetrieveIndexResult _bt_endpoint(IndexScanDesc scan, ScanDirection dir) { - Relation rel; - Buffer buf; - Page page; - BTPageOpaque opaque; - ItemPointer current; - OffsetNumber offnum, - maxoff; - OffsetNumber start = 0; - BlockNumber blkno; - BTItem btitem; - IndexTuple itup; - BTScanOpaque so; + Relation rel; + Buffer buf; + Page page; + BTPageOpaque opaque; + ItemPointer current; + OffsetNumber offnum, + maxoff; + OffsetNumber start = 0; + BlockNumber blkno; + BTItem btitem; + IndexTuple itup; + BTScanOpaque so; RetrieveIndexResult res; - Size keysok; + Size keysok; rel = scan->relation; current = &(scan->currentItemData); diff --git a/src/backend/access/nbtree/nbtsort.c b/src/backend/access/nbtree/nbtsort.c index 09cb43769f2..fae0fc27dab 100644 --- a/src/backend/access/nbtree/nbtsort.c +++ b/src/backend/access/nbtree/nbtsort.c @@ -5,7 +5,7 @@ * * * IDENTIFICATION - * $Id: nbtsort.c,v 1.20 1997/09/07 04:39:02 momjian Exp $ + * $Id: nbtsort.c,v 1.21 1997/09/08 02:20:58 momjian Exp $ * * NOTES * @@ -65,14 +65,14 @@ #ifdef BTREE_BUILD_STATS #include <tcop/tcopprot.h> -extern int ShowExecutorStats; +extern int ShowExecutorStats; #endif -static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags); -static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend); -static void *_bt_pagestate(Relation index, int flags, int level, bool doupper); -static void _bt_uppershutdown(Relation index, BTPageState * state); +static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags); +static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend); +static void *_bt_pagestate(Relation index, int flags, int level, bool doupper); +static void _bt_uppershutdown(Relation index, BTPageState * state); /* * turn on debugging output. @@ -88,9 +88,9 @@ static void _bt_uppershutdown(Relation index, BTPageState * state); #define TAPEBLCKSZ (MAXBLCKSZ << 2) #define TAPETEMP "pg_btsortXXXXXX" -extern int NDirectFileRead; -extern int NDirectFileWrite; -extern char *mktemp(char *template); +extern int NDirectFileRead; +extern int NDirectFileWrite; +extern char *mktemp(char *template); /* * this is what we use to shovel BTItems in and out of memory. it's @@ -107,13 +107,13 @@ extern char *mktemp(char *template); */ typedef struct { - int bttb_magic; /* magic number */ - int bttb_fd; /* file descriptor */ - int bttb_top; /* top of free space within bttb_data */ - short bttb_ntup; /* number of tuples in this block */ - short bttb_eor; /* End-Of-Run marker */ - char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)]; -} BTTapeBlock; + int bttb_magic; /* magic number */ + int bttb_fd; /* file descriptor */ + int bttb_top; /* top of free space within bttb_data */ + short bttb_ntup; /* number of tuples in this block */ + short bttb_eor; /* End-Of-Run marker */ + char bttb_data[TAPEBLCKSZ - 2 * sizeof(double)]; +} BTTapeBlock; /* * this structure holds the bookkeeping for a simple balanced multiway @@ -124,12 +124,12 @@ typedef struct */ typedef struct { - int bts_ntapes; - int bts_tape; - BTTapeBlock **bts_itape; /* input tape blocks */ - BTTapeBlock **bts_otape; /* output tape blocks */ - bool isunique; -} BTSpool; + int bts_ntapes; + int bts_tape; + BTTapeBlock **bts_itape; /* input tape blocks */ + BTTapeBlock **bts_otape; /* output tape blocks */ + bool isunique; +} BTSpool; /*------------------------------------------------------------------------- * sorting comparison routine - returns {-1,0,1} depending on whether @@ -151,13 +151,13 @@ typedef struct */ typedef struct { - Datum *btsk_datum; - char *btsk_nulls; - BTItem btsk_item; -} BTSortKey; + Datum *btsk_datum; + char *btsk_nulls; + BTItem btsk_item; +} BTSortKey; static Relation _bt_sortrel; -static int _bt_nattr; +static int _bt_nattr; static BTSpool *_bt_inspool; static void @@ -171,12 +171,12 @@ _bt_isortcmpinit(Relation index, BTSpool * spool) static int _bt_isortcmp(BTSortKey * k1, BTSortKey * k2) { - Datum *k1_datum = k1->btsk_datum; - Datum *k2_datum = k2->btsk_datum; - char *k1_nulls = k1->btsk_nulls; - char *k2_nulls = k2->btsk_nulls; - bool equal_isnull = false; - int i; + Datum *k1_datum = k1->btsk_datum; + Datum *k2_datum = k2->btsk_datum; + char *k1_nulls = k1->btsk_nulls; + char *k2_nulls = k2->btsk_nulls; + bool equal_isnull = false; + int i; if (k1->btsk_item == (BTItem) NULL) { @@ -226,12 +226,12 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk) if (bti != (BTItem) NULL) { - IndexTuple it = &(bti->bti_itup); - TupleDesc itdesc = index->rd_att; - Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum)); - char *np = (char *) palloc(_bt_nattr * sizeof(char)); - bool isnull; - int i; + IndexTuple it = &(bti->bti_itup); + TupleDesc itdesc = index->rd_att; + Datum *dp = (Datum *) palloc(_bt_nattr * sizeof(Datum)); + char *np = (char *) palloc(_bt_nattr * sizeof(char)); + bool isnull; + int i; for (i = 0; i < _bt_nattr; i++) { @@ -260,17 +260,17 @@ _bt_setsortkey(Relation index, BTItem bti, BTSortKey * sk) */ typedef struct { - int btpqe_tape; /* tape identifier */ - BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */ -} BTPriQueueElem; + int btpqe_tape; /* tape identifier */ + BTSortKey btpqe_item; /* pointer to BTItem in tape buffer */ +} BTPriQueueElem; #define MAXELEM MAXTAPES typedef struct { - int btpq_nelem; - BTPriQueueElem btpq_queue[MAXELEM]; - Relation btpq_rel; -} BTPriQueue; + int btpq_nelem; + BTPriQueueElem btpq_queue[MAXELEM]; + Relation btpq_rel; +} BTPriQueue; /* be sure to call _bt_isortcmpinit first */ #define GREATER(a, b) \ @@ -279,8 +279,8 @@ typedef struct static void _bt_pqsift(BTPriQueue * q, int parent) { - int child; - BTPriQueueElem e; + int child; + BTPriQueueElem e; for (child = parent * 2 + 1; child < q->btpq_nelem; @@ -328,8 +328,8 @@ _bt_pqnext(BTPriQueue * q, BTPriQueueElem * e) static void _bt_pqadd(BTPriQueue * q, BTPriQueueElem * e) { - int child, - parent; + int child, + parent; if (q->btpq_nelem >= MAXELEM) { @@ -422,7 +422,7 @@ _bt_tapeclear(BTTapeBlock * tape) static BTTapeBlock * _bt_tapecreate(char *fname) { - BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock)); + BTTapeBlock *tape = (BTTapeBlock *) palloc(sizeof(BTTapeBlock)); if (tape == (BTTapeBlock *) NULL) { @@ -474,8 +474,8 @@ _bt_tapewrite(BTTapeBlock * tape, int eor) static int _bt_taperead(BTTapeBlock * tape) { - int fd; - int nread; + int fd; + int nread; if (tape->bttb_eor) { @@ -510,11 +510,11 @@ _bt_taperead(BTTapeBlock * tape) * side effects: * - sets 'pos' to the current position within the block. */ -static BTItem +static BTItem _bt_tapenext(BTTapeBlock * tape, char **pos) { - Size itemsz; - BTItem bti; + Size itemsz; + BTItem bti; if (*pos >= tape->bttb_data + tape->bttb_top) { @@ -554,12 +554,12 @@ _bt_tapeadd(BTTapeBlock * tape, BTItem item, int itemsz) * create and initialize a spool structure, including the underlying * files. */ -void * +void * _bt_spoolinit(Relation index, int ntapes, bool isunique) { - BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); - int i; - char *fname = (char *) palloc(sizeof(TAPETEMP) + 1); + BTSpool *btspool = (BTSpool *) palloc(sizeof(BTSpool)); + int i; + char *fname = (char *) palloc(sizeof(TAPETEMP) + 1); if (btspool == (BTSpool *) NULL || fname == (char *) NULL) { @@ -600,8 +600,8 @@ _bt_spoolinit(Relation index, int ntapes, bool isunique) void _bt_spooldestroy(void *spool) { - BTSpool *btspool = (BTSpool *) spool; - int i; + BTSpool *btspool = (BTSpool *) spool; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -617,7 +617,7 @@ _bt_spooldestroy(void *spool) static void _bt_spoolflush(BTSpool * btspool) { - int i; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -637,10 +637,10 @@ _bt_spoolflush(BTSpool * btspool) static void _bt_spoolswap(BTSpool * btspool) { - File tmpfd; - BTTapeBlock *itape; - BTTapeBlock *otape; - int i; + File tmpfd; + BTTapeBlock *itape; + BTTapeBlock *otape; + int i; for (i = 0; i < btspool->bts_ntapes; ++i) { @@ -682,9 +682,9 @@ _bt_spoolswap(BTSpool * btspool) void _bt_spool(Relation index, BTItem btitem, void *spool) { - BTSpool *btspool = (BTSpool *) spool; - BTTapeBlock *itape; - Size itemsz; + BTSpool *btspool = (BTSpool *) spool; + BTTapeBlock *itape; + Size itemsz; _bt_isortcmpinit(index, btspool); @@ -699,13 +699,13 @@ _bt_spool(Relation index, BTItem btitem, void *spool) */ if (btitem == (BTItem) NULL || SPCLEFT(itape) < itemsz) { - BTSortKey *parray = (BTSortKey *) NULL; - BTTapeBlock *otape; - BTItem bti; - char *pos; - int btisz; - int it_ntup = itape->bttb_ntup; - int i; + BTSortKey *parray = (BTSortKey *) NULL; + BTTapeBlock *otape; + BTItem bti; + char *pos; + int btisz; + int it_ntup = itape->bttb_ntup; + int i; /* * build an array of pointers to the BTItemDatas on the input @@ -745,9 +745,9 @@ _bt_spool(Relation index, BTItem btitem, void *spool) _bt_tapeadd(otape, bti, btisz); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_SPOOL) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, - &isnull); + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, + &isnull); printf("_bt_spool: inserted <%x> into output tape %d\n", d, btspool->bts_tape); @@ -802,7 +802,7 @@ _bt_spool(Relation index, BTItem btitem, void *spool) static void _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags) { - BTPageOpaque opaque; + BTPageOpaque opaque; *buf = _bt_getbuf(index, P_NEW, BT_WRITE); #if 0 @@ -824,10 +824,10 @@ _bt_blnewpage(Relation index, Buffer * buf, Page * page, int flags) static void _bt_slideleft(Relation index, Buffer buf, Page page) { - OffsetNumber off; - OffsetNumber maxoff; - ItemId previi; - ItemId thisii; + OffsetNumber off; + OffsetNumber maxoff; + ItemId previi; + ItemId thisii; if (!PageIsEmpty(page)) { @@ -847,10 +847,10 @@ _bt_slideleft(Relation index, Buffer buf, Page page) * allocate and initialize a new BTPageState. the returned structure * is suitable for immediate use by _bt_buildadd. */ -static void * +static void * _bt_pagestate(Relation index, int flags, int level, bool doupper) { - BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState)); + BTPageState *state = (BTPageState *) palloc(sizeof(BTPageState)); memset((char *) state, 0, sizeof(BTPageState)); _bt_blnewpage(index, &(state->btps_buf), &(state->btps_page), flags); @@ -870,12 +870,12 @@ _bt_pagestate(Relation index, int flags, int level, bool doupper) * the page to which the item used to point, e.g., a heap page if * 'opage' is a leaf page). */ -static BTItem +static BTItem _bt_minitem(Page opage, BlockNumber oblkno, int atend) { - OffsetNumber off; - BTItem obti; - BTItem nbti; + OffsetNumber off; + BTItem obti; + BTItem nbti; off = atend ? P_HIKEY : P_FIRSTKEY; obti = (BTItem) PageGetItem(opage, PageGetItemId(opage, off)); @@ -924,18 +924,18 @@ _bt_minitem(Page opage, BlockNumber oblkno, int atend) * * if all keys are unique, 'first' will always be the same as 'last'. */ -static BTItem +static BTItem _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) { - BTPageState *state = (BTPageState *) pstate; - Buffer nbuf; - Page npage; - BTItem last_bti; - OffsetNumber first_off; - OffsetNumber last_off; - OffsetNumber off; - Size pgspc; - Size btisz; + BTPageState *state = (BTPageState *) pstate; + Buffer nbuf; + Page npage; + BTItem last_bti; + OffsetNumber first_off; + OffsetNumber last_off; + OffsetNumber off; + Size pgspc; + Size btisz; nbuf = state->btps_buf; npage = state->btps_page; @@ -948,12 +948,12 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) btisz = DOUBLEALIGN(btisz); if (pgspc < btisz) { - Buffer obuf = nbuf; - Page opage = npage; - OffsetNumber o, - n; - ItemId ii; - ItemId hii; + Buffer obuf = nbuf; + Page opage = npage; + OffsetNumber o, + n; + ItemId ii; + ItemId hii; _bt_blnewpage(index, &nbuf, &npage, flags); @@ -989,11 +989,11 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) #if 0 #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - BTItem tmpbti = + bool isnull; + BTItem tmpbti = (BTItem) PageGetItem(npage, PageGetItemId(npage, n)); - Datum d = index_getattr(&(tmpbti->bti_itup), 1, - index->rd_att, &isnull); + Datum d = index_getattr(&(tmpbti->bti_itup), 1, + index->rd_att, &isnull); printf("_bt_buildadd: moved <%x> to offset %d at level %d\n", d, n, state->btps_level); @@ -1026,8 +1026,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) * set the page (side link) pointers. */ { - BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage); - BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage); + BTPageOpaque oopaque = (BTPageOpaque) PageGetSpecialPointer(opage); + BTPageOpaque nopaque = (BTPageOpaque) PageGetSpecialPointer(npage); oopaque->btpo_next = BufferGetBlockNumber(nbuf); nopaque->btpo_prev = BufferGetBlockNumber(obuf); @@ -1047,7 +1047,7 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) */ if (state->btps_doupper) { - BTItem nbti; + BTItem nbti; if (state->btps_next == (BTPageState *) NULL) { @@ -1077,8 +1077,8 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) #if 0 #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_buildadd: inserted <%x> at offset %d at level %d\n", d, off, state->btps_level); @@ -1109,10 +1109,10 @@ _bt_buildadd(Relation index, void *pstate, BTItem bti, int flags) static void _bt_uppershutdown(Relation index, BTPageState * state) { - BTPageState *s; - BlockNumber blkno; - BTPageOpaque opaque; - BTItem bti; + BTPageState *s; + BlockNumber blkno; + BTPageOpaque opaque; + BTItem bti; for (s = state; s != (BTPageState *) NULL; s = s->btps_next) { @@ -1160,21 +1160,21 @@ _bt_uppershutdown(Relation index, BTPageState * state) static void _bt_merge(Relation index, BTSpool * btspool) { - BTPageState *state; - BTPriQueue q; - BTPriQueueElem e; - BTSortKey btsk; - BTItem bti; - BTTapeBlock *itape; - BTTapeBlock *otape; - char *tapepos[MAXTAPES]; - int tapedone[MAXTAPES]; - int t; - int goodtapes; - int npass; - int nruns; - Size btisz; - bool doleaf = false; + BTPageState *state; + BTPriQueue q; + BTPriQueueElem e; + BTSortKey btsk; + BTItem bti; + BTTapeBlock *itape; + BTTapeBlock *otape; + char *tapepos[MAXTAPES]; + int tapedone[MAXTAPES]; + int t; + int goodtapes; + int npass; + int nruns; + Size btisz; + bool doleaf = false; /* * initialize state needed for the merge into the btree leaf pages. @@ -1279,8 +1279,8 @@ _bt_merge(Relation index, BTSpool * btspool) _bt_buildadd(index, state, bti, BTP_LEAF); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into block %d\n", @@ -1308,8 +1308,8 @@ _bt_merge(Relation index, BTSpool * btspool) _bt_tapeadd(otape, bti, btisz); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(bti->bti_itup), 1, + bool isnull; + Datum d = index_getattr(&(bti->bti_itup), 1, index->rd_att, &isnull); printf("_bt_merge: [pass %d run %d] inserted <%x> from tape %d into output tape %d\n", @@ -1328,7 +1328,7 @@ _bt_merge(Relation index, BTSpool * btspool) itape = btspool->bts_itape[t]; if (!tapedone[t]) { - BTItem newbti = _bt_tapenext(itape, &tapepos[t]); + BTItem newbti = _bt_tapenext(itape, &tapepos[t]); if (newbti == (BTItem) NULL) { @@ -1347,7 +1347,7 @@ _bt_merge(Relation index, BTSpool * btspool) } if (newbti != (BTItem) NULL) { - BTPriQueueElem nexte; + BTPriQueueElem nexte; nexte.btpqe_tape = t; _bt_setsortkey(index, newbti, &(nexte.btpqe_item)); @@ -1397,12 +1397,12 @@ _bt_merge(Relation index, BTSpool * btspool) void _bt_upperbuild(Relation index) { - Buffer rbuf; - BlockNumber blk; - Page rpage; - BTPageOpaque ropaque; - BTPageState *state; - BTItem nbti; + Buffer rbuf; + BlockNumber blk; + Page rpage; + BTPageOpaque ropaque; + BTPageState *state; + BTItem nbti; /* * find the first leaf block. while we're at it, clear the BTP_ROOT @@ -1438,9 +1438,9 @@ _bt_upperbuild(Relation index) nbti = _bt_minitem(rpage, blk, P_RIGHTMOST(ropaque)); #if defined(FASTBUILD_DEBUG) && defined(FASTBUILD_MERGE) { - bool isnull; - Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att, - &isnull); + bool isnull; + Datum d = index_getattr(&(nbti->bti_itup), 1, index->rd_att, + &isnull); printf("_bt_upperbuild: inserting <%x> at %d\n", d, state->btps_level); diff --git a/src/backend/access/nbtree/nbtstrat.c b/src/backend/access/nbtree/nbtstrat.c index 5215d2000d8..6af9df2b65a 100644 --- a/src/backend/access/nbtree/nbtstrat.c +++ b/src/backend/access/nbtree/nbtstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.5 1997/09/07 04:39:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/Attic/nbtstrat.c,v 1.6 1997/09/08 02:20:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,7 +47,7 @@ static StrategyNumber BTNegateCommute[5] = { BTGreaterEqualStrategyNumber }; -static uint16 BTLessTermData[] = { /* XXX type clash */ +static uint16 BTLessTermData[] = { /* XXX type clash */ 2, BTLessStrategyNumber, SK_NEGATE, @@ -55,7 +55,7 @@ static uint16 BTLessTermData[] = { /* XXX type clash */ SK_NEGATE | SK_COMMUTE }; -static uint16 BTLessEqualTermData[] = { /* XXX type clash */ +static uint16 BTLessEqualTermData[] = { /* XXX type clash */ 2, BTLessEqualStrategyNumber, 0x0, @@ -63,7 +63,7 @@ static uint16 BTLessEqualTermData[] = { /* XXX type clash */ SK_COMMUTE }; -static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ +static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ 2, BTGreaterEqualStrategyNumber, 0x0, @@ -71,7 +71,7 @@ static uint16 BTGreaterEqualTermData[] = { /* XXX type clash */ SK_COMMUTE }; -static uint16 BTGreaterTermData[] = { /* XXX type clash */ +static uint16 BTGreaterTermData[] = { /* XXX type clash */ 2, BTGreaterStrategyNumber, SK_NEGATE, @@ -109,7 +109,7 @@ _bt_getstrat(Relation rel, AttrNumber attno, RegProcedure proc) { - StrategyNumber strat; + StrategyNumber strat; strat = RelationGetStrategy(rel, attno, &BTEvaluationData, proc); diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 096f1d2691e..0ee1ef9d321 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.12 1997/09/07 04:39:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.13 1997/09/08 02:21:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #include <catalog/pg_proc.h> #include <executor/execdebug.h> -extern int NIndexTupleProcessed; +extern int NIndexTupleProcessed; #ifndef HAVE_MEMMOVE @@ -35,14 +35,14 @@ extern int NIndexTupleProcessed; ScanKey _bt_mkscankey(Relation rel, IndexTuple itup) { - ScanKey skey; - TupleDesc itupdesc; - int natts; - int i; - Datum arg; - RegProcedure proc; - bool null; - bits16 flag; + ScanKey skey; + TupleDesc itupdesc; + int natts; + int i; + Datum arg; + RegProcedure proc; + bool null; + bits16 flag; natts = rel->rd_rel->relnatts; itupdesc = RelationGetTupleDescriptor(rel); @@ -78,7 +78,7 @@ _bt_freeskey(ScanKey skey) void _bt_freestack(BTStack stack) { - BTStack ostack; + BTStack ostack; while (stack != (BTStack) NULL) { @@ -99,18 +99,18 @@ _bt_freestack(BTStack stack) void _bt_orderkeys(Relation relation, BTScanOpaque so) { - ScanKey xform; - ScanKeyData *cur; - StrategyMap map; - int nbytes; - long test; - int i, - j; - int init[BTMaxStrategyNumber + 1]; - ScanKey key; - uint16 numberOfKeys = so->numberOfKeys; - uint16 new_numberOfKeys = 0; - AttrNumber attno = 1; + ScanKey xform; + ScanKeyData *cur; + StrategyMap map; + int nbytes; + long test; + int i, + j; + int init[BTMaxStrategyNumber + 1]; + ScanKey key; + uint16 numberOfKeys = so->numberOfKeys; + uint16 new_numberOfKeys = 0; + AttrNumber attno = 1; if (numberOfKeys < 1) return; @@ -169,8 +169,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) */ if (init[BTEqualStrategyNumber - 1]) { - ScanKeyData *eq, - *chk; + ScanKeyData *eq, + *chk; eq = &xform[BTEqualStrategyNumber - 1]; for (j = BTMaxStrategyNumber; --j >= 0;) @@ -192,8 +192,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) if (init[BTLessStrategyNumber - 1] && init[BTLessEqualStrategyNumber - 1]) { - ScanKeyData *lt, - *le; + ScanKeyData *lt, + *le; lt = &xform[BTLessStrategyNumber - 1]; le = &xform[BTLessEqualStrategyNumber - 1]; @@ -216,8 +216,8 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) if (init[BTGreaterStrategyNumber - 1] && init[BTGreaterEqualStrategyNumber - 1]) { - ScanKeyData *gt, - *ge; + ScanKeyData *gt, + *ge; gt = &xform[BTGreaterStrategyNumber - 1]; ge = &xform[BTGreaterEqualStrategyNumber - 1]; @@ -288,10 +288,10 @@ _bt_orderkeys(Relation relation, BTScanOpaque so) BTItem _bt_formitem(IndexTuple itup) { - int nbytes_btitem; - BTItem btitem; - Size tuplen; - extern Oid newoid(); + int nbytes_btitem; + BTItem btitem; + Size tuplen; + extern Oid newoid(); /* * see comments in btbuild @@ -318,7 +318,7 @@ _bt_formitem(IndexTuple itup) bool _bt_checkqual(IndexScanDesc scan, IndexTuple itup) { - BTScanOpaque so; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; if (so->numberOfKeys > 0) @@ -334,7 +334,7 @@ _bt_checkqual(IndexScanDesc scan, IndexTuple itup) bool _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz) { - BTScanOpaque so; + BTScanOpaque so; so = (BTScanOpaque) scan->opaque; if (keysz > 0 && so->numberOfKeys >= keysz) @@ -349,13 +349,13 @@ _bt_checkforkeys(IndexScanDesc scan, IndexTuple itup, Size keysz) bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok) { - BTScanOpaque so = (BTScanOpaque) scan->opaque; - Size keysz = so->numberOfKeys; - TupleDesc tupdesc; - ScanKey key; - Datum datum; - bool isNull; - int test; + BTScanOpaque so = (BTScanOpaque) scan->opaque; + Size keysz = so->numberOfKeys; + TupleDesc tupdesc; + ScanKey key; + Datum datum; + bool isNull; + int test; *keysok = 0; if (keysz == 0) diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c index eaf16c1ae9d..6a13b81a1f9 100644 --- a/src/backend/access/rtree/rtget.c +++ b/src/backend/access/rtree/rtget.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.8 1997/09/07 04:39:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.9 1997/09/08 02:21:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,19 +57,19 @@ rtgettuple(IndexScanDesc s, ScanDirection dir) return (res); } -static RetrieveIndexResult +static RetrieveIndexResult rtfirst(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; RTreePageOpaque po; RTreeScanOpaque so; - RTSTACK *stk; - BlockNumber blk; - IndexTuple it; + RTSTACK *stk; + BlockNumber blk; + IndexTuple it; b = ReadBuffer(s->relation, P_ROOT); p = BufferGetPage(b); @@ -140,19 +140,19 @@ rtfirst(IndexScanDesc s, ScanDirection dir) } } -static RetrieveIndexResult +static RetrieveIndexResult rtnext(IndexScanDesc s, ScanDirection dir) { - Buffer b; - Page p; - OffsetNumber n; - OffsetNumber maxoff; + Buffer b; + Page p; + OffsetNumber n; + OffsetNumber maxoff; RetrieveIndexResult res; RTreePageOpaque po; RTreeScanOpaque so; - RTSTACK *stk; - BlockNumber blk; - IndexTuple it; + RTSTACK *stk; + BlockNumber blk; + IndexTuple it; blk = ItemPointerGetBlockNumber(&(s->currentItemData)); n = ItemPointerGetOffsetNumber(&(s->currentItemData)); @@ -241,11 +241,11 @@ rtnext(IndexScanDesc s, ScanDirection dir) } } -static OffsetNumber +static OffsetNumber findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) { - OffsetNumber maxoff; - IndexTuple it; + OffsetNumber maxoff; + IndexTuple it; RTreePageOpaque po; RTreeScanOpaque so; @@ -295,11 +295,11 @@ findnext(IndexScanDesc s, Page p, OffsetNumber n, ScanDirection dir) return (n); } -static RetrieveIndexResult +static RetrieveIndexResult rtscancache(IndexScanDesc s, ScanDirection dir) { RetrieveIndexResult res; - ItemPointer ip; + ItemPointer ip; if (!(ScanDirectionIsNoMovement(dir) && ItemPointerIsValid(&(s->currentItemData)))) @@ -324,14 +324,14 @@ rtscancache(IndexScanDesc s, ScanDirection dir) * rtheapptr returns the item pointer to the tuple in the heap relation * for which itemp is the index relation item pointer. */ -static ItemPointer +static ItemPointer rtheapptr(Relation r, ItemPointer itemp) { - Buffer b; - Page p; - IndexTuple it; - ItemPointer ip; - OffsetNumber n; + Buffer b; + Page p; + IndexTuple it; + ItemPointer ip; + OffsetNumber n; ip = (ItemPointer) palloc(sizeof(ItemPointerData)); if (ItemPointerIsValid(itemp)) diff --git a/src/backend/access/rtree/rtproc.c b/src/backend/access/rtree/rtproc.c index 4b7a9f2a266..5f1d4846f6d 100644 --- a/src/backend/access/rtree/rtproc.c +++ b/src/backend/access/rtree/rtproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.8 1997/09/07 04:39:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtproc.c,v 1.9 1997/09/08 02:21:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,7 +25,7 @@ BOX * rt_box_union(BOX * a, BOX * b) { - BOX *n; + BOX *n; if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL) elog(WARN, "Cannot allocate box for union"); @@ -38,10 +38,10 @@ BOX return (n); } -BOX * +BOX * rt_box_inter(BOX * a, BOX * b) { - BOX *n; + BOX *n; if ((n = (BOX *) palloc(sizeof(*n))) == (BOX *) NULL) elog(WARN, "Cannot allocate box for union"); @@ -85,10 +85,10 @@ rt_bigbox_size(BOX * a, float *size) rt_box_size(a, size); } -POLYGON * +POLYGON * rt_poly_union(POLYGON * a, POLYGON * b) { - POLYGON *p; + POLYGON *p; p = (POLYGON *) PALLOCTYPE(POLYGON); @@ -108,8 +108,8 @@ rt_poly_union(POLYGON * a, POLYGON * b) void rt_poly_size(POLYGON * a, float *size) { - double xdim, - ydim; + double xdim, + ydim; size = (float *) palloc(sizeof(float)); if (a == (POLYGON *) NULL || @@ -127,10 +127,10 @@ rt_poly_size(POLYGON * a, float *size) return; } -POLYGON * +POLYGON * rt_poly_inter(POLYGON * a, POLYGON * b) { - POLYGON *p; + POLYGON *p; p = (POLYGON *) PALLOCTYPE(POLYGON); diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index ae92ea20136..8b1aa533e84 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.14 1997/09/07 04:39:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.15 1997/09/08 02:21:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,20 +34,20 @@ typedef struct SPLITVEC { - OffsetNumber *spl_left; - int spl_nleft; - char *spl_ldatum; - OffsetNumber *spl_right; - int spl_nright; - char *spl_rdatum; -} SPLITVEC; + OffsetNumber *spl_left; + int spl_nleft; + char *spl_ldatum; + OffsetNumber *spl_right; + int spl_nright; + char *spl_rdatum; +} SPLITVEC; typedef struct RTSTATE { - func_ptr unionFn; /* union function */ - func_ptr sizeFn; /* size function */ - func_ptr interFn; /* intersection function */ -} RTSTATE; + func_ptr unionFn; /* union function */ + func_ptr sizeFn; /* size function */ + func_ptr interFn; /* intersection function */ +} RTSTATE; /* non-export function prototypes */ static InsertIndexResult @@ -62,16 +62,16 @@ dosplit(Relation r, Buffer buffer, RTSTACK * stack, static void rtintinsert(Relation r, RTSTACK * stk, IndexTuple ltup, IndexTuple rtup, RTSTATE * rtstate); -static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt); +static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt); static void picksplit(Relation r, Page page, SPLITVEC * v, IndexTuple itup, RTSTATE * rtstate); -static void RTInitBuffer(Buffer b, uint32 f); +static void RTInitBuffer(Buffer b, uint32 f); static OffsetNumber choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate); -static int nospace(Page p, IndexTuple it); -static void initRtstate(RTSTATE * rtstate, Relation index); +static int nospace(Page p, IndexTuple it); +static void initRtstate(RTSTATE * rtstate, Relation index); void @@ -85,31 +85,31 @@ rtbuild(Relation heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - HeapScanDesc scan; - Buffer buffer; - AttrNumber i; - HeapTuple htup; - IndexTuple itup; - TupleDesc hd, - id; + HeapScanDesc scan; + Buffer buffer; + AttrNumber i; + HeapTuple htup; + IndexTuple itup; + TupleDesc hd, + id; InsertIndexResult res; - Datum *d; - bool *nulls; - int nb, - nh, - ni; + Datum *d; + bool *nulls; + int nb, + nh, + ni; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Oid hrelid, - irelid; - Node *pred, - *oldPred; - RTSTATE rtState; + Oid hrelid, + irelid; + Node *pred, + *oldPred; + RTSTATE rtState; initRtstate(&rtState, index); @@ -215,8 +215,8 @@ rtbuild(Relation heap, for (i = 1; i <= natts; i++) { - int attoff; - bool attnull; + int attoff; + bool attnull; /* * Offsets are from the start of the tuple, and are @@ -308,8 +308,8 @@ InsertIndexResult rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel) { InsertIndexResult res; - IndexTuple itup; - RTSTATE rtState; + IndexTuple itup; + RTSTATE rtState; /* generate an index tuple */ itup = index_formtuple(RelationGetTupleDescriptor(r), datum, nulls); @@ -323,18 +323,18 @@ rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation h return (res); } -static InsertIndexResult +static InsertIndexResult rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate) { - Page page; - Buffer buffer; - BlockNumber blk; - IndexTuple which; - OffsetNumber l; - RTSTACK *stack; + Page page; + Buffer buffer; + BlockNumber blk; + IndexTuple which; + OffsetNumber l; + RTSTACK *stack; InsertIndexResult res; RTreePageOpaque opaque; - char *datum; + char *datum; blk = P_ROOT; buffer = InvalidBuffer; @@ -353,8 +353,8 @@ rtdoinsert(Relation r, IndexTuple itup, RTSTATE * rtstate) opaque = (RTreePageOpaque) PageGetSpecialPointer(page); if (!(opaque->flags & F_LEAF)) { - RTSTACK *n; - ItemId iid; + RTSTACK *n; + ItemId iid; n = (RTSTACK *) palloc(sizeof(RTSTACK)); n->rts_parent = stack; @@ -414,12 +414,12 @@ rttighten(Relation r, int att_size, RTSTATE * rtstate) { - char *oldud; - char *tdatum; - Page p; - float old_size, - newd_size; - Buffer b; + char *oldud; + char *tdatum; + Page p; + float old_size, + newd_size; + Buffer b; if (stk == (RTSTACK *) NULL) return; @@ -437,7 +437,7 @@ rttighten(Relation r, if (newd_size != old_size) { - TupleDesc td = RelationGetTupleDescriptor(r); + TupleDesc td = RelationGetTupleDescriptor(r); if (td->attrs[0]->attlen < 0) { @@ -480,35 +480,35 @@ rttighten(Relation r, * his paper. The reason we chose it is that you can implement this * with less information about the data types on which you're operating. */ -static InsertIndexResult +static InsertIndexResult dosplit(Relation r, Buffer buffer, RTSTACK * stack, IndexTuple itup, RTSTATE * rtstate) { - Page p; - Buffer leftbuf, - rightbuf; - Page left, - right; - ItemId itemid; - IndexTuple item; - IndexTuple ltup, - rtup; - OffsetNumber maxoff; - OffsetNumber i; - OffsetNumber leftoff, - rightoff; - BlockNumber lbknum, - rbknum; - BlockNumber bufblock; + Page p; + Buffer leftbuf, + rightbuf; + Page left, + right; + ItemId itemid; + IndexTuple item; + IndexTuple ltup, + rtup; + OffsetNumber maxoff; + OffsetNumber i; + OffsetNumber leftoff, + rightoff; + BlockNumber lbknum, + rbknum; + BlockNumber bufblock; RTreePageOpaque opaque; - int blank; + int blank; InsertIndexResult res; - char *isnull; - SPLITVEC v; - TupleDesc tupDesc; + char *isnull; + SPLITVEC v; + TupleDesc tupDesc; isnull = (char *) palloc(r->rd_rel->relnatts); for (blank = 0; blank < r->rd_rel->relnatts; blank++) @@ -638,12 +638,12 @@ rtintinsert(Relation r, IndexTuple rtup, RTSTATE * rtstate) { - IndexTuple old; - Buffer b; - Page p; - char *ldatum, - *rdatum, - *newdatum; + IndexTuple old; + Buffer b; + Page p; + char *ldatum, + *rdatum, + *newdatum; InsertIndexResult res; if (stk == (RTSTACK *) NULL) @@ -698,8 +698,8 @@ rtintinsert(Relation r, static void rtnewroot(Relation r, IndexTuple lt, IndexTuple rt) { - Buffer b; - Page p; + Buffer b; + Page p; b = ReadBuffer(r, P_ROOT); RTInitBuffer(b, 0); @@ -718,33 +718,33 @@ picksplit(Relation r, IndexTuple itup, RTSTATE * rtstate) { - OffsetNumber maxoff; - OffsetNumber i, - j; - IndexTuple item_1, - item_2; - char *datum_alpha, - *datum_beta; - char *datum_l, - *datum_r; - char *union_d, - *union_dl, - *union_dr; - char *inter_d; - bool firsttime; - float size_alpha, - size_beta, - size_union, - size_inter; - float size_waste, - waste; - float size_l, - size_r; - int nbytes; - OffsetNumber seed_1 = 0, - seed_2 = 0; - OffsetNumber *left, - *right; + OffsetNumber maxoff; + OffsetNumber i, + j; + IndexTuple item_1, + item_2; + char *datum_alpha, + *datum_beta; + char *datum_l, + *datum_r; + char *union_d, + *union_dl, + *union_dr; + char *inter_d; + bool firsttime; + float size_alpha, + size_beta, + size_union, + size_inter; + float size_waste, + waste; + float size_l, + size_r; + int nbytes; + OffsetNumber seed_1 = 0, + seed_2 = 0; + OffsetNumber *left, + *right; maxoff = PageGetMaxOffsetNumber(page); @@ -886,8 +886,8 @@ static void RTInitBuffer(Buffer b, uint32 f) { RTreePageOpaque opaque; - Page page; - Size pageSize; + Page page; + Size pageSize; pageSize = BufferGetPageSize(b); @@ -899,18 +899,18 @@ RTInitBuffer(Buffer b, uint32 f) opaque->flags = f; } -static OffsetNumber +static OffsetNumber choose(Relation r, Page p, IndexTuple it, RTSTATE * rtstate) { - OffsetNumber maxoff; - OffsetNumber i; - char *ud, - *id; - char *datum; - float usize, - dsize; - OffsetNumber which; - float which_grow; + OffsetNumber maxoff; + OffsetNumber i; + char *ud, + *id; + char *datum; + float usize, + dsize; + OffsetNumber which; + float which_grow; id = ((char *) it) + sizeof(IndexTupleData); maxoff = PageGetMaxOffsetNumber(p); @@ -946,7 +946,7 @@ nospace(Page p, IndexTuple it) void freestack(RTSTACK * s) { - RTSTACK *p; + RTSTACK *p; while (s != (RTSTACK *) NULL) { @@ -956,13 +956,13 @@ freestack(RTSTACK * s) } } -char * +char * rtdelete(Relation r, ItemPointer tid) { - BlockNumber blkno; - OffsetNumber offnum; - Buffer buf; - Page page; + BlockNumber blkno; + OffsetNumber offnum; + Buffer buf; + Page page; /* must write-lock on delete */ RelationSetLockForWrite(r); @@ -988,11 +988,11 @@ rtdelete(Relation r, ItemPointer tid) static void initRtstate(RTSTATE * rtstate, Relation index) { - RegProcedure union_proc, - size_proc, - inter_proc; - func_ptr user_fn; - int pronargs; + RegProcedure union_proc, + size_proc, + inter_proc; + func_ptr user_fn; + int pronargs; union_proc = index_getprocid(index, 1, RT_UNION_PROC); size_proc = index_getprocid(index, 1, RT_SIZE_PROC); @@ -1011,18 +1011,18 @@ initRtstate(RTSTATE * rtstate, Relation index) void _rtdump(Relation r) { - Buffer buf; - Page page; - OffsetNumber offnum, - maxoff; - BlockNumber blkno; - BlockNumber nblocks; + Buffer buf; + Page page; + OffsetNumber offnum, + maxoff; + BlockNumber blkno; + BlockNumber nblocks; RTreePageOpaque po; - IndexTuple itup; - BlockNumber itblkno; - OffsetNumber itoffno; - char *datum; - char *itkey; + IndexTuple itup; + BlockNumber itblkno; + OffsetNumber itoffno; + char *datum; + char *itkey; nblocks = RelationGetNumberOfBlocks(r); for (blkno = 0; blkno < nblocks; blkno++) diff --git a/src/backend/access/rtree/rtscan.c b/src/backend/access/rtree/rtscan.c index 26590059d6c..2a4810ccae3 100644 --- a/src/backend/access/rtree/rtscan.c +++ b/src/backend/access/rtree/rtscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.11 1997/09/07 04:39:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtscan.c,v 1.12 1997/09/08 02:21:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,8 +28,8 @@ /* routines defined and used here */ -static void rtregscan(IndexScanDesc s); -static void rtdropscan(IndexScanDesc s); +static void rtregscan(IndexScanDesc s); +static void rtdropscan(IndexScanDesc s); static void rtadjone(IndexScanDesc s, int op, BlockNumber blkno, OffsetNumber offnum); @@ -52,9 +52,9 @@ adjustiptr(IndexScanDesc s, ItemPointer iptr, typedef struct RTScanListData { - IndexScanDesc rtsl_scan; + IndexScanDesc rtsl_scan; struct RTScanListData *rtsl_next; -} RTScanListData; +} RTScanListData; typedef RTScanListData *RTScanList; @@ -67,7 +67,7 @@ rtbeginscan(Relation r, uint16 nkeys, ScanKey key) { - IndexScanDesc s; + IndexScanDesc s; RelationSetLockForRead(r); s = RelationGetIndexScan(r, fromEnd, nkeys, key); @@ -80,8 +80,8 @@ void rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key) { RTreeScanOpaque p; - RegProcedure internal_proc; - int i; + RegProcedure internal_proc; + int i; if (!IndexScanIsValid(s)) { @@ -177,9 +177,9 @@ void rtmarkpos(IndexScanDesc s) { RTreeScanOpaque p; - RTSTACK *o, - *n, - *tmp; + RTSTACK *o, + *n, + *tmp; s->currentMarkData = s->currentItemData; p = (RTreeScanOpaque) s->opaque; @@ -210,9 +210,9 @@ void rtrestrpos(IndexScanDesc s) { RTreeScanOpaque p; - RTSTACK *o, - *n, - *tmp; + RTSTACK *o, + *n, + *tmp; s->currentItemData = s->currentMarkData; p = (RTreeScanOpaque) s->opaque; @@ -260,7 +260,7 @@ rtendscan(IndexScanDesc s) static void rtregscan(IndexScanDesc s) { - RTScanList l; + RTScanList l; l = (RTScanList) palloc(sizeof(RTScanListData)); l->rtsl_scan = s; @@ -271,8 +271,8 @@ rtregscan(IndexScanDesc s) static void rtdropscan(IndexScanDesc s) { - RTScanList l; - RTScanList prev; + RTScanList l; + RTScanList prev; prev = (RTScanList) NULL; @@ -297,8 +297,8 @@ rtdropscan(IndexScanDesc s) void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum) { - RTScanList l; - Oid relid; + RTScanList l; + Oid relid; relid = r->rd_id; for (l = RTScans; l != (RTScanList) NULL; l = l->rtsl_next) @@ -352,7 +352,7 @@ adjustiptr(IndexScanDesc s, BlockNumber blkno, OffsetNumber offnum) { - OffsetNumber curoff; + OffsetNumber curoff; RTreeScanOpaque so; if (ItemPointerIsValid(iptr)) @@ -364,39 +364,43 @@ adjustiptr(IndexScanDesc s, switch (op) { - case RTOP_DEL: - /* back up one if we need to */ - if (curoff >= offnum) - { - - if (curoff > FirstOffsetNumber) - { - /* just adjust the item pointer */ - ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); - } - else + case RTOP_DEL: + /* back up one if we need to */ + if (curoff >= offnum) { - /* remember that we're before the current tuple */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags |= RTS_CURBEFORE; + + if (curoff > FirstOffsetNumber) + { + /* just adjust the item pointer */ + ItemPointerSet(iptr, blkno, OffsetNumberPrev(curoff)); + } else - so->s_flags |= RTS_MRKBEFORE; + { + + /* + * remember that we're before the current + * tuple + */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags |= RTS_CURBEFORE; + else + so->s_flags |= RTS_MRKBEFORE; + } } - } - break; - - case RTOP_SPLIT: - /* back to start of page on split */ - ItemPointerSet(iptr, blkno, FirstOffsetNumber); - if (iptr == &(s->currentItemData)) - so->s_flags &= ~RTS_CURBEFORE; - else - so->s_flags &= ~RTS_MRKBEFORE; - break; - - default: - elog(WARN, "Bad operation in rtree scan adjust: %d", op); + break; + + case RTOP_SPLIT: + /* back to start of page on split */ + ItemPointerSet(iptr, blkno, FirstOffsetNumber); + if (iptr == &(s->currentItemData)) + so->s_flags &= ~RTS_CURBEFORE; + else + so->s_flags &= ~RTS_MRKBEFORE; + break; + + default: + elog(WARN, "Bad operation in rtree scan adjust: %d", op); } } } diff --git a/src/backend/access/rtree/rtstrat.c b/src/backend/access/rtree/rtstrat.c index c71059d3f09..028625d48a1 100644 --- a/src/backend/access/rtree/rtstrat.c +++ b/src/backend/access/rtree/rtstrat.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.7 1997/09/07 04:39:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtstrat.c,v 1.8 1997/09/08 02:21:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -118,7 +118,7 @@ static StrategyNumber RTNegateCommute[RTNStrategies] = { */ /* if you only have "contained-by", how do you determine equality? */ -static uint16 RTContainedByTermData[] = { +static uint16 RTContainedByTermData[] = { 2, /* make two comparisons */ RTContainedByStrategyNumber,/* use "a contained-by b" */ 0x0, /* without any magic */ @@ -127,7 +127,7 @@ static uint16 RTContainedByTermData[] = { }; /* if you only have "contains", how do you determine equality? */ -static uint16 RTContainsTermData[] = { +static uint16 RTContainsTermData[] = { 2, /* make two comparisons */ RTContainsStrategyNumber, /* use "a contains b" */ 0x0, /* without any magic */ @@ -204,7 +204,7 @@ static StrategyNumber RTOperMap[RTNStrategies] = { RTOverlapStrategyNumber }; -static StrategyNumber +static StrategyNumber RelationGetRTStrategy(Relation r, AttrNumber attnum, RegProcedure proc) @@ -231,8 +231,8 @@ RTMapOperator(Relation r, AttrNumber attnum, RegProcedure proc) { - StrategyNumber procstrat; - StrategyMap strategyMap; + StrategyNumber procstrat; + StrategyMap strategyMap; procstrat = RelationGetRTStrategy(r, attnum, proc); strategyMap = IndexStrategyGetStrategyMap(RelationGetIndexStrategy(r), diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index 6d721fe96af..03b82872fd6 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.10 1997/09/07 04:39:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.11 1997/09/08 02:21:14 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -26,9 +26,9 @@ #include <storage/spin.h> #include <commands/vacuum.h> -static int RecoveryCheckingEnabled(void); -static void TransRecover(Relation logRelation); -static bool TransactionLogTest(TransactionId transactionId, XidStatus status); +static int RecoveryCheckingEnabled(void); +static void TransRecover(Relation logRelation); +static bool TransactionLogTest(TransactionId transactionId, XidStatus status); static void TransactionLogUpdate(TransactionId transactionId, XidStatus status); @@ -40,18 +40,18 @@ TransactionLogUpdate(TransactionId transactionId, * ---------------- */ -Relation LogRelation = (Relation) NULL; -Relation TimeRelation = (Relation) NULL; -Relation VariableRelation = (Relation) NULL; +Relation LogRelation = (Relation) NULL; +Relation TimeRelation = (Relation) NULL; +Relation VariableRelation = (Relation) NULL; /* ---------------- * global variables holding cached transaction id's and statuses. * ---------------- */ -TransactionId cachedGetCommitTimeXid; -AbsoluteTime cachedGetCommitTime; -TransactionId cachedTestXid; -XidStatus cachedTestXidStatus; +TransactionId cachedGetCommitTimeXid; +AbsoluteTime cachedGetCommitTime; +TransactionId cachedTestXid; +XidStatus cachedTestXidStatus; /* ---------------- * transaction system constants @@ -65,11 +65,11 @@ XidStatus cachedTestXidStatus; * FirstTransactionId. -cim 3/23/90 * ---------------------------------------------------------------- */ -TransactionId NullTransactionId = (TransactionId) 0; +TransactionId NullTransactionId = (TransactionId) 0; -TransactionId AmiTransactionId = (TransactionId) 512; +TransactionId AmiTransactionId = (TransactionId) 512; -TransactionId FirstTransactionId = (TransactionId) 514; +TransactionId FirstTransactionId = (TransactionId) 514; /* ---------------- * transaction recovery state variables @@ -83,19 +83,19 @@ TransactionId FirstTransactionId = (TransactionId) 514; * goes from zero to one. -cim 3/21/90 * ---------------- */ -int RecoveryCheckingEnableState = 0; +int RecoveryCheckingEnableState = 0; /* ------------------ * spinlock for oid generation * ----------------- */ -extern int OidGenLockId; +extern int OidGenLockId; /* ---------------- * globals that must be reset at abort * ---------------- */ -extern bool BuildingBtree; +extern bool BuildingBtree; /* ---------------- @@ -134,14 +134,14 @@ SetRecoveryCheckingEnabled(bool state) * -------------------------------- */ -static bool /* true/false: does transaction id have +static bool /* true/false: does transaction id have * specified status? */ TransactionLogTest(TransactionId transactionId, /* transaction id to test */ XidStatus status) /* transaction status */ { - BlockNumber blockNumber; - XidStatus xidstatus; /* recorded status of xid */ - bool fail = false; /* success/failure */ + BlockNumber blockNumber; + XidStatus xidstatus; /* recorded status of xid */ + bool fail = false; /* success/failure */ /* ---------------- * during initialization consider all transactions @@ -202,9 +202,9 @@ static void TransactionLogUpdate(TransactionId transactionId, /* trans id to update */ XidStatus status) /* new trans status */ { - BlockNumber blockNumber; - bool fail = false; /* success/failure */ - AbsoluteTime currentTime;/* time of this transaction */ + BlockNumber blockNumber; + bool fail = false; /* success/failure */ + AbsoluteTime currentTime; /* time of this transaction */ /* ---------------- * during initialization we don't record any updates. @@ -276,9 +276,9 @@ AbsoluteTime /* commit time of transaction id */ TransactionIdGetCommitTime(TransactionId transactionId) /* transaction id to * test */ { - BlockNumber blockNumber; - AbsoluteTime commitTime; /* commit time */ - bool fail = false; /* success/failure */ + BlockNumber blockNumber; + AbsoluteTime commitTime; /* commit time */ + bool fail = false; /* success/failure */ /* ---------------- * return invalid if we aren't running yet... @@ -471,9 +471,9 @@ TransRecover(Relation logRelation) void InitializeTransactionLog(void) { - Relation logRelation; - Relation timeRelation; - MemoryContext oldContext; + Relation logRelation; + Relation timeRelation; + MemoryContext oldContext; /* ---------------- * don't do anything during bootstrapping diff --git a/src/backend/access/transam/transsup.c b/src/backend/access/transam/transsup.c index 9809190c942..acdfe93ea90 100644 --- a/src/backend/access/transam/transsup.c +++ b/src/backend/access/transam/transsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.10 1997/09/07 04:39:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/transsup.c,v 1.11 1997/09/08 02:21:18 momjian Exp $ * * NOTES * This file contains support functions for the high @@ -63,7 +63,7 @@ TransComputeBlockNumber(Relation relation, /* relation to test */ * test */ BlockNumber * blockNumberOutP) { - long itemsPerBlock = 0; + long itemsPerBlock = 0; /* ---------------- * we calculate the block number of our transaction @@ -108,17 +108,17 @@ TransComputeBlockNumber(Relation relation, /* relation to test */ */ #ifdef NOT_USED -static XidStatus +static XidStatus TransBlockGetLastTransactionIdStatus(Block tblock, TransactionId baseXid, TransactionId * returnXidP) { - Index index; - Index maxIndex; - bits8 bit1; - bits8 bit2; - BitIndex offset; - XidStatus xstatus; + Index index; + Index maxIndex; + bits8 bit1; + bits8 bit2; + BitIndex offset; + XidStatus xstatus; /* ---------------- * sanity check @@ -188,14 +188,14 @@ TransBlockGetLastTransactionIdStatus(Block tblock, * -------------------------------- */ -static XidStatus +static XidStatus TransBlockGetXidStatus(Block tblock, TransactionId transactionId) { - Index index; - bits8 bit1; - bits8 bit2; - BitIndex offset; + Index index; + bits8 bit1; + bits8 bit2; + BitIndex offset; /* ---------------- * sanity check @@ -245,8 +245,8 @@ TransBlockSetXidStatus(Block tblock, TransactionId transactionId, XidStatus xstatus) { - Index index; - BitIndex offset; + Index index; + BitIndex offset; /* ---------------- * sanity check @@ -275,23 +275,23 @@ TransBlockSetXidStatus(Block tblock, */ switch (xstatus) { - case XID_COMMIT: /* set 10 */ - BitArraySetBit((BitArray) tblock, offset); - BitArrayClearBit((BitArray) tblock, offset + 1); - break; - case XID_ABORT: /* set 01 */ - BitArrayClearBit((BitArray) tblock, offset); - BitArraySetBit((BitArray) tblock, offset + 1); - break; - case XID_INPROGRESS: /* set 00 */ - BitArrayClearBit((BitArray) tblock, offset); - BitArrayClearBit((BitArray) tblock, offset + 1); - break; - default: - elog(NOTICE, - "TransBlockSetXidStatus: invalid status: %d (ignored)", - xstatus); - break; + case XID_COMMIT: /* set 10 */ + BitArraySetBit((BitArray) tblock, offset); + BitArrayClearBit((BitArray) tblock, offset + 1); + break; + case XID_ABORT: /* set 01 */ + BitArrayClearBit((BitArray) tblock, offset); + BitArraySetBit((BitArray) tblock, offset + 1); + break; + case XID_INPROGRESS: /* set 00 */ + BitArrayClearBit((BitArray) tblock, offset); + BitArrayClearBit((BitArray) tblock, offset + 1); + break; + default: + elog(NOTICE, + "TransBlockSetXidStatus: invalid status: %d (ignored)", + xstatus); + break; } } @@ -302,12 +302,12 @@ TransBlockSetXidStatus(Block tblock, * specified transaction id in the trans block. * -------------------------------- */ -static AbsoluteTime +static AbsoluteTime TransBlockGetCommitTime(Block tblock, TransactionId transactionId) { - Index index; - AbsoluteTime *timeArray; + Index index; + AbsoluteTime *timeArray; /* ---------------- * sanity check @@ -348,8 +348,8 @@ TransBlockSetCommitTime(Block tblock, TransactionId transactionId, AbsoluteTime commitTime) { - Index index; - AbsoluteTime *timeArray; + Index index; + AbsoluteTime *timeArray; /* ---------------- * sanity check @@ -394,10 +394,10 @@ TransBlockNumberGetXidStatus(Relation relation, TransactionId xid, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xstatus */ - XidStatus xstatus; /* recorded status of xid */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xstatus */ + XidStatus xstatus; /* recorded status of xid */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY place a read lock on the log relation @@ -451,9 +451,9 @@ TransBlockNumberSetXidStatus(Relation relation, XidStatus xstatus, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xstatus */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xstatus */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY gain exclusive access to the log relation @@ -504,10 +504,10 @@ TransBlockNumberGetCommitTime(Relation relation, TransactionId xid, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ - AbsoluteTime xtime; /* commit time */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing commit time */ + bool localfail; /* bool used if failP = NULL */ + AbsoluteTime xtime; /* commit time */ /* ---------------- * SOMEDAY place a read lock on the time relation @@ -565,9 +565,9 @@ TransBlockNumberSetCommitTime(Relation relation, AbsoluteTime xtime, bool * failP) { - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing commit time */ - bool localfail; /* bool used if failP = NULL */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing commit time */ + bool localfail; /* bool used if failP = NULL */ /* ---------------- * SOMEDAY gain exclusive access to the time relation @@ -620,11 +620,11 @@ TransGetLastRecordedTransaction(Relation relation, * id */ bool * failP) { - BlockNumber blockNumber;/* block number */ - Buffer buffer; /* buffer associated with block */ - Block block; /* block containing xid status */ - BlockNumber n; /* number of blocks in the relation */ - TransactionId baseXid; + BlockNumber blockNumber; /* block number */ + Buffer buffer; /* buffer associated with block */ + Block block; /* block containing xid status */ + BlockNumber n; /* number of blocks in the relation */ + TransactionId baseXid; (*failP) = false; diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 8b4b8557eb2..fb44b210bed 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.10 1997/09/07 04:39:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.11 1997/09/08 02:21:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,18 +20,18 @@ #include <access/heapam.h> #include <catalog/catname.h> -static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size); -static void VariableRelationGetNextOid(Oid * oid_return); -static void VariableRelationGetNextXid(TransactionId * xidP); -static void VariableRelationPutLastXid(TransactionId xid); -static void VariableRelationPutNextOid(Oid * oidP); -static void VariableRelationGetLastXid(TransactionId * xidP); +static void GetNewObjectIdBlock(Oid * oid_return, int oid_block_size); +static void VariableRelationGetNextOid(Oid * oid_return); +static void VariableRelationGetNextXid(TransactionId * xidP); +static void VariableRelationPutLastXid(TransactionId xid); +static void VariableRelationPutNextOid(Oid * oidP); +static void VariableRelationGetLastXid(TransactionId * xidP); /* --------------------- * spin lock for oid generation * --------------------- */ -int OidGenLockId; +int OidGenLockId; /* ---------------------------------------------------------------- * variable relation query/update routines @@ -45,7 +45,7 @@ int OidGenLockId; static void VariableRelationGetNextXid(TransactionId * xidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -87,7 +87,7 @@ VariableRelationGetNextXid(TransactionId * xidP) static void VariableRelationGetLastXid(TransactionId * xidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -130,9 +130,9 @@ VariableRelationGetLastXid(TransactionId * xidP) void VariableRelationPutNextXid(TransactionId xid) { - Buffer buf; + Buffer buf; VariableRelationContents var; - int flushmode; + int flushmode; /* ---------------- * We assume that a spinlock has been acquire to guarantee @@ -176,7 +176,7 @@ VariableRelationPutNextXid(TransactionId xid) static void VariableRelationPutLastXid(TransactionId xid) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -219,7 +219,7 @@ VariableRelationPutLastXid(TransactionId xid) static void VariableRelationGetNextOid(Oid * oid_return) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -289,7 +289,7 @@ VariableRelationGetNextOid(Oid * oid_return) static void VariableRelationPutNextOid(Oid * oidP) { - Buffer buf; + Buffer buf; VariableRelationContents var; /* ---------------- @@ -383,13 +383,13 @@ VariableRelationPutNextOid(Oid * oidP) #define VAR_XID_PREFETCH 32 -static int prefetched_xid_count = 0; +static int prefetched_xid_count = 0; static TransactionId next_prefetched_xid; void GetNewTransactionId(TransactionId * xid) { - TransactionId nextid; + TransactionId nextid; /* ---------------- * during bootstrap initialization, we return the special @@ -457,7 +457,7 @@ GetNewTransactionId(TransactionId * xid) void UpdateLastCommittedXid(TransactionId xid) { - TransactionId lastid; + TransactionId lastid; /* @@ -501,7 +501,7 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object * id */ int oid_block_size) /* number of oids desired */ { - Oid nextoid; + Oid nextoid; /* ---------------- * SOMEDAY obtain exclusive access to the variable relation page @@ -554,8 +554,8 @@ GetNewObjectIdBlock(Oid * oid_return, /* place to return the new object #define VAR_OID_PREFETCH 32 -static int prefetched_oid_count = 0; -static Oid next_prefetched_oid; +static int prefetched_oid_count = 0; +static Oid next_prefetched_oid; void GetNewObjectId(Oid * oid_return)/* place to return the new object id */ @@ -568,7 +568,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */ if (prefetched_oid_count == 0) { - int oid_block_size = VAR_OID_PREFETCH; + int oid_block_size = VAR_OID_PREFETCH; /* ---------------- * during bootstrap time, we want to allocate oids @@ -609,7 +609,7 @@ GetNewObjectId(Oid * oid_return)/* place to return the new object id */ void CheckMaxObjectId(Oid assigned_oid) { - Oid pass_oid; + Oid pass_oid; if (prefetched_oid_count == 0) /* make sure next/max is set, or diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index da32570d87b..b6ff2dd2963 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.14 1997/09/07 04:39:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.15 1997/09/08 02:21:22 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -151,20 +151,20 @@ #include <commands/async.h> #include <commands/sequence.h> -static void AbortTransaction(void); -static void AtAbort_Cache(void); -static void AtAbort_Locks(void); -static void AtAbort_Memory(void); -static void AtCommit_Cache(void); -static void AtCommit_Locks(void); -static void AtCommit_Memory(void); -static void AtStart_Cache(void); -static void AtStart_Locks(void); -static void AtStart_Memory(void); -static void CommitTransaction(void); -static void RecordTransactionAbort(void); -static void RecordTransactionCommit(void); -static void StartTransaction(void); +static void AbortTransaction(void); +static void AtAbort_Cache(void); +static void AtAbort_Locks(void); +static void AtAbort_Memory(void); +static void AtCommit_Cache(void); +static void AtCommit_Locks(void); +static void AtCommit_Memory(void); +static void AtStart_Cache(void); +static void AtStart_Locks(void); +static void AtStart_Memory(void); +static void CommitTransaction(void); +static void RecordTransactionAbort(void); +static void RecordTransactionCommit(void); +static void StartTransaction(void); /* ---------------- * global variables holding the current transaction state. @@ -202,17 +202,17 @@ TransactionState CurrentTransactionState = * V1 transaction system. -cim 3/18/90 * ---------------- */ -TransactionId DisabledTransactionId = (TransactionId) - 1; +TransactionId DisabledTransactionId = (TransactionId) - 1; -CommandId DisabledCommandId = (CommandId) - 1; +CommandId DisabledCommandId = (CommandId) - 1; -AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */ +AbsoluteTime DisabledStartTime = (AbsoluteTime) BIG_ABSTIME; /* 1073741823; */ /* ---------------- * overflow flag * ---------------- */ -bool CommandIdCounterOverflowFlag; +bool CommandIdCounterOverflowFlag; /* ---------------- * catalog creation transaction bootstrapping flag. @@ -220,7 +220,7 @@ bool CommandIdCounterOverflowFlag; * state stuff. -cim 3/19/90 * ---------------- */ -bool AMI_OVERRIDE = false; +bool AMI_OVERRIDE = false; /* ---------------------------------------------------------------- * transaction state accessors @@ -239,7 +239,7 @@ bool AMI_OVERRIDE = false; * only do writes as necessary. * -------------------------------- */ -static int TransactionFlushState = 1; +static int TransactionFlushState = 1; int TransactionFlushEnabled(void) @@ -270,18 +270,18 @@ IsTransactionState(void) switch (s->state) { - case TRANS_DEFAULT: - return false; - case TRANS_START: - return true; - case TRANS_INPROGRESS: - return true; - case TRANS_COMMIT: - return true; - case TRANS_ABORT: - return true; - case TRANS_DISABLED: - return false; + case TRANS_DEFAULT: + return false; + case TRANS_START: + return true; + case TRANS_INPROGRESS: + return true; + case TRANS_COMMIT: + return true; + case TRANS_ABORT: + return true; + case TRANS_DISABLED: + return false; } /* @@ -317,7 +317,7 @@ IsAbortedTransactionBlockState() * themselves. * -------------------------------- */ -int SavedTransactionState; +int SavedTransactionState; void OverrideTransactionSystem(bool flag) @@ -564,8 +564,8 @@ AtStart_Locks() static void AtStart_Memory() { - Portal portal; - MemoryContext portalContext; + Portal portal; + MemoryContext portalContext; /* ---------------- * get the blank portal and its memory context @@ -601,8 +601,8 @@ AtStart_Memory() static void RecordTransactionCommit() { - TransactionId xid; - int leak; + TransactionId xid; + int leak; /* ---------------- * get the current transaction id @@ -701,7 +701,7 @@ AtCommit_Memory() static void RecordTransactionAbort() { - TransactionId xid; + TransactionId xid; /* ---------------- * get the current transaction id @@ -994,73 +994,73 @@ StartTransactionCommand() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual start transaction. - * ---------------- - */ - case TBLOCK_DEFAULT: - StartTransaction(); - break; - - /* ---------------- - * We should never experience this -- if we do it - * means the BEGIN state was not changed in the previous - * CommitTransactionCommand(). If we get it, we print - * a warning and change to the in-progress state. - * ---------------- - */ - case TBLOCK_BEGIN: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN"); - s->blockState = TBLOCK_INPROGRESS; - break; - - /* ---------------- - * This is the case when are somewhere in a transaction - * block and about to start a new command. For now we - * do nothing but someday we may do command-local resource - * initialization. - * ---------------- - */ - case TBLOCK_INPROGRESS: - break; - - /* ---------------- - * As with BEGIN, we should never experience this -- - * if we do it means the END state was not changed in the - * previous CommitTransactionCommand(). If we get it, we - * print a warning, commit the transaction, start a new - * transaction and change to the default state. - * ---------------- - */ - case TBLOCK_END: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END"); - s->blockState = TBLOCK_DEFAULT; - CommitTransaction(); - StartTransaction(); - break; - - /* ---------------- - * Here we are in the middle of a transaction block but - * one of the commands caused an abort so we do nothing - * but remain in the abort state. Eventually we will get - * to the "END TRANSACTION" which will set things straight. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * This means we somehow aborted and the last call to - * CommitTransactionCommand() didn't clear the state so - * we remain in the ENDABORT state and mabey next time - * we get to CommitTransactionCommand() the state will - * get reset to default. - * ---------------- - */ - case TBLOCK_ENDABORT: - elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT"); - break; + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual start transaction. + * ---------------- + */ + case TBLOCK_DEFAULT: + StartTransaction(); + break; + + /* ---------------- + * We should never experience this -- if we do it + * means the BEGIN state was not changed in the previous + * CommitTransactionCommand(). If we get it, we print + * a warning and change to the in-progress state. + * ---------------- + */ + case TBLOCK_BEGIN: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_BEGIN"); + s->blockState = TBLOCK_INPROGRESS; + break; + + /* ---------------- + * This is the case when are somewhere in a transaction + * block and about to start a new command. For now we + * do nothing but someday we may do command-local resource + * initialization. + * ---------------- + */ + case TBLOCK_INPROGRESS: + break; + + /* ---------------- + * As with BEGIN, we should never experience this -- + * if we do it means the END state was not changed in the + * previous CommitTransactionCommand(). If we get it, we + * print a warning, commit the transaction, start a new + * transaction and change to the default state. + * ---------------- + */ + case TBLOCK_END: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_END"); + s->blockState = TBLOCK_DEFAULT; + CommitTransaction(); + StartTransaction(); + break; + + /* ---------------- + * Here we are in the middle of a transaction block but + * one of the commands caused an abort so we do nothing + * but remain in the abort state. Eventually we will get + * to the "END TRANSACTION" which will set things straight. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * This means we somehow aborted and the last call to + * CommitTransactionCommand() didn't clear the state so + * we remain in the ENDABORT state and mabey next time + * we get to CommitTransactionCommand() the state will + * get reset to default. + * ---------------- + */ + case TBLOCK_ENDABORT: + elog(NOTICE, "StartTransactionCommand: unexpected TBLOCK_ENDABORT"); + break; } } @@ -1075,75 +1075,75 @@ CommitTransactionCommand() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual transaction commit - * ---------------- - */ - case TBLOCK_DEFAULT: - CommitTransaction(); - break; - - /* ---------------- - * This is the case right after we get a "BEGIN TRANSACTION" - * command, but the user hasn't done anything else yet, so - * we change to the "transaction block in progress" state - * and return. - * ---------------- - */ - case TBLOCK_BEGIN: - s->blockState = TBLOCK_INPROGRESS; - break; - - /* ---------------- - * This is the case when we have finished executing a command - * someplace within a transaction block. We increment the - * command counter and return. Someday we may free resources - * local to the command. - * - * That someday is today, at least for memory allocated by - * command in the BlankPortal' HeapMemory context. - * - vadim 03/25/97 - * ---------------- - */ - case TBLOCK_INPROGRESS: - CommandCounterIncrement(); + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual transaction commit + * ---------------- + */ + case TBLOCK_DEFAULT: + CommitTransaction(); + break; + + /* ---------------- + * This is the case right after we get a "BEGIN TRANSACTION" + * command, but the user hasn't done anything else yet, so + * we change to the "transaction block in progress" state + * and return. + * ---------------- + */ + case TBLOCK_BEGIN: + s->blockState = TBLOCK_INPROGRESS; + break; + + /* ---------------- + * This is the case when we have finished executing a command + * someplace within a transaction block. We increment the + * command counter and return. Someday we may free resources + * local to the command. + * + * That someday is today, at least for memory allocated by + * command in the BlankPortal' HeapMemory context. + * - vadim 03/25/97 + * ---------------- + */ + case TBLOCK_INPROGRESS: + CommandCounterIncrement(); #ifdef TBL_FREE_CMD_MEMORY - EndPortalAllocMode(); - StartPortalAllocMode(DefaultAllocMode, 0); + EndPortalAllocMode(); + StartPortalAllocMode(DefaultAllocMode, 0); #endif - break; - - /* ---------------- - * This is the case when we just got the "END TRANSACTION" - * statement, so we go back to the default state and - * commit the transaction. - * ---------------- - */ - case TBLOCK_END: - s->blockState = TBLOCK_DEFAULT; - CommitTransaction(); - break; - - /* ---------------- - * Here we are in the middle of a transaction block but - * one of the commands caused an abort so we do nothing - * but remain in the abort state. Eventually we will get - * to the "END TRANSACTION" which will set things straight. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * Here we were in an aborted transaction block which - * just processed the "END TRANSACTION" command from the - * user, so now we return the to default state. - * ---------------- - */ - case TBLOCK_ENDABORT: - s->blockState = TBLOCK_DEFAULT; - break; + break; + + /* ---------------- + * This is the case when we just got the "END TRANSACTION" + * statement, so we go back to the default state and + * commit the transaction. + * ---------------- + */ + case TBLOCK_END: + s->blockState = TBLOCK_DEFAULT; + CommitTransaction(); + break; + + /* ---------------- + * Here we are in the middle of a transaction block but + * one of the commands caused an abort so we do nothing + * but remain in the abort state. Eventually we will get + * to the "END TRANSACTION" which will set things straight. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * Here we were in an aborted transaction block which + * just processed the "END TRANSACTION" command from the + * user, so now we return the to default state. + * ---------------- + */ + case TBLOCK_ENDABORT: + s->blockState = TBLOCK_DEFAULT; + break; } } @@ -1158,71 +1158,71 @@ AbortCurrentTransaction() switch (s->blockState) { - /* ---------------- - * if we aren't in a transaction block, we - * just do our usual abort transaction. - * ---------------- - */ - case TBLOCK_DEFAULT: - AbortTransaction(); - break; - - /* ---------------- - * If we are in the TBLOCK_BEGIN it means something - * screwed up right after reading "BEGIN TRANSACTION" - * so we enter the abort state. Eventually an "END - * TRANSACTION" will fix things. - * ---------------- - */ - case TBLOCK_BEGIN: - s->blockState = TBLOCK_ABORT; - AbortTransaction(); - break; - - /* ---------------- - * This is the case when are somewhere in a transaction - * block which aborted so we abort the transaction and - * set the ABORT state. Eventually an "END TRANSACTION" - * will fix things and restore us to a normal state. - * ---------------- - */ - case TBLOCK_INPROGRESS: - s->blockState = TBLOCK_ABORT; - AbortTransaction(); - break; - - /* ---------------- - * Here, the system was fouled up just after the - * user wanted to end the transaction block so we - * abort the transaction and put us back into the - * default state. - * ---------------- - */ - case TBLOCK_END: - s->blockState = TBLOCK_DEFAULT; - AbortTransaction(); - break; - - /* ---------------- - * Here, we are already in an aborted transaction - * state and are waiting for an "END TRANSACTION" to - * come along and lo and behold, we abort again! - * So we just remain in the abort state. - * ---------------- - */ - case TBLOCK_ABORT: - break; - - /* ---------------- - * Here we were in an aborted transaction block which - * just processed the "END TRANSACTION" command but somehow - * aborted again.. since we must have done the abort - * processing, we return to the default state. - * ---------------- - */ - case TBLOCK_ENDABORT: - s->blockState = TBLOCK_DEFAULT; - break; + /* ---------------- + * if we aren't in a transaction block, we + * just do our usual abort transaction. + * ---------------- + */ + case TBLOCK_DEFAULT: + AbortTransaction(); + break; + + /* ---------------- + * If we are in the TBLOCK_BEGIN it means something + * screwed up right after reading "BEGIN TRANSACTION" + * so we enter the abort state. Eventually an "END + * TRANSACTION" will fix things. + * ---------------- + */ + case TBLOCK_BEGIN: + s->blockState = TBLOCK_ABORT; + AbortTransaction(); + break; + + /* ---------------- + * This is the case when are somewhere in a transaction + * block which aborted so we abort the transaction and + * set the ABORT state. Eventually an "END TRANSACTION" + * will fix things and restore us to a normal state. + * ---------------- + */ + case TBLOCK_INPROGRESS: + s->blockState = TBLOCK_ABORT; + AbortTransaction(); + break; + + /* ---------------- + * Here, the system was fouled up just after the + * user wanted to end the transaction block so we + * abort the transaction and put us back into the + * default state. + * ---------------- + */ + case TBLOCK_END: + s->blockState = TBLOCK_DEFAULT; + AbortTransaction(); + break; + + /* ---------------- + * Here, we are already in an aborted transaction + * state and are waiting for an "END TRANSACTION" to + * come along and lo and behold, we abort again! + * So we just remain in the abort state. + * ---------------- + */ + case TBLOCK_ABORT: + break; + + /* ---------------- + * Here we were in an aborted transaction block which + * just processed the "END TRANSACTION" command but somehow + * aborted again.. since we must have done the abort + * processing, we return to the default state. + * ---------------- + */ + case TBLOCK_ENDABORT: + s->blockState = TBLOCK_DEFAULT; + break; } } diff --git a/src/backend/access/transam/xid.c b/src/backend/access/transam/xid.c index 910d6ac7320..9cfc8235d43 100644 --- a/src/backend/access/transam/xid.c +++ b/src/backend/access/transam/xid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.8 1997/09/07 04:39:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/Attic/xid.c,v 1.9 1997/09/08 02:21:24 momjian Exp $ * * OLD COMMENTS * XXX WARNING @@ -50,11 +50,11 @@ xidin(char *representation) } /* XXX char16 name for catalogs */ -char * +char * xidout(TransactionId transactionId) { /* return(TransactionIdFormString(transactionId)); */ - char *representation; + char *representation; /* maximum 32 bit unsigned integer representation takes 10 chars */ representation = palloc(11); diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 9fd4bf719b3..f96abbd4cb5 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -7,7 +7,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.22 1997/09/07 04:39:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.23 1997/09/08 02:21:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -103,14 +103,14 @@ #define ALLOC(t, c) (t *)calloc((unsigned)(c), sizeof(t)) #define FIRST_TYPE_OID 16 /* OID of the first type */ -extern int Int_yyparse(void); +extern int Int_yyparse(void); static hashnode *AddStr(char *str, int strlength, int mderef); static AttributeTupleForm AllocateAttribute(void); -static bool BootstrapAlreadySeen(Oid id); -static int CompHash(char *str, int len); +static bool BootstrapAlreadySeen(Oid id); +static int CompHash(char *str, int len); static hashnode *FindStr(char *str, int length, hashnode * mderef); -static int gettype(char *type); -static void cleanup(void); +static int gettype(char *type); +static void cleanup(void); /* ---------------- * global variables @@ -134,11 +134,10 @@ static void cleanup(void); #define NUMSQR 529 #define NUMCUBE 12167 -char *strtable[STRTABLESIZE]; -hashnode *hashtable[HASHTABLESIZE]; +char *strtable[STRTABLESIZE]; +hashnode *hashtable[HASHTABLESIZE]; -static int strtable_end = -1; /* Tells us last occupied string - * space */ +static int strtable_end = -1; /* Tells us last occupied string space */ /*- * Basic information associated with each type. This is used before @@ -150,12 +149,12 @@ static int strtable_end = -1; /* Tells us last occupied string */ struct typinfo { - char name[NAMEDATALEN]; - Oid oid; - Oid elem; - int16 len; - Oid inproc; - Oid outproc; + char name[NAMEDATALEN]; + Oid oid; + Oid elem; + int16 len; + Oid inproc; + Oid outproc; }; static struct typinfo Procid[] = { @@ -180,29 +179,29 @@ static struct typinfo Procid[] = { {"_aclitem", 1034, 1033, -1, F_ARRAY_IN, F_ARRAY_OUT} }; -static int n_types = sizeof(Procid) / sizeof(struct typinfo); +static int n_types = sizeof(Procid) / sizeof(struct typinfo); struct typmap { /* a hack */ - Oid am_oid; + Oid am_oid; TypeTupleFormData am_typ; }; static struct typmap **Typ = (struct typmap **) NULL; static struct typmap *Ap = (struct typmap *) NULL; -static int Warnings = 0; -static char Blanks[MAXATTR]; +static int Warnings = 0; +static char Blanks[MAXATTR]; -static char *relname; /* current relation name */ +static char *relname; /* current relation name */ AttributeTupleForm attrtypes[MAXATTR]; /* points to attribute info */ -static char *values[MAXATTR];/* cooresponding attribute values */ -int numattr; /* number of attributes for cur. rel */ -extern int fsyncOff; /* do not fsync the database */ +static char *values[MAXATTR]; /* cooresponding attribute values */ +int numattr; /* number of attributes for cur. rel */ +extern int fsyncOff; /* do not fsync the database */ #ifndef HAVE_SIGSETJMP -static jmp_buf Warn_restart; +static jmp_buf Warn_restart; #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp @@ -211,12 +210,12 @@ static sigjmp_buf Warn_restart; #endif -int DebugMode; +int DebugMode; static GlobalMemory nogc = (GlobalMemory) NULL; /* special no-gc mem * context */ -extern int optind; -extern char *optarg; +extern int optind; +extern char *optarg; /* * At bootstrap time, we first declare all the indices to be built, and @@ -226,20 +225,20 @@ extern char *optarg; typedef struct _IndexList { - char *il_heap; - char *il_ind; - int il_natts; - AttrNumber *il_attnos; - uint16 il_nparams; - Datum *il_params; - FuncIndexInfo *il_finfo; - PredInfo *il_predInfo; + char *il_heap; + char *il_ind; + int il_natts; + AttrNumber *il_attnos; + uint16 il_nparams; + Datum *il_params; + FuncIndexInfo *il_finfo; + PredInfo *il_predInfo; struct _IndexList *il_next; -} IndexList; +} IndexList; static IndexList *ILHead = (IndexList *) NULL; -typedef void (*sig_func) (); +typedef void (*sig_func) (); @@ -293,15 +292,15 @@ BootstrapMain(int argc, char *argv[]) * ---------------------------------------------------------------- */ { - int i; - int portFd = -1; - char *dbName; - int flag; - int override = 1; /* use BootstrapProcessing or - * InitProcessing mode */ + int i; + int portFd = -1; + char *dbName; + int flag; + int override = 1; /* use BootstrapProcessing or + * InitProcessing mode */ - extern int optind; - extern char *optarg; + extern int optind; + extern char *optarg; /* ---------------- * initialize signal handlers @@ -335,30 +334,30 @@ BootstrapMain(int argc, char *argv[]) { switch (flag) { - case 'D': - DataDir = optarg; - break; - case 'd': - DebugMode = 1; /* print out debugging info while parsing */ - break; - case 'C': - Noversion = 1; - break; - case 'F': - fsyncOff = 1; - break; - case 'O': - override = true; - break; - case 'Q': - Quiet = 1; - break; - case 'P': /* specify port */ - portFd = atoi(optarg); - break; - default: - usage(); - break; + case 'D': + DataDir = optarg; + break; + case 'd': + DebugMode = 1; /* print out debugging info while parsing */ + break; + case 'C': + Noversion = 1; + break; + case 'F': + fsyncOff = 1; + break; + case 'O': + override = true; + break; + case 'Q': + Quiet = 1; + break; + case 'P': /* specify port */ + portFd = atoi(optarg); + break; + default: + usage(); + break; } } /* while */ @@ -475,11 +474,11 @@ BootstrapMain(int argc, char *argv[]) void boot_openrel(char *relname) { - int i; + int i; struct typmap **app; - Relation rdesc; - HeapScanDesc sdesc; - HeapTuple tup; + Relation rdesc; + HeapScanDesc sdesc; + HeapTuple tup; if (strlen(relname) > 15) relname[15] = '\000'; @@ -603,8 +602,8 @@ closerel(char *name) void DefineAttr(char *name, char *type, int attnum) { - int attlen; - int t; + int attlen; + int t; if (reldesc != NULL) { @@ -646,10 +645,10 @@ DefineAttr(char *name, char *type, int attnum) void InsertOneTuple(Oid objectid) { - HeapTuple tuple; - TupleDesc tupDesc; + HeapTuple tuple; + TupleDesc tupDesc; - int i; + int i; if (DebugMode) { @@ -687,8 +686,8 @@ InsertOneTuple(Oid objectid) void InsertOneValue(Oid objectid, char *value, int i) { - int typeindex; - char *prt; + int typeindex; + char *prt; struct typmap **app; if (DebugMode) @@ -701,7 +700,7 @@ InsertOneValue(Oid objectid, char *value, int i) if (Typ != (struct typmap **) NULL) { - struct typmap *ap; + struct typmap *ap; if (DebugMode) puts("Typ != NULL"); @@ -767,13 +766,13 @@ InsertOneNull(int i) #define MORE_THAN_THE_NUMBER_OF_CATALOGS 256 -static bool +static bool BootstrapAlreadySeen(Oid id) { - static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS]; - static int nseen = 0; - bool seenthis; - int i; + static Oid seenArray[MORE_THAN_THE_NUMBER_OF_CATALOGS]; + static int nseen = 0; + bool seenthis; + int i; seenthis = false; @@ -800,7 +799,7 @@ BootstrapAlreadySeen(Oid id) static void cleanup() { - static int beenhere = 0; + static int beenhere = 0; if (!beenhere) beenhere = 1; @@ -824,10 +823,10 @@ cleanup() static int gettype(char *type) { - int i; - Relation rdesc; - HeapScanDesc sdesc; - HeapTuple tup; + int i; + Relation rdesc; + HeapScanDesc sdesc; + HeapTuple tup; struct typmap **app; if (Typ != (struct typmap **) NULL) @@ -885,7 +884,7 @@ gettype(char *type) * AllocateAttribute * ---------------- */ -static AttributeTupleForm /* XXX */ +static AttributeTupleForm /* XXX */ AllocateAttribute() { AttributeTupleForm attribute = @@ -914,13 +913,13 @@ AllocateAttribute() * be freed by the CALLER. * ---------------- */ -char * +char * MapArrayTypeName(char *s) { - int i, - j; - static char newStr[NAMEDATALEN]; /* array type names < - * NAMEDATALEN long */ + int i, + j; + static char newStr[NAMEDATALEN]; /* array type names < NAMEDATALEN + * long */ if (s == NULL || s[0] == '\0') return s; @@ -944,8 +943,8 @@ MapArrayTypeName(char *s) int EnterString(char *str) { - hashnode *node; - int len; + hashnode *node; + int len; len = strlen(str); @@ -967,7 +966,7 @@ EnterString(char *str) * associated with the idnum * ---------------- */ -char * +char * LexIDStr(int ident_num) { return (strtable[ident_num]); @@ -986,7 +985,7 @@ LexIDStr(int ident_num) static int CompHash(char *str, int len) { - register int result; + register int result; result = (NUM * str[0] + NUMSQR * str[len - 1] + NUMCUBE * str[(len - 1) / 2]); @@ -1005,7 +1004,7 @@ CompHash(char *str, int len) static hashnode * FindStr(char *str, int length, hashnode * mderef) { - hashnode *node; + hashnode *node; node = hashtable[CompHash(str, length)]; while (node != NULL) @@ -1040,11 +1039,11 @@ FindStr(char *str, int length, hashnode * mderef) static hashnode * AddStr(char *str, int strlength, int mderef) { - hashnode *temp, - *trail, - *newnode; - int hashresult; - int len; + hashnode *temp, + *trail, + *newnode; + int hashresult; + int len; if (++strtable_end == STRTABLESIZE) { @@ -1118,10 +1117,10 @@ index_register(char *heap, FuncIndexInfo * finfo, PredInfo * predInfo) { - Datum *v; - IndexList *newind; - int len; - MemoryContext oldcxt; + Datum *v; + IndexList *newind; + int len; + MemoryContext oldcxt; /* * XXX mao 10/31/92 -- don't gc index reldescs, associated info at @@ -1193,8 +1192,8 @@ index_register(char *heap, void build_indices() { - Relation heap; - Relation ind; + Relation heap; + Relation ind; for (; ILHead != (IndexList *) NULL; ILHead = ILHead->il_next) { diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index a8abbb01eee..779dfec4b27 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.8 1997/09/07 04:40:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.9 1997/09/08 02:21:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,10 +26,10 @@ * relpath - path to the relation * Perhaps this should be in-line code in relopen(). */ -char * +char * relpath(char relname[]) { - char *path; + char *path; if (IsSharedSystemRelationName(relname)) { @@ -91,7 +91,7 @@ IsSystemRelationName(char *relname) bool IsSharedSystemRelationName(char *relname) { - int i; + int i; /* * Quick out: if it's not a system relation, it can't be a shared @@ -128,7 +128,7 @@ IsSharedSystemRelationName(char *relname) Oid newoid() { - Oid lastoid; + Oid lastoid; GetNewObjectId(&lastoid); if (!OidIsValid(lastoid)) @@ -156,9 +156,9 @@ fillatt(TupleDesc tupleDesc) { AttributeTupleForm *attributeP; register TypeTupleForm typp; - HeapTuple tuple; - int i; - int natts = tupleDesc->natts; + HeapTuple tuple; + int i; + int natts = tupleDesc->natts; AttributeTupleForm *att = tupleDesc->attrs; if (natts < 0 || natts > MaxHeapAttributeNumber) diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index c80ddb9727e..1fbb505400e 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.25 1997/09/07 04:40:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.26 1997/09/08 02:21:37 momjian Exp $ * * INTERFACE ROUTINES * heap_creatr() - Create an uncataloged heap relation @@ -61,17 +61,17 @@ static void AddPgRelationTuple(Relation pg_class_desc, Relation new_rel_desc, Oid new_rel_oid, int arch, unsigned natts); -static void AddToTempRelList(Relation r); -static void DeletePgAttributeTuples(Relation rdesc); -static void DeletePgRelationTuple(Relation rdesc); -static void DeletePgTypeTuple(Relation rdesc); -static int RelationAlreadyExists(Relation pg_class_desc, char relname[]); -static void RelationRemoveIndexes(Relation relation); -static void RelationRemoveInheritance(Relation relation); -static void RemoveFromTempRelList(Relation r); -static void addNewRelationType(char *typeName, Oid new_rel_oid); -static void StoreConstraints(Relation rel); -static void RemoveConstraints(Relation rel); +static void AddToTempRelList(Relation r); +static void DeletePgAttributeTuples(Relation rdesc); +static void DeletePgRelationTuple(Relation rdesc); +static void DeletePgTypeTuple(Relation rdesc); +static int RelationAlreadyExists(Relation pg_class_desc, char relname[]); +static void RelationRemoveIndexes(Relation relation); +static void RelationRemoveInheritance(Relation relation); +static void RemoveFromTempRelList(Relation r); +static void addNewRelationType(char *typeName, Oid new_rel_oid); +static void StoreConstraints(Relation rel); +static void RemoveConstraints(Relation rel); /* ---------------------------------------------------------------- @@ -160,11 +160,11 @@ static AttributeTupleForm HeapAtt[] = */ typedef struct tempRelList { - Relation *rels; /* array of relation descriptors */ - int num; /* number of temporary relations */ - int size; /* size of space allocated for the rels + Relation *rels; /* array of relation descriptors */ + int num; /* number of temporary relations */ + int size; /* size of space allocated for the rels * array */ -} TempRelList; +} TempRelList; #define TEMP_REL_LIST_SIZE 32 @@ -194,19 +194,19 @@ heap_creatr(char *name, TupleDesc tupDesc) { register unsigned i; - Oid relid; - Relation rdesc; - int len; - bool nailme = false; - char *relname = name; - char tempname[40]; - int isTemp = 0; - int natts = tupDesc->natts; + Oid relid; + Relation rdesc; + int len; + bool nailme = false; + char *relname = name; + char tempname[40]; + int isTemp = 0; + int natts = tupDesc->natts; /* AttributeTupleForm *att = tupDesc->attrs; */ extern GlobalMemory CacheCxt; - MemoryContext oldcxt; + MemoryContext oldcxt; /* ---------------- * sanity checks @@ -425,9 +425,9 @@ heap_creatr(char *name, static void CheckAttributeNames(TupleDesc tupdesc) { - unsigned i; - unsigned j; - int natts = tupdesc->natts; + unsigned i; + unsigned j; + int natts = tupdesc->natts; /* ---------------- * first check for collision with system attribute names @@ -487,9 +487,9 @@ CheckAttributeNames(TupleDesc tupdesc) static int RelationAlreadyExists(Relation pg_class_desc, char relname[]) { - ScanKeyData key; - HeapScanDesc pg_class_scan; - HeapTuple tup; + ScanKeyData key; + HeapScanDesc pg_class_scan; + HeapTuple tup; /* * If this is not bootstrap (initdb) time, use the catalog index on @@ -558,12 +558,12 @@ AddNewAttributeTuples(Oid new_rel_oid, TupleDesc tupdesc) { AttributeTupleForm *dpp; - unsigned i; - HeapTuple tup; - Relation rdesc; - bool hasindex; - Relation idescs[Num_pg_attr_indices]; - int natts = tupdesc->natts; + unsigned i; + HeapTuple tup; + Relation rdesc; + bool hasindex; + Relation idescs[Num_pg_attr_indices]; + int natts = tupdesc->natts; /* ---------------- * open pg_attribute @@ -659,12 +659,12 @@ AddPgRelationTuple(Relation pg_class_desc, int arch, unsigned natts) { - Form_pg_class new_rel_reltup; - HeapTuple tup; - Relation idescs[Num_pg_class_indices]; - bool isBootstrap; - extern bool ItsSequenceCreation; /* It's hack, I know... - - * vadim 03/28/97 */ + Form_pg_class new_rel_reltup; + HeapTuple tup; + Relation idescs[Num_pg_class_indices]; + bool isBootstrap; + extern bool ItsSequenceCreation; /* It's hack, I know... - vadim + * 03/28/97 */ /* ---------------- * first we munge some of the information in our @@ -737,7 +737,7 @@ AddPgRelationTuple(Relation pg_class_desc, static void addNewRelationType(char *typeName, Oid new_rel_oid) { - Oid new_type_oid; + Oid new_type_oid; /* * The sizes are set to oid size because it makes implementing sets @@ -778,12 +778,12 @@ heap_create(char relname[], unsigned smgr, TupleDesc tupdesc) { - Relation pg_class_desc; - Relation new_rel_desc; - Oid new_rel_oid; + Relation pg_class_desc; + Relation new_rel_desc; + Oid new_rel_oid; /* NameData typeNameData; */ - int natts = tupdesc->natts; + int natts = tupdesc->natts; /* ---------------- * sanity checks @@ -906,10 +906,10 @@ heap_create(char relname[], static void RelationRemoveInheritance(Relation relation) { - Relation catalogRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation catalogRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; /* ---------------- * open pg_inherits @@ -1010,10 +1010,10 @@ RelationRemoveInheritance(Relation relation) static void RelationRemoveIndexes(Relation relation) { - Relation indexRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation indexRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; indexRelation = heap_openr(IndexRelationName); @@ -1050,10 +1050,10 @@ RelationRemoveIndexes(Relation relation) static void DeletePgRelationTuple(Relation rdesc) { - Relation pg_class_desc; - HeapScanDesc pg_class_scan; - ScanKeyData key; - HeapTuple tup; + Relation pg_class_desc; + HeapScanDesc pg_class_scan; + ScanKeyData key; + HeapTuple tup; /* ---------------- * open pg_class @@ -1108,10 +1108,10 @@ DeletePgRelationTuple(Relation rdesc) static void DeletePgAttributeTuples(Relation rdesc) { - Relation pg_attribute_desc; - HeapScanDesc pg_attribute_scan; - ScanKeyData key; - HeapTuple tup; + Relation pg_attribute_desc; + HeapScanDesc pg_attribute_scan; + ScanKeyData key; + HeapTuple tup; /* ---------------- * open pg_attribute @@ -1178,15 +1178,15 @@ DeletePgAttributeTuples(Relation rdesc) static void DeletePgTypeTuple(Relation rdesc) { - Relation pg_type_desc; - HeapScanDesc pg_type_scan; - Relation pg_attribute_desc; - HeapScanDesc pg_attribute_scan; - ScanKeyData key; - ScanKeyData attkey; - HeapTuple tup; - HeapTuple atttup; - Oid typoid; + Relation pg_type_desc; + HeapScanDesc pg_type_scan; + Relation pg_attribute_desc; + HeapScanDesc pg_attribute_scan; + ScanKeyData key; + ScanKeyData attkey; + HeapTuple tup; + HeapTuple atttup; + Oid typoid; /* ---------------- * open pg_type @@ -1254,7 +1254,7 @@ DeletePgTypeTuple(Relation rdesc) if (PointerIsValid(atttup)) { - Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid; + Oid relid = ((AttributeTupleForm) GETSTRUCT(atttup))->attrelid; heap_endscan(pg_type_scan); heap_close(pg_type_desc); @@ -1287,8 +1287,8 @@ DeletePgTypeTuple(Relation rdesc) void heap_destroy(char *relname) { - Relation rdesc; - Oid rid; + Relation rdesc; + Oid rid; /* ---------------- * first open the relation. if the relation does exist, @@ -1458,7 +1458,7 @@ InitTempRelList(void) static void RemoveFromTempRelList(Relation r) { - int i; + int i; if (!tempRels) return; @@ -1500,8 +1500,8 @@ AddToTempRelList(Relation r) void DestroyTempRels(void) { - int i; - Relation rdesc; + int i; + Relation rdesc; if (!tempRels) return; @@ -1518,30 +1518,30 @@ DestroyTempRels(void) tempRels = NULL; } -extern List *flatten_tlist(List * tlist); -extern List * +extern List *flatten_tlist(List * tlist); +extern List * pg_plan(char *query_string, Oid * typev, int nargs, QueryTreeList ** queryListP, CommandDest dest); static void StoreAttrDefault(Relation rel, AttrDefault * attrdef) { - char str[MAX_PARSE_BUFFER]; - char cast[2 * NAMEDATALEN] = {0}; + char str[MAX_PARSE_BUFFER]; + char cast[2 * NAMEDATALEN] = {0}; AttributeTupleForm atp = rel->rd_att->attrs[attrdef->adnum - 1]; - QueryTreeList *queryTree_list; - Query *query; - List *planTree_list; - TargetEntry *te; - Resdom *resdom; - Node *expr; - char *adbin; - MemoryContext oldcxt; - Relation adrel; - Relation idescs[Num_pg_attrdef_indices]; - HeapTuple tuple; - Datum values[4]; - char nulls[4] = {' ', ' ', ' ', ' '}; + QueryTreeList *queryTree_list; + Query *query; + List *planTree_list; + TargetEntry *te; + Resdom *resdom; + Node *expr; + char *adbin; + MemoryContext oldcxt; + Relation adrel; + Relation idescs[Num_pg_attrdef_indices]; + HeapTuple tuple; + Datum values[4]; + char nulls[4] = {' ', ' ', ' ', ' '}; extern GlobalMemory CacheCxt; start:; @@ -1600,19 +1600,19 @@ start:; static void StoreRelCheck(Relation rel, ConstrCheck * check) { - char str[MAX_PARSE_BUFFER]; - QueryTreeList *queryTree_list; - Query *query; - List *planTree_list; - Plan *plan; - List *qual; - char *ccbin; - MemoryContext oldcxt; - Relation rcrel; - Relation idescs[Num_pg_relcheck_indices]; - HeapTuple tuple; - Datum values[4]; - char nulls[4] = {' ', ' ', ' ', ' '}; + char str[MAX_PARSE_BUFFER]; + QueryTreeList *queryTree_list; + Query *query; + List *planTree_list; + Plan *plan; + List *qual; + char *ccbin; + MemoryContext oldcxt; + Relation rcrel; + Relation idescs[Num_pg_relcheck_indices]; + HeapTuple tuple; + Datum values[4]; + char nulls[4] = {' ', ' ', ' ', ' '}; extern GlobalMemory CacheCxt; sprintf(str, "select 1 from %.*s where %s", @@ -1659,8 +1659,8 @@ StoreRelCheck(Relation rel, ConstrCheck * check) static void StoreConstraints(Relation rel) { - TupleConstr *constr = rel->rd_att->constr; - int i; + TupleConstr *constr = rel->rd_att->constr; + int i; if (!constr) return; @@ -1683,10 +1683,10 @@ StoreConstraints(Relation rel) static void RemoveAttrDefault(Relation rel) { - Relation adrel; - HeapScanDesc adscan; - ScanKeyData key; - HeapTuple tup; + Relation adrel; + HeapScanDesc adscan; + ScanKeyData key; + HeapTuple tup; adrel = heap_openr(AttrDefaultRelationName); @@ -1710,10 +1710,10 @@ RemoveAttrDefault(Relation rel) static void RemoveRelCheck(Relation rel) { - Relation rcrel; - HeapScanDesc rcscan; - ScanKeyData key; - HeapTuple tup; + Relation rcrel; + HeapScanDesc rcscan; + ScanKeyData key; + HeapTuple tup; rcrel = heap_openr(RelCheckRelationName); @@ -1737,7 +1737,7 @@ RemoveRelCheck(Relation rel) static void RemoveConstraints(Relation rel) { - TupleConstr *constr = rel->rd_att->constr; + TupleConstr *constr = rel->rd_att->constr; if (!constr) return; diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index 6dd75742798..d6459fbe2b8 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.20 1997/09/07 04:40:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.21 1997/09/08 02:21:40 momjian Exp $ * * * INTERFACE ROUTINES @@ -66,21 +66,21 @@ static Oid RelationNameGetObjectId(char *relationName, Relation pg_class, bool setHasIndexAttribute); -static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName); +static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName); static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo); static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, List * attributeList, int numatts, AttrNumber attNums[]); -static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); -static Oid UpdateRelationRelation(Relation indexRelation); +static void ConstructIndexReldesc(Relation indexRelation, Oid amoid); +static Oid UpdateRelationRelation(Relation indexRelation); static void InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid); static void - AppendAttributeTuples(Relation indexRelation, int numatts); + AppendAttributeTuples(Relation indexRelation, int numatts); static void UpdateIndexRelation(Oid indexoid, Oid heapoid, FuncIndexInfo * funcInfo, int natts, @@ -144,16 +144,16 @@ static FormData_pg_attribute sysatts[] = { * Assumes relation descriptor is valid. * ---------------------------------------------------------------- */ -static Oid +static Oid RelationNameGetObjectId(char *relationName, Relation pg_class, bool setHasIndexAttribute) { - HeapScanDesc pg_class_scan; - HeapTuple pg_class_tuple; - Oid relationObjectId; - Buffer buffer; - ScanKeyData key; + HeapScanDesc pg_class_scan; + HeapTuple pg_class_tuple; + Oid relationObjectId; + Buffer buffer; + ScanKeyData key; /* * If this isn't bootstrap time, we can use the system catalogs to @@ -217,12 +217,12 @@ RelationNameGetObjectId(char *relationName, * GetHeapRelationOid * ---------------------------------------------------------------- */ -static Oid +static Oid GetHeapRelationOid(char *heapRelationName, char *indexRelationName) { - Relation pg_class; - Oid indoid; - Oid heapoid; + Relation pg_class; + Oid indoid; + Oid heapoid; /* ---------------- * XXX ADD INDEXING HERE @@ -268,15 +268,15 @@ GetHeapRelationOid(char *heapRelationName, char *indexRelationName) return heapoid; } -static TupleDesc +static TupleDesc BuildFuncTupleDesc(FuncIndexInfo * funcInfo) { - HeapTuple tuple; - TupleDesc funcTupDesc; - Oid retType; - char *funcname; - int4 nargs; - Oid *argtypes; + HeapTuple tuple; + TupleDesc funcTupDesc; + Oid retType; + char *funcname; + int4 nargs; + Oid *argtypes; /* * Allocate and zero a tuple descriptor. @@ -331,23 +331,23 @@ BuildFuncTupleDesc(FuncIndexInfo * funcInfo) * ConstructTupleDescriptor * ---------------------------------------------------------------- */ -static TupleDesc +static TupleDesc ConstructTupleDescriptor(Oid heapoid, Relation heapRelation, List * attributeList, int numatts, AttrNumber attNums[]) { - TupleDesc heapTupDesc; - TupleDesc indexTupDesc; - IndexElem *IndexKey; - TypeName *IndexKeyType; - AttrNumber atnum; /* attributeNumber[attributeOffset] */ - AttrNumber atind; - int natts; /* RelationTupleForm->relnatts */ - char *from; /* used to simplify memcpy below */ - char *to; /* used to simplify memcpy below */ - int i; + TupleDesc heapTupDesc; + TupleDesc indexTupDesc; + IndexElem *IndexKey; + TypeName *IndexKeyType; + AttrNumber atnum; /* attributeNumber[attributeOffset] */ + AttrNumber atind; + int natts; /* RelationTupleForm->relnatts */ + char *from; /* used to simplify memcpy below */ + char *to; /* used to simplify memcpy below */ + int i; /* ---------------- * allocate the new tuple descriptor @@ -447,7 +447,7 @@ ConstructTupleDescriptor(Oid heapoid, */ if (IndexKeyType != NULL) { - HeapTuple tup; + HeapTuple tup; tup = SearchSysCacheTuple(TYPNAME, PointerGetDatum(IndexKeyType->name), @@ -491,11 +491,11 @@ ConstructTupleDescriptor(Oid heapoid, Form_pg_am AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId) { - Relation pg_am_desc; - HeapScanDesc pg_am_scan; - HeapTuple pg_am_tuple; - ScanKeyData key; - Form_pg_am form; + Relation pg_am_desc; + HeapScanDesc pg_am_scan; + HeapTuple pg_am_tuple; + ScanKeyData key; + Form_pg_am form; /* ---------------- * form a scan key for the pg_am relation @@ -546,7 +546,7 @@ static void ConstructIndexReldesc(Relation indexRelation, Oid amoid) { extern GlobalMemory CacheCxt; - MemoryContext oldcxt; + MemoryContext oldcxt; /* ---------------- * here we make certain to allocate the access method @@ -583,13 +583,13 @@ ConstructIndexReldesc(Relation indexRelation, Oid amoid) * UpdateRelationRelation * ---------------------------------------------------------------- */ -static Oid +static Oid UpdateRelationRelation(Relation indexRelation) { - Relation pg_class; - HeapTuple tuple; - Oid tupleOid; - Relation idescs[Num_pg_class_indices]; + Relation pg_class; + HeapTuple tuple; + Oid tupleOid; + Relation idescs[Num_pg_class_indices]; pg_class = heap_openr(RelationRelationName); @@ -637,8 +637,8 @@ InitializeAttributeOids(Relation indexRelation, int numatts, Oid indexoid) { - TupleDesc tupleDescriptor; - int i; + TupleDesc tupleDescriptor; + int i; tupleDescriptor = RelationGetTupleDescriptor(indexRelation); @@ -655,18 +655,18 @@ InitializeAttributeOids(Relation indexRelation, static void AppendAttributeTuples(Relation indexRelation, int numatts) { - Relation pg_attribute; - HeapTuple tuple; - HeapTuple newtuple; - bool hasind; - Relation idescs[Num_pg_attr_indices]; + Relation pg_attribute; + HeapTuple tuple; + HeapTuple newtuple; + bool hasind; + Relation idescs[Num_pg_attr_indices]; - Datum value[Natts_pg_attribute]; - char nullv[Natts_pg_attribute]; - char replace[Natts_pg_attribute]; + Datum value[Natts_pg_attribute]; + char nullv[Natts_pg_attribute]; + char replace[Natts_pg_attribute]; - TupleDesc indexTupDesc; - int i; + TupleDesc indexTupDesc; + int i; /* ---------------- * open the attribute relation @@ -786,15 +786,15 @@ UpdateIndexRelation(Oid indexoid, bool islossy, bool unique) { - IndexTupleForm indexForm; - IndexElem *IndexKey; - char *predString; - text *predText; - int predLen, - itupLen; - Relation pg_index; - HeapTuple tuple; - int i; + IndexTupleForm indexForm; + IndexElem *IndexKey; + char *predString; + text *predText; + int predLen, + itupLen; + Relation pg_index; + HeapTuple tuple; + int i; /* ---------------- * allocate an IndexTupleForm big enough to hold the @@ -903,19 +903,19 @@ UpdateIndexRelation(Oid indexoid, void UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate) { - Node *newPred; - char *predString; - text *predText; - Relation pg_index; - HeapTuple tuple; - HeapTuple newtup; - ScanKeyData entry; - HeapScanDesc scan; - Buffer buffer; - int i; - Datum values[Natts_pg_index]; - char nulls[Natts_pg_index]; - char replace[Natts_pg_index]; + Node *newPred; + char *predString; + text *predText; + Relation pg_index; + HeapTuple tuple; + HeapTuple newtup; + ScanKeyData entry; + HeapScanDesc scan; + Buffer buffer; + int i; + Datum values[Natts_pg_index]; + char nulls[Natts_pg_index]; + char replace[Natts_pg_index]; /* * Construct newPred as a CNF expression equivalent to the OR of the @@ -988,12 +988,12 @@ InitIndexStrategy(int numatts, Relation indexRelation, Oid accessMethodObjectId) { - IndexStrategy strategy; - RegProcedure *support; - uint16 amstrategies; - uint16 amsupport; - Oid attrelid; - Size strsize; + IndexStrategy strategy; + RegProcedure *support; + uint16 amstrategies; + uint16 amsupport; + Oid attrelid; + Size strsize; extern GlobalMemory CacheCxt; /* ---------------- @@ -1077,12 +1077,12 @@ index_create(char *heapRelationName, bool islossy, bool unique) { - Relation heapRelation; - Relation indexRelation; - TupleDesc indexTupDesc; - Oid heapoid; - Oid indexoid; - PredInfo *predInfo; + Relation heapRelation; + Relation indexRelation; + TupleDesc indexTupDesc; + Oid heapoid; + Oid indexoid; + PredInfo *predInfo; /* ---------------- * check parameters @@ -1150,7 +1150,7 @@ index_create(char *heapRelationName, if (PointerIsValid(funcInfo)) { - HeapTuple proc_tup; + HeapTuple proc_tup; proc_tup = SearchSysCacheTuple(PRONAME, PointerGetDatum(FIgetname(funcInfo)), @@ -1231,11 +1231,11 @@ index_create(char *heapRelationName, void index_destroy(Oid indexId) { - Relation indexRelation; - Relation catalogRelation; - HeapTuple tuple; - HeapScanDesc scan; - ScanKeyData entry; + Relation indexRelation; + Relation catalogRelation; + HeapTuple tuple; + HeapScanDesc scan; + ScanKeyData entry; Assert(OidIsValid(indexId)); @@ -1325,9 +1325,9 @@ FormIndexDatum(int numberOfAttributes, char *nullv, FuncIndexInfoPtr fInfo) { - AttrNumber i; - int offset; - bool isNull; + AttrNumber i; + int offset; + bool isNull; /* ---------------- * for each attribute we need from the heap tuple, @@ -1361,23 +1361,23 @@ FormIndexDatum(int numberOfAttributes, void UpdateStats(Oid relid, long reltuples, bool hasindex) { - Relation whichRel; - Relation pg_class; - HeapScanDesc pg_class_scan; - HeapTuple htup; - HeapTuple newtup; - long relpages; - Buffer buffer; - int i; - Form_pg_class rd_rel; - Relation idescs[Num_pg_class_indices]; + Relation whichRel; + Relation pg_class; + HeapScanDesc pg_class_scan; + HeapTuple htup; + HeapTuple newtup; + long relpages; + Buffer buffer; + int i; + Form_pg_class rd_rel; + Relation idescs[Num_pg_class_indices]; static ScanKeyData key[1] = { {0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure} }; - Datum values[Natts_pg_class]; - char nulls[Natts_pg_class]; - char replace[Natts_pg_class]; + Datum values[Natts_pg_class]; + char nulls[Natts_pg_class]; + char replace[Natts_pg_class]; fmgr_info(ObjectIdEqualRegProcedure, (func_ptr *) & key[0].sk_func, &key[0].sk_nargs); @@ -1534,26 +1534,26 @@ DefaultBuild(Relation heapRelation, FuncIndexInfoPtr funcInfo, PredInfo * predInfo) { - HeapScanDesc scan; - HeapTuple heapTuple; - Buffer buffer; - - IndexTuple indexTuple; - TupleDesc heapDescriptor; - TupleDesc indexDescriptor; - Datum *datum; - char *nullv; - long reltuples, - indtuples; + HeapScanDesc scan; + HeapTuple heapTuple; + Buffer buffer; + + IndexTuple indexTuple; + TupleDesc heapDescriptor; + TupleDesc indexDescriptor; + Datum *datum; + char *nullv; + long reltuples, + indtuples; #ifndef OMIT_PARTIAL_INDEX - ExprContext *econtext; - TupleTable tupleTable; + ExprContext *econtext; + TupleTable tupleTable; TupleTableSlot *slot; #endif - Node *predicate; - Node *oldPred; + Node *predicate; + Node *oldPred; InsertIndexResult insertResult; @@ -1736,7 +1736,7 @@ index_build(Relation heapRelation, FuncIndexInfo * funcInfo, PredInfo * predInfo) { - RegProcedure procedure; + RegProcedure procedure; /* ---------------- * sanity checks @@ -1781,8 +1781,8 @@ index_build(Relation heapRelation, bool IndexIsUnique(Oid indexId) { - HeapTuple tuple; - IndexTupleForm index; + HeapTuple tuple; + IndexTupleForm index; tuple = SearchSysCacheTuple(INDEXRELID, ObjectIdGetDatum(indexId), @@ -1813,12 +1813,12 @@ IndexIsUnique(Oid indexId) bool IndexIsUniqueNoCache(Oid indexId) { - Relation pg_index; - ScanKeyData skey[1]; - HeapScanDesc scandesc; - HeapTuple tuple; - IndexTupleForm index; - bool isunique; + Relation pg_index; + ScanKeyData skey[1]; + HeapScanDesc scandesc; + HeapTuple tuple; + IndexTupleForm index; + bool isunique; pg_index = heap_openr(IndexRelationName); diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 6a89258d972..5dca2e3d9a2 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.12 1997/09/07 04:40:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.13 1997/09/08 02:21:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,21 +44,21 @@ * pg_trigger */ -char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, +char *Name_pg_attr_indices[Num_pg_attr_indices] = {AttributeNameIndex, AttributeNumIndex, AttributeRelidIndex}; -char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, +char *Name_pg_proc_indices[Num_pg_proc_indices] = {ProcedureNameIndex, ProcedureOidIndex, ProcedureSrcIndex}; -char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, +char *Name_pg_type_indices[Num_pg_type_indices] = {TypeNameIndex, TypeOidIndex}; -char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, +char *Name_pg_class_indices[Num_pg_class_indices] = {ClassNameIndex, ClassOidIndex}; -char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; +char *Name_pg_attrdef_indices[Num_pg_attrdef_indices] = {AttrDefaultIndex}; -char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; +char *Name_pg_relcheck_indices[Num_pg_relcheck_indices] = {RelCheckIndex}; -char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; +char *Name_pg_trigger_indices[Num_pg_trigger_indices] = {TriggerRelidIndex}; static HeapTuple @@ -76,7 +76,7 @@ CatalogIndexFetchTuple(Relation heapRelation, void CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]) { - int i; + int i; for (i = 0; i < nIndices; i++) { @@ -90,7 +90,7 @@ CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]) void CatalogCloseIndices(int nIndices, Relation * idescs) { - int i; + int i; for (i = 0; i < nIndices; i++) index_close(idescs[i]); @@ -108,22 +108,22 @@ CatalogIndexInsert(Relation * idescs, Relation heapRelation, HeapTuple heapTuple) { - HeapTuple pgIndexTup; - TupleDesc heapDescriptor; - IndexTupleForm pgIndexP; - Datum datum; - int natts; - AttrNumber *attnumP; - FuncIndexInfo finfo, - *finfoP; - char nulls[INDEX_MAX_KEYS]; - int i; + HeapTuple pgIndexTup; + TupleDesc heapDescriptor; + IndexTupleForm pgIndexP; + Datum datum; + int natts; + AttrNumber *attnumP; + FuncIndexInfo finfo, + *finfoP; + char nulls[INDEX_MAX_KEYS]; + int i; heapDescriptor = RelationGetTupleDescriptor(heapRelation); for (i = 0; i < nIndices; i++) { - TupleDesc indexDescriptor; + TupleDesc indexDescriptor; InsertIndexResult indexRes; indexDescriptor = RelationGetTupleDescriptor(idescs[i]); @@ -176,10 +176,10 @@ CatalogIndexInsert(Relation * idescs, bool CatalogHasIndex(char *catName, Oid catId) { - Relation pg_class; - HeapTuple htup; - Form_pg_class pgRelP; - int i; + Relation pg_class; + HeapTuple htup; + Form_pg_class pgRelP; + int i; Assert(IsSystemRelationName(catName)); @@ -221,15 +221,15 @@ CatalogHasIndex(char *catName, Oid catId) * iterate until we find a tuple that's valid and satisfies the scan * key. */ -static HeapTuple +static HeapTuple CatalogIndexFetchTuple(Relation heapRelation, Relation idesc, ScanKey skey) { - IndexScanDesc sd; + IndexScanDesc sd; RetrieveIndexResult indexRes; - HeapTuple tuple; - Buffer buffer; + HeapTuple tuple; + Buffer buffer; sd = index_beginscan(idesc, false, 1, skey); tuple = (HeapTuple) NULL; @@ -239,7 +239,7 @@ CatalogIndexFetchTuple(Relation heapRelation, indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -271,10 +271,10 @@ AttributeNameIndexScan(Relation heapRelation, Oid relid, char *attname) { - Relation idesc; - ScanKeyData skey; - OidName keyarg; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + OidName keyarg; + HeapTuple tuple; keyarg = mkoidname(relid, attname); ScanKeyEntryInitialize(&skey, @@ -297,10 +297,10 @@ AttributeNumIndexScan(Relation heapRelation, Oid relid, AttrNumber attnum) { - Relation idesc; - ScanKeyData skey; - OidInt2 keyarg; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + OidInt2 keyarg; + HeapTuple tuple; keyarg = mkoidint2(relid, (uint16) attnum); ScanKeyEntryInitialize(&skey, @@ -321,9 +321,9 @@ AttributeNumIndexScan(Relation heapRelation, HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -347,22 +347,21 @@ ProcedureNameIndexScan(Relation heapRelation, int nargs, Oid * argTypes) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; /* tuple being tested */ - HeapTuple return_tuple; /* The tuple pointer we eventually - * return */ - IndexScanDesc sd; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; /* tuple being tested */ + HeapTuple return_tuple; /* The tuple pointer we eventually return */ + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - Form_pg_proc pgProcP; - bool ScanComplete; + Buffer buffer; + Form_pg_proc pgProcP; + bool ScanComplete; /* * The index scan is complete, i.e. we've scanned everything there is * to scan. */ - bool FoundMatch; + bool FoundMatch; /* * In scanning pg_proc, we have found a row that meets our search @@ -392,7 +391,7 @@ ProcedureNameIndexScan(Relation heapRelation, indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -438,12 +437,12 @@ ProcedureNameIndexScan(Relation heapRelation, HeapTuple ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) { - Relation idesc; - IndexScanDesc sd; - ScanKeyData skey; + Relation idesc; + IndexScanDesc sd; + ScanKeyData skey; RetrieveIndexResult indexRes; - HeapTuple tuple; - Buffer buffer; + HeapTuple tuple; + Buffer buffer; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -457,7 +456,7 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -480,9 +479,9 @@ ProcedureSrcIndexScan(Relation heapRelation, text * procSrc) HeapTuple TypeOidIndexScan(Relation heapRelation, Oid typeId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -501,9 +500,9 @@ TypeOidIndexScan(Relation heapRelation, Oid typeId) HeapTuple TypeNameIndexScan(Relation heapRelation, char *typeName) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -522,9 +521,9 @@ TypeNameIndexScan(Relation heapRelation, char *typeName) HeapTuple ClassNameIndexScan(Relation heapRelation, char *relName) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -543,9 +542,9 @@ ClassNameIndexScan(Relation heapRelation, char *relName) HeapTuple ClassOidIndexScan(Relation heapRelation, Oid relId) { - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; ScanKeyEntryInitialize(&skey, (bits16) 0x0, diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 540350bac9b..32c89110c01 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.6 1997/09/07 04:40:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.7 1997/09/08 02:21:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,21 +64,21 @@ AggregateCreate(char *aggName, char *agginitval1, char *agginitval2) { - register i; - Relation aggdesc; - HeapTuple tup; - char nulls[Natts_pg_aggregate]; - Datum values[Natts_pg_aggregate]; - Form_pg_proc proc; - Oid xfn1 = InvalidOid; - Oid xfn2 = InvalidOid; - Oid ffn = InvalidOid; - Oid xbase = InvalidOid; - Oid xret1 = InvalidOid; - Oid xret2 = InvalidOid; - Oid fret = InvalidOid; - Oid fnArgs[8]; - TupleDesc tupDesc; + register i; + Relation aggdesc; + HeapTuple tup; + char nulls[Natts_pg_aggregate]; + Datum values[Natts_pg_aggregate]; + Form_pg_proc proc; + Oid xfn1 = InvalidOid; + Oid xfn2 = InvalidOid; + Oid ffn = InvalidOid; + Oid xbase = InvalidOid; + Oid xret1 = InvalidOid; + Oid xret2 = InvalidOid; + Oid fret = InvalidOid; + Oid fnArgs[8]; + TupleDesc tupDesc; memset(fnArgs, 0, 8 * sizeof(Oid)); @@ -267,16 +267,16 @@ AggregateCreate(char *aggName, } -char * +char * AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull) { - HeapTuple tup; - Relation aggRel; - int initValAttno; - Oid transtype; - text *textInitVal; - char *strInitVal, - *initVal; + HeapTuple tup; + Relation aggRel; + int initValAttno; + Oid transtype; + text *textInitVal; + char *strInitVal, + *initVal; Assert(PointerIsValid(aggName)); Assert(PointerIsValid(isNull)); @@ -295,7 +295,7 @@ AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull) initValAttno = Anum_pg_aggregate_agginitval1; } else - /* can only be 1 or 2 */ + /* can only be 1 or 2 */ { transtype = ((Form_pg_aggregate) GETSTRUCT(tup))->aggtranstype2; initValAttno = Anum_pg_aggregate_agginitval2; diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 67a3a2f1495..422c212811f 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.12 1997/09/07 04:40:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.13 1997/09/08 02:21:48 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -66,7 +66,7 @@ OperatorDef(char *operatorName, bool canHash, char *leftSortName, char *rightSortName); -static void OperatorUpd(Oid baseId, Oid commId, Oid negId); +static void OperatorUpd(Oid baseId, Oid commId, Oid negId); /* ---------------------------------------------------------------- * OperatorGetWithOpenRelation @@ -79,15 +79,15 @@ static void OperatorUpd(Oid baseId, Oid commId, Oid negId); * leftObjectId -- left oid of operator to fetch * rightObjectId -- right oid of operator to fetch */ -static Oid +static Oid OperatorGetWithOpenRelation(Relation pg_operator_desc, const char *operatorName, Oid leftObjectId, Oid rightObjectId) { - HeapScanDesc pg_operator_scan; - Oid operatorObjectId; - HeapTuple tup; + HeapScanDesc pg_operator_scan; + Oid operatorObjectId; + HeapTuple tup; static ScanKeyData opKey[3] = { {0, Anum_pg_operator_oprname, NameEqualRegProcedure}, @@ -145,18 +145,18 @@ OperatorGetWithOpenRelation(Relation pg_operator_desc, * and left and right type names. * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorGet(char *operatorName, char *leftTypeName, char *rightTypeName) { - Relation pg_operator_desc; + Relation pg_operator_desc; - Oid operatorObjectId; - Oid leftObjectId = InvalidOid; - Oid rightObjectId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; + Oid operatorObjectId; + Oid leftObjectId = InvalidOid; + Oid rightObjectId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; /* ---------------- * look up the operator types. @@ -216,18 +216,18 @@ OperatorGet(char *operatorName, * * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, char *operatorName, Oid leftObjectId, Oid rightObjectId) { - register int i; - HeapTuple tup; - Datum values[Natts_pg_operator]; - char nulls[Natts_pg_operator]; - Oid operatorObjectId; - TupleDesc tupDesc; + register int i; + HeapTuple tup; + Datum values[Natts_pg_operator]; + char nulls[Natts_pg_operator]; + Oid operatorObjectId; + TupleDesc tupDesc; /* ---------------- * initialize our nulls[] and values[] arrays @@ -300,18 +300,18 @@ OperatorShellMakeWithOpenRelation(Relation pg_operator_desc, * to the caller. * ---------------------------------------------------------------- */ -static Oid +static Oid OperatorShellMake(char *operatorName, char *leftTypeName, char *rightTypeName) { - Relation pg_operator_desc; - Oid operatorObjectId; + Relation pg_operator_desc; + Oid operatorObjectId; - Oid leftObjectId = InvalidOid; - Oid rightObjectId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; + Oid leftObjectId = InvalidOid; + Oid rightObjectId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; /* ---------------- * get the left and right type oid's for this operator @@ -450,29 +450,29 @@ OperatorDef(char *operatorName, char *leftSortName, char *rightSortName) { - register i, - j; - Relation pg_operator_desc; + register i, + j; + Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; - Buffer buffer; + HeapScanDesc pg_operator_scan; + HeapTuple tup; + Buffer buffer; ItemPointerData itemPointerData; - char nulls[Natts_pg_operator]; - char replaces[Natts_pg_operator]; - Datum values[Natts_pg_operator]; - Oid other_oid = 0; - Oid operatorObjectId; - Oid leftTypeId = InvalidOid; - Oid rightTypeId = InvalidOid; - Oid commutatorId = InvalidOid; - Oid negatorId = InvalidOid; - bool leftDefined = false; - bool rightDefined = false; - char *name[4]; - Oid typeId[8]; - int nargs; - TupleDesc tupDesc; + char nulls[Natts_pg_operator]; + char replaces[Natts_pg_operator]; + Datum values[Natts_pg_operator]; + Oid other_oid = 0; + Oid operatorObjectId; + Oid leftTypeId = InvalidOid; + Oid rightTypeId = InvalidOid; + Oid commutatorId = InvalidOid; + Oid negatorId = InvalidOid; + bool leftDefined = false; + bool rightDefined = false; + char *name[4]; + Oid typeId[8]; + int nargs; + TupleDesc tupDesc; static ScanKeyData opKey[3] = { {0, Anum_pg_operator_oprname, NameEqualRegProcedure}, @@ -765,15 +765,15 @@ OperatorDef(char *operatorName, static void OperatorUpd(Oid baseId, Oid commId, Oid negId) { - register i; - Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; - Buffer buffer; + register i; + Relation pg_operator_desc; + HeapScanDesc pg_operator_scan; + HeapTuple tup; + Buffer buffer; ItemPointerData itemPointerData; - char nulls[Natts_pg_operator]; - char replaces[Natts_pg_operator]; - Datum values[Natts_pg_operator]; + char nulls[Natts_pg_operator]; + char replaces[Natts_pg_operator]; + Datum values[Natts_pg_operator]; static ScanKeyData opKey[1] = { {0, ObjectIdAttributeNumber, ObjectIdEqualRegProcedure}, @@ -985,11 +985,11 @@ OperatorCreate(char *operatorName, char *leftSortName, char *rightSortName) { - Oid commObjectId, - negObjectId; - Oid leftSortObjectId, - rightSortObjectId; - int definedOK; + Oid commObjectId, + negObjectId; + Oid leftSortObjectId, + rightSortObjectId; + int definedOK; if (!leftTypeName && !rightTypeName) elog(WARN, "OperatorCreate : at least one of leftarg or rightarg must be defined"); diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 1dd1b0867c3..e135784ca63 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.6 1997/09/07 04:40:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.7 1997/09/08 02:21:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,23 +55,23 @@ ProcedureCreate(char *procedureName, List * argList, CommandDest dest) { - register i; - Relation rdesc; - HeapTuple tup; - bool defined; - uint16 parameterCount; - char nulls[Natts_pg_proc]; - Datum values[Natts_pg_proc]; - Oid languageObjectId; - Oid typeObjectId; - List *x; - QueryTreeList *querytree_list; - List *plan_list; - Oid typev[8]; - Oid relid; - Oid toid; - text *prosrctext; - TupleDesc tupDesc; + register i; + Relation rdesc; + HeapTuple tup; + bool defined; + uint16 parameterCount; + char nulls[Natts_pg_proc]; + Datum values[Natts_pg_proc]; + Oid languageObjectId; + Oid typeObjectId; + List *x; + QueryTreeList *querytree_list; + List *plan_list; + Oid typev[8]; + Oid relid; + Oid toid; + text *prosrctext; + TupleDesc tupDesc; /* ---------------- * sanity checks @@ -84,7 +84,7 @@ ProcedureCreate(char *procedureName, memset(typev, 0, 8 * sizeof(Oid)); foreach(x, argList) { - Value *t = lfirst(x); + Value *t = lfirst(x); if (parameterCount == 8) elog(WARN, "Procedures cannot take more than 8 arguments"); @@ -270,7 +270,7 @@ ProcedureCreate(char *procedureName, if (RelationGetRelationTupleForm(rdesc)->relhasindex) { - Relation idescs[Num_pg_proc_indices]; + Relation idescs[Num_pg_proc_indices]; CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs); CatalogIndexInsert(idescs, Num_pg_proc_indices, rdesc, tup); diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index 9a31030421c..63bae1ec59b 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.8 1997/09/07 04:40:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.9 1997/09/08 02:21:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,13 +44,13 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, * typeName -- name of type to be fetched * defined -- has the type been defined? */ -static Oid +static Oid TypeGetWithOpenRelation(Relation pg_type_desc, char *typeName, bool * defined) { - HeapScanDesc scan; - HeapTuple tup; + HeapScanDesc scan; + HeapTuple tup; static ScanKeyData typeKey[1] = { {0, Anum_pg_type_typname, NameEqualRegProcedure} @@ -118,8 +118,8 @@ Oid TypeGet(char *typeName, /* name of type to be fetched */ bool * defined) /* has the type been defined? */ { - Relation pg_type_desc; - Oid typeoid; + Relation pg_type_desc; + Oid typeoid; /* ---------------- * open the pg_type relation @@ -150,15 +150,15 @@ TypeGet(char *typeName, /* name of type to be fetched */ * * ---------------------------------------------------------------- */ -static Oid +static Oid TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) { - register int i; - HeapTuple tup; - Datum values[Natts_pg_type]; - char nulls[Natts_pg_type]; - Oid typoid; - TupleDesc tupDesc; + register int i; + HeapTuple tup; + Datum values[Natts_pg_type]; + char nulls[Natts_pg_type]; + Oid typoid; + TupleDesc tupDesc; /* ---------------- * initialize our nulls[] and values[] arrays @@ -214,7 +214,7 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex) { - Relation idescs[Num_pg_type_indices]; + Relation idescs[Num_pg_type_indices]; CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup); @@ -246,8 +246,8 @@ TypeShellMakeWithOpenRelation(Relation pg_type_desc, char *typeName) Oid TypeShellMake(char *typeName) { - Relation pg_type_desc; - Oid typoid; + Relation pg_type_desc; + Oid typoid; Assert(PointerIsValid(typeName)); @@ -295,27 +295,27 @@ TypeCreate(char *typeName, bool passedByValue, char alignment) { - register i, - j; - Relation pg_type_desc; - HeapScanDesc pg_type_scan; - - Oid typeObjectId; - Oid elementObjectId = InvalidOid; - - HeapTuple tup; - char nulls[Natts_pg_type]; - char replaces[Natts_pg_type]; - Datum values[Natts_pg_type]; - - Buffer buffer; - char *procname; - char *procs[4]; - bool defined; + register i, + j; + Relation pg_type_desc; + HeapScanDesc pg_type_scan; + + Oid typeObjectId; + Oid elementObjectId = InvalidOid; + + HeapTuple tup; + char nulls[Natts_pg_type]; + char replaces[Natts_pg_type]; + Datum values[Natts_pg_type]; + + Buffer buffer; + char *procname; + char *procs[4]; + bool defined; ItemPointerData itemPointerData; - TupleDesc tupDesc; + TupleDesc tupDesc; - Oid argList[8]; + Oid argList[8]; static ScanKeyData typeKey[1] = { @@ -522,7 +522,7 @@ TypeCreate(char *typeName, if (RelationGetRelationTupleForm(pg_type_desc)->relhasindex) { - Relation idescs[Num_pg_type_indices]; + Relation idescs[Num_pg_type_indices]; CatalogOpenIndices(Num_pg_type_indices, Name_pg_type_indices, idescs); CatalogIndexInsert(idescs, Num_pg_type_indices, pg_type_desc, tup); @@ -545,11 +545,11 @@ TypeCreate(char *typeName, void TypeRename(char *oldTypeName, char *newTypeName) { - Relation pg_type_desc; - Relation idescs[Num_pg_type_indices]; - Oid type_oid; - HeapTuple tup; - bool defined; + Relation pg_type_desc; + Relation idescs[Num_pg_type_indices]; + Oid type_oid; + HeapTuple tup; + bool defined; ItemPointerData itemPointerData; /* check that that the new type is not already defined */ @@ -603,10 +603,10 @@ TypeRename(char *oldTypeName, char *newTypeName) * the CALLER is responsible for pfreeing the */ -char * +char * makeArrayTypeName(char *typeName) { - char *arr; + char *arr; if (!typeName) return NULL; diff --git a/src/backend/commands/_deadcode/version.c b/src/backend/commands/_deadcode/version.c index c3eb6f47797..00594057672 100644 --- a/src/backend/commands/_deadcode/version.c +++ b/src/backend/commands/_deadcode/version.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.6 1997/09/07 04:41:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/_deadcode/Attic/version.c,v 1.7 1997/09/08 02:22:18 momjian Exp $ * * NOTES * At the point the version is defined, 2 physical relations are created @@ -34,10 +34,10 @@ #define MAX_QUERY_LEN 1024 -char rule_buf[MAX_QUERY_LEN]; +char rule_buf[MAX_QUERY_LEN]; #ifdef NOT_USED -static char attr_list[MAX_QUERY_LEN]; +static char attr_list[MAX_QUERY_LEN]; #endif @@ -105,9 +105,9 @@ eval_as_new_xact(char *query) void DefineVersion(char *name, char *fromRelname, char *date) { - char *bname; - static char saved_basename[512]; - static char saved_snapshot[512]; + char *bname; + static char saved_basename[512]; + static char saved_snapshot[512]; if (date == NULL) { @@ -148,7 +148,7 @@ DefineVersion(char *name, char *fromRelname, char *date) void VersionCreate(char *vname, char *bname) { - static char query_buf[MAX_QUERY_LEN]; + static char query_buf[MAX_QUERY_LEN]; /* * Creating the dummy version relation for triggering rules. @@ -184,12 +184,12 @@ VersionCreate(char *vname, char *bname) static void setAttrList(char *bname) { - Relation rdesc; - int i = 0; - int maxattrs = 0; - char *attrname; - char temp_buf[512]; - int notfirst = 0; + Relation rdesc; + int i = 0; + int maxattrs = 0; + char *attrname; + char temp_buf[512]; + int notfirst = 0; rdesc = heap_openr(bname); if (rdesc == NULL) diff --git a/src/backend/commands/async.c b/src/backend/commands/async.c index 42d440a8676..ee5b9baf553 100644 --- a/src/backend/commands/async.c +++ b/src/backend/commands/async.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.18 1997/09/07 04:40:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/async.c,v 1.19 1997/09/08 02:21:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -86,16 +86,16 @@ #include <storage/lmgr.h> -static int notifyFrontEndPending = 0; -static int notifyIssued = 0; -static Dllist *pendingNotifies = NULL; +static int notifyFrontEndPending = 0; +static int notifyIssued = 0; +static Dllist *pendingNotifies = NULL; -static int AsyncExistsPendingNotify(char *); -static void ClearPendingNotify(void); -static void Async_NotifyFrontEnd(void); -static void Async_Unlisten(char *relname, int pid); -static void Async_UnlistenOnExit(int code, char *relname); +static int AsyncExistsPendingNotify(char *); +static void ClearPendingNotify(void); +static void Async_NotifyFrontEnd(void); +static void Async_Unlisten(char *relname, int pid); +static void Async_UnlistenOnExit(int code, char *relname); /* *-------------------------------------------------------------- @@ -169,20 +169,20 @@ void Async_Notify(char *relname) { - HeapTuple lTuple, - rTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key; - Buffer b; - Datum d, - value[3]; - bool isnull; - char repl[3], - nulls[3]; - - char *notifyName; + HeapTuple lTuple, + rTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key; + Buffer b; + Datum d, + value[3]; + bool isnull; + char repl[3], + nulls[3]; + + char *notifyName; #ifdef ASYNC_DEBUG elog(DEBUG, "Async_Notify: %s", relname); @@ -256,15 +256,15 @@ Async_Notify(char *relname) void Async_NotifyAtCommit() { - HeapTuple lTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key; - Datum d; - int ourpid; - bool isnull; - Buffer b; + HeapTuple lTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key; + Datum d; + int ourpid; + bool isnull; + Buffer b; extern TransactionState CurrentTransactionState; if (!pendingNotifies) @@ -406,21 +406,21 @@ Async_NotifyAtAbort() void Async_Listen(char *relname, int pid) { - Datum values[Natts_pg_listener]; - char nulls[Natts_pg_listener]; - TupleDesc tdesc; - HeapScanDesc s; - HeapTuple htup, - tup; - Relation lDesc; - Buffer b; - Datum d; - int i; - bool isnull; - int alreadyListener = 0; - int ourPid = getpid(); - char *relnamei; - TupleDesc tupDesc; + Datum values[Natts_pg_listener]; + char nulls[Natts_pg_listener]; + TupleDesc tdesc; + HeapScanDesc s; + HeapTuple htup, + tup; + Relation lDesc; + Buffer b; + Datum d; + int i; + bool isnull; + int alreadyListener = 0; + int ourPid = getpid(); + char *relnamei; + TupleDesc tupDesc; #ifdef ASYNC_DEBUG elog(DEBUG, "Async_Listen: %s", relname); @@ -513,8 +513,8 @@ Async_Listen(char *relname, int pid) static void Async_Unlisten(char *relname, int pid) { - Relation lDesc; - HeapTuple lTuple; + Relation lDesc; + HeapTuple lTuple; lTuple = SearchSysCacheTuple(LISTENREL, PointerGetDatum(relname), Int32GetDatum(pid), @@ -560,25 +560,25 @@ Async_UnlistenOnExit(int code, /* from exitpg */ * * -------------------------------------------------------------- */ -GlobalMemory notifyContext = NULL; +GlobalMemory notifyContext = NULL; static void Async_NotifyFrontEnd() { extern CommandDest whereToSendOutput; - HeapTuple lTuple, - rTuple; - Relation lRel; - HeapScanDesc sRel; - TupleDesc tdesc; - ScanKeyData key[2]; - Datum d, - value[3]; - char repl[3], - nulls[3]; - Buffer b; - int ourpid; - bool isnull; + HeapTuple lTuple, + rTuple; + Relation lRel; + HeapScanDesc sRel; + TupleDesc tdesc; + ScanKeyData key[2]; + Datum d, + value[3]; + char repl[3], + nulls[3]; + Buffer b; + int ourpid; + bool isnull; notifyFrontEndPending = 0; @@ -635,7 +635,7 @@ Async_NotifyFrontEnd() static int AsyncExistsPendingNotify(char *relname) { - Dlelem *p; + Dlelem *p; for (p = DLGetHead(pendingNotifies); p != NULL; @@ -652,7 +652,7 @@ AsyncExistsPendingNotify(char *relname) static void ClearPendingNotify() { - Dlelem *p; + Dlelem *p; while ((p = DLRemHead(pendingNotifies)) != NULL) free(DLE_VAL(p)); diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index 2b18cb46df0..9e93388f729 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.14 1997/09/07 04:40:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.15 1997/09/08 02:21:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,8 +50,8 @@ #endif /* !NO_SECURITY */ static Relation copy_heap(Oid OIDOldHeap); -static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap); -static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); +static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap); +static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); /* * cluster @@ -82,18 +82,18 @@ static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex); void cluster(char oldrelname[], char oldindexname[]) { - Oid OIDOldHeap, - OIDOldIndex, - OIDNewHeap; + Oid OIDOldHeap, + OIDOldIndex, + OIDNewHeap; - Relation OldHeap, - OldIndex; - Relation NewHeap; + Relation OldHeap, + OldIndex; + Relation NewHeap; - char NewIndexName[NAMEDATALEN]; - char NewHeapName[NAMEDATALEN]; - char saveoldrelname[NAMEDATALEN]; - char saveoldindexname[NAMEDATALEN]; + char NewIndexName[NAMEDATALEN]; + char NewHeapName[NAMEDATALEN]; + char saveoldrelname[NAMEDATALEN]; + char saveoldindexname[NAMEDATALEN]; /* @@ -189,15 +189,15 @@ cluster(char oldrelname[], char oldindexname[]) StartTransactionCommand(); } -static Relation +static Relation copy_heap(Oid OIDOldHeap) { - char NewName[NAMEDATALEN]; - TupleDesc OldHeapDesc, - tupdesc; - Oid OIDNewHeap; - Relation NewHeap, - OldHeap; + char NewName[NAMEDATALEN]; + TupleDesc OldHeapDesc, + tupdesc; + Oid OIDNewHeap; + Relation NewHeap, + OldHeap; /* * Create a new heap relation with a temporary name, which has the @@ -235,18 +235,18 @@ copy_heap(Oid OIDOldHeap) static void copy_index(Oid OIDOldIndex, Oid OIDNewHeap) { - Relation OldIndex, - NewHeap; - HeapTuple Old_pg_index_Tuple, - Old_pg_index_relation_Tuple, - pg_proc_Tuple; - IndexTupleForm Old_pg_index_Form; - Form_pg_class Old_pg_index_relation_Form; - Form_pg_proc pg_proc_Form; - char *NewIndexName; - AttrNumber *attnumP; - int natts; - FuncIndexInfo *finfo; + Relation OldIndex, + NewHeap; + HeapTuple Old_pg_index_Tuple, + Old_pg_index_relation_Tuple, + pg_proc_Tuple; + IndexTupleForm Old_pg_index_Form; + Form_pg_class Old_pg_index_relation_Form; + Form_pg_proc pg_proc_Form; + char *NewIndexName; + AttrNumber *attnumP; + int natts; + FuncIndexInfo *finfo; NewHeap = heap_open(OIDNewHeap); OldIndex = index_open(OIDOldIndex); @@ -330,15 +330,15 @@ copy_index(Oid OIDOldIndex, Oid OIDNewHeap) static void rebuildheap(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) { - Relation LocalNewHeap, - LocalOldHeap, - LocalOldIndex; - IndexScanDesc ScanDesc; + Relation LocalNewHeap, + LocalOldHeap, + LocalOldIndex; + IndexScanDesc ScanDesc; RetrieveIndexResult ScanResult; - ItemPointer HeapTid; - HeapTuple LocalHeapTuple; - Buffer LocalBuffer; - Oid OIDNewHeapInsert; + ItemPointer HeapTid; + HeapTuple LocalHeapTuple; + Buffer LocalBuffer; + Oid OIDNewHeapInsert; /* * Open the relations I need. Scan through the OldHeap on the OldIndex diff --git a/src/backend/commands/command.c b/src/backend/commands/command.c index 7af9b37c072..0e409396ace 100644 --- a/src/backend/commands/command.c +++ b/src/backend/commands/command.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.14 1997/09/07 04:40:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/command.c,v 1.15 1997/09/08 02:22:01 momjian Exp $ * * NOTES * The PortalExecutorHeapMemory crap needs to be eliminated @@ -46,7 +46,7 @@ * This is where the XXXSuperDuperHacky code was. -cim 3/15/90 * ---------------- */ -MemoryContext PortalExecutorHeapMemory = NULL; +MemoryContext PortalExecutorHeapMemory = NULL; /* -------------------------------- * PortalCleanup @@ -55,7 +55,7 @@ MemoryContext PortalExecutorHeapMemory = NULL; void PortalCleanup(Portal portal) { - MemoryContext context; + MemoryContext context; /* ---------------- * sanity checks @@ -97,10 +97,10 @@ PerformPortalFetch(char *name, char *tag, CommandDest dest) { - Portal portal; - int feature; - QueryDesc *queryDesc; - MemoryContext context; + Portal portal; + int feature; + QueryDesc *queryDesc; + MemoryContext context; /* ---------------- * sanity checks @@ -151,7 +151,7 @@ PerformPortalFetch(char *name, BeginCommand(name, queryDesc->operation, portal->attinfo, /* QueryDescGetTypeInfo(queryDesc), - * */ + * */ false, /* portal fetches don't end up in * relations */ false, /* this is a portal fetch, not a "retrieve @@ -190,7 +190,7 @@ PerformPortalFetch(char *name, void PerformPortalClose(char *name, CommandDest dest) { - Portal portal; + Portal portal; /* ---------------- * sanity checks @@ -257,22 +257,22 @@ PerformAddAttribute(char *relationName, bool inherits, ColumnDef * colDef) { - Relation relrdesc, - attrdesc; - HeapScanDesc attsdesc; - HeapTuple reltup; - HeapTuple attributeTuple; + Relation relrdesc, + attrdesc; + HeapScanDesc attsdesc; + HeapTuple reltup; + HeapTuple attributeTuple; AttributeTupleForm attribute; FormData_pg_attribute attributeD; - int i; - int minattnum, - maxatts; - HeapTuple tup; - ScanKeyData key[2]; + int i; + int minattnum, + maxatts; + HeapTuple tup; + ScanKeyData key[2]; ItemPointerData oldTID; - Relation idescs[Num_pg_attr_indices]; - Relation ridescs[Num_pg_class_indices]; - bool hasindex; + Relation idescs[Num_pg_attr_indices]; + Relation ridescs[Num_pg_class_indices]; + bool hasindex; /* * permissions checking. this would normally be done in utility.c, @@ -310,10 +310,10 @@ PerformAddAttribute(char *relationName, { if (inherits) { - Oid myrelid, - childrelid; - List *child, - *children; + Oid myrelid, + childrelid; + List *child, + *children; relrdesc = heap_openr(relationName); if (!RelationIsValid(relrdesc)) @@ -418,10 +418,10 @@ PerformAddAttribute(char *relationName, i = 1 + minattnum; { - HeapTuple typeTuple; - TypeTupleForm form; - char *p; - int attnelems; + HeapTuple typeTuple; + TypeTupleForm form; + char *p; + int attnelems; /* * XXX use syscache here as an optimization diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index 795e9f5584f..d1e1db0cd43 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.30 1997/09/07 04:40:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.31 1997/09/08 02:22:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,33 +42,33 @@ /* non-export function prototypes */ -static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim); -static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim); -static Oid GetOutputFunction(Oid type); -static Oid GetTypeElement(Oid type); -static Oid GetInputFunction(Oid type); -static Oid IsTypeByVal(Oid type); +static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim); +static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim); +static Oid GetOutputFunction(Oid type); +static Oid GetTypeElement(Oid type); +static Oid GetInputFunction(Oid type); +static Oid IsTypeByVal(Oid type); static void GetIndexRelations(Oid main_relation_oid, int *n_indices, Relation ** index_rels); #ifdef COPY_PATCH -static void CopyReadNewline(FILE * fp, int *newline); -static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline); +static void CopyReadNewline(FILE * fp, int *newline); +static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline); #else -static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim); +static char *CopyReadAttribute(FILE * fp, bool * isnull, char *delim); #endif -static void CopyAttributeOut(FILE * fp, char *string, char *delim); -static int CountTuples(Relation relation); +static void CopyAttributeOut(FILE * fp, char *string, char *delim); +static int CountTuples(Relation relation); -extern FILE *Pfout, - *Pfin; +extern FILE *Pfout, + *Pfin; #ifdef COPY_DEBUG -static int lineno; +static int lineno; #endif @@ -107,11 +107,11 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, the class. ----------------------------------------------------------------------------*/ - FILE *fp; - Relation rel; - extern char *UserName; /* defined in global.c */ - const AclMode required_access = from ? ACL_WR : ACL_RD; - int result; + FILE *fp; + Relation rel; + extern char *UserName; /* defined in global.c */ + const AclMode required_access = from ? ACL_WR : ACL_RD; + int result; rel = heap_openr(relname); if (rel == NULL) @@ -169,7 +169,7 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, } else { - mode_t oumask; /* Pre-existing umask value */ + mode_t oumask; /* Pre-existing umask value */ oumask = umask((mode_t) 0); fp = AllocateFile(filename, "w"); @@ -199,19 +199,19 @@ DoCopy(char *relname, bool binary, bool oids, bool from, bool pipe, static void CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) { - HeapTuple tuple; - HeapScanDesc scandesc; + HeapTuple tuple; + HeapScanDesc scandesc; - int32 attr_count, - i; + int32 attr_count, + i; AttributeTupleForm *attr; - func_ptr *out_functions; - int dummy; - Oid out_func_oid; - Oid *elements; - Datum value; - bool isnull; /* The attribute we are copying is null */ - char *nulls; + func_ptr *out_functions; + int dummy; + Oid out_func_oid; + Oid *elements; + Datum value; + bool isnull; /* The attribute we are copying is null */ + char *nulls; /* * <nulls> is a (dynamically allocated) array with one character per @@ -220,9 +220,9 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) * * <nulls> is meaningful only if we are doing a binary copy. */ - char *string; - int32 ntuples; - TupleDesc tupDesc; + char *string; + int32 ntuples; + TupleDesc tupDesc; scandesc = heap_beginscan(rel, 0, NULL, 0, NULL); @@ -311,8 +311,8 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (binary) { - int32 null_ct = 0, - length; + int32 null_ct = 0, + length; for (i = 0; i < attr_count; i++) { @@ -358,54 +358,54 @@ CopyTo(Relation rel, bool binary, bool oids, FILE * fp, char *delim) static void CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) { - HeapTuple tuple; - AttrNumber attr_count; + HeapTuple tuple; + AttrNumber attr_count; AttributeTupleForm *attr; - func_ptr *in_functions; - int i, - dummy; - Oid in_func_oid; - Datum *values; - char *nulls, - *index_nulls; - bool *byval; - bool isnull; - bool has_index; - int done = 0; - char *string = NULL, - *ptr; - Relation *index_rels; - int32 len, - null_ct, - null_id; - int32 ntuples, - tuples_read = 0; - bool reading_to_eof = true; - Oid *elements; - FuncIndexInfo *finfo, - **finfoP = NULL; - TupleDesc *itupdescArr; - HeapTuple pgIndexTup; + func_ptr *in_functions; + int i, + dummy; + Oid in_func_oid; + Datum *values; + char *nulls, + *index_nulls; + bool *byval; + bool isnull; + bool has_index; + int done = 0; + char *string = NULL, + *ptr; + Relation *index_rels; + int32 len, + null_ct, + null_id; + int32 ntuples, + tuples_read = 0; + bool reading_to_eof = true; + Oid *elements; + FuncIndexInfo *finfo, + **finfoP = NULL; + TupleDesc *itupdescArr; + HeapTuple pgIndexTup; IndexTupleForm *pgIndexP = NULL; - int *indexNatts = NULL; - char *predString; - Node **indexPred = NULL; - TupleDesc rtupdesc; - ExprContext *econtext = NULL; + int *indexNatts = NULL; + char *predString; + Node **indexPred = NULL; + TupleDesc rtupdesc; + ExprContext *econtext = NULL; #ifndef OMIT_PARTIAL_INDEX - TupleTable tupleTable; + TupleTable tupleTable; TupleTableSlot *slot = NULL; #endif - int natts; - AttrNumber *attnumP; - Datum *idatum; - int n_indices; + int natts; + AttrNumber *attnumP; + Datum *idatum; + int n_indices; InsertIndexResult indexRes; - TupleDesc tupDesc; - Oid loaded_oid; - bool skip_tuple = false; + TupleDesc tupDesc; + Oid loaded_oid; + bool skip_tuple = false; tupDesc = RelationGetTupleDescriptor(rel); attr = tupDesc->attrs; @@ -541,7 +541,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (!binary) { #ifdef COPY_PATCH - int newline = 0; + int newline = 0; #endif #ifdef COPY_DEBUG @@ -647,58 +647,58 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) switch (attr[i]->attlen) { - case sizeof(char): - values[i] = (Datum) * (unsigned char *) ptr; - ptr += sizeof(char); - break; - case sizeof(short): - ptr = (char *) SHORTALIGN(ptr); - values[i] = (Datum) * (unsigned short *) ptr; - ptr += sizeof(short); - break; - case sizeof(int32): - ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) * (uint32 *) ptr; - ptr += sizeof(int32); - break; - default: - elog(WARN, "COPY BINARY: impossible size!"); - break; + case sizeof(char): + values[i] = (Datum) * (unsigned char *) ptr; + ptr += sizeof(char); + break; + case sizeof(short): + ptr = (char *) SHORTALIGN(ptr); + values[i] = (Datum) * (unsigned short *) ptr; + ptr += sizeof(short); + break; + case sizeof(int32): + ptr = (char *) INTALIGN(ptr); + values[i] = (Datum) * (uint32 *) ptr; + ptr += sizeof(int32); + break; + default: + elog(WARN, "COPY BINARY: impossible size!"); + break; } } else if (nulls[i] != 'n') { switch (attr[i]->attlen) { - case -1: - if (attr[i]->attalign == 'd') - ptr = (char *) DOUBLEALIGN(ptr); - else + case -1: + if (attr[i]->attalign == 'd') + ptr = (char *) DOUBLEALIGN(ptr); + else + ptr = (char *) INTALIGN(ptr); + values[i] = (Datum) ptr; + ptr += *(uint32 *) ptr; + break; + case sizeof(char): + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + case sizeof(short): + ptr = (char *) SHORTALIGN(ptr); + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + case sizeof(int32): ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += *(uint32 *) ptr; - break; - case sizeof(char): - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - case sizeof(short): - ptr = (char *) SHORTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - case sizeof(int32): - ptr = (char *) INTALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; - break; - default: - if (attr[i]->attalign == 'd') - ptr = (char *) DOUBLEALIGN(ptr); - else - ptr = (char *) LONGALIGN(ptr); - values[i] = (Datum) ptr; - ptr += attr[i]->attlen; + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; + break; + default: + if (attr[i]->attalign == 'd') + ptr = (char *) DOUBLEALIGN(ptr); + else + ptr = (char *) LONGALIGN(ptr); + values[i] = (Datum) ptr; + ptr += attr[i]->attlen; } } } @@ -721,7 +721,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (rel->trigdesc && rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRInsertTriggers(rel, tuple); @@ -743,7 +743,7 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) if (rel->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("CopyFrom", rel, tuple); @@ -826,10 +826,10 @@ CopyFrom(Relation rel, bool binary, bool oids, FILE * fp, char *delim) -static Oid +static Oid GetOutputFunction(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -842,10 +842,10 @@ GetOutputFunction(Oid type) return (InvalidOid); } -static Oid +static Oid GetTypeElement(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -859,10 +859,10 @@ GetTypeElement(Oid type) return (InvalidOid); } -static Oid +static Oid GetInputFunction(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -875,10 +875,10 @@ GetInputFunction(Oid type) return (InvalidOid); } -static Oid +static Oid IsTypeByVal(Oid type) { - HeapTuple typeTuple; + HeapTuple typeTuple; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type), @@ -902,24 +902,24 @@ IsTypeByVal(Oid type) typedef struct rel_list { - Oid index_rel_oid; + Oid index_rel_oid; struct rel_list *next; -} RelationList; +} RelationList; static void GetIndexRelations(Oid main_relation_oid, int *n_indices, Relation ** index_rels) { - RelationList *head, - *scan; - Relation pg_index_rel; - HeapScanDesc scandesc; - Oid index_relation_oid; - HeapTuple tuple; - TupleDesc tupDesc; - int i; - bool isnull; + RelationList *head, + *scan; + Relation pg_index_rel; + HeapScanDesc scandesc; + Oid index_relation_oid; + HeapTuple tuple; + TupleDesc tupDesc; + int i; + bool isnull; pg_index_rel = heap_openr(IndexRelationName); scandesc = heap_beginscan(pg_index_rel, 0, NULL, 0, NULL); @@ -978,10 +978,10 @@ GetIndexRelations(Oid main_relation_oid, /* returns 1 is c is in s */ -static bool +static bool inString(char c, char *s) { - int i; + int i; if (s) { @@ -1026,17 +1026,17 @@ CopyReadNewline(FILE * fp, int *newline) * can be used as standard input. */ -static char * +static char * #ifdef COPY_PATCH CopyReadAttribute(FILE * fp, bool * isnull, char *delim, int *newline) #else CopyReadAttribute(FILE * fp, bool * isnull, char *delim) #endif { - static char attribute[EXT_ATTLEN]; - char c; - int done = 0; - int i = 0; + static char attribute[EXT_ATTLEN]; + char c; + int done = 0; + int i = 0; #ifdef COPY_PATCH /* if last delimiter was a newline return a NULL attribute */ @@ -1064,26 +1064,33 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) return (NULL); switch (c) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - int val; - - val = VALUE(c); - c = getc(fp); - if (ISOCTAL(c)) + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': { - val = (val << 3) + VALUE(c); + int val; + + val = VALUE(c); c = getc(fp); if (ISOCTAL(c)) { val = (val << 3) + VALUE(c); + c = getc(fp); + if (ISOCTAL(c)) + { + val = (val << 3) + VALUE(c); + } + else + { + if (feof(fp)) + return (NULL); + ungetc(c, fp); + } } else { @@ -1091,44 +1098,37 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) return (NULL); ungetc(c, fp); } + c = val & 0377; } - else - { - if (feof(fp)) - return (NULL); - ungetc(c, fp); - } - c = val & 0377; - } - break; - case 'b': - c = '\b'; - break; - case 'f': - c = '\f'; - break; - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'v': - c = '\v'; - break; - case 'N': - attribute[0] = '\0'; /* just to be safe */ - *isnull = (bool) true; - break; - case '.': - c = getc(fp); - if (c != '\n') - elog(WARN, "CopyReadAttribute - end of record marker corrupted"); - return (NULL); - break; + break; + case 'b': + c = '\b'; + break; + case 'f': + c = '\f'; + break; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'v': + c = '\v'; + break; + case 'N': + attribute[0] = '\0'; /* just to be safe */ + *isnull = (bool) true; + break; + case '.': + c = getc(fp); + if (c != '\n') + elog(WARN, "CopyReadAttribute - end of record marker corrupted"); + return (NULL); + break; } } else if (inString(c, delim) || c == '\n') @@ -1153,9 +1153,9 @@ CopyReadAttribute(FILE * fp, bool * isnull, char *delim) static void CopyAttributeOut(FILE * fp, char *string, char *delim) { - char c; - int is_array = false; - int len = strlen(string); + char c; + int is_array = false; + int len = strlen(string); /* XXX - This is a kludge, we should check the data type */ if (len && (string[0] == '{') && (string[len - 1] == '}')) @@ -1194,10 +1194,10 @@ CopyAttributeOut(FILE * fp, char *string, char *delim) static int CountTuples(Relation relation) { - HeapScanDesc scandesc; - HeapTuple tuple; + HeapScanDesc scandesc; + HeapTuple tuple; - int i; + int i; scandesc = heap_beginscan(relation, 0, NULL, 0, NULL); diff --git a/src/backend/commands/creatinh.c b/src/backend/commands/creatinh.c index 92641ca70d6..e1dac613fe6 100644 --- a/src/backend/commands/creatinh.c +++ b/src/backend/commands/creatinh.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.15 1997/09/07 04:40:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/creatinh.c,v 1.16 1997/09/08 02:22:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,8 +36,8 @@ static int checkAttrExists(char *attributeName, char *attributeType, List * schema); -static List *MergeAttributes(List * schema, List * supers, List ** supconstr); -static void StoreCatalogInheritance(Oid relationId, List * supers); +static List *MergeAttributes(List * schema, List * supers, List ** supconstr); +static void StoreCatalogInheritance(Oid relationId, List * supers); /* ---------------------------------------------------------------- * DefineRelation -- @@ -47,20 +47,20 @@ static void StoreCatalogInheritance(Oid relationId, List * supers); void DefineRelation(CreateStmt * stmt) { - char *relname = palloc(NAMEDATALEN); - List *schema = stmt->tableElts; - int numberOfAttributes; - Oid relationId; - char archChar; - List *inheritList = NULL; - char *archiveName = NULL; - TupleDesc descriptor; - List *constraints; - int heaploc, - archloc; - - char *typename = NULL; /* the typename of this relation. - * not useod for now */ + char *relname = palloc(NAMEDATALEN); + List *schema = stmt->tableElts; + int numberOfAttributes; + Oid relationId; + char archChar; + List *inheritList = NULL; + char *archiveName = NULL; + TupleDesc descriptor; + List *constraints; + int heaploc, + archloc; + + char *typename = NULL;/* the typename of this relation. not + * useod for now */ if (strlen(stmt->relname) >= NAMEDATALEN) elog(WARN, "the relation name %s is >= %d characters long", stmt->relname, @@ -84,19 +84,19 @@ DefineRelation(CreateStmt * stmt) switch (stmt->archiveType) { - case ARCH_NONE: - archChar = 'n'; - break; - case ARCH_LIGHT: - archChar = 'l'; - break; - case ARCH_HEAVY: - archChar = 'h'; - break; - default: - elog(WARN, "Botched archive mode %d, ignoring", - stmt->archiveType); - break; + case ARCH_NONE: + archChar = 'n'; + break; + case ARCH_LIGHT: + archChar = 'l'; + break; + case ARCH_HEAVY: + archChar = 'h'; + break; + default: + elog(WARN, "Botched archive mode %d, ignoring", + stmt->archiveType); + break; } if (stmt->location == -1) @@ -145,15 +145,15 @@ DefineRelation(CreateStmt * stmt) if (constraints != NIL) { - List *entry; - int nconstr = length(constraints); - ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck)); - int ncheck = 0; - int i; + List *entry; + int nconstr = length(constraints); + ConstrCheck *check = (ConstrCheck *) palloc(nconstr * sizeof(ConstrCheck)); + int ncheck = 0; + int i; foreach(entry, constraints) { - ConstraintDef *cdef = (ConstraintDef *) lfirst(entry); + ConstraintDef *cdef = (ConstraintDef *) lfirst(entry); if (cdef->type == CONSTR_CHECK) { @@ -204,7 +204,7 @@ DefineRelation(CreateStmt * stmt) */ if (archChar != 'n') { - TupleDesc tupdesc; + TupleDesc tupdesc; /* * Need to create an archive relation for this heap relation. We @@ -279,12 +279,12 @@ RemoveRelation(char *name) * \ / * stud_emp {7:percent} */ -static List * +static List * MergeAttributes(List * schema, List * supers, List ** supconstr) { - List *entry; - List *inhSchema = NIL; - List *constraints = NIL; + List *entry; + List *inhSchema = NIL; + List *constraints = NIL; /* * Validates that there are no duplications. Validity checking of @@ -292,8 +292,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) */ foreach(entry, schema) { - List *rest; - ColumnDef *coldef = lfirst(entry); + List *rest; + ColumnDef *coldef = lfirst(entry); foreach(rest, lnext(entry)) { @@ -301,7 +301,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) /* * check for duplicated relation names */ - ColumnDef *restdef = lfirst(rest); + ColumnDef *restdef = lfirst(rest); if (!strcmp(coldef->colname, restdef->colname)) { @@ -312,7 +312,7 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) } foreach(entry, supers) { - List *rest; + List *rest; foreach(rest, lnext(entry)) { @@ -329,12 +329,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) */ foreach(entry, supers) { - char *name = strVal(lfirst(entry)); - Relation relation; - List *partialResult = NIL; - AttrNumber attrno; - TupleDesc tupleDesc; - TupleConstr *constr; + char *name = strVal(lfirst(entry)); + Relation relation; + List *partialResult = NIL; + AttrNumber attrno; + TupleDesc tupleDesc; + TupleConstr *constr; relation = heap_openr(name); if (relation == NULL) @@ -354,11 +354,11 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) for (attrno = relation->rd_rel->relnatts - 1; attrno >= 0; attrno--) { AttributeTupleForm attribute = tupleDesc->attrs[attrno]; - char *attributeName; - char *attributeType; - HeapTuple tuple; - ColumnDef *def; - TypeName *typename; + char *attributeName; + char *attributeType; + HeapTuple tuple; + ColumnDef *def; + TypeName *typename; /* * form name, type and constraints @@ -398,8 +398,8 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) def->defval = NULL; if (attribute->atthasdef) { - AttrDefault *attrdef = constr->defval; - int i; + AttrDefault *attrdef = constr->defval; + int i; Assert(constr != NULL && constr->num_defval > 0); @@ -417,12 +417,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) if (constr && constr->num_check > 0) { - ConstrCheck *check = constr->check; - int i; + ConstrCheck *check = constr->check; + int i; for (i = 0; i < constr->num_check; i++) { - ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef)); + ConstraintDef *cdef = (ConstraintDef *) palloc(sizeof(ConstraintDef)); cdef->type = CONSTR_CHECK; if (check[i].ccname[0] == '$') @@ -461,12 +461,12 @@ MergeAttributes(List * schema, List * supers, List ** supconstr) static void StoreCatalogInheritance(Oid relationId, List * supers) { - Relation relation; - TupleDesc desc; - int16 seqNumber; - List *entry; - List *idList; - HeapTuple tuple; + Relation relation; + TupleDesc desc; + int16 seqNumber; + List *entry; + List *idList; + HeapTuple tuple; /* ---------------- * sanity checks @@ -488,8 +488,8 @@ StoreCatalogInheritance(Oid relationId, List * supers) idList = NIL; foreach(entry, supers) { - Datum datum[Natts_pg_inherits]; - char nullarr[Natts_pg_inherits]; + Datum datum[Natts_pg_inherits]; + char nullarr[Natts_pg_inherits]; tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(strVal(lfirst(entry))), @@ -536,11 +536,11 @@ StoreCatalogInheritance(Oid relationId, List * supers) */ foreach(entry, idList) { - HeapTuple tuple; - Oid id; - int16 number; - List *next; - List *current; + HeapTuple tuple; + Oid id; + int16 number; + List *next; + List *current; id = (Oid) lfirsti(entry); current = entry; @@ -572,9 +572,9 @@ StoreCatalogInheritance(Oid relationId, List * supers) */ foreach(entry, idList) { - Oid name; - List *rest; - bool found = false; + Oid name; + List *rest; + bool found = false; again: name = lfirsti(entry); @@ -613,8 +613,8 @@ again: foreach(entry, idList) { - Datum datum[Natts_pg_ipl]; - char nullarr[Natts_pg_ipl]; + Datum datum[Natts_pg_ipl]; + char nullarr[Natts_pg_ipl]; datum[0] = ObjectIdGetDatum(relationId); /* iplrel */ datum[1] = ObjectIdGetDatum(lfirsti(entry)); @@ -642,11 +642,11 @@ again: static int checkAttrExists(char *attributeName, char *attributeType, List * schema) { - List *s; + List *s; foreach(s, schema) { - ColumnDef *def = lfirst(s); + ColumnDef *def = lfirst(s); if (!strcmp(attributeName, def->colname)) { @@ -672,10 +672,10 @@ checkAttrExists(char *attributeName, char *attributeType, List * schema) * the CALLER is responsible for freeing the memory allocated */ -char * +char * MakeArchiveName(Oid relationId) { - char *arch; + char *arch; /* * Archive relations are named a,XXXXX where XXXXX == the OID of the diff --git a/src/backend/commands/defind.c b/src/backend/commands/defind.c index 9b8c5a0218a..92bb0e7c093 100644 --- a/src/backend/commands/defind.c +++ b/src/backend/commands/defind.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.13 1997/09/07 04:40:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/defind.c,v 1.14 1997/09/08 02:22:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,19 +39,19 @@ #define IsFuncIndex(ATTR_LIST) (((IndexElem*)lfirst(ATTR_LIST))->args!=NULL) /* non-export function prototypes */ -static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid); +static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid); static void CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid); static void - CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid); + CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid); static void FuncIndexArgs(IndexElem * funcIndex, AttrNumber * attNumP, Oid * argTypes, Oid * opOidP, Oid relId); static void NormIndexAttrs(List * attList, AttrNumber * attNumP, Oid * opOidP, Oid relId); -static char *GetDefaultOpClass(Oid atttypid); +static char *GetDefaultOpClass(Oid atttypid); /* * DefineIndex -- @@ -76,18 +76,18 @@ DefineIndex(char *heapRelationName, Expr * predicate, List * rangetable) { - Oid *classObjectId; - Oid accessMethodId; - Oid relationId; - int numberOfAttributes; - AttrNumber *attributeNumberA; - HeapTuple tuple; - uint16 parameterCount = 0; - Datum *parameterA = NULL; - FuncIndexInfo fInfo; - List *cnfPred = NULL; - bool lossy = FALSE; - List *pl; + Oid *classObjectId; + Oid accessMethodId; + Oid relationId; + int numberOfAttributes; + AttrNumber *attributeNumberA; + HeapTuple tuple; + uint16 parameterCount = 0; + Datum *parameterA = NULL; + FuncIndexInfo fInfo; + List *cnfPred = NULL; + bool lossy = FALSE; + List *pl; /* * Handle attributes @@ -138,7 +138,7 @@ DefineIndex(char *heapRelationName, */ foreach(pl, parameterList) { - ParamString *param = (ParamString *) lfirst(pl); + ParamString *param = (ParamString *) lfirst(pl); if (!strcasecmp(param->name, "islossy")) lossy = TRUE; @@ -162,8 +162,8 @@ DefineIndex(char *heapRelationName, if (IsFuncIndex(attributeList)) { - IndexElem *funcIndex = lfirst(attributeList); - int nargs; + IndexElem *funcIndex = lfirst(attributeList); + int nargs; nargs = length(funcIndex->args); if (nargs > INDEX_MAX_KEYS) @@ -225,23 +225,23 @@ DefineIndex(char *heapRelationName, void ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) { - Oid *classObjectId; - Oid accessMethodId; - Oid indexId, - relationId; - Oid indproc; - int numberOfAttributes; - AttrNumber *attributeNumberA; - HeapTuple tuple; - FuncIndexInfo fInfo; - FuncIndexInfo *funcInfo = NULL; - IndexTupleForm index; - Node *oldPred = NULL; - List *cnfPred = NULL; - PredInfo *predInfo; - Relation heapRelation; - Relation indexRelation; - int i; + Oid *classObjectId; + Oid accessMethodId; + Oid indexId, + relationId; + Oid indproc; + int numberOfAttributes; + AttrNumber *attributeNumberA; + HeapTuple tuple; + FuncIndexInfo fInfo; + FuncIndexInfo *funcInfo = NULL; + IndexTupleForm index; + Node *oldPred = NULL; + List *cnfPred = NULL; + PredInfo *predInfo; + Relation heapRelation; + Relation indexRelation; + int i; /* * compute index relation id and access method id @@ -283,7 +283,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) if (VARSIZE(&index->indpred) != 0) { - char *predString; + char *predString; predString = fmgr(F_TEXTOUT, &index->indpred); oldPred = stringToNode(predString); @@ -366,7 +366,7 @@ ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable) static void CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid) { - List *item; + List *item; foreach(item, predList) { @@ -377,8 +377,8 @@ CheckPredicate(List * predList, List * rangeTable, Oid baseRelOid) static void CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid) { - List *clauses = NIL, - *clause; + List *clauses = NIL, + *clause; if (is_opclause(predicate)) { @@ -401,8 +401,8 @@ CheckPredExpr(Node * predicate, List * rangeTable, Oid baseRelOid) static void CheckPredClause(Expr * predicate, List * rangeTable, Oid baseRelOid) { - Var *pred_var; - Const *pred_const; + Var *pred_var; + Const *pred_const; pred_var = (Var *) get_leftop(predicate); pred_const = (Const *) get_rightop(predicate); @@ -427,8 +427,8 @@ FuncIndexArgs(IndexElem * funcIndex, Oid * opOidP, Oid relId) { - List *rest; - HeapTuple tuple; + List *rest; + HeapTuple tuple; AttributeTupleForm att; tuple = SearchSysCacheTuple(CLANAME, @@ -449,7 +449,7 @@ FuncIndexArgs(IndexElem * funcIndex, */ for (rest = funcIndex->args; rest != NIL; rest = lnext(rest)) { - char *arg; + char *arg; arg = strVal(lfirst(rest)); @@ -475,8 +475,8 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ Oid * opOidP, Oid relId) { - List *rest; - HeapTuple tuple; + List *rest; + HeapTuple tuple; /* * process attributeList @@ -484,7 +484,7 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ for (rest = attList; rest != NIL; rest = lnext(rest)) { - IndexElem *attribute; + IndexElem *attribute; AttributeTupleForm attform; attribute = lfirst(rest); @@ -531,10 +531,10 @@ NormIndexAttrs(List * attList, /* list of IndexElem's */ } } -static char * +static char * GetDefaultOpClass(Oid atttypid) { - HeapTuple tuple; + HeapTuple tuple; tuple = SearchSysCacheTuple(CLADEFTYPE, ObjectIdGetDatum(atttypid), @@ -559,7 +559,7 @@ GetDefaultOpClass(Oid atttypid) void RemoveIndex(char *name) { - HeapTuple tuple; + HeapTuple tuple; tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(name), diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index fb1df213cec..52a0b716f97 100644 --- a/src/backend/commands/define.c +++ b/src/backend/commands/define.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.14 1997/09/07 04:40:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.15 1997/09/08 02:22:09 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -53,8 +53,8 @@ #include <tcop/dest.h> #include <catalog/pg_user.h> -static char *defGetString(DefElem * def); -static int defGetTypeLength(DefElem * def); +static char *defGetString(DefElem * def); +static int defGetTypeLength(DefElem * def); #define DEFAULT_TYPDELIM ',' @@ -66,7 +66,7 @@ case_translate_language_name(const char *input, char *output) Translate the input language name to lower case, except if it's C, translate to upper case. --------------------------------------------------------------------------*/ - int i; + int i; for (i = 0; i < NAMEDATALEN && input[i] != '\0'; ++i) output[i] = tolower(input[i]); @@ -90,7 +90,7 @@ compute_return_type(const Node * returnType, if (nodeTag(returnType) == T_TypeName) { /* a set of values */ - TypeName *setType = (TypeName *) returnType; + TypeName *setType = (TypeName *) returnType; *prorettype_p = setType->name; *returnsSet_p = true; @@ -116,7 +116,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, These are the full parameters of a C or internal function. ---------------------------------------------------------------------------*/ - List *pl; + List *pl; /* the defaults */ *byte_pct_p = BYTE_PCT; @@ -126,7 +126,7 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, foreach(pl, (List *) parameters) { - ParamString *param = (ParamString *) lfirst(pl); + ParamString *param = (ParamString *) lfirst(pl); if (strcasecmp(param->name, "iscachable") == 0) { @@ -153,8 +153,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, { if (sscanf(param->val, "%d", perbyte_cpu_p) == 0) { - int count; - char *ptr; + int count; + char *ptr; for (count = 0, ptr = param->val; *ptr != '\0'; ptr++) if (*ptr == '!') @@ -166,8 +166,8 @@ compute_full_attributes(const List * parameters, int32 * byte_pct_p, { if (sscanf(param->val, "%d", percall_cpu_p) == 0) { - int count; - char *ptr; + int count; + char *ptr; for (count = 0, ptr = param->val; *ptr != '\0'; ptr++) if (*ptr == '!') @@ -212,16 +212,16 @@ interpret_AS_clause(const char languageName[], const char as[], void CreateFunction(ProcedureStmt * stmt, CommandDest dest) { - char *probin_str; + char *probin_str; /* pathname of executable file that executes this function, if any */ - char *prosrc_str; + char *prosrc_str; /* SQL that executes this function, if any */ - char *prorettype; + char *prorettype; /* Type of return value (or member of set of values) from function */ - char languageName[NAMEDATALEN]; + char languageName[NAMEDATALEN]; /* * name of language of function, with case adjusted: "C", "internal", @@ -232,12 +232,12 @@ CreateFunction(ProcedureStmt * stmt, CommandDest dest) * The following are attributes of the function, as expressed in the * CREATE FUNCTION statement, where applicable. */ - int32 byte_pct, - perbyte_cpu, - percall_cpu, - outin_ratio; - bool canCache; - bool returnsSet; + int32 byte_pct, + perbyte_cpu, + percall_cpu, + outin_ratio; + bool canCache; + bool returnsSet; /* The function returns a set of values, as opposed to a singleton. */ @@ -317,30 +317,29 @@ void DefineOperator(char *oprName, List * parameters) { - uint16 precedence = 0; /* operator precedence */ - bool canHash = false; /* operator hashes */ - bool isLeftAssociative = true; /* operator is left + uint16 precedence = 0; /* operator precedence */ + bool canHash = false;/* operator hashes */ + bool isLeftAssociative = true; /* operator is left * associative */ - char *functionName = NULL; /* function for operator */ - char *typeName1 = NULL; /* first type name */ - char *typeName2 = NULL; /* second type name */ - char *commutatorName = NULL; /* optional commutator - * operator name */ - char *negatorName = NULL; /* optional negator operator name */ - char *restrictionName = NULL; /* optional restrict. sel. - * procedure */ - char *joinName = NULL; /* optional join sel. procedure + char *functionName = NULL; /* function for operator */ + char *typeName1 = NULL; /* first type name */ + char *typeName2 = NULL; /* second type name */ + char *commutatorName = NULL; /* optional commutator operator * name */ - char *sortName1 = NULL; /* optional first sort operator */ - char *sortName2 = NULL; /* optional second sort operator */ - List *pl; + char *negatorName = NULL; /* optional negator operator name */ + char *restrictionName = NULL; /* optional restrict. sel. + * procedure */ + char *joinName = NULL;/* optional join sel. procedure name */ + char *sortName1 = NULL; /* optional first sort operator */ + char *sortName2 = NULL; /* optional second sort operator */ + List *pl; /* * loop over the definition list and extract the information we need. */ foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); if (!strcasecmp(defel->defname, "leftarg")) { @@ -465,19 +464,19 @@ void DefineAggregate(char *aggName, List * parameters) { - char *stepfunc1Name = NULL; - char *stepfunc2Name = NULL; - char *finalfuncName = NULL; - char *baseType = NULL; - char *stepfunc1Type = NULL; - char *stepfunc2Type = NULL; - char *init1 = NULL; - char *init2 = NULL; - List *pl; + char *stepfunc1Name = NULL; + char *stepfunc2Name = NULL; + char *finalfuncName = NULL; + char *baseType = NULL; + char *stepfunc1Type = NULL; + char *stepfunc2Type = NULL; + char *init1 = NULL; + char *init2 = NULL; + List *pl; foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); /* * sfunc1 @@ -573,19 +572,19 @@ DefineAggregate(char *aggName, List * parameters) void DefineType(char *typeName, List * parameters) { - int16 internalLength = 0; /* int2 */ - int16 externalLength = 0; /* int2 */ - char *elemName = NULL; - char *inputName = NULL; - char *outputName = NULL; - char *sendName = NULL; - char *receiveName = NULL; - char *defaultValue = NULL; /* Datum */ - bool byValue = false; - char delimiter = DEFAULT_TYPDELIM; - char *shadow_type; - List *pl; - char alignment = 'i'; /* default alignment */ + int16 internalLength = 0; /* int2 */ + int16 externalLength = 0; /* int2 */ + char *elemName = NULL; + char *inputName = NULL; + char *outputName = NULL; + char *sendName = NULL; + char *receiveName = NULL; + char *defaultValue = NULL; /* Datum */ + bool byValue = false; + char delimiter = DEFAULT_TYPDELIM; + char *shadow_type; + List *pl; + char alignment = 'i';/* default alignment */ /* * Type names can only be 15 characters long, so that the shadow type @@ -599,7 +598,7 @@ DefineType(char *typeName, List * parameters) foreach(pl, parameters) { - DefElem *defel = (DefElem *) lfirst(pl); + DefElem *defel = (DefElem *) lfirst(pl); if (!strcasecmp(defel->defname, "internallength")) { @@ -623,7 +622,7 @@ DefineType(char *typeName, List * parameters) } else if (!strcasecmp(defel->defname, "delimiter")) { - char *p = defGetString(defel); + char *p = defGetString(defel); delimiter = p[0]; } @@ -645,7 +644,7 @@ DefineType(char *typeName, List * parameters) } else if (!strcasecmp(defel->defname, "alignment")) { - char *a = defGetString(defel); + char *a = defGetString(defel); if (!strcasecmp(a, "double")) { @@ -720,7 +719,7 @@ DefineType(char *typeName, List * parameters) pfree(shadow_type); } -static char * +static char * defGetString(DefElem * def) { if (nodeTag(def->arg) != T_String) diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index 192076e3911..c1ad092e92f 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.11 1997/09/07 04:40:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.12 1997/09/08 02:22:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,13 +28,13 @@ typedef struct ExplainState { /* options */ - bool printCost; /* print cost */ - bool printNodes; /* do nodeToString() instead */ + bool printCost; /* print cost */ + bool printNodes; /* do nodeToString() instead */ /* other states */ - List *rtable; /* range table */ -} ExplainState; + List *rtable; /* range table */ +} ExplainState; -static char *Explain_PlanToString(Plan * plan, ExplainState * es); +static char *Explain_PlanToString(Plan * plan, ExplainState * es); /* * ExplainQuery - @@ -44,15 +44,15 @@ static char *Explain_PlanToString(Plan * plan, ExplainState * es); void ExplainQuery(Query * query, bool verbose, CommandDest dest) { - char *s = NULL, - *s2; - Plan *plan; - ExplainState *es; - int len; + char *s = NULL, + *s2; + Plan *plan; + ExplainState *es; + int len; if (IsAbortedTransactionBlockState()) { - char *tag = "*ABORT STATE*"; + char *tag = "*ABORT STATE*"; EndCommand(tag, dest); @@ -118,9 +118,9 @@ ExplainQuery(Query * query, bool verbose, CommandDest dest) static void explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) { - char *pname; - char buf[1000]; - int i; + char *pname; + char buf[1000]; + int i; if (plan == NULL) { @@ -130,51 +130,51 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) switch (nodeTag(plan)) { - case T_Result: - pname = "Result"; - break; - case T_Append: - pname = "Append"; - break; - case T_NestLoop: - pname = "Nested Loop"; - break; - case T_MergeJoin: - pname = "Merge Join"; - break; - case T_HashJoin: - pname = "Hash Join"; - break; - case T_SeqScan: - pname = "Seq Scan"; - break; - case T_IndexScan: - pname = "Index Scan"; - break; - case T_Temp: - pname = "Temp Scan"; - break; - case T_Sort: - pname = "Sort"; - break; - case T_Group: - pname = "Group"; - break; - case T_Agg: - pname = "Aggregate"; - break; - case T_Unique: - pname = "Unique"; - break; - case T_Hash: - pname = "Hash"; - break; - case T_Tee: - pname = "Tee"; - break; - default: - pname = ""; - break; + case T_Result: + pname = "Result"; + break; + case T_Append: + pname = "Append"; + break; + case T_NestLoop: + pname = "Nested Loop"; + break; + case T_MergeJoin: + pname = "Merge Join"; + break; + case T_HashJoin: + pname = "Hash Join"; + break; + case T_SeqScan: + pname = "Seq Scan"; + break; + case T_IndexScan: + pname = "Index Scan"; + break; + case T_Temp: + pname = "Temp Scan"; + break; + case T_Sort: + pname = "Sort"; + break; + case T_Group: + pname = "Group"; + break; + case T_Agg: + pname = "Aggregate"; + break; + case T_Unique: + pname = "Unique"; + break; + case T_Hash: + pname = "Hash"; + break; + case T_Tee: + pname = "Tee"; + break; + default: + pname = ""; + break; } for (i = 0; i < indent; i++) @@ -183,18 +183,18 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) appendStringInfo(str, pname); switch (nodeTag(plan)) { - case T_SeqScan: - case T_IndexScan: - if (((Scan *) plan)->scanrelid > 0) - { - RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable); - - sprintf(buf, " on %s", rte->refname); - appendStringInfo(str, buf); - } - break; - default: - break; + case T_SeqScan: + case T_IndexScan: + if (((Scan *) plan)->scanrelid > 0) + { + RangeTblEntry *rte = nth(((Scan *) plan)->scanrelid - 1, es->rtable); + + sprintf(buf, " on %s", rte->refname); + appendStringInfo(str, buf); + } + break; + default: + break; } if (es->printCost) { @@ -224,11 +224,11 @@ explain_outNode(StringInfo str, Plan * plan, int indent, ExplainState * es) return; } -static char * +static char * Explain_PlanToString(Plan * plan, ExplainState * es) { - StringInfo str; - char *s; + StringInfo str; + char *s; if (plan == NULL) return ""; diff --git a/src/backend/commands/purge.c b/src/backend/commands/purge.c index 8000bbc7352..78265c93cc5 100644 --- a/src/backend/commands/purge.c +++ b/src/backend/commands/purge.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.7 1997/09/07 04:40:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/purge.c,v 1.8 1997/09/08 02:22:11 momjian Exp $ * * Note: * XXX There are many instances of int32 instead of ...Time. These @@ -28,7 +28,7 @@ #include <commands/purge.h> #include <utils/builtins.h> /* for isreltime() */ -static char cmdname[] = "RelationPurge"; +static char cmdname[] = "RelationPurge"; #define RELATIVE 01 #define ABSOLUTE 02 @@ -38,23 +38,23 @@ RelationPurge(char *relationName, char *absoluteTimeString, char *relativeTimeString) { - register i; - AbsoluteTime absoluteTime = INVALID_ABSTIME; - RelativeTime relativeTime = INVALID_RELTIME; - bits8 dateTag; - Relation relation; - HeapScanDesc scan; + register i; + AbsoluteTime absoluteTime = INVALID_ABSTIME; + RelativeTime relativeTime = INVALID_RELTIME; + bits8 dateTag; + Relation relation; + HeapScanDesc scan; static ScanKeyData key[1] = { {0, Anum_pg_class_relname, F_NAMEEQ} }; - Buffer buffer; - HeapTuple newTuple, - oldTuple; - AbsoluteTime currentTime; - char *values[Natts_pg_class]; - char nulls[Natts_pg_class]; - char replace[Natts_pg_class]; - Relation idescs[Num_pg_class_indices]; + Buffer buffer; + HeapTuple newTuple, + oldTuple; + AbsoluteTime currentTime; + char *values[Natts_pg_class]; + char nulls[Natts_pg_class]; + char replace[Natts_pg_class]; + Relation idescs[Num_pg_class_indices]; /* * XXX for some reason getmyrelids (in inval.c) barfs when you diff --git a/src/backend/commands/recipe.c b/src/backend/commands/recipe.c index bf05c293d13..7796b164c3a 100644 --- a/src/backend/commands/recipe.c +++ b/src/backend/commands/recipe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.7 1997/09/07 04:40:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/recipe.c,v 1.8 1997/09/08 02:22:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,26 +50,26 @@ beginRecipe(RecipeStmt * stmt) /* structure to keep track of the tee node plans */ typedef struct _teePlanInfo { - char *tpi_relName; - Query *tpi_parsetree; - Plan *tpi_plan; -} TeePlanInfo; + char *tpi_relName; + Query *tpi_parsetree; + Plan *tpi_plan; +} TeePlanInfo; typedef struct _teeInfo { - int num; - TeePlanInfo *val; -} TeeInfo; + int num; + TeePlanInfo *val; +} TeeInfo; -QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2); -void OffsetVarAttno(Node * node, int varno, int offset); +QueryTreeList *appendQlist(QueryTreeList * q1, QueryTreeList * q2); +void OffsetVarAttno(Node * node, int varno, int offset); static void appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName); -static Plan * +static Plan * replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo); @@ -83,12 +83,12 @@ static void tg_rewriteQuery(TgRecipe * r, TgNode * n, QueryTreeList * q, QueryTreeList * inputQlist); -static Node * +static Node * tg_replaceNumberedParam(Node * expression, int pnum, int rt_ind, char *teeRelName); -static Node * +static Node * tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist); static QueryTreeList * @@ -129,18 +129,18 @@ tg_parseTeeNode(TgRecipe * r, void beginRecipe(RecipeStmt * stmt) { - TgRecipe *r; - int i; - QueryTreeList *qList; - char portalName[1024]; + TgRecipe *r; + int i; + QueryTreeList *qList; + char portalName[1024]; - Plan *plan; - TupleDesc attinfo; - QueryDesc *queryDesc; - Query *parsetree; + Plan *plan; + TupleDesc attinfo; + QueryDesc *queryDesc; + Query *parsetree; - int numTees; - TeeInfo *teeInfo; + int numTees; + TeeInfo *teeInfo; /* * retrieveRecipe() reads the recipe from the database and returns a @@ -177,7 +177,7 @@ beginRecipe(RecipeStmt * stmt) */ for (i = 0; i < r->eyes->num; i++) { - TgNodePtr e; + TgNodePtr e; e = r->eyes->val[i]; if (e->inNodes->num > 1) @@ -231,9 +231,9 @@ beginRecipe(RecipeStmt * stmt) * ---------------------------------------------------------- */ if (teeInfo) { - int t; - Plan *tplan; - Tee *newplan; + int t; + Plan *tplan; + Tee *newplan; for (t = 0; t < teeInfo->num; t++) { @@ -320,12 +320,12 @@ tg_rewriteQuery(TgRecipe * r, QueryTreeList * q, QueryTreeList * inputQlist) { - Query *orig; - Query *inputQ; - int i; - List *rtable; - List *input_rtable; - int rt_length; + Query *orig; + Query *inputQ; + int i; + List *rtable; + List *input_rtable; + int rt_length; /* orig is the original parse tree of the node */ orig = q->qtrees[0]; @@ -380,8 +380,8 @@ tg_rewriteQuery(TgRecipe * r, */ if (orig->targetList != NIL) { - List *tl; - TargetEntry *tle; + List *tl; + TargetEntry *tle; foreach(tl, orig->targetList) { @@ -425,134 +425,134 @@ tg_rewriteQuery(TgRecipe * r, it returns a (possibly modified) Node*. */ -static Node * +static Node * tg_replaceNumberedParam(Node * expression, int pnum, /* the number of the parameter */ int rt_ind, /* the range table index */ char *teeRelName) /* the relname of the tee * table */ { - TargetEntry *param_tle; - Param *p; - Var *newVar, - *oldVar; + TargetEntry *param_tle; + Param *p; + Var *newVar, + *oldVar; if (expression == NULL) return NULL; switch (nodeTag(expression)) { - case T_Param: - { - - /* - * the node is a parameter, substitute the entry from the - * target list of the child that corresponds to the parameter - * number - */ - p = (Param *) expression; - - /* we only deal with the case of numbered parameters */ - if (p->paramkind == PARAM_NUM && p->paramid == pnum) + case T_Param: { - if (p->param_tlist) - { - - /* - * we have a parameter with an attribute like $N.foo - * so replace it with a new var node - */ + /* + * the node is a parameter, substitute the entry from the + * target list of the child that corresponds to the + * parameter number + */ + p = (Param *) expression; - /* param tlist can only have one entry in them! */ - param_tle = (TargetEntry *) (lfirst(p->param_tlist)); - oldVar = (Var *) param_tle->expr; - oldVar->varno = rt_ind; - oldVar->varnoold = rt_ind; - return (Node *) oldVar; - } - else + /* we only deal with the case of numbered parameters */ + if (p->paramkind == PARAM_NUM && p->paramid == pnum) { - /* we have $N without the .foo */ - bool defined; - bool isRel; - - /* - * TODO here, we need to check to see whether the type - * of the tee is a complex type (relation) or a simple - * type - */ - /* - * if it is a simple type, then we need to get the - * "result" attribute from the tee relation - */ - - isRel = (typeid_get_relid(p->paramtype) != 0); - if (isRel) + if (p->param_tlist) { - newVar = makeVar(rt_ind, - 0, /* the whole tuple */ - TypeGet(teeRelName, &defined), - rt_ind, - 0); - return (Node *) newVar; + + /* + * we have a parameter with an attribute like + * $N.foo so replace it with a new var node + */ + + /* param tlist can only have one entry in them! */ + param_tle = (TargetEntry *) (lfirst(p->param_tlist)); + oldVar = (Var *) param_tle->expr; + oldVar->varno = rt_ind; + oldVar->varnoold = rt_ind; + return (Node *) oldVar; } else - newVar = makeVar(rt_ind, - 1, /* just the first field, + { + /* we have $N without the .foo */ + bool defined; + bool isRel; + + /* + * TODO here, we need to check to see whether the + * type of the tee is a complex type (relation) or + * a simple type + */ + + /* + * if it is a simple type, then we need to get the + * "result" attribute from the tee relation + */ + + isRel = (typeid_get_relid(p->paramtype) != 0); + if (isRel) + { + newVar = makeVar(rt_ind, + 0, /* the whole tuple */ + TypeGet(teeRelName, &defined), + rt_ind, + 0); + return (Node *) newVar; + } + else + newVar = makeVar(rt_ind, + 1, /* just the first field, * which is 'result' */ - TypeGet(teeRelName, &defined), - rt_ind, - 0); - return (Node *) newVar; + TypeGet(teeRelName, &defined), + rt_ind, + 0); + return (Node *) newVar; + } + } + else + { + elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind); } } - else + break; + case T_Expr: { - elog(NOTICE, "tg_replaceNumberedParam: unexpected paramkind value of %d", p->paramkind); - } - } - break; - case T_Expr: - { - /* - * the node is an expression, we need to recursively call - * ourselves until we find parameter nodes - */ - List *l; - Expr *expr = (Expr *) expression; - List *newArgs; + /* + * the node is an expression, we need to recursively call + * ourselves until we find parameter nodes + */ + List *l; + Expr *expr = (Expr *) expression; + List *newArgs; - /* - * we have to make a new args lists because Params can be - * replaced by Var nodes in tg_replaceNumberedParam() - */ - newArgs = NIL; + /* + * we have to make a new args lists because Params can be + * replaced by Var nodes in tg_replaceNumberedParam() + */ + newArgs = NIL; - /* - * we only care about argument to expressions, it doesn't - * matter when the opType is - */ - /* recursively rewrite the arguments of this expression */ - foreach(l, expr->args) + /* + * we only care about argument to expressions, it doesn't + * matter when the opType is + */ + /* recursively rewrite the arguments of this expression */ + foreach(l, expr->args) + { + newArgs = lappend(newArgs, + tg_replaceNumberedParam(lfirst(l), + pnum, + rt_ind, + teeRelName)); + } + /* change the arguments of the expression */ + expr->args = newArgs; + } + break; + default: { - newArgs = lappend(newArgs, - tg_replaceNumberedParam(lfirst(l), - pnum, - rt_ind, - teeRelName)); + /* ignore other expr types */ } - /* change the arguments of the expression */ - expr->args = newArgs; - } - break; - default: - { - /* ignore other expr types */ - } } return expression; @@ -572,118 +572,118 @@ tg_replaceNumberedParam(Node * expression, it returns a (possibly modified) Node*. */ -static Node * +static Node * tg_rewriteParamsInExpr(Node * expression, QueryTreeList * inputQlist) { - List *tl; - TargetEntry *param_tle, - *tle; - Param *p; - int childno; - char *resname; + List *tl; + TargetEntry *param_tle, + *tle; + Param *p; + int childno; + char *resname; if (expression == NULL) return NULL; switch (nodeTag(expression)) { - case T_Param: - { - - /* - * the node is a parameter, substitute the entry from the - * target list of the child that corresponds to the parameter - * number - */ - p = (Param *) expression; - - /* we only deal with the case of numbered parameters */ - if (p->paramkind == PARAM_NUM) + case T_Param: { - /* paramid's start from 1 */ - childno = p->paramid - 1; - if (p->param_tlist) + /* + * the node is a parameter, substitute the entry from the + * target list of the child that corresponds to the + * parameter number + */ + p = (Param *) expression; + + /* we only deal with the case of numbered parameters */ + if (p->paramkind == PARAM_NUM) { + /* paramid's start from 1 */ + childno = p->paramid - 1; - /* - * we have a parameter with an attribute like $N.foo - * so match the resname "foo" against the target list - * of the (N-1)th inputQlist - */ + if (p->param_tlist) + { - /* param tlist can only have one entry in them! */ - param_tle = (TargetEntry *) (lfirst(p->param_tlist)); - resname = param_tle->resdom->resname; + /* + * we have a parameter with an attribute like + * $N.foo so match the resname "foo" against the + * target list of the (N-1)th inputQlist + */ - if (inputQlist->qtrees[childno]) - { - foreach(tl, inputQlist->qtrees[childno]->targetList) + /* param tlist can only have one entry in them! */ + param_tle = (TargetEntry *) (lfirst(p->param_tlist)); + resname = param_tle->resdom->resname; + + if (inputQlist->qtrees[childno]) { - tle = lfirst(tl); - if (strcmp(resname, tle->resdom->resname) == 0) + foreach(tl, inputQlist->qtrees[childno]->targetList) { - return tle->expr; + tle = lfirst(tl); + if (strcmp(resname, tle->resdom->resname) == 0) + { + return tle->expr; + } } } + else + { + elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid); + } + } else { - elog(WARN, "tg_rewriteParamsInExpr:can't substitute for parameter %d when that input is unconnected", p->paramid); + /* we have $N without the .foo */ + /* use the first resdom in the targetlist of the */ + /* appropriate child query */ + tl = inputQlist->qtrees[childno]->targetList; + tle = lfirst(tl); + return tle->expr; } - } else { - /* we have $N without the .foo */ - /* use the first resdom in the targetlist of the */ - /* appropriate child query */ - tl = inputQlist->qtrees[childno]->targetList; - tle = lfirst(tl); - return tle->expr; + elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind); } } - else + break; + case T_Expr: { - elog(NOTICE, "tg_rewriteParamsInExpr: unexpected paramkind value of %d", p->paramkind); - } - } - break; - case T_Expr: - { - /* - * the node is an expression, we need to recursively call - * ourselves until we find parameter nodes - */ - List *l; - Expr *expr = (Expr *) expression; - List *newArgs; + /* + * the node is an expression, we need to recursively call + * ourselves until we find parameter nodes + */ + List *l; + Expr *expr = (Expr *) expression; + List *newArgs; - /* - * we have to make a new args lists because Params can be - * replaced by Var nodes in tg_rewriteParamsInExpr() - */ - newArgs = NIL; + /* + * we have to make a new args lists because Params can be + * replaced by Var nodes in tg_rewriteParamsInExpr() + */ + newArgs = NIL; - /* - * we only care about argument to expressions, it doesn't - * matter when the opType is - */ - /* recursively rewrite the arguments of this expression */ - foreach(l, expr->args) - { - newArgs = lappend(newArgs, + /* + * we only care about argument to expressions, it doesn't + * matter when the opType is + */ + /* recursively rewrite the arguments of this expression */ + foreach(l, expr->args) + { + newArgs = lappend(newArgs, tg_rewriteParamsInExpr(lfirst(l), inputQlist)); + } + /* change the arguments of the expression */ + expr->args = newArgs; + } + break; + default: + { + /* ignore other expr types */ } - /* change the arguments of the expression */ - expr->args = newArgs; - } - break; - default: - { - /* ignore other expr types */ - } } return expression; @@ -703,12 +703,12 @@ static int getParamTypes(TgElement * elem, Oid typev[]) { /* this code is similar to ProcedureDefine() */ - int16 parameterCount; - bool defined; - Oid toid; - char *t; - int i, - j; + int16 parameterCount; + bool defined; + Oid toid; + char *t; + int i, + j; parameterCount = 0; for (i = 0; i < 8; i++) @@ -763,10 +763,10 @@ tg_parseTeeNode(TgRecipe * r, TeeInfo * teeInfo) { - QueryTreeList *q; - char *tt; - int rt_ind; - Query *orig; + QueryTreeList *q; + char *tt; + int rt_ind; + Query *orig; /* * the input Node is a tee node, so we need to do the following: we @@ -831,21 +831,21 @@ tg_parseTeeNode(TgRecipe * r, static QueryTreeList * tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) { - TgElement *elem; - char *funcName; - Oid typev[8]; /* eight arguments maximum */ - int i; - int parameterCount; - - QueryTreeList *qList; /* the parse tree of the nodeElement */ - QueryTreeList *inputQlist; /* the list of parse trees for the inputs + TgElement *elem; + char *funcName; + Oid typev[8]; /* eight arguments maximum */ + int i; + int parameterCount; + + QueryTreeList *qList; /* the parse tree of the nodeElement */ + QueryTreeList *inputQlist; /* the list of parse trees for the inputs * to this node */ - QueryTreeList *q; - Oid relid; - TgNode *child; - Relation rel; - unsigned int len; - TupleDesc tupdesc; + QueryTreeList *q; + Oid relid; + TgNode *child; + Relation rel; + unsigned int len; + TupleDesc tupdesc; qList = NULL; @@ -856,79 +856,79 @@ tg_parseSubQuery(TgRecipe * r, TgNode * n, TeeInfo * teeInfo) elem = n->nodeElem; switch (elem->srcLang) { - case TG_SQL: - { + case TG_SQL: + { - /* - * for SQL ingredients, the SQL query is contained in the - * 'src' field - */ + /* + * for SQL ingredients, the SQL query is contained in + * the 'src' field + */ #ifdef DEBUG_RECIPE - elog(NOTICE, "calling parser with %s", elem->src); + elog(NOTICE, "calling parser with %s", elem->src); #endif /* DEBUG_RECIPE */ - parameterCount = getParamTypes(elem, typev); + parameterCount = getParamTypes(elem, typev); - qList = parser(elem->src, typev, parameterCount); + qList = parser(elem->src, typev, parameterCount); - if (qList->len > 1) - { - elog(NOTICE, - "tg_parseSubQuery: parser produced > 1 query tree"); + if (qList->len > 1) + { + elog(NOTICE, + "tg_parseSubQuery: parser produced > 1 query tree"); + } } - } - break; - case TG_C: - { - /* C ingredients are registered functions in postgres */ - - /* - * we create a new query string by using the function name - * (found in the 'src' field) and adding parameters to it - * so if the function was FOOBAR and took in two - * arguments, we would create a string select - * FOOBAR($1,$2) - */ - char newquery[1000]; + break; + case TG_C: + { + /* C ingredients are registered functions in postgres */ - funcName = elem->src; - parameterCount = getParamTypes(elem, typev); + /* + * we create a new query string by using the function + * name (found in the 'src' field) and adding + * parameters to it so if the function was FOOBAR and + * took in two arguments, we would create a string + * select FOOBAR($1,$2) + */ + char newquery[1000]; - if (parameterCount > 0) - { - int i; + funcName = elem->src; + parameterCount = getParamTypes(elem, typev); - sprintf(newquery, "select %s($1", funcName); - for (i = 1; i < parameterCount; i++) + if (parameterCount > 0) { - sprintf(newquery, "%s,$%d", newquery, i); + int i; + + sprintf(newquery, "select %s($1", funcName); + for (i = 1; i < parameterCount; i++) + { + sprintf(newquery, "%s,$%d", newquery, i); + } + sprintf(newquery, "%s)", newquery); } - sprintf(newquery, "%s)", newquery); - } - else - sprintf(newquery, "select %s()", funcName); + else + sprintf(newquery, "select %s()", funcName); #ifdef DEBUG_RECIPE - elog(NOTICE, "calling parser with %s", newquery); + elog(NOTICE, "calling parser with %s", newquery); #endif /* DEBUG_RECIPE */ - qList = parser(newquery, typev, parameterCount); - if (qList->len > 1) - { - elog(NOTICE, - "tg_parseSubQuery: parser produced > 1 query tree"); + qList = parser(newquery, typev, parameterCount); + if (qList->len > 1) + { + elog(NOTICE, + "tg_parseSubQuery: parser produced > 1 query tree"); + } } - } - break; - case TG_RECIPE_GRAPH: - elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!"); - break; - case TG_COMPILED: - elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!"); - break; - default: - elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang); + break; + case TG_RECIPE_GRAPH: + elog(NOTICE, "tg_parseSubQuery: can't parse recipe graph ingredients yet!"); + break; + case TG_COMPILED: + elog(NOTICE, "tg_parseSubQuery: can't parse compiled ingredients yet!"); + break; + default: + elog(NOTICE, "tg_parseSubQuery: unknown srcLang: %d", elem->srcLang); } /* parse each of the subrecipes that are input to this node */ @@ -1110,41 +1110,41 @@ OffsetVarAttno(Node * node, int varno, int offset) return; switch (nodeTag(node)) { - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; - - OffsetVarAttno(tle->expr, varno, offset); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - OffsetVarAttno((Node *) expr->args, varno, offset); - } - break; - case T_Var: - { - Var *var = (Var *) node; + OffsetVarAttno(tle->expr, varno, offset); + } + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - if (var->varno == varno) - var->varattno += offset; - } - break; - case T_List: - { - List *l; + OffsetVarAttno((Node *) expr->args, varno, offset); + } + break; + case T_Var: + { + Var *var = (Var *) node; - foreach(l, (List *) node) + if (var->varno == varno) + var->varattno += offset; + } + break; + case T_List: { - OffsetVarAttno(lfirst(l), varno, offset); + List *l; + + foreach(l, (List *) node) + { + OffsetVarAttno(lfirst(l), varno, offset); + } } - } - break; - default: - /* ignore the others */ - break; + break; + default: + /* ignore the others */ + break; } } @@ -1156,13 +1156,13 @@ OffsetVarAttno(Node * node, int varno, int offset) * returns a new querytree list */ -QueryTreeList * +QueryTreeList * appendQlist(QueryTreeList * q1, QueryTreeList * q2) { - QueryTreeList *newq; - int i, - j; - int newlen; + QueryTreeList *newq; + int i, + j; + int newlen; if (q1 == NULL) return q2; @@ -1191,7 +1191,7 @@ appendQlist(QueryTreeList * q1, QueryTreeList * q2) static void appendTeeQuery(TeeInfo * teeInfo, QueryTreeList * q, char *teeNodeName) { - int i; + int i; Assert(teeInfo); @@ -1223,9 +1223,9 @@ static void replaceSeqScan(Plan * plan, Plan * parent, int rt_ind, Plan * tplan) { - Scan *snode; - Tee *teePlan; - Result *newPlan; + Scan *snode; + Tee *teePlan; + Result *newPlan; if (plan == NULL) { @@ -1306,16 +1306,16 @@ replaceSeqScan(Plan * plan, Plan * parent, * places the sequential scans of the Tee table with * a connection to the actual tee plan node */ -static Plan * +static Plan * replaceTeeScans(Plan * plan, Query * parsetree, TeeInfo * teeInfo) { - int i; - List *rtable; - RangeTblEntry *rte; - char prefix[5]; - int rt_ind; - Plan *tplan; + int i; + List *rtable; + RangeTblEntry *rte; + char prefix[5]; + int rt_ind; + Plan *tplan; rtable = parsetree->rtable; if (rtable == NULL) diff --git a/src/backend/commands/remove.c b/src/backend/commands/remove.c index cafe4d09710..5b31866cf24 100644 --- a/src/backend/commands/remove.c +++ b/src/backend/commands/remove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.11 1997/09/07 04:40:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/remove.c,v 1.12 1997/09/08 02:22:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,16 +48,16 @@ RemoveOperator(char *operatorName, /* operator name */ char *typeName1, /* first type name */ char *typeName2) /* optional second type name */ { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Oid typeId1 = InvalidOid; - Oid typeId2 = InvalidOid; - bool defined; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Oid typeId1 = InvalidOid; + Oid typeId2 = InvalidOid; + bool defined; ItemPointerData itemPointerData; - Buffer buffer; - ScanKeyData operatorKey[3]; - char *userName; + Buffer buffer; + ScanKeyData operatorKey[3]; + char *userName; if (typeName1) { @@ -148,14 +148,14 @@ RemoveOperator(char *operatorName, /* operator name */ static void SingleOpOperatorRemove(Oid typeOid) { - Relation rdesc; - ScanKeyData key[3]; - HeapScanDesc sdesc; - HeapTuple tup; + Relation rdesc; + ScanKeyData key[3]; + HeapScanDesc sdesc; + HeapTuple tup; ItemPointerData itemPointerData; - Buffer buffer; - static attnums[3] = {7, 8, 9}; /* left, right, return */ - register i; + Buffer buffer; + static attnums[3] = {7, 8, 9}; /* left, right, return */ + register i; ScanKeyEntryInitialize(&key[0], 0, 0, ObjectIdEqualRegProcedure, (Datum) typeOid); @@ -186,17 +186,17 @@ AttributeAndRelationRemove(Oid typeOid) { struct oidlist { - Oid reloid; + Oid reloid; struct oidlist *next; }; struct oidlist *oidptr, - *optr; - Relation rdesc; - ScanKeyData key[1]; - HeapScanDesc sdesc; - HeapTuple tup; + *optr; + Relation rdesc; + ScanKeyData key[1]; + HeapScanDesc sdesc; + HeapTuple tup; ItemPointerData itemPointerData; - Buffer buffer; + Buffer buffer; /* * Get the oid's of the relations to be removed by scanning the entire @@ -237,7 +237,7 @@ AttributeAndRelationRemove(Oid typeOid) tup = heap_getnext(sdesc, 0, &buffer); if (PointerIsValid(tup)) { - char *name; + char *name; name = (((Form_pg_class) GETSTRUCT(tup))->relname).data; heap_destroy(name); @@ -257,16 +257,16 @@ AttributeAndRelationRemove(Oid typeOid) void RemoveType(char *typeName) /* type name to be removed */ { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Oid typeOid; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Oid typeOid; ItemPointerData itemPointerData; static ScanKeyData typeKey[1] = { {0, Anum_pg_type_typname, NameEqualRegProcedure} }; - char *shadow_type; - char *userName; + char *shadow_type; + char *userName; #ifndef NO_SECURITY userName = GetPgUserName(); @@ -332,20 +332,20 @@ RemoveFunction(char *functionName, /* function name to be removed */ int nargs, List * argNameList /* list of TypeNames */ ) { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; - Buffer buffer = InvalidBuffer; - bool bufferUsed = FALSE; - Oid argList[8]; - Form_pg_proc the_proc = NULL; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; + Buffer buffer = InvalidBuffer; + bool bufferUsed = FALSE; + Oid argList[8]; + Form_pg_proc the_proc = NULL; ItemPointerData itemPointerData; static ScanKeyData key[3] = { {0, Anum_pg_proc_proname, NameEqualRegProcedure} }; - char *userName; - char *typename; - int i; + char *userName; + char *typename; + int i; memset(argList, 0, 8 * sizeof(Oid)); for (i = 0; i < nargs; i++) @@ -431,14 +431,14 @@ RemoveFunction(char *functionName, /* function name to be removed */ void RemoveAggregate(char *aggName, char *aggType) { - Relation relation; - HeapScanDesc scan; - HeapTuple tup; + Relation relation; + HeapScanDesc scan; + HeapTuple tup; ItemPointerData itemPointerData; - char *userName; - Oid basetypeID = InvalidOid; - bool defined; - ScanKeyData aggregateKey[3]; + char *userName; + Oid basetypeID = InvalidOid; + bool defined; + ScanKeyData aggregateKey[3]; /* diff --git a/src/backend/commands/rename.c b/src/backend/commands/rename.c index 9b8df698346..d96fb762f28 100644 --- a/src/backend/commands/rename.c +++ b/src/backend/commands/rename.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.8 1997/09/07 04:40:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/Attic/rename.c,v 1.9 1997/09/08 02:22:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,13 +66,13 @@ renameatt(char *relname, char *userName, int recurse) { - Relation relrdesc, - attrdesc; - HeapTuple reltup, - oldatttup, - newatttup; + Relation relrdesc, + attrdesc; + HeapTuple reltup, + oldatttup, + newatttup; ItemPointerData oldTID; - Relation idescs[Num_pg_attr_indices]; + Relation idescs[Num_pg_attr_indices]; /* * permissions checking. this would normally be done in utility.c, @@ -101,10 +101,10 @@ renameatt(char *relname, */ if (recurse) { - Oid myrelid, - childrelid; - List *child, - *children; + Oid myrelid, + childrelid; + List *child, + *children; relrdesc = heap_openr(relname); if (!RelationIsValid(relrdesc)) @@ -126,7 +126,7 @@ renameatt(char *relname, */ foreach(child, children) { - char *childname; + char *childname; childrelid = lfirsti(child); if (childrelid == myrelid) @@ -213,13 +213,13 @@ renameatt(char *relname, void renamerel(char oldrelname[], char newrelname[]) { - Relation relrdesc; /* for RELATION relation */ - HeapTuple oldreltup, - newreltup; + Relation relrdesc; /* for RELATION relation */ + HeapTuple oldreltup, + newreltup; ItemPointerData oldTID; - char oldpath[MAXPGPATH], - newpath[MAXPGPATH]; - Relation idescs[Num_pg_class_indices]; + char oldpath[MAXPGPATH], + newpath[MAXPGPATH]; + Relation idescs[Num_pg_class_indices]; if (IsSystemRelationName(oldrelname)) { diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index c4bd8c40dcf..3f5bc371636 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -24,37 +24,37 @@ #define SEQ_MAXVALUE ((int4)0x7FFFFFFF) #define SEQ_MINVALUE -(SEQ_MAXVALUE) -bool ItsSequenceCreation = false; +bool ItsSequenceCreation = false; typedef struct FormData_pg_sequence { - NameData sequence_name; - int4 last_value; - int4 increment_by; - int4 max_value; - int4 min_value; - int4 cache_value; - char is_cycled; - char is_called; -} FormData_pg_sequence; + NameData sequence_name; + int4 last_value; + int4 increment_by; + int4 max_value; + int4 min_value; + int4 cache_value; + char is_cycled; + char is_called; +} FormData_pg_sequence; typedef FormData_pg_sequence *SequenceTupleForm; typedef struct sequence_magic { - uint32 magic; -} sequence_magic; + uint32 magic; +} sequence_magic; typedef struct SeqTableData { - char *name; - Oid relid; - Relation rel; - int4 cached; - int4 last; - int4 increment; + char *name; + Oid relid; + Relation rel; + int4 cached; + int4 last; + int4 increment; struct SeqTableData *next; -} SeqTableData; +} SeqTableData; typedef SeqTableData *SeqTable; @@ -62,8 +62,8 @@ static SeqTable seqtab = NULL; static SeqTable init_sequence(char *caller, char *name); static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf); -static void init_params(CreateSeqStmt * seq, SequenceTupleForm new); -static int get_param(DefElem * def); +static void init_params(CreateSeqStmt * seq, SequenceTupleForm new); +static int get_param(DefElem * def); /* * DefineSequence -- @@ -73,18 +73,18 @@ void DefineSequence(CreateSeqStmt * seq) { FormData_pg_sequence new; - CreateStmt *stmt = makeNode(CreateStmt); - ColumnDef *coldef; - TypeName *typnam; - Relation rel; - Buffer buf; - PageHeader page; + CreateStmt *stmt = makeNode(CreateStmt); + ColumnDef *coldef; + TypeName *typnam; + Relation rel; + Buffer buf; + PageHeader page; sequence_magic *sm; - HeapTuple tuple; - TupleDesc tupDesc; - Datum value[SEQ_COL_LASTCOL]; - char null[SEQ_COL_LASTCOL]; - int i; + HeapTuple tuple; + TupleDesc tupDesc; + Datum value[SEQ_COL_LASTCOL]; + char null[SEQ_COL_LASTCOL]; + int i; /* Check and set values */ init_params(seq, &new); @@ -106,46 +106,46 @@ DefineSequence(CreateSeqStmt * seq) switch (i) { - case SEQ_COL_NAME: - typnam->name = "name"; - coldef->colname = "sequence_name"; - value[i - 1] = PointerGetDatum(seq->seqname); - break; - case SEQ_COL_LASTVAL: - typnam->name = "int4"; - coldef->colname = "last_value"; - value[i - 1] = Int32GetDatum(new.last_value); - break; - case SEQ_COL_INCBY: - typnam->name = "int4"; - coldef->colname = "increment_by"; - value[i - 1] = Int32GetDatum(new.increment_by); - break; - case SEQ_COL_MAXVALUE: - typnam->name = "int4"; - coldef->colname = "max_value"; - value[i - 1] = Int32GetDatum(new.max_value); - break; - case SEQ_COL_MINVALUE: - typnam->name = "int4"; - coldef->colname = "min_value"; - value[i - 1] = Int32GetDatum(new.min_value); - break; - case SEQ_COL_CACHE: - typnam->name = "int4"; - coldef->colname = "cache_value"; - value[i - 1] = Int32GetDatum(new.cache_value); - break; - case SEQ_COL_CYCLE: - typnam->name = "char"; - coldef->colname = "is_cycled"; - value[i - 1] = CharGetDatum(new.is_cycled); - break; - case SEQ_COL_CALLED: - typnam->name = "char"; - coldef->colname = "is_called"; - value[i - 1] = CharGetDatum('f'); - break; + case SEQ_COL_NAME: + typnam->name = "name"; + coldef->colname = "sequence_name"; + value[i - 1] = PointerGetDatum(seq->seqname); + break; + case SEQ_COL_LASTVAL: + typnam->name = "int4"; + coldef->colname = "last_value"; + value[i - 1] = Int32GetDatum(new.last_value); + break; + case SEQ_COL_INCBY: + typnam->name = "int4"; + coldef->colname = "increment_by"; + value[i - 1] = Int32GetDatum(new.increment_by); + break; + case SEQ_COL_MAXVALUE: + typnam->name = "int4"; + coldef->colname = "max_value"; + value[i - 1] = Int32GetDatum(new.max_value); + break; + case SEQ_COL_MINVALUE: + typnam->name = "int4"; + coldef->colname = "min_value"; + value[i - 1] = Int32GetDatum(new.min_value); + break; + case SEQ_COL_CACHE: + typnam->name = "int4"; + coldef->colname = "cache_value"; + value[i - 1] = Int32GetDatum(new.cache_value); + break; + case SEQ_COL_CYCLE: + typnam->name = "char"; + coldef->colname = "is_cycled"; + value[i - 1] = CharGetDatum(new.is_cycled); + break; + case SEQ_COL_CALLED: + typnam->name = "char"; + coldef->colname = "is_called"; + value[i - 1] = CharGetDatum('f'); + break; } stmt->tableElts = lappend(stmt->tableElts, coldef); } @@ -203,18 +203,18 @@ DefineSequence(CreateSeqStmt * seq) int4 nextval(struct varlena * seqin) { - char *seqname = textout(seqin); - SeqTable elm; - Buffer buf; + char *seqname = textout(seqin); + SeqTable elm; + Buffer buf; SequenceTupleForm seq; ItemPointerData iptr; - int4 incby, - maxv, - minv, - cache; - int4 result, - next, - rescnt = 0; + int4 incby, + maxv, + minv, + cache; + int4 result, + next, + rescnt = 0; /* open and WIntentLock sequence */ elm = init_sequence("nextval", seqname); @@ -303,9 +303,9 @@ nextval(struct varlena * seqin) int4 currval(struct varlena * seqin) { - char *seqname = textout(seqin); - SeqTable elm; - int4 result; + char *seqname = textout(seqin); + SeqTable elm; + int4 result; /* open and WIntentLock sequence */ elm = init_sequence("currval", seqname); @@ -322,13 +322,13 @@ currval(struct varlena * seqin) } -static SequenceTupleForm +static SequenceTupleForm read_info(char *caller, SeqTable elm, Buffer * buf) { ItemPointerData iptr; - PageHeader page; - ItemId lp; - HeapTuple tuple; + PageHeader page; + ItemId lp; + HeapTuple tuple; sequence_magic *sm; SequenceTupleForm seq; @@ -362,12 +362,12 @@ read_info(char *caller, SeqTable elm, Buffer * buf) } -static SeqTable +static SeqTable init_sequence(char *caller, char *name) { - SeqTable elm, - priv = (SeqTable) NULL; - SeqTable temp; + SeqTable elm, + priv = (SeqTable) NULL; + SeqTable temp; for (elm = seqtab; elm != (SeqTable) NULL;) { @@ -436,8 +436,8 @@ init_sequence(char *caller, char *name) void CloseSequences(void) { - SeqTable elm; - Relation rel; + SeqTable elm; + Relation rel; ItsSequenceCreation = false; @@ -461,17 +461,17 @@ CloseSequences(void) static void init_params(CreateSeqStmt * seq, SequenceTupleForm new) { - DefElem *last_value = NULL; - DefElem *increment_by = NULL; - DefElem *max_value = NULL; - DefElem *min_value = NULL; - DefElem *cache_value = NULL; - List *option; + DefElem *last_value = NULL; + DefElem *increment_by = NULL; + DefElem *max_value = NULL; + DefElem *min_value = NULL; + DefElem *cache_value = NULL; + List *option; new->is_cycled = 'f'; foreach(option, seq->options) { - DefElem *defel = (DefElem *) lfirst(option); + DefElem *defel = (DefElem *) lfirst(option); if (!strcasecmp(defel->defname, "increment")) increment_by = defel; diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 53ab1838cfe..e25c955d8d7 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -32,36 +32,36 @@ #include "utils/syscache.h" #endif -TriggerData *CurrentTriggerData = NULL; +TriggerData *CurrentTriggerData = NULL; -void RelationBuildTriggers(Relation relation); -void FreeTriggerDesc(Relation relation); +void RelationBuildTriggers(Relation relation); +void FreeTriggerDesc(Relation relation); -static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger); +static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger); -extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs); +extern void fmgr_info(Oid procedureId, func_ptr * function, int *nargs); extern GlobalMemory CacheCxt; void CreateTrigger(CreateTrigStmt * stmt) { - int16 tgtype; - int16 tgattr[8] = {0}; - Datum values[Natts_pg_trigger]; - char nulls[Natts_pg_trigger]; - Relation rel; - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - Relation relrdesc; - HeapTuple tuple; + int16 tgtype; + int16 tgattr[8] = {0}; + Datum values[Natts_pg_trigger]; + char nulls[Natts_pg_trigger]; + Relation rel; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + Relation relrdesc; + HeapTuple tuple; ItemPointerData oldTID; - Relation idescs[Num_pg_trigger_indices]; - Relation ridescs[Num_pg_class_indices]; - MemoryContext oldcxt; - Oid fargtypes[8]; - int found = 0; - int i; + Relation idescs[Num_pg_trigger_indices]; + Relation ridescs[Num_pg_class_indices]; + MemoryContext oldcxt; + Oid fargtypes[8]; + int found = 0; + int i; if (IsSystemRelationName(stmt->relname)) elog(WARN, "CreateTrigger: can't create trigger for system relation %s", stmt->relname); @@ -86,24 +86,24 @@ CreateTrigger(CreateTrigStmt * stmt) { switch (stmt->actions[i]) { - case 'i': - if (TRIGGER_FOR_INSERT(tgtype)) - elog(WARN, "CreateTrigger: double INSERT event specified"); - TRIGGER_SETT_INSERT(tgtype); - break; - case 'd': - if (TRIGGER_FOR_DELETE(tgtype)) - elog(WARN, "CreateTrigger: double DELETE event specified"); - TRIGGER_SETT_DELETE(tgtype); - break; - case 'u': - if (TRIGGER_FOR_UPDATE(tgtype)) - elog(WARN, "CreateTrigger: double UPDATE event specified"); - TRIGGER_SETT_UPDATE(tgtype); - break; - default: - elog(WARN, "CreateTrigger: unknown event specified"); - break; + case 'i': + if (TRIGGER_FOR_INSERT(tgtype)) + elog(WARN, "CreateTrigger: double INSERT event specified"); + TRIGGER_SETT_INSERT(tgtype); + break; + case 'd': + if (TRIGGER_FOR_DELETE(tgtype)) + elog(WARN, "CreateTrigger: double DELETE event specified"); + TRIGGER_SETT_DELETE(tgtype); + break; + case 'u': + if (TRIGGER_FOR_UPDATE(tgtype)) + elog(WARN, "CreateTrigger: double UPDATE event specified"); + TRIGGER_SETT_UPDATE(tgtype); + break; + default: + elog(WARN, "CreateTrigger: unknown event specified"); + break; } } @@ -145,14 +145,14 @@ CreateTrigger(CreateTrigStmt * stmt) values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); if (stmt->args) { - List *le; - char *args; - int16 nargs = length(stmt->args); - int len = 0; + List *le; + char *args; + int16 nargs = length(stmt->args); + int len = 0; foreach(le, stmt->args) { - char *ar = (char *) lfirst(le); + char *ar = (char *) lfirst(le); len += strlen(ar) + 4; } @@ -213,17 +213,17 @@ CreateTrigger(CreateTrigStmt * stmt) void DropTrigger(DropTrigStmt * stmt) { - Relation rel; - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - Relation relrdesc; - HeapTuple tuple; + Relation rel; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + Relation relrdesc; + HeapTuple tuple; ItemPointerData oldTID; - Relation ridescs[Num_pg_class_indices]; - MemoryContext oldcxt; - int found = 0; - int tgfound = 0; + Relation ridescs[Num_pg_class_indices]; + MemoryContext oldcxt; + int found = 0; + int tgfound = 0; #ifndef NO_SECURITY if (!pg_ownercheck(GetPgUserName(), stmt->relname, RELNAME)) @@ -295,10 +295,10 @@ DropTrigger(DropTrigStmt * stmt) void RelationRemoveTriggers(Relation rel) { - Relation tgrel; - HeapScanDesc tgscan; - ScanKeyData key; - HeapTuple tup; + Relation tgrel; + HeapScanDesc tgscan; + ScanKeyData key; + HeapTuple tup; tgrel = heap_openr(TriggerRelationName); RelationSetLockForWrite(tgrel); @@ -319,22 +319,22 @@ RelationRemoveTriggers(Relation rel) void RelationBuildTriggers(Relation relation) { - TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc)); - int ntrigs = relation->rd_rel->reltriggers; - Trigger *triggers = NULL; - Trigger *build; - Relation tgrel; + TriggerDesc *trigdesc = (TriggerDesc *) palloc(sizeof(TriggerDesc)); + int ntrigs = relation->rd_rel->reltriggers; + Trigger *triggers = NULL; + Trigger *build; + Relation tgrel; Form_pg_trigger pg_trigger; - Relation irel; - ScanKeyData skey; - HeapTuple tuple; - IndexScanDesc sd; + Relation irel; + ScanKeyData skey; + HeapTuple tuple; + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - ItemPointer iptr; + Buffer buffer; + ItemPointer iptr; struct varlena *val; - bool isnull; - int found; + bool isnull; + int found; memset(trigdesc, 0, sizeof(TriggerDesc)); @@ -386,8 +386,8 @@ RelationBuildTriggers(Relation relation) NAMEDATALEN, relation->rd_rel->relname.data); if (build->tgnargs > 0) { - char *p; - int i; + char *p; + int i; val = (struct varlena *) fastgetattr(tuple, Anum_pg_trigger_tgargs, @@ -437,10 +437,10 @@ RelationBuildTriggers(Relation relation) void FreeTriggerDesc(Relation relation) { - TriggerDesc *trigdesc = relation->trigdesc; - Trigger ***t; - Trigger *trigger; - int i; + TriggerDesc *trigdesc = relation->trigdesc; + Trigger ***t; + Trigger *trigger; + int i; if (trigdesc == NULL) return; @@ -483,9 +483,9 @@ FreeTriggerDesc(Relation relation) static void DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger) { - uint16 *n; - Trigger ***t, - ***tp; + uint16 *n; + Trigger ***t, + ***tp; if (TRIGGER_FOR_ROW(trigger->tgtype)) /* Is ROW/STATEMENT * trigger */ @@ -557,11 +557,11 @@ DescribeTrigger(TriggerDesc * trigdesc, Trigger * trigger) HeapTuple ExecBRInsertTriggers(Relation rel, HeapTuple tuple) { - int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT]; - Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT]; - HeapTuple newtuple = tuple; - int nargs; - int i; + int ntrigs = rel->trigdesc->n_before_row[TRIGGER_EVENT_INSERT]; + Trigger **trigger = rel->trigdesc->tg_before_row[TRIGGER_EVENT_INSERT]; + HeapTuple newtuple = tuple; + int nargs; + int i; CurrentTriggerData = (TriggerData *) palloc(sizeof(TriggerData)); CurrentTriggerData->tg_event = TRIGGER_EVENT_INSERT | TRIGGER_EVENT_ROW; diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 30690f0f32b..66fbbd5db2b 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.43 1997/09/07 04:41:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.44 1997/09/08 02:22:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -56,11 +56,11 @@ #include <port-protos.h> -bool VacuumRunning = false; +bool VacuumRunning = false; -static Portal vc_portal; +static Portal vc_portal; -static int MESSAGE_LEVEL; /* message level */ +static int MESSAGE_LEVEL; /* message level */ #define swapLong(a,b) {long tmp; tmp=a; a=b; b=tmp;} #define swapInt(a,b) {int tmp; tmp=a; a=b; b=tmp;} @@ -72,46 +72,46 @@ static int MESSAGE_LEVEL; /* message level */ /* non-export function prototypes */ -static void vc_init(void); -static void vc_shutdown(void); -static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols); +static void vc_init(void); +static void vc_shutdown(void); +static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols); static VRelList vc_getrels(NameData * VacRelP); -static void vc_vacone(Oid relid, bool analyze, List * va_cols); -static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl); -static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel); -static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl); -static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel); -static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups); -static void vc_scanoneind(Relation indrel, int nhtups); -static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup); -static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len); -static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats); -static void vc_delhilowstats(Oid relid, int attcnt, int *attnums); -static void vc_setpagelock(Relation rel, BlockNumber blkno); +static void vc_vacone(Oid relid, bool analyze, List * va_cols); +static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl); +static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel); +static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList vpl); +static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel); +static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups); +static void vc_scanoneind(Relation indrel, int nhtups); +static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup); +static void vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucket_len); +static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats); +static void vc_delhilowstats(Oid relid, int attcnt, int *attnums); +static void vc_setpagelock(Relation rel, BlockNumber blkno); static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl); -static void vc_reappage(VPageList vpl, VPageDescr vpc); -static void vc_vpinsert(VPageList vpl, VPageDescr vpnew); -static void vc_free(VRelList vrl); -static void vc_getindices(Oid relid, int *nindices, Relation ** Irel); -static void vc_clsindices(int nindices, Relation * Irel); +static void vc_reappage(VPageList vpl, VPageDescr vpc); +static void vc_vpinsert(VPageList vpl, VPageDescr vpnew); +static void vc_free(VRelList vrl); +static void vc_getindices(Oid relid, int *nindices, Relation ** Irel); +static void vc_clsindices(int nindices, Relation * Irel); static Relation vc_getarchrel(Relation heaprel); -static void vc_archive(Relation archrel, HeapTuple htup); -static bool vc_isarchrel(char *rname); -static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc); -static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)); -static int vc_cmp_blk(char *left, char *right); -static int vc_cmp_offno(char *left, char *right); -static bool vc_enough_space(VPageDescr vpd, Size len); +static void vc_archive(Relation archrel, HeapTuple htup); +static bool vc_isarchrel(char *rname); +static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc); +static char *vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)); +static int vc_cmp_blk(char *left, char *right); +static int vc_cmp_offno(char *left, char *right); +static bool vc_enough_space(VPageDescr vpd, Size len); void vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) { - char *pname; - MemoryContext old; + char *pname; + MemoryContext old; PortalVariableMemory pmem; - NameData VacRel; - List *le; - List *va_cols = NIL; + NameData VacRel; + List *le; + List *va_cols = NIL; /* * Create a portal for safe memory across transctions. We need to @@ -139,8 +139,8 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) Assert(va_spec == NIL || analyze); foreach(le, va_spec) { - char *col = (char *) lfirst(le); - char *dest; + char *col = (char *) lfirst(le); + char *dest; dest = (char *) palloc(strlen(col) + 1); strcpy(dest, col); @@ -183,7 +183,7 @@ vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec) static void vc_init() { - int fd; + int fd; if ((fd = open("pg_vlock", O_CREAT | O_EXCL, 0600)) < 0) elog(WARN, "can't create lock file -- another vacuum cleaner running?"); @@ -238,8 +238,8 @@ vc_abort() static void vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols) { - VRelList vrl, - cur; + VRelList vrl, + cur; /* get list of relations */ vrl = vc_getrels(VacRelP); @@ -254,25 +254,25 @@ vc_vacuum(NameData * VacRelP, bool analyze, List * va_cols) vc_free(vrl); } -static VRelList +static VRelList vc_getrels(NameData * VacRelP) { - Relation pgclass; - TupleDesc pgcdesc; - HeapScanDesc pgcscan; - HeapTuple pgctup; - Buffer buf; + Relation pgclass; + TupleDesc pgcdesc; + HeapScanDesc pgcscan; + HeapTuple pgctup; + Buffer buf; PortalVariableMemory portalmem; - MemoryContext old; - VRelList vrl, - cur; - Datum d; - char *rname; - char rkind; - int16 smgrno; - bool n; - ScanKeyData pgckey; - bool found = false; + MemoryContext old; + VRelList vrl, + cur; + Datum d; + char *rname; + char rkind; + int16 smgrno; + bool n; + ScanKeyData pgckey; + bool found = false; StartTransactionCommand(); @@ -404,23 +404,23 @@ vc_getrels(NameData * VacRelP) static void vc_vacone(Oid relid, bool analyze, List * va_cols) { - Relation pgclass; - TupleDesc pgcdesc; - HeapTuple pgctup, - pgttup; - Buffer pgcbuf; - HeapScanDesc pgcscan; - Relation onerel; - ScanKeyData pgckey; - VPageListData Vvpl; /* List of pages to vacuum and/or clean + Relation pgclass; + TupleDesc pgcdesc; + HeapTuple pgctup, + pgttup; + Buffer pgcbuf; + HeapScanDesc pgcscan; + Relation onerel; + ScanKeyData pgckey; + VPageListData Vvpl; /* List of pages to vacuum and/or clean * indices */ - VPageListData Fvpl; /* List of pages with space enough for + VPageListData Fvpl; /* List of pages with space enough for * re-using */ - VPageDescr *vpp; - Relation *Irel; - int32 nindices, - i; - VRelStats *vacrelstats; + VPageDescr *vpp; + Relation *Irel; + int32 nindices, + i; + VRelStats *vacrelstats; StartTransactionCommand(); @@ -454,8 +454,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) vacrelstats->hasindex = false; if (analyze && !IsSystemRelationName((RelationGetRelationName(onerel))->data)) { - int attr_cnt, - *attnums = NULL; + int attr_cnt, + *attnums = NULL; AttributeTupleForm *attr; attr_cnt = onerel->rd_att->natts; @@ -463,8 +463,8 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) if (va_cols != NIL) { - int tcnt = 0; - List *le; + int tcnt = 0; + List *le; if (length(va_cols) > attr_cnt) elog(WARN, "vacuum: too many attributes specified for relation %s", @@ -472,7 +472,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) attnums = (int *) palloc(attr_cnt * sizeof(int)); foreach(le, va_cols) { - char *col = (char *) lfirst(le); + char *col = (char *) lfirst(le); for (i = 0; i < attr_cnt; i++) { @@ -495,9 +495,9 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) for (i = 0; i < attr_cnt; i++) { - Operator func_operator; + Operator func_operator; OperatorTupleForm pgopform; - VacAttrStats *stats; + VacAttrStats *stats; stats = &vacrelstats->vacattrstats[i]; stats->attr = palloc(ATTRIBUTE_TUPLE_SIZE); @@ -513,7 +513,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper("=", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmpeq), &nargs); @@ -524,7 +524,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper("<", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmplt), &nargs); @@ -535,7 +535,7 @@ vc_vacone(Oid relid, bool analyze, List * va_cols) func_operator = oper(">", stats->attr->atttypid, stats->attr->atttypid, true); if (func_operator != NULL) { - int nargs; + int nargs; pgopform = (OperatorTupleForm) GETSTRUCT(func_operator); fmgr_info(pgopform->oprcode, &(stats->f_cmpgt), &nargs); @@ -642,39 +642,39 @@ static void vc_scanheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl) { - int nblocks, - blkno; - ItemId itemid; - ItemPointer itemptr; - HeapTuple htup; - Buffer buf; - Page page, - tempPage = NULL; - OffsetNumber offnum, - maxoff; - bool pgchanged, - tupgone, - dobufrel, - notup; - char *relname; - VPageDescr vpc, - vp; - uint32 nvac, - ntups, - nunused, - ncrash, - nempg, - nnepg, - nchpg, - nemend; - Size frsize, - frsusf; - Size min_tlen = MAXTUPLEN; - Size max_tlen = 0; - int32 i /* , attr_cnt */ ; - struct rusage ru0, - ru1; - bool do_shrinking = true; + int nblocks, + blkno; + ItemId itemid; + ItemPointer itemptr; + HeapTuple htup; + Buffer buf; + Page page, + tempPage = NULL; + OffsetNumber offnum, + maxoff; + bool pgchanged, + tupgone, + dobufrel, + notup; + char *relname; + VPageDescr vpc, + vp; + uint32 nvac, + ntups, + nunused, + ncrash, + nempg, + nnepg, + nchpg, + nemend; + Size frsize, + frsusf; + Size min_tlen = MAXTUPLEN; + Size max_tlen = 0; + int32 i /* , attr_cnt */ ; + struct rusage ru0, + ru1; + bool do_shrinking = true; getrusage(RUSAGE_SELF, &ru0); @@ -844,11 +844,11 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.", if (tupgone) { - ItemId lpp; + ItemId lpp; if (tempPage == (Page) NULL) { - Size pageSize; + Size pageSize; pageSize = PageGetPageSize(page); tempPage = (Page) palloc(pageSize); @@ -927,7 +927,7 @@ DELETE_TRANSACTION_ID_VALID %d, TUPGONE %d.", */ if (do_shrinking && Vvpl->vpl_npages - nemend > 0) { - int nusf; /* blocks usefull for re-using */ + int nusf; /* blocks usefull for re-using */ nusf = Vvpl->vpl_npages - nemend; if ((Vvpl->vpl_pgdesc[nusf - 1])->vpd_blkno == nblocks - nemend - 1) @@ -972,50 +972,50 @@ static void vc_rpfheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl, VPageList Fvpl, int nindices, Relation * Irel) { - TransactionId myXID; - CommandId myCID; - AbsoluteTime myCTM = 0; - Buffer buf, - ToBuf; - int nblocks, - blkno; - Page page, - ToPage = NULL; - OffsetNumber offnum = 0, - maxoff = 0, - newoff, - moff; - ItemId itemid, - newitemid; - HeapTuple htup, - newtup; - TupleDesc tupdesc = NULL; - Datum *idatum = NULL; - char *inulls = NULL; + TransactionId myXID; + CommandId myCID; + AbsoluteTime myCTM = 0; + Buffer buf, + ToBuf; + int nblocks, + blkno; + Page page, + ToPage = NULL; + OffsetNumber offnum = 0, + maxoff = 0, + newoff, + moff; + ItemId itemid, + newitemid; + HeapTuple htup, + newtup; + TupleDesc tupdesc = NULL; + Datum *idatum = NULL; + char *inulls = NULL; InsertIndexResult iresult; - VPageListData Nvpl; - VPageDescr ToVpd = NULL, - Fvplast, - Vvplast, - vpc, - *vpp; - int ToVpI = 0; - IndDesc *Idesc, - *idcur; - int Fblklast, - Vblklast, - i; - Size tlen; - int nmoved, - Fnpages, - Vnpages; - int nchkmvd, - ntups; - bool isempty, - dowrite; - Relation archrel; - struct rusage ru0, - ru1; + VPageListData Nvpl; + VPageDescr ToVpd = NULL, + Fvplast, + Vvplast, + vpc, + *vpp; + int ToVpI = 0; + IndDesc *Idesc, + *idcur; + int Fblklast, + Vblklast, + i; + Size tlen; + int nmoved, + Fnpages, + Vnpages; + int nchkmvd, + ntups; + bool isempty, + dowrite; + Relation archrel; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1342,9 +1342,9 @@ Elapsed %u/%u sec.", /* vacuum indices again if needed */ if (Irel != (Relation *) NULL) { - VPageDescr *vpleft, - *vpright, - vpsave; + VPageDescr *vpleft, + *vpright, + vpsave; /* re-sort Nvpl.vpl_pgdesc */ for (vpleft = Nvpl.vpl_pgdesc, @@ -1426,12 +1426,12 @@ Elapsed %u/%u sec.", static void vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl) { - Buffer buf; - Page page; - VPageDescr *vpp; - Relation archrel; - int nblocks; - int i; + Buffer buf; + Page page; + VPageDescr *vpp; + Relation archrel; + int nblocks; + int i; nblocks = Vvpl->vpl_npages; /* if the relation has an archive, open it */ @@ -1486,9 +1486,9 @@ vc_vacheap(VRelStats * vacrelstats, Relation onerel, VPageList Vvpl) static void vc_vacpage(Page page, VPageDescr vpd, Relation archrel) { - ItemId itemid; - HeapTuple htup; - int i; + ItemId itemid; + HeapTuple htup; + int i; Assert(vpd->vpd_nusd == 0); for (i = 0; i < vpd->vpd_noff; i++) @@ -1513,11 +1513,11 @@ static void vc_scanoneind(Relation indrel, int nhtups) { RetrieveIndexResult res; - IndexScanDesc iscan; - int nitups; - int nipages; - struct rusage ru0, - ru1; + IndexScanDesc iscan; + int nitups; + int nipages; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1567,14 +1567,14 @@ static void vc_vaconeind(VPageList vpl, Relation indrel, int nhtups) { RetrieveIndexResult res; - IndexScanDesc iscan; - ItemPointer heapptr; - int nvac; - int nitups; - int nipages; - VPageDescr vp; - struct rusage ru0, - ru1; + IndexScanDesc iscan; + ItemPointer heapptr; + int nvac; + int nitups; + int nipages; + VPageDescr vp; + struct rusage ru0, + ru1; getrusage(RUSAGE_SELF, &ru0); @@ -1639,14 +1639,14 @@ vc_vaconeind(VPageList vpl, Relation indrel, int nhtups) * * vpl->VPageDescr_array is sorted in right order. */ -static VPageDescr +static VPageDescr vc_tidreapped(ItemPointer itemptr, VPageList vpl) { - OffsetNumber ioffno; - OffsetNumber *voff; - VPageDescr vp, - *vpp; - VPageDescrData vpd; + OffsetNumber ioffno; + OffsetNumber *voff; + VPageDescr vp, + *vpp; + VPageDescrData vpd; vpd.vpd_blkno = ItemPointerGetBlockNumber(itemptr); ioffno = ItemPointerGetOffsetNumber(itemptr); @@ -1702,17 +1702,17 @@ vc_tidreapped(ItemPointer itemptr, VPageList vpl) static void vc_attrstats(Relation onerel, VRelStats * vacrelstats, HeapTuple htup) { - int i, - attr_cnt = vacrelstats->va_natts; - VacAttrStats *vacattrstats = vacrelstats->vacattrstats; - TupleDesc tupDesc = onerel->rd_att; - Datum value; - bool isnull; + int i, + attr_cnt = vacrelstats->va_natts; + VacAttrStats *vacattrstats = vacrelstats->vacattrstats; + TupleDesc tupDesc = onerel->rd_att; + Datum value; + bool isnull; for (i = 0; i < attr_cnt; i++) { - VacAttrStats *stats = &vacattrstats[i]; - bool value_hit = true; + VacAttrStats *stats = &vacattrstats[i]; + bool value_hit = true; value = (Datum) heap_getattr(htup, InvalidBuffer, stats->attr->attnum, tupDesc, &isnull); @@ -1806,7 +1806,7 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke *bucket = value; else { - int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value)); + int len = (attr->attlen != -1 ? attr->attlen : VARSIZE(value)); if (len > *bucket_len) { @@ -1833,20 +1833,20 @@ vc_bucketcpy(AttributeTupleForm attr, Datum value, Datum * bucket, int16 * bucke static void vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrelstats) { - Relation rd, - ad, - sd; - HeapScanDesc rsdesc, - asdesc; - TupleDesc sdesc; - HeapTuple rtup, - atup, - stup; - Buffer rbuf, - abuf; - Form_pg_class pgcform; - ScanKeyData rskey, - askey; + Relation rd, + ad, + sd; + HeapScanDesc rsdesc, + asdesc; + TupleDesc sdesc; + HeapTuple rtup, + atup, + stup; + Buffer rbuf, + abuf; + Form_pg_class pgcform; + ScanKeyData rskey, + askey; AttributeTupleForm attp; /* @@ -1872,8 +1872,8 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels if (vacrelstats != NULL && vacrelstats->va_natts > 0) { - VacAttrStats *vacattrstats = vacrelstats->vacattrstats; - int natts = vacrelstats->va_natts; + VacAttrStats *vacattrstats = vacrelstats->vacattrstats; + int natts = vacrelstats->va_natts; ad = heap_openr(AttributeRelationName); sd = heap_openr(StatisticRelationName); @@ -1884,12 +1884,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels while (HeapTupleIsValid(atup = heap_getnext(asdesc, 0, &abuf))) { - int i; - float32data selratio; /* average ratio of rows selected + int i; + float32data selratio; /* average ratio of rows selected * for a random constant */ - VacAttrStats *stats; - Datum values[Natts_pg_statistic]; - char nulls[Natts_pg_statistic]; + VacAttrStats *stats; + Datum values[Natts_pg_statistic]; + char nulls[Natts_pg_statistic]; attp = (AttributeTupleForm) GETSTRUCT(atup); if (attp->attnum <= 0) /* skip system attributes for now, */ @@ -1916,18 +1916,18 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels selratio = 0; else if (VacAttrStatsLtGtValid(stats) && stats->min_cnt + stats->max_cnt == stats->nonnull_cnt) { - double min_cnt_d = stats->min_cnt, - max_cnt_d = stats->max_cnt, - null_cnt_d = stats->null_cnt, - nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */ + double min_cnt_d = stats->min_cnt, + max_cnt_d = stats->max_cnt, + null_cnt_d = stats->null_cnt, + nonnullcnt_d = stats->nonnull_cnt; /* prevent overflow */ selratio = (min_cnt_d * min_cnt_d + max_cnt_d * max_cnt_d + null_cnt_d * null_cnt_d) / (nonnullcnt_d + null_cnt_d) / (nonnullcnt_d + null_cnt_d); } else { - double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt); - double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt); + double most = (double) (stats->best_cnt > stats->null_cnt ? stats->best_cnt : stats->null_cnt); + double total = ((double) stats->nonnull_cnt) + ((double) stats->null_cnt); /* * we assume count of other values are 20% of best @@ -1948,12 +1948,12 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels */ if (VacAttrStatsLtGtValid(stats) && stats->initialized /* && * !IsSystemRelationName( - * pgcform->relname.data) - */ ) + * + pgcform->relname.data) */ ) { - func_ptr out_function; - char *out_string; - int dummy; + func_ptr out_function; + char *out_string; + int dummy; for (i = 0; i < Natts_pg_statistic; ++i) nulls[i] = ' '; @@ -2016,10 +2016,10 @@ vc_updstats(Oid relid, int npages, int ntups, bool hasindex, VRelStats * vacrels static void vc_delhilowstats(Oid relid, int attcnt, int *attnums) { - Relation pgstatistic; - HeapScanDesc pgsscan; - HeapTuple pgstup; - ScanKeyData pgskey; + Relation pgstatistic; + HeapScanDesc pgsscan; + HeapTuple pgstup; + ScanKeyData pgskey; pgstatistic = heap_openr(StatisticRelationName); @@ -2038,7 +2038,7 @@ vc_delhilowstats(Oid relid, int attcnt, int *attnums) if (attcnt > 0) { Form_pg_statistic pgs = (Form_pg_statistic) GETSTRUCT(pgstup); - int i; + int i; for (i = 0; i < attcnt; i++) { @@ -2075,7 +2075,7 @@ vc_setpagelock(Relation rel, BlockNumber blkno) static void vc_reappage(VPageList vpl, VPageDescr vpc) { - VPageDescr newvpd; + VPageDescr newvpd; /* allocate a VPageDescrData entry */ newvpd = (VPageDescr) palloc(sizeof(VPageDescrData) + vpc->vpd_noff * sizeof(OffsetNumber)); @@ -2110,8 +2110,8 @@ vc_vpinsert(VPageList vpl, VPageDescr vpnew) static void vc_free(VRelList vrl) { - VRelList p_vrl; - MemoryContext old; + VRelList p_vrl; + MemoryContext old; PortalVariableMemory pmem; pmem = PortalGetVariableMemory(vc_portal); @@ -2138,11 +2138,11 @@ vc_free(VRelList vrl) #define ARCHIVE_PREFIX "a," -static Relation +static Relation vc_getarchrel(Relation heaprel) { - Relation archrel; - char *archrelname; + Relation archrel; + char *archrelname; archrelname = palloc(sizeof(ARCHIVE_PREFIX) + NAMEDATALEN); /* bogus */ sprintf(archrelname, "%s%d", ARCHIVE_PREFIX, heaprel->rd_id); @@ -2165,7 +2165,7 @@ vc_archive(Relation archrel, HeapTuple htup) doinsert(archrel, htup); } -static bool +static bool vc_isarchrel(char *rname) { if (strncmp(ARCHIVE_PREFIX, rname, strlen(ARCHIVE_PREFIX)) == 0) @@ -2174,14 +2174,14 @@ vc_isarchrel(char *rname) return (false); } -static char * +static char * vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, char *)) { - int res; - int last = nelem - 1; - int celm = nelem / 2; - bool last_move, - first_move; + int res; + int last = nelem - 1; + int celm = nelem / 2; + bool last_move, + first_move; last_move = first_move = true; for (;;) @@ -2231,8 +2231,8 @@ vc_find_eq(char *bot, int nelem, int size, char *elm, int (*compar) (char *, cha static int vc_cmp_blk(char *left, char *right) { - BlockNumber lblk, - rblk; + BlockNumber lblk, + rblk; lblk = (*((VPageDescr *) left))->vpd_blkno; rblk = (*((VPageDescr *) right))->vpd_blkno; @@ -2261,17 +2261,17 @@ vc_cmp_offno(char *left, char *right) static void vc_getindices(Oid relid, int *nindices, Relation ** Irel) { - Relation pgindex; - Relation irel; - TupleDesc pgidesc; - HeapTuple pgitup; - HeapScanDesc pgiscan; - Datum d; - int i, - k; - bool n; - ScanKeyData pgikey; - Oid *ioid; + Relation pgindex; + Relation irel; + TupleDesc pgidesc; + HeapTuple pgitup; + HeapScanDesc pgiscan; + Datum d; + int i, + k; + bool n; + ScanKeyData pgikey; + Oid *ioid; *nindices = i = 0; @@ -2354,11 +2354,11 @@ vc_clsindices(int nindices, Relation * Irel) static void vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc) { - IndDesc *idcur; - HeapTuple pgIndexTup; - AttrNumber *attnumP; - int natts; - int i; + IndDesc *idcur; + HeapTuple pgIndexTup; + AttrNumber *attnumP; + int natts; + int i; *Idesc = (IndDesc *) palloc(nindices * sizeof(IndDesc)); @@ -2390,7 +2390,7 @@ vc_mkindesc(Relation onerel, int nindices, Relation * Irel, IndDesc ** Idesc) } /* vc_mkindesc */ -static bool +static bool vc_enough_space(VPageDescr vpd, Size len) { diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 99439de9ce3..c4f411021ad 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.9 1997/09/07 04:41:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.10 1997/09/08 02:22:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,13 +44,13 @@ static void DefineVirtualRelation(char *relname, List * tlist) { - CreateStmt createStmt; - List *attrList, - *t; - TargetEntry *entry; - Resdom *res; - char *resname; - char *restypename; + CreateStmt createStmt; + List *attrList, + *t; + TargetEntry *entry; + Resdom *res; + char *resname; + char *restypename; /* * create a list with one entry per attribute of this relation. Each @@ -63,8 +63,8 @@ DefineVirtualRelation(char *relname, List * tlist) { foreach(t, tlist) { - ColumnDef *def = makeNode(ColumnDef); - TypeName *typename; + ColumnDef *def = makeNode(ColumnDef); + TypeName *typename; /* * find the names of the attribute & its type @@ -123,7 +123,7 @@ DefineVirtualRelation(char *relname, List * tlist) * XXX it also means viewName cannot be 16 chars long! - ay 11/94 *------------------------------------------------------------------ */ -char * +char * MakeRetrieveViewRuleName(char *viewName) { /* @@ -135,7 +135,7 @@ MakeRetrieveViewRuleName(char *viewName) namestrcpy(rule_name, buf); */ - char *buf; + char *buf; buf = palloc(strlen(viewName) + 5); sprintf(buf, "_RET%s", viewName); @@ -145,9 +145,9 @@ MakeRetrieveViewRuleName(char *viewName) static RuleStmt * FormViewRetrieveRule(char *viewName, Query * viewParse) { - RuleStmt *rule; - char *rname; - Attr *attr; + RuleStmt *rule; + char *rname; + Attr *attr; /* * Create a RuleStmt that corresponds to the suitable rewrite rule @@ -172,12 +172,12 @@ FormViewRetrieveRule(char *viewName, Query * viewParse) static void DefineViewRules(char *viewName, Query * viewParse) { - RuleStmt *retrieve_rule = NULL; + RuleStmt *retrieve_rule = NULL; #ifdef NOTYET - RuleStmt *replace_rule = NULL; - RuleStmt *append_rule = NULL; - RuleStmt *delete_rule = NULL; + RuleStmt *replace_rule = NULL; + RuleStmt *append_rule = NULL; + RuleStmt *delete_rule = NULL; #endif @@ -226,10 +226,10 @@ DefineViewRules(char *viewName, Query * viewParse) static void UpdateRangeTableOfViewParse(char *viewName, Query * viewParse) { - List *old_rt; - List *new_rt; - RangeTblEntry *rt_entry1, - *rt_entry2; + List *old_rt; + List *new_rt; + RangeTblEntry *rt_entry1, + *rt_entry2; /* * first offset all var nodes by 2 @@ -277,7 +277,7 @@ UpdateRangeTableOfViewParse(char *viewName, Query * viewParse) void DefineView(char *viewName, Query * viewParse) { - List *viewTlist; + List *viewTlist; viewTlist = viewParse->targetList; @@ -313,7 +313,7 @@ DefineView(char *viewName, Query * viewParse) void RemoveView(char *viewName) { - char *rname; + char *rname; /* * first remove all the "view" rules... Currently we only have one! diff --git a/src/backend/executor/execAmi.c b/src/backend/executor/execAmi.c index 401924485e0..3aeb78ed370 100644 --- a/src/backend/executor/execAmi.c +++ b/src/backend/executor/execAmi.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.6 1997/09/07 04:41:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execAmi.c,v 1.7 1997/09/08 02:22:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -74,8 +74,8 @@ ExecOpenScanR(Oid relOid, Relation * returnRelation, /* return */ Pointer * returnScanDesc) /* return */ { - Relation relation; - Pointer scanDesc; + Relation relation; + Pointer scanDesc; /* ---------------- * note: scanDesc returned by ExecBeginScan can be either @@ -104,10 +104,10 @@ ExecOpenScanR(Oid relOid, * returns a relation descriptor given an object id. * ---------------------------------------------------------------- */ -static Relation +static Relation ExecOpenR(Oid relationOid, bool isindex) { - Relation relation; + Relation relation; relation = (Relation) NULL; @@ -141,7 +141,7 @@ ExecOpenR(Oid relationOid, bool isindex) * -cim 9/14/89 * ---------------------------------------------------------------- */ -static Pointer +static Pointer ExecBeginScan(Relation relation, int nkeys, ScanKey skeys, @@ -149,7 +149,7 @@ ExecBeginScan(Relation relation, ScanDirection dir, TimeQual time_range) { - Pointer scanDesc; + Pointer scanDesc; scanDesc = NULL; @@ -198,8 +198,8 @@ void ExecCloseR(Plan * node) { CommonScanState *state; - Relation relation; - HeapScanDesc scanDesc; + Relation relation; + HeapScanDesc scanDesc; /* ---------------- * shut down the heap scan and close the heap relation @@ -208,29 +208,29 @@ ExecCloseR(Plan * node) switch (nodeTag(node)) { - case T_SeqScan: - state = ((SeqScan *) node)->scanstate; - break; + case T_SeqScan: + state = ((SeqScan *) node)->scanstate; + break; - case T_IndexScan: - state = ((IndexScan *) node)->scan.scanstate; - break; + case T_IndexScan: + state = ((IndexScan *) node)->scan.scanstate; + break; - case T_Material: - state = &(((Material *) node)->matstate->csstate); - break; + case T_Material: + state = &(((Material *) node)->matstate->csstate); + break; - case T_Sort: - state = &(((Sort *) node)->sortstate->csstate); - break; + case T_Sort: + state = &(((Sort *) node)->sortstate->csstate); + break; - case T_Agg: - state = &(((Agg *) node)->aggstate->csstate); - break; + case T_Agg: + state = &(((Agg *) node)->aggstate->csstate); + break; - default: - elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!"); - return; + default: + elog(DEBUG, "ExecCloseR: not a scan, material, or sort node!"); + return; } relation = state->css_currentRelation; @@ -249,12 +249,12 @@ ExecCloseR(Plan * node) */ if (nodeTag(node) == T_IndexScan) { - IndexScan *iscan = (IndexScan *) node; + IndexScan *iscan = (IndexScan *) node; IndexScanState *indexstate; - int numIndices; - RelationPtr indexRelationDescs; + int numIndices; + RelationPtr indexRelationDescs; IndexScanDescPtr indexScanDescs; - int i; + int i; indexstate = iscan->indxstate; numIndices = indexstate->iss_NumIndices; @@ -292,32 +292,32 @@ ExecReScan(Plan * node, ExprContext * exprCtxt, Plan * parent) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqReScan((SeqScan *) node, exprCtxt, parent); - return; - - case T_IndexScan: - ExecIndexReScan((IndexScan *) node, exprCtxt, parent); - return; - - case T_Material: - - /* - * the first call to ExecReScan should have no effect because - * everything is initialized properly already. the following - * calls will be handled by ExecSeqReScan() because the nodes - * below the Material node have already been materialized into a - * temp relation. - */ - return; + case T_SeqScan: + ExecSeqReScan((SeqScan *) node, exprCtxt, parent); + return; + + case T_IndexScan: + ExecIndexReScan((IndexScan *) node, exprCtxt, parent); + return; + + case T_Material: + + /* + * the first call to ExecReScan should have no effect because + * everything is initialized properly already. the following + * calls will be handled by ExecSeqReScan() because the nodes + * below the Material node have already been materialized into + * a temp relation. + */ + return; - case T_Tee: - ExecTeeReScan((Tee *) node, exprCtxt, parent); - break; + case T_Tee: + ExecTeeReScan((Tee *) node, exprCtxt, parent); + break; - default: - elog(WARN, "ExecReScan: not a seqscan or indexscan node."); - return; + default: + elog(WARN, "ExecReScan: not a seqscan or indexscan node."); + return; } } @@ -355,21 +355,21 @@ ExecMarkPos(Plan * node) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqMarkPos((SeqScan *) node); - break; + case T_SeqScan: + ExecSeqMarkPos((SeqScan *) node); + break; - case T_IndexScan: - ExecIndexMarkPos((IndexScan *) node); - break; + case T_IndexScan: + ExecIndexMarkPos((IndexScan *) node); + break; - case T_Sort: - ExecSortMarkPos((Sort *) node); - break; + case T_Sort: + ExecSortMarkPos((Sort *) node); + break; - default: - /* elog(DEBUG, "ExecMarkPos: unsupported node type"); */ - break; + default: + /* elog(DEBUG, "ExecMarkPos: unsupported node type"); */ + break; } return; } @@ -385,21 +385,21 @@ ExecRestrPos(Plan * node) { switch (nodeTag(node)) { - case T_SeqScan: - ExecSeqRestrPos((SeqScan *) node); - return; + case T_SeqScan: + ExecSeqRestrPos((SeqScan *) node); + return; - case T_IndexScan: - ExecIndexRestrPos((IndexScan *) node); - return; + case T_IndexScan: + ExecIndexRestrPos((IndexScan *) node); + return; - case T_Sort: - ExecSortRestrPos((Sort *) node); - return; + case T_Sort: + ExecSortRestrPos((Sort *) node); + return; - default: - /* elog(DEBUG, "ExecRestrPos: node type not supported"); */ - return; + default: + /* elog(DEBUG, "ExecRestrPos: node type not supported"); */ + return; } } @@ -422,7 +422,7 @@ Relation ExecCreatR(TupleDesc tupType, Oid relationOid) { - Relation relDesc; + Relation relDesc; EU3_printf("ExecCreatR: %s type=%d oid=%d\n", "entering: ", tupType, relationOid); diff --git a/src/backend/executor/execFlatten.c b/src/backend/executor/execFlatten.c index 43d616712fa..cc98dd6e204 100644 --- a/src/backend/executor/execFlatten.c +++ b/src/backend/executor/execFlatten.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.3 1997/09/07 04:41:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/execFlatten.c,v 1.4 1997/09/08 02:22:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ ExecEvalIter(Iter * iterNode, bool * resultIsNull, bool * iterIsDone) { - Node *expression; + Node *expression; expression = iterNode->iterexpr; @@ -66,13 +66,13 @@ ExecEvalFjoin(TargetEntry * tlist, { #ifdef SETS_FIXED - bool isDone; - int curNode; - List *tlistP; + bool isDone; + int curNode; + List *tlistP; - Fjoin *fjNode = tlist->fjoin; - DatumPtr resVect = fjNode->fj_results; - BoolPtr alwaysDone = fjNode->fj_alwaysDone; + Fjoin *fjNode = tlist->fjoin; + DatumPtr resVect = fjNode->fj_results; + BoolPtr alwaysDone = fjNode->fj_alwaysDone; if (fj_isDone) *fj_isDone = false; @@ -90,7 +90,7 @@ ExecEvalFjoin(TargetEntry * tlist, curNode = 1; foreach(tlistP, lnext(tlist)) { - TargetEntry *tle = lfirst(tlistP); + TargetEntry *tle = lfirst(tlistP); resVect[curNode] = ExecEvalIter((Iter *) tle->expr, econtext, @@ -181,19 +181,19 @@ ExecEvalFjoin(TargetEntry * tlist, } #ifdef SETS_FIXED -static bool +static bool FjoinBumpOuterNodes(TargetEntry * tlist, ExprContext * econtext, DatumPtr results, char *nulls) { - bool funcIsDone = true; - Fjoin *fjNode = tlist->fjoin; - char *alwaysDone = fjNode->fj_alwaysDone; - List *outerList = lnext(tlist); - List *trailers = lnext(tlist); - int trailNode = 1; - int curNode = 1; + bool funcIsDone = true; + Fjoin *fjNode = tlist->fjoin; + char *alwaysDone = fjNode->fj_alwaysDone; + List *outerList = lnext(tlist); + List *trailers = lnext(tlist); + int trailNode = 1; + int curNode = 1; /* * Run through list of functions until we get to one that isn't yet @@ -201,7 +201,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist, */ while ((funcIsDone == true) && (outerList != NIL)) { - TargetEntry *tle = lfirst(outerList); + TargetEntry *tle = lfirst(outerList); if (alwaysDone[curNode] == true) nulls[curNode] = 'n'; @@ -232,7 +232,7 @@ FjoinBumpOuterNodes(TargetEntry * tlist, trailNode = 1; while (trailNode != curNode - 1) { - TargetEntry *tle = lfirst(trailers); + TargetEntry *tle = lfirst(trailers); if (alwaysDone[trailNode] != true) results[trailNode] = ExecEvalIter((Iter) tle->expr, diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index 3ad41bd393f..1c9476fc35f 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.6 1997/09/07 04:41:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.7 1997/09/08 02:22:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,24 +60,24 @@ * Initialize the Junk filter. *------------------------------------------------------------------------- */ -JunkFilter * +JunkFilter * ExecInitJunkFilter(List * targetList) { - JunkFilter *junkfilter; - List *cleanTargetList; - int len, - cleanLength; - TupleDesc tupType, - cleanTupType; - List *t; - TargetEntry *tle; - Resdom *resdom, - *cleanResdom; - int resjunk; - AttrNumber cleanResno; - AttrNumber *cleanMap; - Size size; - Node *expr; + JunkFilter *junkfilter; + List *cleanTargetList; + int len, + cleanLength; + TupleDesc tupType, + cleanTupType; + List *t; + TargetEntry *tle; + Resdom *resdom, + *cleanResdom; + int resjunk; + AttrNumber cleanResno; + AttrNumber *cleanMap; + Size size; + Node *expr; /* --------------------- * First find the "clean" target list, i.e. all the entries @@ -91,7 +91,7 @@ ExecInitJunkFilter(List * targetList) foreach(t, targetList) { - TargetEntry *rtarget = lfirst(t); + TargetEntry *rtarget = lfirst(t); if (rtarget->resdom != NULL) { @@ -120,11 +120,11 @@ ExecInitJunkFilter(List * targetList) else { #ifdef SETS_FIXED - List *fjListP; - Fjoin *cleanFjoin; - List *cleanFjList; - List *fjList = lfirst(t); - Fjoin *fjNode = (Fjoin *) tl_node(fjList); + List *fjListP; + Fjoin *cleanFjoin; + List *cleanFjList; + List *fjList = lfirst(t); + Fjoin *fjNode = (Fjoin *) tl_node(fjList); cleanFjoin = (Fjoin) copyObject((Node) fjNode); cleanFjList = lcons(cleanFjoin, NIL); @@ -139,7 +139,7 @@ ExecInitJunkFilter(List * targetList) foreach(fjListP, lnext(fjList)) { - TargetEntry *tle = lfirst(fjListP); + TargetEntry *tle = lfirst(fjListP); resdom = tle->resdom; expr = tle->expr; @@ -189,7 +189,7 @@ ExecInitJunkFilter(List * targetList) cleanResno = 1; foreach(t, targetList) { - TargetEntry *tle = lfirst(t); + TargetEntry *tle = lfirst(t); if (tle->resdom != NULL) { @@ -205,9 +205,9 @@ ExecInitJunkFilter(List * targetList) else { #ifdef SETS_FIXED - List fjListP; - List fjList = lfirst(t); - Fjoin fjNode = (Fjoin) lfirst(fjList); + List fjListP; + List fjList = lfirst(t); + Fjoin fjNode = (Fjoin) lfirst(fjList); /* what the hell is this????? */ resdom = (Resdom) lfirst(get_fj_innerNode(fjNode)); @@ -219,7 +219,7 @@ ExecInitJunkFilter(List * targetList) #ifdef SETS_FIXED foreach(fjListP, lnext(fjList)) { - TargetEntry *tle = lfirst(fjListP); + TargetEntry *tle = lfirst(fjListP); resdom = tle->resdom; cleanMap[cleanResno - 1] = resdom->resno; @@ -270,14 +270,14 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, Datum * value, bool * isNull) { - List *targetList; - List *t; - Resdom *resdom; - AttrNumber resno; - char *resname; - int resjunk; - TupleDesc tupType; - HeapTuple tuple; + List *targetList; + List *t; + Resdom *resdom; + AttrNumber resno; + char *resname; + int resjunk; + TupleDesc tupType; + HeapTuple tuple; /* --------------------- * first look in the junkfilter's target list for @@ -289,7 +289,7 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, foreach(t, targetList) { - TargetEntry *tle = lfirst(t); + TargetEntry *tle = lfirst(t); resdom = tle->resdom; resname = resdom->resname; @@ -330,19 +330,19 @@ ExecGetJunkAttribute(JunkFilter * junkfilter, HeapTuple ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot) { - HeapTuple tuple; - HeapTuple cleanTuple; - AttrNumber *cleanMap; - TupleDesc cleanTupType; - TupleDesc tupType; - int cleanLength; - bool isNull; - int i; - Size size; - Datum *values; - char *nulls; - Datum values_array[64]; - char nulls_array[64]; + HeapTuple tuple; + HeapTuple cleanTuple; + AttrNumber *cleanMap; + TupleDesc cleanTupType; + TupleDesc tupType; + int cleanLength; + bool isNull; + int i; + Size size; + Datum *values; + char *nulls; + Datum values_array[64]; + char nulls_array[64]; /* ---------------- * get info from the slot and the junk filter @@ -391,7 +391,7 @@ ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot) */ for (i = 0; i < cleanLength; i++) { - Datum d = (Datum) + Datum d = (Datum) heap_getattr(tuple, InvalidBuffer, cleanMap[i], tupType, &isNull); values[i] = d; diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index 2bf0edaf35e..c7ff5aa9107 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -26,7 +26,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.23 1997/09/07 04:41:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.24 1997/09/08 02:22:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,14 +62,14 @@ ExecCheckPerms(CmdType operation, int resultRelation, List * rangeTable, static TupleDesc InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate); -static void EndPlan(Plan * plan, EState * estate); +static void EndPlan(Plan * plan, EState * estate); static TupleTableSlot * ExecutePlan(EState * estate, Plan * plan, Query * parseTree, CmdType operation, int numberTuples, ScanDirection direction, void (*printfunc) ()); -static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), - EState * estate); +static void ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), + EState * estate); static void ExecAppend(TupleTableSlot * slot, ItemPointer tupleid, EState * estate); @@ -83,7 +83,7 @@ ExecReplace(TupleTableSlot * slot, ItemPointer tupleid, /* end of local decls */ #ifdef QUERY_LIMIT -static int queryLimit = ALL_TUPLES; +static int queryLimit = ALL_TUPLES; #undef ALL_TUPLES #define ALL_TUPLES queryLimit @@ -112,7 +112,7 @@ ExecutorLimit(int limit) TupleDesc ExecutorStart(QueryDesc * queryDesc, EState * estate) { - TupleDesc result; + TupleDesc result; /* sanity checks */ Assert(queryDesc != NULL); @@ -157,12 +157,12 @@ ExecutorStart(QueryDesc * queryDesc, EState * estate) TupleTableSlot * ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) { - CmdType operation; - Query *parseTree; - Plan *plan; + CmdType operation; + Query *parseTree; + Plan *plan; TupleTableSlot *result; - CommandDest dest; - void (*destination) (); + CommandDest dest; + void (*destination) (); /* ---------------- * sanity checks @@ -200,7 +200,7 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) if ((nodeTag(plan) == T_IndexScan) && (((IndexScan *) plan)->indxstate->iss_RuntimeKeyInfo != NULL)) { - ExprContext *econtext; + ExprContext *econtext; econtext = ((IndexScan *) plan)->scan.scanstate->cstate.cs_ExprContext; ExecIndexReScan((IndexScan *) plan, econtext, plan); @@ -211,57 +211,57 @@ ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count) switch (feature) { - case EXEC_RUN: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - ALL_TUPLES, - ForwardScanDirection, - destination); - break; - case EXEC_FOR: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - count, - ForwardScanDirection, - destination); - break; + case EXEC_RUN: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + ALL_TUPLES, + ForwardScanDirection, + destination); + break; + case EXEC_FOR: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + count, + ForwardScanDirection, + destination); + break; - /* ---------------- - * retrieve next n "backward" tuples - * ---------------- - */ - case EXEC_BACK: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - count, - BackwardScanDirection, - destination); - break; + /* ---------------- + * retrieve next n "backward" tuples + * ---------------- + */ + case EXEC_BACK: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + count, + BackwardScanDirection, + destination); + break; - /* ---------------- - * return one tuple but don't "retrieve" it. - * (this is used by the rule manager..) -cim 9/14/89 - * ---------------- - */ - case EXEC_RETONE: - result = ExecutePlan(estate, - plan, - parseTree, - operation, - ONE_TUPLE, - ForwardScanDirection, - destination); - break; - default: - result = NULL; - elog(DEBUG, "ExecutorRun: Unknown feature %d", feature); - break; + /* ---------------- + * return one tuple but don't "retrieve" it. + * (this is used by the rule manager..) -cim 9/14/89 + * ---------------- + */ + case EXEC_RETONE: + result = ExecutePlan(estate, + plan, + parseTree, + operation, + ONE_TUPLE, + ForwardScanDirection, + destination); + break; + default: + result = NULL; + elog(DEBUG, "ExecutorRun: Unknown feature %d", feature); + break; } return result; @@ -303,17 +303,17 @@ ExecCheckPerms(CmdType operation, List * rangeTable, Query * parseTree) { - int i = 1; - Oid relid; - HeapTuple htp; - List *lp; - List *qvars, - *tvars; - int32 ok = 1, - aclcheck_result = -1; - char *opstr; - NameData rname; - char *userName; + int i = 1; + Oid relid; + HeapTuple htp; + List *lp; + List *qvars, + *tvars; + int32 ok = 1, + aclcheck_result = -1; + char *opstr; + NameData rname; + char *userName; #define CHECK(MODE) pg_aclcheck(rname.data, userName, MODE) @@ -321,7 +321,7 @@ ExecCheckPerms(CmdType operation, foreach(lp, rangeTable) { - RangeTblEntry *rte = lfirst(lp); + RangeTblEntry *rte = lfirst(lp); relid = rte->relid; htp = SearchSysCacheTuple(RELOID, @@ -348,20 +348,21 @@ ExecCheckPerms(CmdType operation, } switch (operation) { - case CMD_INSERT: - ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) || - ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); - opstr = "append"; - break; - case CMD_NOTIFY: /* what does this mean?? -- jw, 1/6/94 */ - case CMD_DELETE: - case CMD_UPDATE: - ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); - opstr = "write"; - break; - default: - elog(WARN, "ExecCheckPerms: bogus operation %d", - operation); + case CMD_INSERT: + ok = ((aclcheck_result = CHECK(ACL_AP)) == ACLCHECK_OK) || + ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); + opstr = "append"; + break; + case CMD_NOTIFY: /* what does this mean?? -- jw, + * 1/6/94 */ + case CMD_DELETE: + case CMD_UPDATE: + ok = ((aclcheck_result = CHECK(ACL_WR)) == ACLCHECK_OK); + opstr = "write"; + break; + default: + elog(WARN, "ExecCheckPerms: bogus operation %d", + operation); } } else @@ -388,16 +389,16 @@ ExecCheckPerms(CmdType operation, * and start up the rule manager * ---------------------------------------------------------------- */ -static TupleDesc +static TupleDesc InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) { - List *rangeTable; - int resultRelation; - Relation intoRelationDesc; + List *rangeTable; + int resultRelation; + Relation intoRelationDesc; - TupleDesc tupType; - List *targetList; - int len; + TupleDesc tupType; + List *targetList; + int len; /* ---------------- * get information from query descriptor @@ -434,11 +435,11 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) * initialize the result relation info stuff. * ---------------- */ - RelationInfo *resultRelationInfo; - Index resultRelationIndex; - RangeTblEntry *rtentry; - Oid resultRelationOid; - Relation resultRelationDesc; + RelationInfo *resultRelationInfo; + Index resultRelationIndex; + RangeTblEntry *rtentry; + Oid resultRelationOid; + Relation resultRelationDesc; resultRelationIndex = resultRelation; rtentry = rt_fetch(resultRelationIndex, rangeTable); @@ -492,8 +493,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) * ---------------- */ { - int nSlots = ExecCountSlotsNode(plan); - TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */ + int nSlots = ExecCountSlotsNode(plan); + TupleTable tupleTable = ExecCreateTupleTable(nSlots + 10); /* why add ten? - jolly */ estate->es_tupleTable = tupleTable; } @@ -530,7 +531,7 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) operation == CMD_INSERT) { - JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList); + JunkFilter *j = (JunkFilter *) ExecInitJunkFilter(targetList); estate->es_junkFilter = j; } @@ -545,10 +546,10 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) if (operation == CMD_SELECT) { - char *intoName; - char archiveMode; - Oid intoRelationId; - TupleDesc tupdesc; + char *intoName; + char archiveMode; + Oid intoRelationId; + TupleDesc tupdesc; if (!parseTree->isPortal) { @@ -626,8 +627,8 @@ InitPlan(CmdType operation, Query * parseTree, Plan * plan, EState * estate) static void EndPlan(Plan * plan, EState * estate) { - RelationInfo *resultRelationInfo; - Relation intoRelationDesc; + RelationInfo *resultRelationInfo; + Relation intoRelationDesc; /* ---------------- * get information from state @@ -647,7 +648,7 @@ EndPlan(Plan * plan, EState * estate) * ---------------- */ { - TupleTable tupleTable = (TupleTable) estate->es_tupleTable; + TupleTable tupleTable = (TupleTable) estate->es_tupleTable; ExecDestroyTupleTable(tupleTable, true); /* was missing last arg */ estate->es_tupleTable = NULL; @@ -659,7 +660,7 @@ EndPlan(Plan * plan, EState * estate) */ if (resultRelationInfo != NULL) { - Relation resultRelationDesc; + Relation resultRelationDesc; resultRelationDesc = resultRelationInfo->ri_RelationDesc; heap_close(resultRelationDesc); @@ -706,12 +707,12 @@ ExecutePlan(EState * estate, ScanDirection direction, void (*printfunc) ()) { - JunkFilter *junkfilter; + JunkFilter *junkfilter; TupleTableSlot *slot; - ItemPointer tupleid = NULL; + ItemPointer tupleid = NULL; ItemPointerData tuple_ctid; - int current_tuple_count; + int current_tuple_count; TupleTableSlot *result; /* ---------------- @@ -770,11 +771,11 @@ ExecutePlan(EState * estate, */ if ((junkfilter = estate->es_junkFilter) != (JunkFilter *) NULL) { - Datum datum; + Datum datum; /* NameData attrName; */ - HeapTuple newTuple; - bool isNull; + HeapTuple newTuple; + bool isNull; /* --------------- * extract the 'ctid' junk attribute. @@ -822,50 +823,50 @@ ExecutePlan(EState * estate, switch (operation) { - case CMD_SELECT: - ExecRetrieve(slot, /* slot containing tuple */ - printfunc, /* print function */ - estate); /* */ - result = slot; - break; + case CMD_SELECT: + ExecRetrieve(slot, /* slot containing tuple */ + printfunc, /* print function */ + estate); /* */ + result = slot; + break; - case CMD_INSERT: - ExecAppend(slot, tupleid, estate); - result = NULL; - break; + case CMD_INSERT: + ExecAppend(slot, tupleid, estate); + result = NULL; + break; - case CMD_DELETE: - ExecDelete(slot, tupleid, estate); - result = NULL; - break; + case CMD_DELETE: + ExecDelete(slot, tupleid, estate); + result = NULL; + break; - case CMD_UPDATE: - ExecReplace(slot, tupleid, estate, parseTree); - result = NULL; - break; + case CMD_UPDATE: + ExecReplace(slot, tupleid, estate, parseTree); + result = NULL; + break; - /* - * Total hack. I'm ignoring any accessor functions for - * Relation, RelationTupleForm, NameData. Assuming that - * NameData.data has offset 0. - */ - case CMD_NOTIFY: - { - RelationInfo *rInfo = estate->es_result_relation_info; - Relation rDesc = rInfo->ri_RelationDesc; + /* + * Total hack. I'm ignoring any accessor functions for + * Relation, RelationTupleForm, NameData. Assuming that + * NameData.data has offset 0. + */ + case CMD_NOTIFY: + { + RelationInfo *rInfo = estate->es_result_relation_info; + Relation rDesc = rInfo->ri_RelationDesc; + + Async_Notify(rDesc->rd_rel->relname.data); + result = NULL; + current_tuple_count = 0; + numberTuples = 1; + elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname); + } + break; - Async_Notify(rDesc->rd_rel->relname.data); + default: + elog(DEBUG, "ExecutePlan: unknown operation in queryDesc"); result = NULL; - current_tuple_count = 0; - numberTuples = 1; - elog(DEBUG, "ExecNotify %s", &rDesc->rd_rel->relname); - } - break; - - default: - elog(DEBUG, "ExecutePlan: unknown operation in queryDesc"); - result = NULL; - break; + break; } /* ---------------- * check our tuple count.. if we've returned the @@ -901,8 +902,8 @@ ExecRetrieve(TupleTableSlot * slot, void (*printfunc) (), EState * estate) { - HeapTuple tuple; - TupleDesc attrtype; + HeapTuple tuple; + TupleDesc attrtype; /* ---------------- * get the heap tuple out of the tuple table slot @@ -944,11 +945,11 @@ ExecAppend(TupleTableSlot * slot, ItemPointer tupleid, EState * estate) { - HeapTuple tuple; - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - int numIndices; - Oid newId; + HeapTuple tuple; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + int numIndices; + Oid newId; /* ---------------- * get the heap tuple out of the tuple table slot @@ -973,7 +974,7 @@ ExecAppend(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_INSERT] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRInsertTriggers(resultRelationDesc, tuple); @@ -995,7 +996,7 @@ ExecAppend(TupleTableSlot * slot, if (resultRelationDesc->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("ExecAppend", resultRelationDesc, tuple); @@ -1049,8 +1050,8 @@ ExecDelete(TupleTableSlot * slot, ItemPointer tupleid, EState * estate) { - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; /* ---------------- * get the result relation information @@ -1063,7 +1064,7 @@ ExecDelete(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_DELETE] > 0) { - bool dodelete; + bool dodelete; dodelete = ExecBRDeleteTriggers(resultRelationDesc, tupleid); @@ -1118,10 +1119,10 @@ ExecReplace(TupleTableSlot * slot, EState * estate, Query * parseTree) { - HeapTuple tuple; - RelationInfo *resultRelationInfo; - Relation resultRelationDesc; - int numIndices; + HeapTuple tuple; + RelationInfo *resultRelationInfo; + Relation resultRelationDesc; + int numIndices; /* ---------------- * abort the operation if not running transactions @@ -1158,7 +1159,7 @@ ExecReplace(TupleTableSlot * slot, if (resultRelationDesc->trigdesc && resultRelationDesc->trigdesc->n_before_row[TRIGGER_EVENT_UPDATE] > 0) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecBRUpdateTriggers(resultRelationDesc, tupleid, tuple); @@ -1180,7 +1181,7 @@ ExecReplace(TupleTableSlot * slot, if (resultRelationDesc->rd_att->constr) { - HeapTuple newtuple; + HeapTuple newtuple; newtuple = ExecConstraints("ExecReplace", resultRelationDesc, tuple); @@ -1244,21 +1245,21 @@ ExecReplace(TupleTableSlot * slot, ExecARUpdateTriggers(resultRelationDesc, tupleid, tuple); } -static HeapTuple +static HeapTuple ExecAttrDefault(Relation rel, HeapTuple tuple) { - int ndef = rel->rd_att->constr->num_defval; - AttrDefault *attrdef = rel->rd_att->constr->defval; - ExprContext *econtext = makeNode(ExprContext); - HeapTuple newtuple; - Node *expr; - bool isnull; - bool isdone; - Datum val; - Datum *replValue = NULL; - char *replNull = NULL; - char *repl = NULL; - int i; + int ndef = rel->rd_att->constr->num_defval; + AttrDefault *attrdef = rel->rd_att->constr->defval; + ExprContext *econtext = makeNode(ExprContext); + HeapTuple newtuple; + Node *expr; + bool isnull; + bool isdone; + Datum val; + Datum *replValue = NULL; + char *replNull = NULL; + char *repl = NULL; + int i; econtext->ecxt_scantuple = NULL; /* scan tuple slot */ econtext->ecxt_innertuple = NULL; /* inner tuple slot */ @@ -1309,18 +1310,18 @@ ExecAttrDefault(Relation rel, HeapTuple tuple) } -static char * +static char * ExecRelCheck(Relation rel, HeapTuple tuple) { - int ncheck = rel->rd_att->constr->num_check; - ConstrCheck *check = rel->rd_att->constr->check; - ExprContext *econtext = makeNode(ExprContext); + int ncheck = rel->rd_att->constr->num_check; + ConstrCheck *check = rel->rd_att->constr->check; + ExprContext *econtext = makeNode(ExprContext); TupleTableSlot *slot = makeNode(TupleTableSlot); - RangeTblEntry *rte = makeNode(RangeTblEntry); - List *rtlist; - List *qual; - bool res; - int i; + RangeTblEntry *rte = makeNode(RangeTblEntry); + List *rtlist; + List *qual; + bool res; + int i; slot->val = tuple; slot->ttc_shouldFree = false; @@ -1370,7 +1371,7 @@ ExecRelCheck(Relation rel, HeapTuple tuple) HeapTuple ExecConstraints(char *caller, Relation rel, HeapTuple tuple) { - HeapTuple newtuple = tuple; + HeapTuple newtuple = tuple; Assert(rel->rd_att->constr); @@ -1379,7 +1380,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple) if (rel->rd_att->constr->has_not_null) { - int attrChk; + int attrChk; for (attrChk = 1; attrChk <= rel->rd_att->natts; attrChk++) { @@ -1391,7 +1392,7 @@ ExecConstraints(char *caller, Relation rel, HeapTuple tuple) if (rel->rd_att->constr->num_check > 0) { - char *failed; + char *failed; if ((failed = ExecRelCheck(rel, tuple)) != NULL) elog(WARN, "%s: rejected due to CHECK constraint %s", caller, failed); diff --git a/src/backend/executor/execProcnode.c b/src/backend/executor/execProcnode.c index 89caefd162e..7e8cce52c70 100644 --- a/src/backend/executor/execProcnode.c +++ b/src/backend/executor/execProcnode.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.3 1997/09/07 04:41:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execProcnode.c,v 1.4 1997/09/08 02:22:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -105,7 +105,7 @@ bool ExecInitNode(Plan * node, EState * estate, Plan * parent) { - bool result; + bool result; /* ---------------- * do nothing when we get to the end @@ -117,82 +117,82 @@ ExecInitNode(Plan * node, EState * estate, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - result = ExecInitResult((Result *) node, estate, parent); - break; - - case T_Append: - result = ExecInitAppend((Append *) node, estate, parent); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - result = ExecInitSeqScan((SeqScan *) node, estate, parent); - break; - - case T_IndexScan: - result = ExecInitIndexScan((IndexScan *) node, estate, parent); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - result = ExecInitNestLoop((NestLoop *) node, estate, parent); - break; - - case T_MergeJoin: - result = ExecInitMergeJoin((MergeJoin *) node, estate, parent); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - result = ExecInitMaterial((Material *) node, estate, parent); - break; - - case T_Sort: - result = ExecInitSort((Sort *) node, estate, parent); - break; - - case T_Unique: - result = ExecInitUnique((Unique *) node, estate, parent); - break; - - case T_Group: - result = ExecInitGroup((Group *) node, estate, parent); - break; - - case T_Agg: - result = ExecInitAgg((Agg *) node, estate, parent); - break; - - case T_Hash: - result = ExecInitHash((Hash *) node, estate, parent); - break; - - case T_HashJoin: - result = ExecInitHashJoin((HashJoin *) node, estate, parent); - break; - - case T_Tee: - result = ExecInitTee((Tee *) node, estate, parent); - break; - - default: - elog(DEBUG, "ExecInitNode: node not yet supported: %d", - nodeTag(node)); - result = FALSE; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + result = ExecInitResult((Result *) node, estate, parent); + break; + + case T_Append: + result = ExecInitAppend((Append *) node, estate, parent); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + result = ExecInitSeqScan((SeqScan *) node, estate, parent); + break; + + case T_IndexScan: + result = ExecInitIndexScan((IndexScan *) node, estate, parent); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + result = ExecInitNestLoop((NestLoop *) node, estate, parent); + break; + + case T_MergeJoin: + result = ExecInitMergeJoin((MergeJoin *) node, estate, parent); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + result = ExecInitMaterial((Material *) node, estate, parent); + break; + + case T_Sort: + result = ExecInitSort((Sort *) node, estate, parent); + break; + + case T_Unique: + result = ExecInitUnique((Unique *) node, estate, parent); + break; + + case T_Group: + result = ExecInitGroup((Group *) node, estate, parent); + break; + + case T_Agg: + result = ExecInitAgg((Agg *) node, estate, parent); + break; + + case T_Hash: + result = ExecInitHash((Hash *) node, estate, parent); + break; + + case T_HashJoin: + result = ExecInitHashJoin((HashJoin *) node, estate, parent); + break; + + case T_Tee: + result = ExecInitTee((Tee *) node, estate, parent); + break; + + default: + elog(DEBUG, "ExecInitNode: node not yet supported: %d", + nodeTag(node)); + result = FALSE; } return result; @@ -220,82 +220,82 @@ ExecProcNode(Plan * node, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - result = ExecResult((Result *) node); - break; - - case T_Append: - result = ExecProcAppend((Append *) node); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - result = ExecSeqScan((SeqScan *) node); - break; - - case T_IndexScan: - result = ExecIndexScan((IndexScan *) node); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - result = ExecNestLoop((NestLoop *) node, parent); - break; - - case T_MergeJoin: - result = ExecMergeJoin((MergeJoin *) node); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - result = ExecMaterial((Material *) node); - break; - - case T_Sort: - result = ExecSort((Sort *) node); - break; - - case T_Unique: - result = ExecUnique((Unique *) node); - break; - - case T_Group: - result = ExecGroup((Group *) node); - break; - - case T_Agg: - result = ExecAgg((Agg *) node); - break; - - case T_Hash: - result = ExecHash((Hash *) node); - break; - - case T_HashJoin: - result = ExecHashJoin((HashJoin *) node); - break; - - case T_Tee: - result = ExecTee((Tee *) node, parent); - break; - - default: - elog(DEBUG, "ExecProcNode: node not yet supported: %d", - nodeTag(node)); - result = FALSE; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + result = ExecResult((Result *) node); + break; + + case T_Append: + result = ExecProcAppend((Append *) node); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + result = ExecSeqScan((SeqScan *) node); + break; + + case T_IndexScan: + result = ExecIndexScan((IndexScan *) node); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + result = ExecNestLoop((NestLoop *) node, parent); + break; + + case T_MergeJoin: + result = ExecMergeJoin((MergeJoin *) node); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + result = ExecMaterial((Material *) node); + break; + + case T_Sort: + result = ExecSort((Sort *) node); + break; + + case T_Unique: + result = ExecUnique((Unique *) node); + break; + + case T_Group: + result = ExecGroup((Group *) node); + break; + + case T_Agg: + result = ExecAgg((Agg *) node); + break; + + case T_Hash: + result = ExecHash((Hash *) node); + break; + + case T_HashJoin: + result = ExecHashJoin((HashJoin *) node); + break; + + case T_Tee: + result = ExecTee((Tee *) node, parent); + break; + + default: + elog(DEBUG, "ExecProcNode: node not yet supported: %d", + nodeTag(node)); + result = FALSE; } return result; @@ -309,68 +309,68 @@ ExecCountSlotsNode(Plan * node) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - return ExecCountSlotsResult((Result *) node); - - case T_Append: - return ExecCountSlotsAppend((Append *) node); - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - return ExecCountSlotsSeqScan((SeqScan *) node); - - case T_IndexScan: - return ExecCountSlotsIndexScan((IndexScan *) node); - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - return ExecCountSlotsNestLoop((NestLoop *) node); - - case T_MergeJoin: - return ExecCountSlotsMergeJoin((MergeJoin *) node); - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - return ExecCountSlotsMaterial((Material *) node); - - case T_Sort: - return ExecCountSlotsSort((Sort *) node); - - case T_Unique: - return ExecCountSlotsUnique((Unique *) node); - - case T_Group: - return ExecCountSlotsGroup((Group *) node); - - case T_Agg: - return ExecCountSlotsAgg((Agg *) node); - - case T_Hash: - return ExecCountSlotsHash((Hash *) node); - - case T_HashJoin: - return ExecCountSlotsHashJoin((HashJoin *) node); - - case T_Tee: - return ExecCountSlotsTee((Tee *) node); - - default: - elog(WARN, "ExecCountSlotsNode: node not yet supported: %d", - nodeTag(node)); - break; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + return ExecCountSlotsResult((Result *) node); + + case T_Append: + return ExecCountSlotsAppend((Append *) node); + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + return ExecCountSlotsSeqScan((SeqScan *) node); + + case T_IndexScan: + return ExecCountSlotsIndexScan((IndexScan *) node); + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + return ExecCountSlotsNestLoop((NestLoop *) node); + + case T_MergeJoin: + return ExecCountSlotsMergeJoin((MergeJoin *) node); + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + return ExecCountSlotsMaterial((Material *) node); + + case T_Sort: + return ExecCountSlotsSort((Sort *) node); + + case T_Unique: + return ExecCountSlotsUnique((Unique *) node); + + case T_Group: + return ExecCountSlotsGroup((Group *) node); + + case T_Agg: + return ExecCountSlotsAgg((Agg *) node); + + case T_Hash: + return ExecCountSlotsHash((Hash *) node); + + case T_HashJoin: + return ExecCountSlotsHashJoin((HashJoin *) node); + + case T_Tee: + return ExecCountSlotsTee((Tee *) node); + + default: + elog(WARN, "ExecCountSlotsNode: node not yet supported: %d", + nodeTag(node)); + break; } return 0; } @@ -399,85 +399,85 @@ ExecEndNode(Plan * node, Plan * parent) switch (nodeTag(node)) { - /* ---------------- - * control nodes - * ---------------- - */ - case T_Result: - ExecEndResult((Result *) node); - break; - - case T_Append: - ExecEndAppend((Append *) node); - break; - - /* ---------------- - * scan nodes - * ---------------- - */ - case T_SeqScan: - ExecEndSeqScan((SeqScan *) node); - break; - - case T_IndexScan: - ExecEndIndexScan((IndexScan *) node); - break; - - /* ---------------- - * join nodes - * ---------------- - */ - case T_NestLoop: - ExecEndNestLoop((NestLoop *) node); - break; - - case T_MergeJoin: - ExecEndMergeJoin((MergeJoin *) node); - break; - - /* ---------------- - * materialization nodes - * ---------------- - */ - case T_Material: - ExecEndMaterial((Material *) node); - break; - - case T_Sort: - ExecEndSort((Sort *) node); - break; - - case T_Unique: - ExecEndUnique((Unique *) node); - break; - - case T_Group: - ExecEndGroup((Group *) node); - break; - - case T_Agg: - ExecEndAgg((Agg *) node); - break; - - /* ---------------- - * XXX add hooks to these - * ---------------- - */ - case T_Hash: - ExecEndHash((Hash *) node); - break; - - case T_HashJoin: - ExecEndHashJoin((HashJoin *) node); - break; - - case T_Tee: - ExecEndTee((Tee *) node, parent); - break; - - default: - elog(DEBUG, "ExecEndNode: node not yet supported", - nodeTag(node)); - break; + /* ---------------- + * control nodes + * ---------------- + */ + case T_Result: + ExecEndResult((Result *) node); + break; + + case T_Append: + ExecEndAppend((Append *) node); + break; + + /* ---------------- + * scan nodes + * ---------------- + */ + case T_SeqScan: + ExecEndSeqScan((SeqScan *) node); + break; + + case T_IndexScan: + ExecEndIndexScan((IndexScan *) node); + break; + + /* ---------------- + * join nodes + * ---------------- + */ + case T_NestLoop: + ExecEndNestLoop((NestLoop *) node); + break; + + case T_MergeJoin: + ExecEndMergeJoin((MergeJoin *) node); + break; + + /* ---------------- + * materialization nodes + * ---------------- + */ + case T_Material: + ExecEndMaterial((Material *) node); + break; + + case T_Sort: + ExecEndSort((Sort *) node); + break; + + case T_Unique: + ExecEndUnique((Unique *) node); + break; + + case T_Group: + ExecEndGroup((Group *) node); + break; + + case T_Agg: + ExecEndAgg((Agg *) node); + break; + + /* ---------------- + * XXX add hooks to these + * ---------------- + */ + case T_Hash: + ExecEndHash((Hash *) node); + break; + + case T_HashJoin: + ExecEndHashJoin((HashJoin *) node); + break; + + case T_Tee: + ExecEndTee((Tee *) node, parent); + break; + + default: + elog(DEBUG, "ExecEndNode: node not yet supported", + nodeTag(node)); + break; } } diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 7b8cb18ef25..a1e01402656 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.13 1997/09/07 04:41:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.14 1997/09/08 02:22:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -65,31 +65,31 @@ * Currently only used by ExecHashGetBucket and set only by ExecMakeVarConst * and by ExecEvalArrayRef. */ -bool execConstByVal; -int execConstLen; +bool execConstByVal; +int execConstLen; /* static functions decls */ -static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull); +static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull); static Datum ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext, bool * isNull, bool * isDone); -static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull); +static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull); static Datum ExecEvalFunc(Expr * funcClause, ExprContext * econtext, bool * isNull, bool * isDone); static void ExecEvalFuncArgs(FunctionCachePtr fcache, ExprContext * econtext, List * argList, Datum argV[], bool * argIsDone); -static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull); +static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull); static Datum ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull); -static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull); -static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull); +static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull); +static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull); static Datum ExecMakeFunctionResult(Node * node, List * arguments, ExprContext * econtext, bool * isNull, bool * isDone); -static bool ExecQualClause(Node * clause, ExprContext * econtext); +static bool ExecQualClause(Node * clause, ExprContext * econtext); /* -------------------------------- * ExecEvalArrayRef @@ -100,24 +100,24 @@ static bool ExecQualClause(Node * clause, ExprContext * econtext); * * -------------------------------- */ -static Datum +static Datum ExecEvalArrayRef(ArrayRef * arrayRef, ExprContext * econtext, bool * isNull, bool * isDone) { - bool dummy; - int i = 0, - j = 0; - ArrayType *array_scanner; - List *upperIndexpr, - *lowerIndexpr; - Node *assgnexpr; - List *elt; - IntArray upper, - lower; - int *lIndex; - char *dataPtr; + bool dummy; + int i = 0, + j = 0; + ArrayType *array_scanner; + List *upperIndexpr, + *lowerIndexpr; + Node *assgnexpr; + List *elt; + IntArray upper, + lower; + int *lIndex; + char *dataPtr; *isNull = false; array_scanner = (ArrayType *) ExecEvalExpr(arrayRef->refexpr, @@ -199,7 +199,7 @@ ExecEvalArrayRef(ArrayRef * arrayRef, * aggregate found in the given expression context. * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull) { @@ -230,17 +230,17 @@ ExecEvalAggreg(Aggreg * agg, ExprContext * econtext, bool * isNull) * We have an Assert to make sure this entry condition is met. * * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) { - Datum result; + Datum result; TupleTableSlot *slot; - AttrNumber attnum; - HeapTuple heapTuple; - TupleDesc tuple_type; - Buffer buffer; - bool byval; - int16 len; + AttrNumber attnum; + HeapTuple heapTuple; + TupleDesc tuple_type; + Buffer buffer; + bool byval; + int16 len; /* ---------------- * get the slot we want @@ -248,18 +248,18 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) */ switch (variable->varno) { - case INNER: /* get the tuple from the inner node */ - slot = econtext->ecxt_innertuple; - break; + case INNER: /* get the tuple from the inner node */ + slot = econtext->ecxt_innertuple; + break; - case OUTER: /* get the tuple from the outer node */ - slot = econtext->ecxt_outertuple; - break; + case OUTER: /* get the tuple from the outer node */ + slot = econtext->ecxt_outertuple; + break; - default: /* get the tuple from the relation being + default: /* get the tuple from the relation being * scanned */ - slot = econtext->ecxt_scantuple; - break; + slot = econtext->ecxt_scantuple; + break; } /* ---------------- @@ -286,8 +286,8 @@ ExecEvalVar(Var * variable, ExprContext * econtext, bool * isNull) if (attnum == InvalidAttrNumber) { TupleTableSlot *tempSlot; - TupleDesc td; - HeapTuple tup; + TupleDesc td; + HeapTuple tup; tempSlot = makeNode(TupleTableSlot); tempSlot->ttc_shouldFree = false; @@ -380,11 +380,11 @@ Datum ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) { - char *thisParameterName; - int thisParameterKind; - AttrNumber thisParameterId; - int matchFound; - ParamListInfo paramList; + char *thisParameterName; + int thisParameterKind; + AttrNumber thisParameterId; + int matchFound; + ParamListInfo paramList; thisParameterName = expression->paramname; thisParameterKind = expression->paramkind; @@ -409,44 +409,44 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) { switch (thisParameterKind) { - case PARAM_NAMED: - if (thisParameterKind == paramList->kind && - strcmp(paramList->name, thisParameterName) == 0) - { - matchFound = 1; - } - break; - case PARAM_NUM: - if (thisParameterKind == paramList->kind && - paramList->id == thisParameterId) - { - matchFound = 1; - } - break; - case PARAM_OLD: - case PARAM_NEW: - if (thisParameterKind == paramList->kind && - paramList->id == thisParameterId) - { - matchFound = 1; - - /* - * sanity check - */ - if (strcmp(paramList->name, thisParameterName) != 0) + case PARAM_NAMED: + if (thisParameterKind == paramList->kind && + strcmp(paramList->name, thisParameterName) == 0) { - elog(WARN, - "ExecEvalParam: new/old params with same id & diff names"); + matchFound = 1; } - } - break; - default: + break; + case PARAM_NUM: + if (thisParameterKind == paramList->kind && + paramList->id == thisParameterId) + { + matchFound = 1; + } + break; + case PARAM_OLD: + case PARAM_NEW: + if (thisParameterKind == paramList->kind && + paramList->id == thisParameterId) + { + matchFound = 1; + + /* + * sanity check + */ + if (strcmp(paramList->name, thisParameterName) != 0) + { + elog(WARN, + "ExecEvalParam: new/old params with same id & diff names"); + } + } + break; + default: - /* - * oops! this is not supposed to happen! - */ - elog(WARN, "ExecEvalParam: invalid paramkind %d", - thisParameterKind); + /* + * oops! this is not supposed to happen! + */ + elog(WARN, "ExecEvalParam: invalid paramkind %d", + thisParameterKind); } if (!matchFound) { @@ -477,10 +477,10 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) if (expression->param_tlist != NIL) { - HeapTuple tup; - Datum value; - List *tlist = expression->param_tlist; - TargetEntry *tle = (TargetEntry *) lfirst(tlist); + HeapTuple tup; + Datum value; + List *tlist = expression->param_tlist; + TargetEntry *tle = (TargetEntry *) lfirst(tlist); TupleTableSlot *slot = (TupleTableSlot *) paramList->value; tup = slot->val; @@ -508,12 +508,12 @@ ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull) * ---------------- */ #ifdef NOT_USED -static char * +static char * GetAttributeByNum(TupleTableSlot * slot, AttrNumber attrno, bool * isNull) { - Datum retval; + Datum retval; if (!AttributeNumberIsValid(attrno)) elog(WARN, "GetAttributeByNum: Invalid attribute number"); @@ -545,7 +545,7 @@ GetAttributeByNum(TupleTableSlot * slot, /* XXX char16 name for catalogs */ #ifdef NOT_USED -char * +char * att_by_num(TupleTableSlot * slot, AttrNumber attrno, bool * isNull) @@ -555,15 +555,15 @@ att_by_num(TupleTableSlot * slot, #endif -char * +char * GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull) { - AttrNumber attrno; - TupleDesc tupdesc; - HeapTuple tuple; - Datum retval; - int natts; - int i; + AttrNumber attrno; + TupleDesc tupdesc; + HeapTuple tuple; + Datum retval; + int natts; + int i; if (attname == NULL) elog(WARN, "GetAttributeByName: Invalid attribute name"); @@ -608,7 +608,7 @@ GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull) /* XXX char16 name for catalogs */ #ifdef NOT_USED -char * +char * att_by_name(TupleTableSlot * slot, char *attname, bool * isNull) { return (GetAttributeByName(slot, attname, isNull)); @@ -623,10 +623,10 @@ ExecEvalFuncArgs(FunctionCachePtr fcache, Datum argV[], bool * argIsDone) { - int i; - bool argIsNull, - *nullVect; - List *arg; + int i; + bool argIsNull, + *nullVect; + List *arg; nullVect = fcache->nullVect; @@ -663,18 +663,18 @@ ExecEvalFuncArgs(FunctionCachePtr fcache, * ExecMakeFunctionResult * ---------------- */ -static Datum +static Datum ExecMakeFunctionResult(Node * node, List * arguments, ExprContext * econtext, bool * isNull, bool * isDone) { - Datum argv[MAXFMGRARGS]; + Datum argv[MAXFMGRARGS]; FunctionCachePtr fcache; - Func *funcNode = NULL; - Oper *operNode = NULL; - bool funcisset = false; + Func *funcNode = NULL; + Oper *operNode = NULL; + bool funcisset = false; /* * This is kind of ugly, Func nodes now have targetlists so that we @@ -703,7 +703,7 @@ ExecMakeFunctionResult(Node * node, */ if (fcache->nargs != 0) { - bool argDone; + bool argDone; if (fcache->nargs > MAXFMGRARGS) elog(WARN, "ExecMakeFunctionResult: too many arguments"); @@ -774,7 +774,7 @@ ExecMakeFunctionResult(Node * node, */ if (fcache->language == SQLlanguageId) { - Datum result; + Datum result; Assert(funcNode); result = postquel_function(funcNode, (char **) argv, isNull, isDone); @@ -788,7 +788,7 @@ ExecMakeFunctionResult(Node * node, */ if ((*isDone) && (fcache->hasSetArg)) { - bool argDone; + bool argDone; ExecEvalFuncArgs(fcache, econtext, arguments, argv, &argDone); @@ -828,7 +828,7 @@ ExecMakeFunctionResult(Node * node, } else { - int i; + int i; if (isDone) *isDone = true; @@ -863,13 +863,13 @@ ExecMakeFunctionResult(Node * node, * ExecEvalOper * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull) { - Oper *op; - List *argList; + Oper *op; + List *argList; FunctionCachePtr fcache; - bool isDone; + bool isDone; /* ---------------- * an opclause is a list (op args). (I think) @@ -908,14 +908,14 @@ ExecEvalOper(Expr * opClause, ExprContext * econtext, bool * isNull) * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalFunc(Expr * funcClause, ExprContext * econtext, bool * isNull, bool * isDone) { - Func *func; - List *argList; + Func *func; + List *argList; FunctionCachePtr fcache; /* ---------------- @@ -963,12 +963,12 @@ ExecEvalFunc(Expr * funcClause, * need to know this, mind you... * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull) { - Datum expr_value; - Node *clause; - bool isDone; + Datum expr_value; + Node *clause; + bool isDone; clause = lfirst(notclause->args); @@ -1002,14 +1002,14 @@ ExecEvalNot(Expr * notclause, ExprContext * econtext, bool * isNull) * ExecEvalOr * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull) { - List *clauses; - List *clause; - bool isDone; - bool IsNull; - Datum const_value = 0; + List *clauses; + List *clause; + bool isDone; + bool IsNull; + Datum const_value = 0; IsNull = false; clauses = orExpr->args; @@ -1066,14 +1066,14 @@ ExecEvalOr(Expr * orExpr, ExprContext * econtext, bool * isNull) * ExecEvalAnd * ---------------------------------------------------------------- */ -static Datum +static Datum ExecEvalAnd(Expr * andExpr, ExprContext * econtext, bool * isNull) { - List *clauses; - List *clause; - Datum const_value = 0; - bool isDone; - bool IsNull; + List *clauses; + List *clause; + Datum const_value = 0; + bool isDone; + bool IsNull; IsNull = false; @@ -1149,7 +1149,7 @@ ExecEvalExpr(Node * expression, bool * isNull, bool * isDone) { - Datum retDatum = 0; + Datum retDatum = 0; *isNull = false; @@ -1173,68 +1173,68 @@ ExecEvalExpr(Node * expression, switch (nodeTag(expression)) { - case T_Var: - retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull); - break; - case T_Const: - { - Const *con = (Const *) expression; + case T_Var: + retDatum = (Datum) ExecEvalVar((Var *) expression, econtext, isNull); + break; + case T_Const: + { + Const *con = (Const *) expression; - if (con->constisnull) - *isNull = true; - retDatum = con->constvalue; + if (con->constisnull) + *isNull = true; + retDatum = con->constvalue; + break; + } + case T_Param: + retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull); break; - } - case T_Param: - retDatum = (Datum) ExecEvalParam((Param *) expression, econtext, isNull); - break; - case T_Iter: - retDatum = (Datum) ExecEvalIter((Iter *) expression, - econtext, - isNull, - isDone); - break; - case T_Aggreg: - retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression, - econtext, - isNull); - break; - case T_ArrayRef: - retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression, + case T_Iter: + retDatum = (Datum) ExecEvalIter((Iter *) expression, econtext, isNull, isDone); - break; - case T_Expr: - { - Expr *expr = (Expr *) expression; - - switch (expr->opType) + break; + case T_Aggreg: + retDatum = (Datum) ExecEvalAggreg((Aggreg *) expression, + econtext, + isNull); + break; + case T_ArrayRef: + retDatum = (Datum) ExecEvalArrayRef((ArrayRef *) expression, + econtext, + isNull, + isDone); + break; + case T_Expr: { - case OP_EXPR: - retDatum = (Datum) ExecEvalOper(expr, econtext, isNull); - break; - case FUNC_EXPR: - retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone); - break; - case OR_EXPR: - retDatum = (Datum) ExecEvalOr(expr, econtext, isNull); - break; - case AND_EXPR: - retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull); - break; - case NOT_EXPR: - retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); - break; - default: - elog(WARN, "ExecEvalExpr: unknown expression type"); + Expr *expr = (Expr *) expression; + + switch (expr->opType) + { + case OP_EXPR: + retDatum = (Datum) ExecEvalOper(expr, econtext, isNull); + break; + case FUNC_EXPR: + retDatum = (Datum) ExecEvalFunc(expr, econtext, isNull, isDone); + break; + case OR_EXPR: + retDatum = (Datum) ExecEvalOr(expr, econtext, isNull); + break; + case AND_EXPR: + retDatum = (Datum) ExecEvalAnd(expr, econtext, isNull); + break; + case NOT_EXPR: + retDatum = (Datum) ExecEvalNot(expr, econtext, isNull); + break; + default: + elog(WARN, "ExecEvalExpr: unknown expression type"); + break; + } break; } + default: + elog(WARN, "ExecEvalExpr: unknown expression type"); break; - } - default: - elog(WARN, "ExecEvalExpr: unknown expression type"); - break; } return retDatum; @@ -1256,12 +1256,12 @@ ExecEvalExpr(Node * expression, * rest of the qualification) * ---------------------------------------------------------------- */ -static bool +static bool ExecQualClause(Node * clause, ExprContext * econtext) { - Datum expr_value; - bool isNull; - bool isDone; + Datum expr_value; + bool isNull; + bool isDone; /* when there is a null clause, consider the qualification to be true */ if (clause == NULL) @@ -1304,8 +1304,8 @@ ExecQualClause(Node * clause, ExprContext * econtext) bool ExecQual(List * qual, ExprContext * econtext) { - List *clause; - bool result; + List *clause; + bool result; /* ---------------- * debugging stuff @@ -1356,9 +1356,9 @@ ExecQual(List * qual, ExprContext * econtext) int ExecTargetListLength(List * targetlist) { - int len; - List *tl; - TargetEntry *curTle; + int len; + List *tl; + TargetEntry *curTle; len = 0; foreach(tl, targetlist) @@ -1380,7 +1380,7 @@ ExecTargetListLength(List * targetlist) * expression context and return a tuple. * ---------------------------------------------------------------- */ -static HeapTuple +static HeapTuple ExecTargetList(List * targetlist, int nodomains, TupleDesc targettype, @@ -1388,18 +1388,18 @@ ExecTargetList(List * targetlist, ExprContext * econtext, bool * isDone) { - char nulls_array[64]; - bool fjNullArray[64]; - bool *fjIsNull; - char *null_head; - List *tl; - TargetEntry *tle; - Node *expr; - Resdom *resdom; - AttrNumber resind; - Datum constvalue; - HeapTuple newTuple; - bool isNull; + char nulls_array[64]; + bool fjNullArray[64]; + bool *fjIsNull; + char *null_head; + List *tl; + TargetEntry *tle; + Node *expr; + Resdom *resdom; + AttrNumber resind; + Datum constvalue; + HeapTuple newTuple; + bool isNull; /* ---------------- * debugging stuff @@ -1497,12 +1497,12 @@ ExecTargetList(List * targetlist, } else { - int curNode; - Resdom *fjRes; - List *fjTlist = (List *) tle->expr; - Fjoin *fjNode = tle->fjoin; - int nNodes = fjNode->fj_nNodes; - DatumPtr results = fjNode->fj_results; + int curNode; + Resdom *fjRes; + List *fjTlist = (List *) tle->expr; + Fjoin *fjNode = tle->fjoin; + int nNodes = fjNode->fj_nNodes; + DatumPtr results = fjNode->fj_results; ExecEvalFjoin(tle, econtext, fjIsNull, isDone); if (*isDone) @@ -1529,7 +1529,7 @@ ExecTargetList(List * targetlist, curNode++, fjTlist = lnext(fjTlist)) { #if 0 /* what is this?? */ - Node *outernode = lfirst(fjTlist); + Node *outernode = lfirst(fjTlist); fjRes = (Resdom *) outernode->iterexpr; #endif @@ -1582,12 +1582,12 @@ TupleTableSlot * ExecProject(ProjectionInfo * projInfo, bool * isDone) { TupleTableSlot *slot; - List *targetlist; - int len; - TupleDesc tupType; - Datum *tupValue; - ExprContext *econtext; - HeapTuple newTuple; + List *targetlist; + int len; + TupleDesc tupType; + Datum *tupValue; + ExprContext *econtext; + HeapTuple newTuple; /* ---------------- * sanity checks diff --git a/src/backend/executor/execScan.c b/src/backend/executor/execScan.c index 6ea50bb2a93..84dac56a237 100644 --- a/src/backend/executor/execScan.c +++ b/src/backend/executor/execScan.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.4 1997/09/07 04:41:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execScan.c,v 1.5 1997/09/08 02:22:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,15 +48,15 @@ ExecScan(Scan * node, * tuple */ { CommonScanState *scanstate; - EState *estate; - List *qual; - bool isDone; + EState *estate; + List *qual; + bool isDone; TupleTableSlot *slot; TupleTableSlot *resultSlot; - HeapTuple newTuple; + HeapTuple newTuple; - ExprContext *econtext; + ExprContext *econtext; ProjectionInfo *projInfo; diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index 287f75699af..373e94ae1a7 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.7 1997/09/07 04:41:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.8 1997/09/08 02:22:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -153,7 +153,7 @@ TupleTable /* return: address of table */ ExecCreateTupleTable(int initialSize) /* initial number of slots * in table */ { - TupleTable newtable; /* newly allocated table */ + TupleTable newtable; /* newly allocated table */ TupleTableSlot *array; /* newly allocated slot array */ /* ---------------- @@ -200,9 +200,9 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */ bool shouldFree) /* true if we should free slot * contents */ { - int next; /* next avaliable slot */ + int next; /* next avaliable slot */ TupleTableSlot *array; /* start of table array */ - int i; /* counter */ + int i; /* counter */ /* ---------------- * sanity checks @@ -229,8 +229,8 @@ ExecDestroyTupleTable(TupleTable table, /* tuple table */ if (shouldFree) for (i = 0; i < next; i++) { - TupleTableSlot slot; - HeapTuple tuple; + TupleTableSlot slot; + HeapTuple tuple; slot = array[i]; tuple = slot.val; @@ -280,7 +280,7 @@ TupleTableSlot * /* return: the slot allocated in the tuple * table */ ExecAllocTableSlot(TupleTable table) { - int slotnum; /* new slot number */ + int slotnum; /* new slot number */ /* ---------------- * sanity checks @@ -383,7 +383,7 @@ ExecStoreTuple(HeapTuple tuple, /* tuple to store */ TupleTableSlot * /* return: slot passed */ ExecClearTuple(TupleTableSlot * slot) /* slot in which to store tuple */ { - HeapTuple oldtuple; /* prior contents of slot */ + HeapTuple oldtuple; /* prior contents of slot */ /* ---------------- * sanity checks @@ -462,7 +462,7 @@ ExecSetSlotPolicy(TupleTableSlot * slot, /* slot to change */ bool shouldFree) /* true if we call pfree() when we * gc. */ { - bool old_shouldFree = slot->ttc_shouldFree; + bool old_shouldFree = slot->ttc_shouldFree; slot->ttc_shouldFree = shouldFree; @@ -490,7 +490,7 @@ TupleDesc /* return: old slot tuple descriptor */ ExecSetSlotDescriptor(TupleTableSlot * slot, /* slot to change */ TupleDesc tupdesc) /* tuple descriptor */ { - TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; + TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; slot->ttc_tupleDescriptor = tupdesc; return old_tupdesc; @@ -521,7 +521,7 @@ TupleDesc /* return: old slot tuple descriptor */ ExecSetNewSlotDescriptor(TupleTableSlot * slot, /* slot to change */ TupleDesc tupdesc) /* tuple descriptor */ { - TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; + TupleDesc old_tupdesc = slot->ttc_tupleDescriptor; slot->ttc_tupleDescriptor = tupdesc; slot->ttc_descIsNew = true; @@ -557,7 +557,7 @@ Buffer /* return: old slot buffer */ ExecSetSlotBuffer(TupleTableSlot * slot, /* slot to change */ Buffer b) /* tuple descriptor */ { - Buffer oldb = slot->ttc_buffer; + Buffer oldb = slot->ttc_buffer; slot->ttc_buffer = b; @@ -578,7 +578,7 @@ void ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */ { /* Buffer b = SlotBuffer((TupleTableSlot*) slot); */ - Buffer b = slot->ttc_buffer; + Buffer b = slot->ttc_buffer; if (BufferIsValid(b)) IncrBufferRefCount(b); @@ -599,7 +599,7 @@ ExecIncrSlotBufferRefcnt(TupleTableSlot * slot) /* slot to bump refcnt */ bool /* return: true if tuple in slot is NULL */ TupIsNull(TupleTableSlot * slot) /* slot to check */ { - HeapTuple tuple; /* contents of slot (returned) */ + HeapTuple tuple; /* contents of slot (returned) */ /* ---------------- * if the slot itself is null then we return true @@ -733,136 +733,136 @@ NodeGetResultTupleSlot(Plan * node) switch (nodeTag(node)) { - case T_Result: - { - ResultState *resstate = ((Result *) node)->resstate; - - slot = resstate->cstate.cs_ResultTupleSlot; - } - break; + case T_Result: + { + ResultState *resstate = ((Result *) node)->resstate; - case T_SeqScan: - { - CommonScanState *scanstate = ((SeqScan *) node)->scanstate; + slot = resstate->cstate.cs_ResultTupleSlot; + } + break; - slot = scanstate->cstate.cs_ResultTupleSlot; - } - break; + case T_SeqScan: + { + CommonScanState *scanstate = ((SeqScan *) node)->scanstate; - case T_NestLoop: - { - NestLoopState *nlstate = ((NestLoop *) node)->nlstate; + slot = scanstate->cstate.cs_ResultTupleSlot; + } + break; - slot = nlstate->jstate.cs_ResultTupleSlot; - } - break; + case T_NestLoop: + { + NestLoopState *nlstate = ((NestLoop *) node)->nlstate; - case T_Append: - { - Append *n = (Append *) node; - AppendState *unionstate; - List *unionplans; - int whichplan; - Plan *subplan; - - unionstate = n->unionstate; - unionplans = n->unionplans; - whichplan = unionstate->as_whichplan; - - subplan = (Plan *) nth(whichplan, unionplans); - slot = NodeGetResultTupleSlot(subplan); + slot = nlstate->jstate.cs_ResultTupleSlot; + } break; - } - case T_IndexScan: - { - CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate; + case T_Append: + { + Append *n = (Append *) node; + AppendState *unionstate; + List *unionplans; + int whichplan; + Plan *subplan; + + unionstate = n->unionstate; + unionplans = n->unionplans; + whichplan = unionstate->as_whichplan; + + subplan = (Plan *) nth(whichplan, unionplans); + slot = NodeGetResultTupleSlot(subplan); + break; + } - slot = scanstate->cstate.cs_ResultTupleSlot; - } - break; + case T_IndexScan: + { + CommonScanState *scanstate = ((IndexScan *) node)->scan.scanstate; - case T_Material: - { - MaterialState *matstate = ((Material *) node)->matstate; + slot = scanstate->cstate.cs_ResultTupleSlot; + } + break; - slot = matstate->csstate.css_ScanTupleSlot; - } - break; + case T_Material: + { + MaterialState *matstate = ((Material *) node)->matstate; - case T_Sort: - { - SortState *sortstate = ((Sort *) node)->sortstate; + slot = matstate->csstate.css_ScanTupleSlot; + } + break; - slot = sortstate->csstate.css_ScanTupleSlot; - } - break; + case T_Sort: + { + SortState *sortstate = ((Sort *) node)->sortstate; - case T_Agg: - { - AggState *aggstate = ((Agg *) node)->aggstate; + slot = sortstate->csstate.css_ScanTupleSlot; + } + break; - slot = aggstate->csstate.cstate.cs_ResultTupleSlot; - } - break; + case T_Agg: + { + AggState *aggstate = ((Agg *) node)->aggstate; - case T_Group: - { - GroupState *grpstate = ((Group *) node)->grpstate; + slot = aggstate->csstate.cstate.cs_ResultTupleSlot; + } + break; - slot = grpstate->csstate.cstate.cs_ResultTupleSlot; - } - break; + case T_Group: + { + GroupState *grpstate = ((Group *) node)->grpstate; - case T_Hash: - { - HashState *hashstate = ((Hash *) node)->hashstate; + slot = grpstate->csstate.cstate.cs_ResultTupleSlot; + } + break; - slot = hashstate->cstate.cs_ResultTupleSlot; - } - break; + case T_Hash: + { + HashState *hashstate = ((Hash *) node)->hashstate; - case T_Unique: - { - UniqueState *uniquestate = ((Unique *) node)->uniquestate; + slot = hashstate->cstate.cs_ResultTupleSlot; + } + break; - slot = uniquestate->cs_ResultTupleSlot; - } - break; + case T_Unique: + { + UniqueState *uniquestate = ((Unique *) node)->uniquestate; - case T_MergeJoin: - { - MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate; + slot = uniquestate->cs_ResultTupleSlot; + } + break; - slot = mergestate->jstate.cs_ResultTupleSlot; - } - break; + case T_MergeJoin: + { + MergeJoinState *mergestate = ((MergeJoin *) node)->mergestate; - case T_HashJoin: - { - HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate; + slot = mergestate->jstate.cs_ResultTupleSlot; + } + break; - slot = hashjoinstate->jstate.cs_ResultTupleSlot; - } - break; + case T_HashJoin: + { + HashJoinState *hashjoinstate = ((HashJoin *) node)->hashjoinstate; - case T_Tee: - { - TeeState *teestate = ((Tee *) node)->teestate; + slot = hashjoinstate->jstate.cs_ResultTupleSlot; + } + break; - slot = teestate->cstate.cs_ResultTupleSlot; - } - break; + case T_Tee: + { + TeeState *teestate = ((Tee *) node)->teestate; - default: - /* ---------------- - * should never get here - * ---------------- - */ - elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ", - nodeTag(node)); + slot = teestate->cstate.cs_ResultTupleSlot; + } + break; - return NULL; + default: + /* ---------------- + * should never get here + * ---------------- + */ + elog(WARN, "NodeGetResultTupleSlot: node not yet supported: %d ", + nodeTag(node)); + + return NULL; } return slot; } @@ -897,7 +897,7 @@ TupleDesc ExecGetTupType(Plan * node) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; if (node == NULL) return NULL; @@ -948,11 +948,11 @@ ExecCopyTupType(TupleDesc td, int natts) TupleDesc ExecTypeFromTL(List * targetList) { - List *tlcdr; - TupleDesc typeInfo; - Resdom *resdom; - Oid restype; - int len; + List *tlcdr; + TupleDesc typeInfo; + Resdom *resdom; + Oid restype; + int len; /* ---------------- * examine targetlist - if empty then return NULL @@ -977,7 +977,7 @@ ExecTypeFromTL(List * targetList) tlcdr = targetList; while (tlcdr != NIL) { - TargetEntry *tle = lfirst(tlcdr); + TargetEntry *tle = lfirst(tlcdr); if (tle->resdom != NULL) { @@ -1005,13 +1005,13 @@ ExecTypeFromTL(List * targetList) } else { - Resdom *fjRes; - List *fjTlistP; - List *fjList = lfirst(tlcdr); + Resdom *fjRes; + List *fjTlistP; + List *fjList = lfirst(tlcdr); #ifdef SETS_FIXED - TargetEntry *tle; - Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin; + TargetEntry *tle; + Fjoin *fjNode = ((TargetEntry *) lfirst(fjList))->fjoin; tle = fjNode->fj_innerNode; /* ??? */ #endif @@ -1037,7 +1037,7 @@ ExecTypeFromTL(List * targetList) foreach(fjTlistP, lnext(fjList)) { - TargetEntry *fjTle = lfirst(fjTlistP); + TargetEntry *fjTle = lfirst(fjTlistP); fjRes = fjTle->resdom; diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 3795c2d1018..0f3338d3cb9 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.15 1997/09/07 04:41:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.16 1997/09/08 02:22:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,13 +67,13 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple, int *numAttsOutP, * appended, replaced, deleted. * ---------------------------------------------------------------- */ -int NTupleProcessed; -int NTupleRetrieved; -int NTupleReplaced; -int NTupleAppended; -int NTupleDeleted; -int NIndexTupleInserted; -extern int NIndexTupleProcessed; /* have to be defined in the +int NTupleProcessed; +int NTupleRetrieved; +int NTupleReplaced; +int NTupleAppended; +int NTupleDeleted; +int NIndexTupleInserted; +extern int NIndexTupleProcessed; /* have to be defined in the * access method level so that the * cinterface.a will link ok. */ @@ -159,7 +159,7 @@ DisplayTupleCount(FILE * statfp) void ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent) { - int baseId; + int baseId; baseId = estate->es_BaseId; cstate->cs_base_id = baseId; @@ -178,9 +178,9 @@ ExecAssignNodeBaseInfo(EState * estate, CommonState * cstate, Plan * parent) void ExecAssignExprContext(EState * estate, CommonState * commonstate) { - ExprContext *econtext; - ParamListInfo paraminfo; - List *rangeTable; + ExprContext *econtext; + ParamListInfo paraminfo; + List *rangeTable; paraminfo = estate->es_param_list_info; rangeTable = estate->es_range_table; @@ -223,8 +223,8 @@ ExecAssignResultType(CommonState * commonstate, void ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate) { - Plan *outerPlan; - TupleDesc tupDesc; + Plan *outerPlan; + TupleDesc tupDesc; outerPlan = outerPlan(node); tupDesc = ExecGetTupType(outerPlan); @@ -239,13 +239,13 @@ ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate) void ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate) { - List *targetList; - int i; - int len; - List *tl; - TargetEntry *tle; - List *fjtl; - TupleDesc origTupDesc; + List *targetList; + int i; + int len; + List *tl; + TargetEntry *tle; + List *fjtl; + TupleDesc origTupDesc; targetList = node->targetlist; origTupDesc = ExecTypeFromTL(targetList); @@ -269,7 +269,7 @@ ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate) #ifdef SETS_FIXED if (!tl_is_resdom(tle)) { - Fjoin *fj = (Fjoin *) lfirst(tle); + Fjoin *fj = (Fjoin *) lfirst(tle); /* it is a FJoin */ fjtl = lnext(tle); @@ -309,7 +309,7 @@ void ExecFreeResultType(CommonState * commonstate) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; slot = commonstate->cs_ResultTupleSlot; tupType = slot->ttc_tupleDescriptor; @@ -329,8 +329,8 @@ void ExecAssignProjectionInfo(Plan * node, CommonState * commonstate) { ProjectionInfo *projInfo; - List *targetList; - int len; + List *targetList; + int len; targetList = node->targetlist; len = ExecTargetListLength(targetList); @@ -407,7 +407,7 @@ void ExecFreeScanType(CommonScanState * csstate) { TupleTableSlot *slot; - TupleDesc tupType; + TupleDesc tupType; slot = csstate->css_ScanTupleSlot; tupType = slot->ttc_tupleDescriptor; @@ -439,8 +439,8 @@ ExecAssignScanType(CommonScanState * csstate, void ExecAssignScanTypeFromOuterPlan(Plan * node, CommonScanState * csstate) { - Plan *outerPlan; - TupleDesc tupDesc; + Plan *outerPlan; + TupleDesc tupDesc; outerPlan = outerPlan(node); tupDesc = ExecGetTupType(outerPlan); @@ -571,10 +571,10 @@ ExecFreeTypeInfo(TupleDesc typeInfo) TupleDesc QueryDescGetTypeInfo(QueryDesc * queryDesc) { - Plan *plan; - TupleDesc tupleType; - List *targetList; - AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo)); + Plan *plan; + TupleDesc tupleType; + List *targetList; + AttrInfo *attinfo = (AttrInfo *) palloc(sizeof(AttrInfo)); plan = queryDesc->plantree; tupleType = (TupleDesc) ExecGetTupType(plan); @@ -611,9 +611,9 @@ ExecGetIndexKeyInfo(IndexTupleForm indexTuple, AttrNumber ** attsOutP, FuncIndexInfoPtr fInfoP) { - int i; - int numKeys; - AttrNumber *attKeys; + int i; + int numKeys; + AttrNumber *attKeys; /* ---------------- * check parameters @@ -708,32 +708,32 @@ void ExecOpenIndices(Oid resultRelationOid, RelationInfo * resultRelationInfo) { - Relation indexRd; - HeapScanDesc indexSd; - ScanKeyData key; - HeapTuple tuple; - IndexTupleForm indexStruct; - Oid indexOid; - List *oidList; - List *nkeyList; - List *keyList; - List *fiList; - char *predString; - List *predList; - List *indexoid; - List *numkeys; - List *indexkeys; - List *indexfuncs; - List *indexpreds; - int len; - - RelationPtr relationDescs; - IndexInfo **indexInfoArray; + Relation indexRd; + HeapScanDesc indexSd; + ScanKeyData key; + HeapTuple tuple; + IndexTupleForm indexStruct; + Oid indexOid; + List *oidList; + List *nkeyList; + List *keyList; + List *fiList; + char *predString; + List *predList; + List *indexoid; + List *numkeys; + List *indexkeys; + List *indexfuncs; + List *indexpreds; + int len; + + RelationPtr relationDescs; + IndexInfo **indexInfoArray; FuncIndexInfoPtr fInfoP; - int numKeyAtts; - AttrNumber *indexKeyAtts; - PredInfo *predicate; - int i; + int numKeyAtts; + AttrNumber *indexKeyAtts; + PredInfo *predicate; + int i; /* ---------------- * open pg_index @@ -857,7 +857,7 @@ ExecOpenIndices(Oid resultRelationOid, for (i = 0; i < len; i++) { - IndexInfo *ii = makeNode(IndexInfo); + IndexInfo *ii = makeNode(IndexInfo); ii->ii_NumKeyAttributes = 0; ii->ii_KeyAttributeNumbers = (AttrNumber *) NULL; @@ -875,7 +875,7 @@ ExecOpenIndices(Oid resultRelationOid, i = 0; foreach(indexoid, oidList) { - Relation indexDesc; + Relation indexDesc; indexOid = lfirsti(indexoid); indexDesc = index_open(indexOid); @@ -954,9 +954,9 @@ ExecOpenIndices(Oid resultRelationOid, void ExecCloseIndices(RelationInfo * resultRelationInfo) { - int i; - int numIndices; - RelationPtr relationDescs; + int i; + int numIndices; + RelationPtr relationDescs; numIndices = resultRelationInfo->ri_NumIndices; relationDescs = resultRelationInfo->ri_IndexRelationDescs; @@ -986,14 +986,14 @@ ExecFormIndexTuple(HeapTuple heapTuple, Relation indexRelation, IndexInfo * indexInfo) { - IndexTuple indexTuple; - TupleDesc heapDescriptor; - TupleDesc indexDescriptor; - Datum *datum; - char *nulls; - - int numberOfAttributes; - AttrNumber *keyAttributeNumbers; + IndexTuple indexTuple; + TupleDesc heapDescriptor; + TupleDesc indexDescriptor; + Datum *datum; + char *nulls; + + int numberOfAttributes; + AttrNumber *keyAttributeNumbers; FuncIndexInfoPtr fInfoP; /* ---------------- @@ -1075,24 +1075,24 @@ ExecInsertIndexTuples(TupleTableSlot * slot, EState * estate, bool is_update) { - HeapTuple heapTuple; - RelationInfo *resultRelationInfo; - int i; - int numIndices; - RelationPtr relationDescs; - Relation heapRelation; - IndexInfo **indexInfoArray; - IndexInfo *indexInfo; - Node *predicate; - bool satisfied; - ExprContext *econtext; + HeapTuple heapTuple; + RelationInfo *resultRelationInfo; + int i; + int numIndices; + RelationPtr relationDescs; + Relation heapRelation; + IndexInfo **indexInfoArray; + IndexInfo *indexInfo; + Node *predicate; + bool satisfied; + ExprContext *econtext; InsertIndexResult result; - int numberOfAttributes; - AttrNumber *keyAttributeNumbers; + int numberOfAttributes; + AttrNumber *keyAttributeNumbers; FuncIndexInfoPtr fInfoP; - TupleDesc heapDescriptor; - Datum *datum; - char *nulls; + TupleDesc heapDescriptor; + Datum *datum; + char *nulls; heapTuple = slot->val; @@ -1189,10 +1189,10 @@ void setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, List * rangeTable) { - List *tl; - TargetEntry *tle; - Node *expr; - int varno; + List *tl; + TargetEntry *tle; + Node *expr; + int varno; tl = targetList; @@ -1206,9 +1206,9 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, expr = tle->expr; if (expr && IsA(expr, Var)) { - Var *var; - RangeTblEntry *rtentry; - Relation rd; + Var *var; + RangeTblEntry *rtentry; + Relation rd; var = (Var *) expr; rtentry = rt_fetch(var->varnoold, rangeTable); @@ -1238,7 +1238,7 @@ setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, void resetVarAttrLenForCreateTable(TupleDesc tupType) { - int varno; + int varno; for (varno = 0; varno < tupType->natts; varno++) { diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index 96b9b19dcb6..6b10ead6516 100644 --- a/src/backend/executor/functions.c +++ b/src/backend/executor/functions.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.8 1997/09/07 04:41:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.9 1997/09/08 02:22:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,15 +44,15 @@ typedef enum { F_EXEC_START, F_EXEC_RUN, F_EXEC_DONE -} ExecStatus; +} ExecStatus; typedef struct local_es { - QueryDesc *qd; - EState *estate; + QueryDesc *qd; + EState *estate; struct local_es *next; - ExecStatus status; -} execution_state; + ExecStatus status; +} execution_state; #define LAST_POSTQUEL_COMMAND(es) ((es)->next == (execution_state *)NULL) @@ -62,7 +62,7 @@ static execution_state * init_execution_state(FunctionCachePtr fcache, char *args[]); static TupleTableSlot *postquel_getnext(execution_state * es); -static void postquel_end(execution_state * es); +static void postquel_end(execution_state * es); static void postquel_sub_params(execution_state * es, int nargs, char *args[], bool * nullV); @@ -77,10 +77,10 @@ ProjectAttribute(TupleDesc TD, HeapTuple tup, bool * isnullP) { - Datum val, - valueP; - Var *attrVar = (Var *) tlist->expr; - AttrNumber attrno = attrVar->varattno; + Datum val, + valueP; + Var *attrVar = (Var *) tlist->expr; + AttrNumber attrno = attrVar->varattno; val = PointerGetDatum(heap_getattr(tup, @@ -105,10 +105,10 @@ init_execution_state(FunctionCachePtr fcache, execution_state *newes; execution_state *nextes; execution_state *preves; - QueryTreeList *queryTree_list; - int i; - List *planTree_list; - int nargs; + QueryTreeList *queryTree_list; + int i; + List *planTree_list; + int nargs; nargs = fcache->nargs; @@ -122,9 +122,9 @@ init_execution_state(FunctionCachePtr fcache, for (i = 0; i < queryTree_list->len; i++) { - EState *estate; - Query *queryTree = (Query *) (queryTree_list->qtrees[i]); - Plan *planTree = lfirst(planTree_list); + EState *estate; + Query *queryTree = (Query *) (queryTree_list->qtrees[i]); + Plan *planTree = lfirst(planTree_list); if (!nextes) nextes = (execution_state *) palloc(sizeof(execution_state)); @@ -140,8 +140,8 @@ init_execution_state(FunctionCachePtr fcache, if (nargs > 0) { - int i; - ParamListInfo paramLI; + int i; + ParamListInfo paramLI; paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData)); @@ -171,7 +171,7 @@ init_execution_state(FunctionCachePtr fcache, return newes; } -static TupleDesc +static TupleDesc postquel_start(execution_state * es) { #ifdef FUNC_UTIL_PATCH @@ -191,7 +191,7 @@ postquel_start(execution_state * es) static TupleTableSlot * postquel_getnext(execution_state * es) { - int feature; + int feature; #ifdef FUNC_UTIL_PATCH if (es->qd->operation == CMD_UTILITY) @@ -236,8 +236,8 @@ postquel_sub_params(execution_state * es, char *args[], bool * nullV) { - ParamListInfo paramLI; - EState *estate; + ParamListInfo paramLI; + EState *estate; estate = es->estate; paramLI = estate->es_param_list_info; @@ -259,9 +259,9 @@ copy_function_result(FunctionCachePtr fcache, TupleTableSlot * resultSlot) { TupleTableSlot *funcSlot; - TupleDesc resultTd; - HeapTuple newTuple; - HeapTuple oldTuple; + TupleDesc resultTd; + HeapTuple newTuple; + HeapTuple oldTuple; Assert(!TupIsNull(resultSlot)); oldTuple = resultSlot->val; @@ -279,8 +279,8 @@ copy_function_result(FunctionCachePtr fcache, */ if (TupIsNull(funcSlot)) { - int i = 0; - TupleDesc funcTd = funcSlot->ttc_tupleDescriptor; + int i = 0; + TupleDesc funcTd = funcSlot->ttc_tupleDescriptor; while (i < oldTuple->t_natts) { @@ -298,7 +298,7 @@ copy_function_result(FunctionCachePtr fcache, return ExecStoreTuple(newTuple, funcSlot, InvalidBuffer, true); } -static Datum +static Datum postquel_execute(execution_state * es, FunctionCachePtr fcache, List * fTlist, @@ -306,7 +306,7 @@ postquel_execute(execution_state * es, bool * isNull) { TupleTableSlot *slot; - Datum value; + Datum value; #ifdef INDEXSCAN_PATCH @@ -360,8 +360,8 @@ postquel_execute(execution_state * es, resSlot = copy_function_result(fcache, slot); if (fTlist != NIL) { - HeapTuple tup; - TargetEntry *tle = lfirst(fTlist); + HeapTuple tup; + TargetEntry *tle = lfirst(fTlist); tup = resSlot->val; value = ProjectAttribute(resSlot->ttc_tupleDescriptor, @@ -401,9 +401,9 @@ Datum postquel_function(Func * funcNode, char **args, bool * isNull, bool * isDone) { execution_state *es; - Datum result = 0; + Datum result = 0; FunctionCachePtr fcache = funcNode->func_fcache; - CommandId savedId; + CommandId savedId; /* * Before we start do anything we must save CurrentScanCommandId to diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index ee03f6854d9..92fa9bbe1ef 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -36,18 +36,18 @@ */ typedef struct AggFuncInfo { - Oid xfn1_oid; - Oid xfn2_oid; - Oid finalfn_oid; - func_ptr xfn1; - func_ptr xfn2; - func_ptr finalfn; - int xfn1_nargs; - int xfn2_nargs; - int finalfn_nargs; -} AggFuncInfo; + Oid xfn1_oid; + Oid xfn2_oid; + Oid finalfn_oid; + func_ptr xfn1; + func_ptr xfn2; + func_ptr finalfn; + int xfn1_nargs; + int xfn2_nargs; + int finalfn_nargs; +} AggFuncInfo; -static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); +static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); /* --------------------------------------- @@ -90,26 +90,26 @@ static Datum aggGetAttr(TupleTableSlot * tuple, Aggreg * agg, bool * isNull); TupleTableSlot * ExecAgg(Agg * node) { - AggState *aggstate; - EState *estate; - Aggreg **aggregates; - Plan *outerPlan; - int i, - nagg; - Datum *value1, - *value2; - int *noInitValue; - AggFuncInfo *aggFuncInfo; - long nTuplesAgged = 0; - ExprContext *econtext; + AggState *aggstate; + EState *estate; + Aggreg **aggregates; + Plan *outerPlan; + int i, + nagg; + Datum *value1, + *value2; + int *noInitValue; + AggFuncInfo *aggFuncInfo; + long nTuplesAgged = 0; + ExprContext *econtext; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - HeapTuple oneTuple; - char *nulls; - bool isDone; - bool isNull = FALSE, - isNull1 = FALSE, - isNull2 = FALSE; + HeapTuple oneTuple; + char *nulls; + bool isDone; + bool isNull = FALSE, + isNull1 = FALSE, + isNull2 = FALSE; /* --------------------- * get state info from node @@ -143,19 +143,19 @@ ExecAgg(Agg * node) for (i = 0; i < nagg; i++) { - Aggreg *agg; - char *aggname; - HeapTuple aggTuple; + Aggreg *agg; + char *aggname; + HeapTuple aggTuple; Form_pg_aggregate aggp; - Oid xfn1_oid, - xfn2_oid, - finalfn_oid; - func_ptr xfn1_ptr, - xfn2_ptr, - finalfn_ptr; - int xfn1_nargs, - xfn2_nargs, - finalfn_nargs; + Oid xfn1_oid, + xfn2_oid, + finalfn_oid; + func_ptr xfn1_ptr, + xfn2_ptr, + finalfn_ptr; + int xfn1_nargs, + xfn2_nargs, + finalfn_nargs; agg = aggregates[i]; @@ -240,7 +240,7 @@ ExecAgg(Agg * node) */ for (;;) { - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot; isNull = isNull1 = isNull2 = 0; @@ -258,9 +258,9 @@ ExecAgg(Agg * node) */ if (nTuplesAgged == 0) { - TupleDesc tupType; - Datum *tupValue; - char *null_array; + TupleDesc tupType; + Datum *tupValue; + char *null_array; tupType = aggstate->csstate.css_ScanTupleSlot->ttc_tupleDescriptor; tupValue = projInfo->pi_tupValue; @@ -277,29 +277,29 @@ ExecAgg(Agg * node) for (i = 0; i < nagg; i++) { - AttrNumber attnum; - int2 attlen; - Datum newVal = (Datum) NULL; - AggFuncInfo *aggfns = &aggFuncInfo[i]; - Datum args[2]; - Node *tagnode = NULL; + AttrNumber attnum; + int2 attlen; + Datum newVal = (Datum) NULL; + AggFuncInfo *aggfns = &aggFuncInfo[i]; + Datum args[2]; + Node *tagnode = NULL; switch (nodeTag(aggregates[i]->target)) { - case T_Var: - tagnode = NULL; - newVal = aggGetAttr(outerslot, - aggregates[i], - &isNull); - break; - case T_Expr: - tagnode = ((Expr *) aggregates[i]->target)->oper; - econtext->ecxt_scantuple = outerslot; - newVal = ExecEvalExpr(aggregates[i]->target, econtext, - &isNull, NULL); - break; - default: - elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i); + case T_Var: + tagnode = NULL; + newVal = aggGetAttr(outerslot, + aggregates[i], + &isNull); + break; + case T_Expr: + tagnode = ((Expr *) aggregates[i]->target)->oper; + econtext->ecxt_scantuple = outerslot; + newVal = ExecEvalExpr(aggregates[i]->target, econtext, + &isNull, NULL); + break; + default: + elog(WARN, "ExecAgg: Bad Agg->Target for Agg %d", i); } if (isNull) @@ -309,7 +309,7 @@ ExecAgg(Agg * node) { if (noInitValue[i]) { - int byVal; + int byVal; /* * value1 and value2 has not been initialized. This is @@ -371,7 +371,7 @@ ExecAgg(Agg * node) if (aggfns->xfn2) { - Datum xfn2_val = value2[i]; + Datum xfn2_val = value2[i]; value2[i] = (Datum) fmgr_c(aggfns->xfn2, aggfns->xfn2_oid, @@ -399,8 +399,8 @@ ExecAgg(Agg * node) */ for (i = 0; i < nagg; i++) { - char *args[2]; - AggFuncInfo *aggfns = &aggFuncInfo[i]; + char *args[2]; + AggFuncInfo *aggfns = &aggFuncInfo[i]; if (noInitValue[i]) { @@ -490,9 +490,9 @@ ExecAgg(Agg * node) bool ExecInitAgg(Agg * node, EState * estate, Plan * parent) { - AggState *aggstate; - Plan *outerPlan; - ExprContext *econtext; + AggState *aggstate; + Plan *outerPlan; + ExprContext *econtext; /* * assign the node's execution state @@ -566,8 +566,8 @@ ExecCountSlotsAgg(Agg * node) void ExecEndAgg(Agg * node) { - AggState *aggstate; - Plan *outerPlan; + AggState *aggstate; + Plan *outerPlan; aggstate = node->aggstate; @@ -590,16 +590,16 @@ ExecEndAgg(Agg * node) * get the attribute (specified in the Var node in agg) to aggregate * over from the tuple */ -static Datum +static Datum aggGetAttr(TupleTableSlot * slot, Aggreg * agg, bool * isNull) { - Datum result; - AttrNumber attnum; - HeapTuple heapTuple; - TupleDesc tuple_type; - Buffer buffer; + Datum result; + AttrNumber attnum; + HeapTuple heapTuple; + TupleDesc tuple_type; + Buffer buffer; /* ---------------- * extract tuple information from the slot @@ -619,8 +619,8 @@ aggGetAttr(TupleTableSlot * slot, if (attnum == InvalidAttrNumber) { TupleTableSlot *tempSlot; - TupleDesc td; - HeapTuple tup; + TupleDesc td; + HeapTuple tup; tempSlot = makeNode(TupleTableSlot); tempSlot->ttc_shouldFree = false; diff --git a/src/backend/executor/nodeAppend.c b/src/backend/executor/nodeAppend.c index 043ad5d9743..da43dc8ee3d 100644 --- a/src/backend/executor/nodeAppend.c +++ b/src/backend/executor/nodeAppend.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.6 1997/09/07 04:41:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAppend.c,v 1.7 1997/09/08 02:22:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ #include "utils/mcxt.h" #include "parser/parsetree.h" /* for rt_store() macro */ -static bool exec_append_initialize_next(Append * node); +static bool exec_append_initialize_next(Append * node); /* ---------------------------------------------------------------- * exec-append-initialize-next @@ -75,20 +75,20 @@ static bool exec_append_initialize_next(Append * node); * Returns t iff there is a "next" scan to process. * ---------------------------------------------------------------- */ -static bool +static bool exec_append_initialize_next(Append * node) { - EState *estate; - AppendState *unionstate; + EState *estate; + AppendState *unionstate; TupleTableSlot *result_slot; - List *rangeTable; + List *rangeTable; - int whichplan; - int nplans; - List *rtentries; - ResTarget *rtentry; + int whichplan; + int nplans; + List *rtentries; + ResTarget *rtentry; - Index unionrelid; + Index unionrelid; /* ---------------- * get information from the append node @@ -184,16 +184,16 @@ exec_append_initialize_next(Append * node) bool ExecInitAppend(Append * node, EState * estate, Plan * parent) { - AppendState *unionstate; - int nplans; - List *resultList = NULL; - List *rtentries; - List *unionplans; - bool *initialized; - int i; - Plan *initNode; - List *junkList; - RelationInfo *es_rri = estate->es_result_relation_info; + AppendState *unionstate; + int nplans; + List *resultList = NULL; + List *rtentries; + List *unionplans; + bool *initialized; + int i; + Plan *initNode; + List *junkList; + RelationInfo *es_rri = estate->es_result_relation_info; /* ---------------- * assign execution state to node and get information @@ -251,13 +251,13 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) if ((es_rri != (RelationInfo *) NULL) && (node->unionrelid == es_rri->ri_RangeTableIndex)) { - RelationInfo *rri; - List *rtentryP; + RelationInfo *rri; + List *rtentryP; foreach(rtentryP, rtentries) { - Oid reloid; - RangeTblEntry *rtentry = lfirst(rtentryP); + Oid reloid; + RangeTblEntry *rtentry = lfirst(rtentryP); reloid = rtentry->relid; rri = makeNode(RelationInfo); @@ -281,8 +281,8 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) for (i = 0; i < nplans; i++) { - JunkFilter *j; - List *targetList; + JunkFilter *j; + List *targetList; /* ---------------- * NOTE: we first modify range table in @@ -343,9 +343,9 @@ ExecInitAppend(Append * node, EState * estate, Plan * parent) int ExecCountSlotsAppend(Append * node) { - List *plan; - List *unionplans = node->unionplans; - int nSlots = 0; + List *plan; + List *unionplans = node->unionplans; + int nSlots = 0; foreach(plan, unionplans) { @@ -365,15 +365,15 @@ ExecCountSlotsAppend(Append * node) TupleTableSlot * ExecProcAppend(Append * node) { - EState *estate; - AppendState *unionstate; + EState *estate; + AppendState *unionstate; - int whichplan; - List *unionplans; - Plan *subnode; + int whichplan; + List *unionplans; + Plan *subnode; TupleTableSlot *result; TupleTableSlot *result_slot; - ScanDirection direction; + ScanDirection direction; /* ---------------- * get information from the node @@ -458,13 +458,13 @@ ExecProcAppend(Append * node) void ExecEndAppend(Append * node) { - AppendState *unionstate; - int nplans; - List *unionplans; - bool *initialized; - int i; - List *resultRelationInfoList; - RelationInfo *resultRelationInfo; + AppendState *unionstate; + int nplans; + List *unionplans; + bool *initialized; + int i; + List *resultRelationInfoList; + RelationInfo *resultRelationInfo; /* ---------------- * get information from the node @@ -494,7 +494,7 @@ ExecEndAppend(Append * node) resultRelationInfoList = unionstate->as_result_relation_info_list; while (resultRelationInfoList != NIL) { - Relation resultRelationDesc; + Relation resultRelationDesc; resultRelationInfo = (RelationInfo *) lfirst(resultRelationInfoList); resultRelationDesc = resultRelationInfo->ri_RelationDesc; diff --git a/src/backend/executor/nodeGroup.c b/src/backend/executor/nodeGroup.c index 1a96a1ee911..c7e63696c0b 100644 --- a/src/backend/executor/nodeGroup.c +++ b/src/backend/executor/nodeGroup.c @@ -13,7 +13,7 @@ * columns. (ie. tuples from the same group are consecutive) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.6 1997/09/07 04:41:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeGroup.c,v 1.7 1997/09/08 02:22:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,17 +66,17 @@ ExecGroup(Group * node) static TupleTableSlot * ExecGroupEveryTuple(Group * node) { - GroupState *grpstate; - EState *estate; - ExprContext *econtext; + GroupState *grpstate; + EState *estate; + ExprContext *econtext; - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot, - *lastslot; + *lastslot; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - bool isDone; + bool isDone; /* --------------------- * get state info from node @@ -167,17 +167,17 @@ ExecGroupEveryTuple(Group * node) static TupleTableSlot * ExecGroupOneTuple(Group * node) { - GroupState *grpstate; - EState *estate; - ExprContext *econtext; + GroupState *grpstate; + EState *estate; + ExprContext *econtext; - HeapTuple outerTuple = NULL; + HeapTuple outerTuple = NULL; TupleTableSlot *outerslot, - *lastslot; + *lastslot; ProjectionInfo *projInfo; TupleTableSlot *resultSlot; - bool isDone; + bool isDone; /* --------------------- * get state info from node @@ -291,8 +291,8 @@ ExecGroupOneTuple(Group * node) bool ExecInitGroup(Group * node, EState * estate, Plan * parent) { - GroupState *grpstate; - Plan *outerPlan; + GroupState *grpstate; + Plan *outerPlan; /* * assign the node's execution state @@ -358,8 +358,8 @@ ExecCountSlotsGroup(Group * node) void ExecEndGroup(Group * node) { - GroupState *grpstate; - Plan *outerPlan; + GroupState *grpstate; + Plan *outerPlan; grpstate = node->grpstate; @@ -379,22 +379,22 @@ ExecEndGroup(Group * node) /* * code swiped from nodeUnique.c */ -static bool +static bool sameGroup(TupleTableSlot * oldslot, TupleTableSlot * newslot, int numCols, AttrNumber * grpColIdx, TupleDesc tupdesc) { - bool isNull1, - isNull2; - char *attr1, - *attr2; - char *val1, - *val2; - int i; - AttrNumber att; - Oid typoutput; + bool isNull1, + isNull2; + char *attr1, + *attr2; + char *val1, + *val2; + int i; + AttrNumber att; + Oid typoutput; for (i = 0; i < numCols; i++) { diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index b25939fa832..b0e7ca4dd53 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.11 1997/09/07 04:41:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHash.c,v 1.12 1997/09/08 02:22:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,12 +42,12 @@ #include "utils/palloc.h" #include "utils/hsearch.h" -extern int NBuffers; -static int HashTBSize; +extern int NBuffers; +static int HashTBSize; -static void mk_hj_temp(char *tempname); -static int hashFunc(char *key, int len); -static int ExecHashPartition(Hash * node); +static void mk_hj_temp(char *tempname); +static int hashFunc(char *key, int len); +static int ExecHashPartition(Hash * node); static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable); static void ExecHashOverflowInsert(HashJoinTable hashtable, @@ -64,20 +64,20 @@ ExecHashOverflowInsert(HashJoinTable hashtable, TupleTableSlot * ExecHash(Hash * node) { - EState *estate; - HashState *hashstate; - Plan *outerNode; - Var *hashkey; - HashJoinTable hashtable; + EState *estate; + HashState *hashstate; + Plan *outerNode; + Var *hashkey; + HashJoinTable hashtable; TupleTableSlot *slot; - ExprContext *econtext; + ExprContext *econtext; - int nbatch; - File *batches = NULL; - RelativeAddr *batchPos; - int *batchSizes; - int i; - RelativeAddr *innerbatchNames; + int nbatch; + File *batches = NULL; + RelativeAddr *batchPos; + int *batchSizes; + int i; + RelativeAddr *innerbatchNames; /* ---------------- * get state info from node @@ -167,8 +167,8 @@ ExecHash(Hash * node) bool ExecInitHash(Hash * node, EState * estate, Plan * parent) { - HashState *hashstate; - Plan *outerPlan; + HashState *hashstate; + Plan *outerPlan; SO1_printf("ExecInitHash: %s\n", "initializing hash node"); @@ -240,9 +240,9 @@ ExecCountSlotsHash(Hash * node) void ExecEndHash(Hash * node) { - HashState *hashstate; - Plan *outerPlan; - File *batches; + HashState *hashstate; + Plan *outerPlan; + File *batches; /* ---------------- * get info from the hash state @@ -268,10 +268,10 @@ ExecEndHash(Hash * node) ExecEndNode(outerPlan, (Plan *) node); } -static RelativeAddr +static RelativeAddr hashTableAlloc(int size, HashJoinTable hashtable) { - RelativeAddr p; + RelativeAddr p; p = hashtable->top; hashtable->top += size; @@ -290,23 +290,23 @@ hashTableAlloc(int size, HashJoinTable hashtable) HashJoinTable ExecHashTableCreate(Hash * node) { - Plan *outerNode; - int nbatch; - int ntuples; - int tupsize; - IpcMemoryId shmid; - HashJoinTable hashtable; - HashBucket bucket; - int nbuckets; - int totalbuckets; - int bucketsize; - int i; - RelativeAddr *outerbatchNames; - RelativeAddr *outerbatchPos; - RelativeAddr *innerbatchNames; - RelativeAddr *innerbatchPos; - int *innerbatchSizes; - RelativeAddr tempname; + Plan *outerNode; + int nbatch; + int ntuples; + int tupsize; + IpcMemoryId shmid; + HashJoinTable hashtable; + HashBucket bucket; + int nbuckets; + int totalbuckets; + int bucketsize; + int i; + RelativeAddr *outerbatchNames; + RelativeAddr *outerbatchPos; + RelativeAddr *innerbatchNames; + RelativeAddr *innerbatchPos; + int *innerbatchSizes; + RelativeAddr tempname; nbatch = -1; HashTBSize = NBuffers / 2; @@ -461,15 +461,15 @@ ExecHashTableInsert(HashJoinTable hashtable, File * batches) { TupleTableSlot *slot; - HeapTuple heapTuple; - HashBucket bucket; - int bucketno; - int nbatch; - int batchno; - char *buffer; - RelativeAddr *batchPos; - int *batchSizes; - char *pos; + HeapTuple heapTuple; + HashBucket bucket; + int bucketno; + int nbatch; + int batchno; + char *buffer; + RelativeAddr *batchPos; + int *batchSizes; + char *pos; nbatch = hashtable->nbatch; batchPos = (RelativeAddr *) ABSADDR(hashtable->innerbatchPos); @@ -551,9 +551,9 @@ ExecHashGetBucket(HashJoinTable hashtable, ExprContext * econtext, Var * hashkey) { - int bucketno; - Datum keyval; - bool isNull; + int bucketno; + Datum keyval; + bool isNull; /* ---------------- @@ -606,10 +606,10 @@ ExecHashOverflowInsert(HashJoinTable hashtable, HashBucket bucket, HeapTuple heapTuple) { - OverflowTuple otuple; - RelativeAddr newend; - OverflowTuple firstotuple; - OverflowTuple lastotuple; + OverflowTuple otuple; + RelativeAddr newend; + OverflowTuple firstotuple; + OverflowTuple lastotuple; firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple); lastotuple = (OverflowTuple) ABSADDR(bucket->lastotuple); @@ -687,14 +687,14 @@ ExecScanHashBucket(HashJoinState * hjstate, List * hjclauses, ExprContext * econtext) { - HeapTuple heapTuple; - bool qualResult; - OverflowTuple otuple = NULL; - OverflowTuple curotuple; + HeapTuple heapTuple; + bool qualResult; + OverflowTuple otuple = NULL; + OverflowTuple curotuple; TupleTableSlot *inntuple; - OverflowTuple firstotuple; - OverflowTuple lastotuple; - HashJoinTable hashtable; + OverflowTuple firstotuple; + OverflowTuple lastotuple; + HashJoinTable hashtable; hashtable = hjstate->hj_HashTable; firstotuple = (OverflowTuple) ABSADDR(bucket->firstotuple); @@ -785,7 +785,7 @@ static int hashFunc(char *key, int len) { register unsigned int h; - register int l; + register int l; register unsigned char *k; /* @@ -828,11 +828,11 @@ hashFunc(char *key, int len) static int ExecHashPartition(Hash * node) { - Plan *outerNode; - int b; - int pages; - int ntuples; - int tupsize; + Plan *outerNode; + int b; + int pages; + int ntuples; + int tupsize; /* * get size information for plan node @@ -866,8 +866,8 @@ ExecHashPartition(Hash * node) void ExecHashTableReset(HashJoinTable hashtable, int ntuples) { - int i; - HashBucket bucket; + int i; + HashBucket bucket; hashtable->nbuckets = hashtable->totalbuckets = ceil((double) ntuples / NTUP_PER_BUCKET); @@ -886,7 +886,7 @@ ExecHashTableReset(HashJoinTable hashtable, int ntuples) hashtable->pcount = hashtable->nprocess; } -static int hjtmpcnt = 0; +static int hjtmpcnt = 0; static void mk_hj_temp(char *tempname) diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 3548e38cc86..b0c6eec3c02 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.6 1997/09/07 04:41:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeHashjoin.c,v 1.7 1997/09/08 02:22:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ #include "utils/palloc.h" static TupleTableSlot * - ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate); + ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate); static TupleTableSlot * ExecHashJoinGetSavedTuple(HashJoinState * hjstate, char *buffer, @@ -43,7 +43,7 @@ static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch); -static int ExecHashJoinNewBatch(HashJoinState * hjstate); +static int ExecHashJoinNewBatch(HashJoinState * hjstate); @@ -59,39 +59,39 @@ static int ExecHashJoinNewBatch(HashJoinState * hjstate); TupleTableSlot * /* return: a tuple or NULL */ ExecHashJoin(HashJoin * node) { - HashJoinState *hjstate; - EState *estate; - Plan *outerNode; - Hash *hashNode; - List *hjclauses; - Expr *clause; - List *qual; - ScanDirection dir; + HashJoinState *hjstate; + EState *estate; + Plan *outerNode; + Hash *hashNode; + List *hjclauses; + Expr *clause; + List *qual; + ScanDirection dir; TupleTableSlot *inntuple; - Var *outerVar; - ExprContext *econtext; + Var *outerVar; + ExprContext *econtext; - HashJoinTable hashtable; - int bucketno; - HashBucket bucket; - HeapTuple curtuple; + HashJoinTable hashtable; + int bucketno; + HashBucket bucket; + HeapTuple curtuple; - bool qualResult; + bool qualResult; TupleTableSlot *outerTupleSlot; TupleTableSlot *innerTupleSlot; - int nbatch; - int curbatch; - File *outerbatches; - RelativeAddr *outerbatchNames; - RelativeAddr *outerbatchPos; - Var *innerhashkey; - int batch; - int batchno; - char *buffer; - int i; - bool hashPhaseDone; - char *pos; + int nbatch; + int curbatch; + File *outerbatches; + RelativeAddr *outerbatchNames; + RelativeAddr *outerbatchPos; + Var *innerhashkey; + int batch; + int batchno; + char *buffer; + int i; + bool hashPhaseDone; + char *pos; /* ---------------- * get information from HashJoin node @@ -125,7 +125,7 @@ ExecHashJoin(HashJoin * node) if (hjstate->jstate.cs_TupFromTlist) { TupleTableSlot *result; - bool isDone; + bool isDone; result = ExecProject(hjstate->jstate.cs_ProjInfo, &isDone); if (!isDone) @@ -322,7 +322,7 @@ ExecHashJoin(HashJoin * node) { ProjectionInfo *projInfo; TupleTableSlot *result; - bool isDone; + bool isDone; hjstate->hj_CurBucket = bucket; hjstate->hj_CurTuple = curtuple; @@ -394,9 +394,9 @@ ExecHashJoin(HashJoin * node) bool /* return: initialization status */ ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent) { - HashJoinState *hjstate; - Plan *outerNode; - Hash *hashNode; + HashJoinState *hjstate; + Plan *outerNode; + Hash *hashNode; /* ---------------- * assign the node's execution state @@ -451,7 +451,7 @@ ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent) * ---------------- */ { - HashState *hashstate = hashNode->hashstate; + HashState *hashstate = hashNode->hashstate; TupleTableSlot *slot = hashstate->cstate.cs_ResultTupleSlot; @@ -513,7 +513,7 @@ ExecCountSlotsHashJoin(HashJoin * node) void ExecEndHashJoin(HashJoin * node) { - HashJoinState *hjstate; + HashJoinState *hjstate; /* ---------------- * get info from the HashJoin state @@ -572,13 +572,13 @@ static TupleTableSlot * ExecHashJoinOuterGetTuple(Plan * node, Plan * parent, HashJoinState * hjstate) { TupleTableSlot *slot; - HashJoinTable hashtable; - int curbatch; - File *outerbatches; - char *outerreadPos; - int batchno; - char *outerreadBuf; - int outerreadBlk; + HashJoinTable hashtable; + int curbatch; + File *outerbatches; + char *outerreadPos; + int batchno; + char *outerreadBuf; + int outerreadBlk; hashtable = hjstate->hj_HashTable; curbatch = hashtable->curbatch; @@ -626,11 +626,11 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate, int *block, /* return parameter */ char **position) /* return parameter */ { - char *bufstart; - char *bufend; - int cc; - HeapTuple heapTuple; - HashJoinTable hashtable; + char *bufstart; + char *bufend; + int cc; + HeapTuple heapTuple; + HashJoinTable hashtable; hashtable = hjstate->hj_HashTable; bufend = buffer + *(long *) buffer; @@ -666,20 +666,20 @@ ExecHashJoinGetSavedTuple(HashJoinState * hjstate, static int ExecHashJoinNewBatch(HashJoinState * hjstate) { - File *innerBatches; - File *outerBatches; - int *innerBatchSizes; - Var *innerhashkey; - HashJoinTable hashtable; - int nbatch; - char *readPos; - int readBlk; - char *readBuf; + File *innerBatches; + File *outerBatches; + int *innerBatchSizes; + Var *innerhashkey; + HashJoinTable hashtable; + int nbatch; + char *readPos; + int readBlk; + char *readBuf; TupleTableSlot *slot; - ExprContext *econtext; - int i; - int cc; - int newbatch; + ExprContext *econtext; + int i; + int cc; + int newbatch; hashtable = hjstate->hj_HashTable; outerBatches = hjstate->hj_OuterBatches; @@ -793,7 +793,7 @@ ExecHashJoinNewBatch(HashJoinState * hjstate) static int ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch) { - int b; + int b; if (bucketno < hashtable->nbuckets || nbatch == 0) return 0; @@ -813,16 +813,16 @@ ExecHashJoinGetBatch(int bucketno, HashJoinTable hashtable, int nbatch) * ---------------------------------------------------------------- */ -char * +char * ExecHashJoinSaveTuple(HeapTuple heapTuple, char *buffer, File file, char *position) { - long *pageend; - char *pagestart; - char *pagebound; - int cc; + long *pageend; + char *pagestart; + char *pagebound; + int cc; pageend = (long *) buffer; pagestart = (char *) (buffer + sizeof(long)); diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index c89a4fcb081..61fca80a0cf 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.8 1997/09/07 04:41:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.9 1997/09/08 02:22:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -82,19 +82,19 @@ static TupleTableSlot *IndexNext(IndexScan * node); static TupleTableSlot * IndexNext(IndexScan * node) { - EState *estate; + EState *estate; CommonScanState *scanstate; IndexScanState *indexstate; - ScanDirection direction; - int indexPtr; + ScanDirection direction; + int indexPtr; IndexScanDescPtr scanDescs; - IndexScanDesc scandesc; - Relation heapRelation; + IndexScanDesc scandesc; + Relation heapRelation; RetrieveIndexResult result; - ItemPointer iptr; - HeapTuple tuple; + ItemPointer iptr; + HeapTuple tuple; TupleTableSlot *slot; - Buffer buffer = InvalidBuffer; + Buffer buffer = InvalidBuffer; /* ---------------- * extract necessary information from index scan node @@ -219,30 +219,30 @@ ExecIndexScan(IndexScan * node) void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent) { - EState *estate; + EState *estate; IndexScanState *indexstate; - ScanDirection direction; + ScanDirection direction; IndexScanDescPtr scanDescs; - ScanKey *scanKeys; - IndexScanDesc sdesc; - ScanKey skey; - int numIndices; - int i; - - Pointer *runtimeKeyInfo; - int indexPtr; - int *numScanKeys; - List *indxqual; - List *qual; - int n_keys; - ScanKey scan_keys; - int *run_keys; - int j; - Expr *clause; - Node *scanexpr; - Datum scanvalue; - bool isNull; - bool isDone; + ScanKey *scanKeys; + IndexScanDesc sdesc; + ScanKey skey; + int numIndices; + int i; + + Pointer *runtimeKeyInfo; + int indexPtr; + int *numScanKeys; + List *indxqual; + List *qual; + int n_keys; + ScanKey scan_keys; + int *run_keys; + int j; + Expr *clause; + Node *scanexpr; + Datum scanvalue; + bool isNull; + bool isDone; indexstate = node->indxstate; estate = node->scan.plan.state; @@ -335,9 +335,9 @@ ExecEndIndexScan(IndexScan * node) { CommonScanState *scanstate; IndexScanState *indexstate; - ScanKey *scanKeys; - int numIndices; - int i; + ScanKey *scanKeys; + int numIndices; + int i; scanstate = node->scan.scanstate; indexstate = node->indxstate; @@ -399,8 +399,8 @@ ExecIndexMarkPos(IndexScan * node) { IndexScanState *indexstate; IndexScanDescPtr indexScanDescs; - IndexScanDesc scanDesc; - int indexPtr; + IndexScanDesc scanDesc; + int indexPtr; indexstate = node->indxstate; indexPtr = indexstate->iss_IndexPtr; @@ -430,8 +430,8 @@ ExecIndexRestrPos(IndexScan * node) { IndexScanState *indexstate; IndexScanDescPtr indexScanDescs; - IndexScanDesc scanDesc; - int indexPtr; + IndexScanDesc scanDesc; + int indexPtr; indexstate = node->indxstate; indexPtr = indexstate->iss_IndexPtr; @@ -465,27 +465,27 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) { IndexScanState *indexstate; CommonScanState *scanstate; - List *indxqual; - List *indxid; - int i; - int numIndices; - int indexPtr; - ScanKey *scanKeys; - int *numScanKeys; - RelationPtr relationDescs; + List *indxqual; + List *indxid; + int i; + int numIndices; + int indexPtr; + ScanKey *scanKeys; + int *numScanKeys; + RelationPtr relationDescs; IndexScanDescPtr scanDescs; - Pointer *runtimeKeyInfo; - bool have_runtime_keys; - List *rangeTable; - RangeTblEntry *rtentry; - Index relid; - Oid reloid; - TimeQual timeQual; - - Relation currentRelation; - HeapScanDesc currentScanDesc; - ScanDirection direction; - int baseid; + Pointer *runtimeKeyInfo; + bool have_runtime_keys; + List *rangeTable; + RangeTblEntry *rtentry; + Index relid; + Oid reloid; + TimeQual timeQual; + + Relation currentRelation; + HeapScanDesc currentScanDesc; + ScanDirection direction; + int baseid; /* ---------------- * assign execution state to node @@ -600,11 +600,11 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (i = 0; i < numIndices; i++) { - int j; - List *qual; - int n_keys; - ScanKey scan_keys; - int *run_keys; + int j; + List *qual; + int n_keys; + ScanKey scan_keys; + int *run_keys; qual = nth(i, indxqual); n_keys = length(qual); @@ -623,17 +623,16 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (j = 0; j < n_keys; j++) { - Expr *clause; /* one part of index qual */ - Oper *op; /* operator used in scan.. */ - Node *leftop; /* expr on lhs of operator */ - Node *rightop; /* expr on rhs ... */ - bits16 flags = 0; - - int scanvar; /* which var identifies varattno */ - AttrNumber varattno = 0; /* att number used in scan */ - Oid opid; /* operator id used in scan */ - Datum scanvalue = 0; /* value used in scan (if - * const) */ + Expr *clause; /* one part of index qual */ + Oper *op; /* operator used in scan.. */ + Node *leftop; /* expr on lhs of operator */ + Node *rightop;/* expr on rhs ... */ + bits16 flags = 0; + + int scanvar;/* which var identifies varattno */ + AttrNumber varattno = 0; /* att number used in scan */ + Oid opid; /* operator id used in scan */ + Datum scanvalue = 0; /* value used in scan (if const) */ /* ---------------- * extract clause information from the qualification @@ -702,7 +701,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) } else if (IsA(leftop, Param)) { - bool isnull; + bool isnull; /* ---------------- * if the leftop is a Param node then it means @@ -785,7 +784,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) } else if (IsA(rightop, Param)) { - bool isnull; + bool isnull; /* ---------------- * if the rightop is a Param node then it means @@ -885,8 +884,8 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) indexstate->iss_RuntimeKeyInfo = NULL; for (i = 0; i < numIndices; i++) { - List *qual; - int n_keys; + List *qual; + int n_keys; qual = nth(i, indxqual); n_keys = length(qual); @@ -947,7 +946,7 @@ ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent) */ for (i = 0; i < numIndices; i++) { - Oid indexOid; + Oid indexOid; indexOid = (Oid) nthi(i, indxid); diff --git a/src/backend/executor/nodeMaterial.c b/src/backend/executor/nodeMaterial.c index 49ba73d3bf0..6ff8598901e 100644 --- a/src/backend/executor/nodeMaterial.c +++ b/src/backend/executor/nodeMaterial.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.7 1997/09/07 04:41:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMaterial.c,v 1.8 1997/09/08 02:22:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,16 +50,16 @@ TupleTableSlot * /* result tuple from subplan */ ExecMaterial(Material * node) { - EState *estate; - MaterialState *matstate; - Plan *outerNode; - ScanDirection dir; - Relation tempRelation; - Relation currentRelation; - HeapScanDesc currentScanDesc; - HeapTuple heapTuple; + EState *estate; + MaterialState *matstate; + Plan *outerNode; + ScanDirection dir; + Relation tempRelation; + Relation currentRelation; + HeapScanDesc currentScanDesc; + HeapTuple heapTuple; TupleTableSlot *slot; - Buffer buffer; + Buffer buffer; /* ---------------- * get state info from node @@ -190,10 +190,10 @@ ExecMaterial(Material * node) bool /* initialization status */ ExecInitMaterial(Material * node, EState * estate, Plan * parent) { - MaterialState *matstate; - Plan *outerPlan; - TupleDesc tupType; - Relation tempDesc; + MaterialState *matstate; + Plan *outerPlan; + TupleDesc tupType; + Relation tempDesc; /* int len; */ @@ -308,9 +308,9 @@ ExecCountSlotsMaterial(Material * node) void ExecEndMaterial(Material * node) { - MaterialState *matstate; - Relation tempRelation; - Plan *outerPlan; + MaterialState *matstate; + Relation tempRelation; + Plan *outerPlan; /* ---------------- * get info from the material state @@ -349,8 +349,8 @@ ExecEndMaterial(Material * node) List /* nothing of interest */ ExecMaterialMarkPos(Material node) { - MaterialState matstate; - HeapScanDesc sdesc; + MaterialState matstate; + HeapScanDesc sdesc; /* ---------------- * if we haven't materialized yet, just return NIL. @@ -379,8 +379,8 @@ ExecMaterialMarkPos(Material node) void ExecMaterialRestrPos(Material node) { - MaterialState matstate; - HeapScanDesc sdesc; + MaterialState matstate; + HeapScanDesc sdesc; /* ---------------- * if we haven't materialized yet, just return. diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 348d3fa1e00..621cfcea901 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.9 1997/09/07 04:41:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.10 1997/09/08 02:22:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ #include "utils/lsyscache.h" #include "utils/psort.h" -static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext); +static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext); /* ---------------------------------------------------------------- * MarkInnerTuple and RestoreInnerTuple macros @@ -142,13 +142,13 @@ static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econt * by "sortOp". * ---------------------------------------------------------------- */ -static List * +static List * MJFormOSortopI(List * qualList, Oid sortOp) { - List *qualCopy; - List *qualcdr; - Expr *qual; - Oper *op; + List *qualCopy; + List *qualcdr; + Expr *qual; + Oper *op; /* ---------------- * qualList is a list: ((op .. ..) ...) @@ -206,11 +206,11 @@ MJFormOSortopI(List * qualList, Oid sortOp) * by "sortOp" and reversing the positions of the keys. * ---------------------------------------------------------------- */ -static List * +static List * MJFormISortopO(List * qualList, Oid sortOp) { - List *ISortopO; - List *qualcdr; + List *ISortopO; + List *qualcdr; /* ---------------- * first generate OSortopI, a list of the form @@ -226,9 +226,9 @@ MJFormISortopO(List * qualList, Oid sortOp) */ foreach(qualcdr, ISortopO) { - Expr *qual; - List *inner; - List *outer; + Expr *qual; + List *inner; + List *outer; qual = lfirst(qualcdr); @@ -257,14 +257,14 @@ MJFormISortopO(List * qualList, Oid sortOp) * if (key1i > key2i) is true and (key1j = key2j) for 0 < j < i. * ---------------------------------------------------------------- */ -static bool +static bool MergeCompare(List * eqQual, List * compareQual, ExprContext * econtext) { - List *clause; - List *eqclause; - Datum const_value; - bool isNull; - bool isDone; + List *clause; + List *eqclause; + Datum const_value; + bool isNull; + bool isDone; /* ---------------- * if we have no compare qualification, return nil @@ -394,7 +394,7 @@ CleanUpSort(Plan * plan) if (plan->type == T_Sort) { - Sort *sort = (Sort *) plan; + Sort *sort = (Sort *) plan; psort_end(sort); } @@ -451,25 +451,25 @@ CleanUpSort(Plan * plan) TupleTableSlot * ExecMergeJoin(MergeJoin * node) { - EState *estate; + EState *estate; MergeJoinState *mergestate; - ScanDirection direction; - List *innerSkipQual; - List *outerSkipQual; - List *mergeclauses; - List *qual; - bool qualResult; - bool compareResult; - - Plan *innerPlan; + ScanDirection direction; + List *innerSkipQual; + List *outerSkipQual; + List *mergeclauses; + List *qual; + bool qualResult; + bool compareResult; + + Plan *innerPlan; TupleTableSlot *innerTupleSlot; - Plan *outerPlan; + Plan *outerPlan; TupleTableSlot *outerTupleSlot; TupleTableSlot *markedTupleSlot; - ExprContext *econtext; + ExprContext *econtext; /* ---------------- * get information from node @@ -503,7 +503,7 @@ ExecMergeJoin(MergeJoin * node) { TupleTableSlot *result; ProjectionInfo *projInfo; - bool isDone; + bool isDone; projInfo = mergestate->jstate.cs_ProjInfo; result = ExecProject(projInfo, &isDone); @@ -523,349 +523,185 @@ ExecMergeJoin(MergeJoin * node) switch (mergestate->mj_JoinState) { - /* - * ******************************** EXEC_MJ_INITIALIZE means - * that this is the first time ExecMergeJoin() has been called - * and so we have to initialize the inner, outer and marked - * tuples as well as various stuff in the expression context. ******************************** - * - */ - case EXEC_MJ_INITIALIZE: - MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n"); - /* ---------------- - * Note: at this point, if either of our inner or outer - * tuples are nil, then the join ends immediately because - * we know one of the subplans is empty. - * ---------------- - */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - if (TupIsNull(innerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** inner tuple is nil ****\n"); - return NULL; - } + /* + * ******************************** EXEC_MJ_INITIALIZE + * means that this is the first time ExecMergeJoin() has + * been called and so we have to initialize the inner, + * outer and marked tuples as well as various stuff in the + * expression context. ******************************** + * + */ + case EXEC_MJ_INITIALIZE: + MJ_printf("ExecMergeJoin: EXEC_MJ_INITIALIZE\n"); + /* ---------------- + * Note: at this point, if either of our inner or outer + * tuples are nil, then the join ends immediately because + * we know one of the subplans is empty. + * ---------------- + */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + if (TupIsNull(innerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** inner tuple is nil ****\n"); + return NULL; + } - outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); - if (TupIsNull(outerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); - return NULL; - } - - /* ---------------- - * store the inner and outer tuple in the merge state - * ---------------- - */ - econtext->ecxt_innertuple = innerTupleSlot; - econtext->ecxt_outertuple = outerTupleSlot; - - /* ---------------- - * set the marked tuple to nil - * and initialize its tuple descriptor atttributes. - * -jeff 10 july 1991 - * ---------------- - */ - ExecClearTuple(mergestate->mj_MarkedTupleSlot); - mergestate->mj_MarkedTupleSlot->ttc_tupleDescriptor = - innerTupleSlot->ttc_tupleDescriptor; + outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); + if (TupIsNull(outerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); + return NULL; + } + + /* ---------------- + * store the inner and outer tuple in the merge state + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + econtext->ecxt_outertuple = outerTupleSlot; + + /* ---------------- + * set the marked tuple to nil + * and initialize its tuple descriptor atttributes. + * -jeff 10 july 1991 + * ---------------- + */ + ExecClearTuple(mergestate->mj_MarkedTupleSlot); + mergestate->mj_MarkedTupleSlot->ttc_tupleDescriptor = + innerTupleSlot->ttc_tupleDescriptor; /* mergestate->mj_MarkedTupleSlot->ttc_execTupDescriptor = innerTupleSlot->ttc_execTupDescriptor; */ - /* ---------------- - * initialize merge join state to skip inner tuples. - * ---------------- - */ - mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; - break; - - /* - * ******************************** EXEC_MJ_JOINMARK means we - * have just found a new outer tuple and a possible matching - * inner tuple. This is the case after the INITIALIZE, - * SKIPOUTER or SKIPINNER states. ******************************** - * - */ - case EXEC_MJ_JOINMARK: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n"); - ExecMarkPos(innerPlan); - - innerTupleSlot = econtext->ecxt_innertuple; - MarkInnerTuple(innerTupleSlot, mergestate); - - mergestate->mj_JoinState = EXEC_MJ_JOINTEST; - break; - - /* - * ******************************** EXEC_MJ_JOINTEST means we - * have two tuples which might satisify the merge clause, so - * we test them. - * - * If they do satisify, then we join them and move on to the next - * inner tuple (EXEC_MJ_JOINTUPLES). - * - * If they do not satisify then advance to next outer tuple. ******************************** - * - */ - case EXEC_MJ_JOINTEST: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n"); - - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; - } - break; - - /* - * ******************************** EXEC_MJ_JOINTUPLES means - * we have two tuples which satisified the merge clause so we - * join them and then proceed to get the next inner tuple - * (EXEC_NEXT_INNER). ******************************** - * - */ - case EXEC_MJ_JOINTUPLES: - MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); - mergestate->mj_JoinState = EXEC_MJ_NEXTINNER; - - qualResult = ExecQual((List *) qual, econtext); - MJ_DEBUG_QUAL(qual, qualResult); - - if (qualResult) - { /* ---------------- - * qualification succeeded. now form the desired - * projection tuple and return the slot containing it. + * initialize merge join state to skip inner tuples. * ---------------- */ - ProjectionInfo *projInfo; - TupleTableSlot *result; - bool isDone; - - MJ_printf("ExecMergeJoin: **** returning tuple ****\n"); - - projInfo = mergestate->jstate.cs_ProjInfo; - - result = ExecProject(projInfo, &isDone); - mergestate->jstate.cs_TupFromTlist = !isDone; - return result; - } - break; - - /* - * ******************************** EXEC_MJ_NEXTINNER means - * advance the inner scan to the next tuple. If the tuple is - * not nil, we then proceed to test it against the join - * qualification. ******************************** - * - */ - case EXEC_MJ_NEXTINNER: - MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n"); - - /* ---------------- - * now we get the next inner tuple, if any - * ---------------- - */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(innerTupleSlot); - econtext->ecxt_innertuple = innerTupleSlot; - - if (TupIsNull(innerTupleSlot)) - { - mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINTEST; - } - break; - - /* - * ******************************** EXEC_MJ_NEXTOUTER means - * - * outer inner outer tuple - 5 5 - marked tuple 5 5 6 - * 6 - inner tuple 7 7 - * - * we know we just bumped into the first inner tuple > current - * outer tuple so get a new outer tuple and then proceed to - * test it against the marked tuple (EXEC_MJ_TESTOUTER) ******************************** - * - */ - case EXEC_MJ_NEXTOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n"); - - outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(outerTupleSlot); - econtext->ecxt_outertuple = outerTupleSlot; - - /* ---------------- - * if the outer tuple is null then we know - * we are done with the join - * ---------------- - */ - if (TupIsNull(outerTupleSlot)) - { - MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); - CleanUpSort(node->join.lefttree->lefttree); - CleanUpSort(node->join.righttree->lefttree); - return NULL; - } - - mergestate->mj_JoinState = EXEC_MJ_TESTOUTER; - break; - - /* - * ******************************** EXEC_MJ_TESTOUTER If the - * new outer tuple and the marked tuple satisify the merge - * clause then we know we have duplicates in the outer scan so - * we have to restore the inner scan to the marked tuple and - * proceed to join the new outer tuples with the inner tuples - * (EXEC_MJ_JOINTEST) - * - * This is the case when - * - * outer inner 4 5 - marked tuple outer tuple - 5 5 new - * outer tuple - 5 5 6 8 - inner tuple 7 12 - * - * new outer tuple = marked tuple - * - * If the outer tuple fails the test, then we know we have to - * proceed to skip outer tuples until outer >= inner - * (EXEC_MJ_SKIPOUTER). - * - * This is the case when - * - * outer inner 5 5 - marked tuple outer tuple - 5 5 new - * outer tuple - 6 8 - inner tuple 7 12 - * - * new outer tuple > marked tuple - * - ******************************** - * - */ - case EXEC_MJ_TESTOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n"); - - /* ---------------- - * here we compare the outer tuple with the marked inner tuple - * by using the marked tuple in place of the inner tuple. - * ---------------- - */ - innerTupleSlot = econtext->ecxt_innertuple; - markedTupleSlot = mergestate->mj_MarkedTupleSlot; - econtext->ecxt_innertuple = markedTupleSlot; - - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - /* ---------------- - * the merge clause matched so now we juggle the slots - * back the way they were and proceed to JOINTEST. - * ---------------- + mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; + break; + + /* + * ******************************** EXEC_MJ_JOINMARK means + * we have just found a new outer tuple and a possible + * matching inner tuple. This is the case after the + * INITIALIZE, SKIPOUTER or SKIPINNER states. ******************************** + * */ - econtext->ecxt_innertuple = innerTupleSlot; + case EXEC_MJ_JOINMARK: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINMARK\n"); + ExecMarkPos(innerPlan); - RestoreInnerTuple(innerTupleSlot, markedTupleSlot); + innerTupleSlot = econtext->ecxt_innertuple; + MarkInnerTuple(innerTupleSlot, mergestate); - ExecRestrPos(innerPlan); mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + break; - } - else - { - /* ---------------- - * if the inner tuple was nil and the new outer - * tuple didn't match the marked outer tuple then - * we may have the case: + /* + * ******************************** EXEC_MJ_JOINTEST means + * we have two tuples which might satisify the merge + * clause, so we test them. * - * outer inner - * 4 4 - marked tuple - * new outer - 5 4 - * 6 nil - inner tuple - * 7 + * If they do satisify, then we join them and move on to the + * next inner tuple (EXEC_MJ_JOINTUPLES). + * + * If they do not satisify then advance to next outer tuple. ******************************** * - * which means that all subsequent outer tuples will be - * larger than our inner tuples. - * ---------------- */ - if (TupIsNull(innerTupleSlot)) + case EXEC_MJ_JOINTEST: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTEST\n"); + + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) { - MJ_printf("ExecMergeJoin: **** wierd case 1 ****\n"); - return NULL; + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; + } + break; + + /* + * ******************************** EXEC_MJ_JOINTUPLES + * means we have two tuples which satisified the merge + * clause so we join them and then proceed to get the next + * inner tuple (EXEC_NEXT_INNER). ******************************** + * + */ + case EXEC_MJ_JOINTUPLES: + MJ_printf("ExecMergeJoin: EXEC_MJ_JOINTUPLES\n"); + mergestate->mj_JoinState = EXEC_MJ_NEXTINNER; + + qualResult = ExecQual((List *) qual, econtext); + MJ_DEBUG_QUAL(qual, qualResult); + + if (qualResult) + { + /* ---------------- + * qualification succeeded. now form the desired + * projection tuple and return the slot containing it. + * ---------------- + */ + ProjectionInfo *projInfo; + TupleTableSlot *result; + bool isDone; + + MJ_printf("ExecMergeJoin: **** returning tuple ****\n"); + + projInfo = mergestate->jstate.cs_ProjInfo; + + result = ExecProject(projInfo, &isDone); + mergestate->jstate.cs_TupFromTlist = !isDone; + return result; } + break; + + /* + * ******************************** EXEC_MJ_NEXTINNER + * means advance the inner scan to the next tuple. If the + * tuple is not nil, we then proceed to test it against + * the join qualification. ******************************** + * + */ + case EXEC_MJ_NEXTINNER: + MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTINNER\n"); /* ---------------- - * restore the inner tuple and continue on to - * skip outer tuples. + * now we get the next inner tuple, if any * ---------------- */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(innerTupleSlot); econtext->ecxt_innertuple = innerTupleSlot; - mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; - } - break; - - /* - * ******************************** EXEC_MJ_SKIPOUTER means - * skip over tuples in the outer plan until we find an outer - * tuple > current inner tuple. - * - * For example: - * - * outer inner 5 5 5 5 outer tuple - 6 8 - inner - * tuple 7 12 8 14 - * - * we have to advance the outer scan until we find the outer 8. - * - ******************************** - * - */ - case EXEC_MJ_SKIPOUTER: - MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n"); - /* ---------------- - * before we advance, make sure the current tuples - * do not satisify the mergeclauses. If they do, then - * we update the marked tuple and go join them. - * ---------------- - */ - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - ExecMarkPos(innerPlan); - innerTupleSlot = econtext->ecxt_innertuple; - MarkInnerTuple(innerTupleSlot, mergestate); - - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + if (TupIsNull(innerTupleSlot)) + { + mergestate->mj_JoinState = EXEC_MJ_NEXTOUTER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + } break; - } - - /* ---------------- - * ok, now test the skip qualification - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - outerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); - - /* ---------------- - * compareResult is true as long as we should - * continue skipping tuples. - * ---------------- - */ - if (compareResult) - { + + /* + * ******************************** EXEC_MJ_NEXTOUTER + * means + * + * outer inner outer tuple - 5 5 - marked tuple 5 5 + * 6 6 - inner tuple 7 7 + * + * we know we just bumped into the first inner tuple > + * current outer tuple so get a new outer tuple and then + * proceed to test it against the marked tuple + * (EXEC_MJ_TESTOUTER) ******************************** + * + */ + case EXEC_MJ_NEXTOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_NEXTOUTER\n"); outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); MJ_DEBUG_PROC_NODE(outerTupleSlot); @@ -878,169 +714,342 @@ ExecMergeJoin(MergeJoin * node) */ if (TupIsNull(outerTupleSlot)) { - MJ_printf("ExecMergeJoin: **** outerTuple is nil ****\n"); + MJ_printf("ExecMergeJoin: **** outer tuple is nil ****\n"); + CleanUpSort(node->join.lefttree->lefttree); + CleanUpSort(node->join.righttree->lefttree); return NULL; } + + mergestate->mj_JoinState = EXEC_MJ_TESTOUTER; + break; + + /* + * ******************************** EXEC_MJ_TESTOUTER If + * the new outer tuple and the marked tuple satisify the + * merge clause then we know we have duplicates in the + * outer scan so we have to restore the inner scan to the + * marked tuple and proceed to join the new outer tuples + * with the inner tuples (EXEC_MJ_JOINTEST) + * + * This is the case when + * + * outer inner 4 5 - marked tuple outer tuple - 5 5 + * new outer tuple - 5 5 6 8 - inner tuple 7 + * 12 + * + * new outer tuple = marked tuple + * + * If the outer tuple fails the test, then we know we have to + * proceed to skip outer tuples until outer >= inner + * (EXEC_MJ_SKIPOUTER). + * + * This is the case when + * + * outer inner 5 5 - marked tuple outer tuple - 5 5 + * new outer tuple - 6 8 - inner tuple 7 12 + * + * new outer tuple > marked tuple + * + ******************************* + * + * + */ + case EXEC_MJ_TESTOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_TESTOUTER\n"); + /* ---------------- - * otherwise test the new tuple against the skip qual. - * (we remain in the EXEC_MJ_SKIPOUTER state) + * here we compare the outer tuple with the marked inner tuple + * by using the marked tuple in place of the inner tuple. * ---------------- */ - break; - } - - /* ---------------- - * now check the inner skip qual to see if we - * should now skip inner tuples... if we fail the - * inner skip qual, then we know we have a new pair - * of matching tuples. - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - innerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); - - if (compareResult) - { - mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINMARK; - } - break; - - /* - * ******************************** EXEC_MJ_SKIPINNER means - * skip over tuples in the inner plan until we find an inner - * tuple > current outer tuple. - * - * For example: - * - * outer inner 5 5 5 5 outer tuple - 12 8 - inner - * tuple 14 10 17 12 - * - * we have to advance the inner scan until we find the inner 12. - * - ******************************** - * - */ - case EXEC_MJ_SKIPINNER: - MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n"); - /* ---------------- - * before we advance, make sure the current tuples - * do not satisify the mergeclauses. If they do, then - * we update the marked tuple and go join them. - * ---------------- - */ - qualResult = ExecQual((List *) mergeclauses, econtext); - MJ_DEBUG_QUAL(mergeclauses, qualResult); - - if (qualResult) - { - ExecMarkPos(innerPlan); innerTupleSlot = econtext->ecxt_innertuple; + markedTupleSlot = mergestate->mj_MarkedTupleSlot; + econtext->ecxt_innertuple = markedTupleSlot; - MarkInnerTuple(innerTupleSlot, mergestate); + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + /* ---------------- + * the merge clause matched so now we juggle the slots + * back the way they were and proceed to JOINTEST. + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + + RestoreInnerTuple(innerTupleSlot, markedTupleSlot); - mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + ExecRestrPos(innerPlan); + mergestate->mj_JoinState = EXEC_MJ_JOINTEST; + + } + else + { + /* ---------------- + * if the inner tuple was nil and the new outer + * tuple didn't match the marked outer tuple then + * we may have the case: + * + * outer inner + * 4 4 - marked tuple + * new outer - 5 4 + * 6 nil - inner tuple + * 7 + * + * which means that all subsequent outer tuples will be + * larger than our inner tuples. + * ---------------- + */ + if (TupIsNull(innerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** wierd case 1 ****\n"); + return NULL; + } + + /* ---------------- + * restore the inner tuple and continue on to + * skip outer tuples. + * ---------------- + */ + econtext->ecxt_innertuple = innerTupleSlot; + mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; + } break; - } - - /* ---------------- - * ok, now test the skip qualification - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - innerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); - - /* ---------------- - * compareResult is true as long as we should - * continue skipping tuples. - * ---------------- - */ - if (compareResult) - { + + /* + * ******************************** EXEC_MJ_SKIPOUTER + * means skip over tuples in the outer plan until we find + * an outer tuple > current inner tuple. + * + * For example: + * + * outer inner 5 5 5 5 outer tuple - 6 8 - + * inner tuple 7 12 8 14 + * + * we have to advance the outer scan until we find the outer + * 8. + * + ******************************* + * + * + */ + case EXEC_MJ_SKIPOUTER: + MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPOUTER\n"); /* ---------------- - * now try and get a new inner tuple + * before we advance, make sure the current tuples + * do not satisify the mergeclauses. If they do, then + * we update the marked tuple and go join them. * ---------------- */ - innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); - MJ_DEBUG_PROC_NODE(innerTupleSlot); - econtext->ecxt_innertuple = innerTupleSlot; + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + ExecMarkPos(innerPlan); + innerTupleSlot = econtext->ecxt_innertuple; + + MarkInnerTuple(innerTupleSlot, mergestate); + + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + break; + } /* ---------------- - * if the inner tuple is null then we know - * we have to restore the inner scan - * and advance to the next outer tuple + * ok, now test the skip qualification * ---------------- */ - if (TupIsNull(innerTupleSlot)) + compareResult = MergeCompare(mergeclauses, + outerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); + + /* ---------------- + * compareResult is true as long as we should + * continue skipping tuples. + * ---------------- + */ + if (compareResult) { + + outerTupleSlot = ExecProcNode(outerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(outerTupleSlot); + econtext->ecxt_outertuple = outerTupleSlot; + /* ---------------- - * this is an interesting case.. all our - * inner tuples are smaller then our outer - * tuples so we never found an inner tuple - * to mark. - * - * outer inner - * outer tuple - 5 4 - * 5 4 - * 6 nil - inner tuple - * 7 - * - * This means the join should end. + * if the outer tuple is null then we know + * we are done with the join * ---------------- */ - MJ_printf("ExecMergeJoin: **** wierd case 2 ****\n"); - return NULL; + if (TupIsNull(outerTupleSlot)) + { + MJ_printf("ExecMergeJoin: **** outerTuple is nil ****\n"); + return NULL; + } + /* ---------------- + * otherwise test the new tuple against the skip qual. + * (we remain in the EXEC_MJ_SKIPOUTER state) + * ---------------- + */ + break; } /* ---------------- - * otherwise test the new tuple against the skip qual. - * (we remain in the EXEC_MJ_SKIPINNER state) + * now check the inner skip qual to see if we + * should now skip inner tuples... if we fail the + * inner skip qual, then we know we have a new pair + * of matching tuples. * ---------------- */ + compareResult = MergeCompare(mergeclauses, + innerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); + + if (compareResult) + { + mergestate->mj_JoinState = EXEC_MJ_SKIPINNER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINMARK; + } break; - } - - /* ---------------- - * compare finally failed and we have stopped skipping - * inner tuples so now check the outer skip qual - * to see if we should now skip outer tuples... - * ---------------- - */ - compareResult = MergeCompare(mergeclauses, - outerSkipQual, - econtext); - - MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); - - if (compareResult) - { - mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; - } - else - { - mergestate->mj_JoinState = EXEC_MJ_JOINMARK; - } - - break; - - /* - * ******************************** if we get here it means - * our code is fucked up and so we just end the join - * prematurely. ******************************** - * - */ - default: - elog(NOTICE, "ExecMergeJoin: invalid join state. aborting"); - return NULL; + + /* + * ******************************** EXEC_MJ_SKIPINNER + * means skip over tuples in the inner plan until we find + * an inner tuple > current outer tuple. + * + * For example: + * + * outer inner 5 5 5 5 outer tuple - 12 8 - inner + * tuple 14 10 17 12 + * + * we have to advance the inner scan until we find the inner + * 12. + * + ******************************* + * + * + */ + case EXEC_MJ_SKIPINNER: + MJ_printf("ExecMergeJoin: EXEC_MJ_SKIPINNER\n"); + /* ---------------- + * before we advance, make sure the current tuples + * do not satisify the mergeclauses. If they do, then + * we update the marked tuple and go join them. + * ---------------- + */ + qualResult = ExecQual((List *) mergeclauses, econtext); + MJ_DEBUG_QUAL(mergeclauses, qualResult); + + if (qualResult) + { + ExecMarkPos(innerPlan); + innerTupleSlot = econtext->ecxt_innertuple; + + MarkInnerTuple(innerTupleSlot, mergestate); + + mergestate->mj_JoinState = EXEC_MJ_JOINTUPLES; + break; + } + + /* ---------------- + * ok, now test the skip qualification + * ---------------- + */ + compareResult = MergeCompare(mergeclauses, + innerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(innerSkipQual, compareResult); + + /* ---------------- + * compareResult is true as long as we should + * continue skipping tuples. + * ---------------- + */ + if (compareResult) + { + /* ---------------- + * now try and get a new inner tuple + * ---------------- + */ + innerTupleSlot = ExecProcNode(innerPlan, (Plan *) node); + MJ_DEBUG_PROC_NODE(innerTupleSlot); + econtext->ecxt_innertuple = innerTupleSlot; + + /* ---------------- + * if the inner tuple is null then we know + * we have to restore the inner scan + * and advance to the next outer tuple + * ---------------- + */ + if (TupIsNull(innerTupleSlot)) + { + /* ---------------- + * this is an interesting case.. all our + * inner tuples are smaller then our outer + * tuples so we never found an inner tuple + * to mark. + * + * outer inner + * outer tuple - 5 4 + * 5 4 + * 6 nil - inner tuple + * 7 + * + * This means the join should end. + * ---------------- + */ + MJ_printf("ExecMergeJoin: **** wierd case 2 ****\n"); + return NULL; + } + + /* ---------------- + * otherwise test the new tuple against the skip qual. + * (we remain in the EXEC_MJ_SKIPINNER state) + * ---------------- + */ + break; + } + + /* ---------------- + * compare finally failed and we have stopped skipping + * inner tuples so now check the outer skip qual + * to see if we should now skip outer tuples... + * ---------------- + */ + compareResult = MergeCompare(mergeclauses, + outerSkipQual, + econtext); + + MJ_DEBUG_MERGE_COMPARE(outerSkipQual, compareResult); + + if (compareResult) + { + mergestate->mj_JoinState = EXEC_MJ_SKIPOUTER; + } + else + { + mergestate->mj_JoinState = EXEC_MJ_JOINMARK; + } + + break; + + /* + * ******************************** if we get here it + * means our code is fucked up and so we just end the join + * prematurely. ******************************** + * + */ + default: + elog(NOTICE, "ExecMergeJoin: invalid join state. aborting"); + return NULL; } } } @@ -1057,13 +1066,13 @@ bool ExecInitMergeJoin(MergeJoin * node, EState * estate, Plan * parent) { MergeJoinState *mergestate; - List *joinclauses; - RegProcedure rightsortop; - RegProcedure leftsortop; - RegProcedure sortop; + List *joinclauses; + RegProcedure rightsortop; + RegProcedure leftsortop; + RegProcedure sortop; - List *OSortopI; - List *ISortopO; + List *OSortopI; + List *ISortopO; MJ1_printf("ExecInitMergeJoin: %s\n", "initializing node"); diff --git a/src/backend/executor/nodeNestloop.c b/src/backend/executor/nodeNestloop.c index e7cba2e756e..d8d5f38d6db 100644 --- a/src/backend/executor/nodeNestloop.c +++ b/src/backend/executor/nodeNestloop.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.4 1997/09/07 04:41:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeNestloop.c,v 1.5 1997/09/08 02:22:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,17 +57,17 @@ TupleTableSlot * ExecNestLoop(NestLoop * node, Plan * parent) { - NestLoopState *nlstate; - Plan *innerPlan; - Plan *outerPlan; - bool needNewOuterTuple; + NestLoopState *nlstate; + Plan *innerPlan; + Plan *outerPlan; + bool needNewOuterTuple; TupleTableSlot *outerTupleSlot; TupleTableSlot *innerTupleSlot; - List *qual; - bool qualResult; - ExprContext *econtext; + List *qual; + bool qualResult; + ExprContext *econtext; /* ---------------- * get information from the node @@ -86,7 +86,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) */ econtext = nlstate->jstate.cs_ExprContext; - /* ---------------- * get the current outer tuple + /* ---------------- * get the current outer tuple * ---------------- */ outerTupleSlot = nlstate->jstate.cs_OuterTupleSlot; @@ -101,7 +101,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) if (nlstate->jstate.cs_TupFromTlist) { TupleTableSlot *result; - bool isDone; + bool isDone; result = ExecProject(nlstate->jstate.cs_ProjInfo, &isDone); if (!isDone) @@ -238,7 +238,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) */ ProjectionInfo *projInfo; TupleTableSlot *result; - bool isDone; + bool isDone; ENL1_printf("qualification succeeded, projecting tuple"); @@ -267,7 +267,7 @@ ExecNestLoop(NestLoop * node, Plan * parent) bool ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent) { - NestLoopState *nlstate; + NestLoopState *nlstate; NL1_printf("ExecInitNestLoop: %s\n", "initializing node"); @@ -347,7 +347,7 @@ ExecCountSlotsNestLoop(NestLoop * node) void ExecEndNestLoop(NestLoop * node) { - NestLoopState *nlstate; + NestLoopState *nlstate; NL1_printf("ExecEndNestLoop: %s\n", "ending node processing"); diff --git a/src/backend/executor/nodeResult.c b/src/backend/executor/nodeResult.c index 743bd73f2b3..4e0e62ddfe2 100644 --- a/src/backend/executor/nodeResult.c +++ b/src/backend/executor/nodeResult.c @@ -27,7 +27,7 @@ * SeqScan (emp.all) * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.3 1997/09/07 04:41:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeResult.c,v 1.4 1997/09/08 02:22:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,14 +53,14 @@ TupleTableSlot * ExecResult(Result * node) { - ResultState *resstate; + ResultState *resstate; TupleTableSlot *outerTupleSlot; TupleTableSlot *resultSlot; - Plan *outerPlan; - ExprContext *econtext; - Node *qual; - bool qualResult; - bool isDone; + Plan *outerPlan; + ExprContext *econtext; + Node *qual; + bool qualResult; + bool isDone; ProjectionInfo *projInfo; /* ---------------- @@ -191,7 +191,7 @@ ExecResult(Result * node) bool ExecInitResult(Result * node, EState * estate, Plan * parent) { - ResultState *resstate; + ResultState *resstate; /* ---------------- * assign execution state to node @@ -267,7 +267,7 @@ ExecCountSlotsResult(Result * node) void ExecEndResult(Result * node) { - ResultState *resstate; + ResultState *resstate; resstate = node->resstate; diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index d3451f8026f..1d04360c9d2 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.5 1997/09/07 04:41:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.6 1997/09/08 02:22:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,13 +49,13 @@ static TupleTableSlot *SeqNext(SeqScan * node); static TupleTableSlot * SeqNext(SeqScan * node) { - HeapTuple tuple; - HeapScanDesc scandesc; + HeapTuple tuple; + HeapScanDesc scandesc; CommonScanState *scanstate; - EState *estate; - ScanDirection direction; + EState *estate; + ScanDirection direction; TupleTableSlot *slot; - Buffer buffer; + Buffer buffer; /* ---------------- * get information from the estate and scan state @@ -118,7 +118,7 @@ TupleTableSlot * ExecSeqScan(SeqScan * node) { TupleTableSlot *slot; - Plan *outerPlan; + Plan *outerPlan; S_printf("ExecSeqScan: scanning node: "); S_nodeDisplay(node); @@ -150,19 +150,19 @@ ExecSeqScan(SeqScan * node) * subplans of scans. * ---------------------------------------------------------------- */ -static Oid +static Oid InitScanRelation(SeqScan * node, EState * estate, CommonScanState * scanstate, Plan * outerPlan) { - Index relid; - List *rangeTable; - RangeTblEntry *rtentry; - Oid reloid; - TimeQual timeQual; - ScanDirection direction; - Relation currentRelation; - HeapScanDesc currentScanDesc; - RelationInfo *resultRelationInfo; + Index relid; + List *rangeTable; + RangeTblEntry *rtentry; + Oid reloid; + TimeQual timeQual; + ScanDirection direction; + Relation currentRelation; + HeapScanDesc currentScanDesc; + RelationInfo *resultRelationInfo; if (outerPlan == NULL) { @@ -239,9 +239,9 @@ bool ExecInitSeqScan(SeqScan * node, EState * estate, Plan * parent) { CommonScanState *scanstate; - Plan *outerPlan; - Oid reloid; - HeapScanDesc scandesc; + Plan *outerPlan; + Oid reloid; + HeapScanDesc scandesc; /* ---------------- * assign the node's execution state @@ -315,7 +315,7 @@ void ExecEndSeqScan(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; + Plan *outerPlan; /* ---------------- * get information from node @@ -369,11 +369,11 @@ void ExecSeqReScan(SeqScan * node, ExprContext * exprCtxt, Plan * parent) { CommonScanState *scanstate; - EState *estate; - Plan *outerPlan; - Relation rdesc; - HeapScanDesc sdesc; - ScanDirection direction; + EState *estate; + Plan *outerPlan; + Relation rdesc; + HeapScanDesc sdesc; + ScanDirection direction; scanstate = node->scanstate; estate = node->plan.state; @@ -406,8 +406,8 @@ void ExecSeqMarkPos(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; - HeapScanDesc sdesc; + Plan *outerPlan; + HeapScanDesc sdesc; scanstate = node->scanstate; @@ -445,8 +445,8 @@ void ExecSeqRestrPos(SeqScan * node) { CommonScanState *scanstate; - Plan *outerPlan; - HeapScanDesc sdesc; + Plan *outerPlan; + HeapScanDesc sdesc; scanstate = node->scanstate; diff --git a/src/backend/executor/nodeSort.c b/src/backend/executor/nodeSort.c index eb2e2e7b180..64f56bc99a7 100644 --- a/src/backend/executor/nodeSort.c +++ b/src/backend/executor/nodeSort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.7 1997/09/07 04:41:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSort.c,v 1.8 1997/09/08 02:22:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,17 +32,17 @@ * Returns an array of ScanKeyData. * ---------------------------------------------------------------- */ -static ScanKey +static ScanKey FormSortKeys(Sort * sortnode) { - ScanKey sortkeys; - List *targetList; - List *tl; - int keycount; - Resdom *resdom; - AttrNumber resno; - Index reskey; - Oid reskeyop; + ScanKey sortkeys; + List *targetList; + List *tl; + int keycount; + Resdom *resdom; + AttrNumber resno; + Index reskey; + Oid reskeyop; /* ---------------- * get information from the node @@ -65,7 +65,7 @@ FormSortKeys(Sort * sortnode) */ foreach(tl, targetList) { - TargetEntry *target = (TargetEntry *) lfirst(tl); + TargetEntry *target = (TargetEntry *) lfirst(tl); resdom = target->resdom; resno = resdom->resno; @@ -104,13 +104,13 @@ FormSortKeys(Sort * sortnode) TupleTableSlot * ExecSort(Sort * node) { - EState *estate; - SortState *sortstate; - Plan *outerNode; - ScanDirection dir; - int keycount; - ScanKey sortkeys; - HeapTuple heapTuple; + EState *estate; + SortState *sortstate; + Plan *outerNode; + ScanDirection dir; + int keycount; + ScanKey sortkeys; + HeapTuple heapTuple; TupleTableSlot *slot; /* ---------------- @@ -231,9 +231,9 @@ ExecSort(Sort * node) bool ExecInitSort(Sort * node, EState * estate, Plan * parent) { - SortState *sortstate; - Plan *outerPlan; - ScanKey sortkeys; + SortState *sortstate; + Plan *outerPlan; + ScanKey sortkeys; SO1_printf("ExecInitSort: %s\n", "initializing sort node"); @@ -330,8 +330,8 @@ ExecCountSlotsSort(Sort * node) void ExecEndSort(Sort * node) { - SortState *sortstate; - Plan *outerPlan; + SortState *sortstate; + Plan *outerPlan; /* ---------------- * get info from the sort state @@ -371,7 +371,7 @@ ExecEndSort(Sort * node) void ExecSortMarkPos(Sort * node) { - SortState *sortstate; + SortState *sortstate; /* ---------------- * if we haven't sorted yet, just return @@ -395,7 +395,7 @@ ExecSortMarkPos(Sort * node) void ExecSortRestrPos(Sort * node) { - SortState *sortstate; + SortState *sortstate; /* ---------------- * if we haven't sorted yet, just return. diff --git a/src/backend/executor/nodeTee.c b/src/backend/executor/nodeTee.c index 8a1e233125a..e3ddfe39d66 100644 --- a/src/backend/executor/nodeTee.c +++ b/src/backend/executor/nodeTee.c @@ -15,7 +15,7 @@ * ExecEndTee * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.7 1997/09/07 04:41:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/Attic/nodeTee.c,v 1.8 1997/09/08 02:22:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,12 +47,12 @@ bool ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) { - TeeState *teeState; - Plan *outerPlan; - int len; - Relation bufferRel; - TupleDesc tupType; - EState *estate; + TeeState *teeState; + Plan *outerPlan; + int len; + Relation bufferRel; + TupleDesc tupType; + EState *estate; /* * it is possible that the Tee has already been initialized since it @@ -154,7 +154,7 @@ ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) if (node->teeTableName[0] != '\0') { - Relation r; + Relation r; teeState->tee_bufferRelname = pstrdup(node->teeTableName); @@ -168,7 +168,7 @@ ExecInitTee(Tee * node, EState * currentEstate, Plan * parent) bufferRel = heap_openr(teeState->tee_bufferRelname); else bufferRel = heap_open(heap_create(teeState->tee_bufferRelname, - /*FIX */ NULL, + /* FIX */ NULL, 'n', DEFAULT_SMGR, tupType)); @@ -232,10 +232,10 @@ ExecCountSlotsTee(Tee * node) static void initTeeScanDescs(Tee * node) { - TeeState *teeState; - Relation bufferRel; - ScanDirection dir; - MemoryContext orig; + TeeState *teeState; + Relation bufferRel; + ScanDirection dir; + MemoryContext orig; teeState = node->teestate; if (teeState->tee_leftScanDesc && teeState->tee_rightScanDesc) @@ -292,20 +292,20 @@ initTeeScanDescs(Tee * node) TupleTableSlot * ExecTee(Tee * node, Plan * parent) { - EState *estate; - TeeState *teeState; - int leftPlace, - rightPlace, - lastPlace; - int branch; + EState *estate; + TeeState *teeState; + int leftPlace, + rightPlace, + lastPlace; + int branch; TupleTableSlot *result; TupleTableSlot *slot; - Plan *childNode; - ScanDirection dir; - HeapTuple heapTuple; - Relation bufferRel; - HeapScanDesc scanDesc; - Buffer buffer; + Plan *childNode; + ScanDirection dir; + HeapTuple heapTuple; + Relation bufferRel; + HeapScanDesc scanDesc; + Buffer buffer; estate = ((Plan *) node)->state; teeState = node->teestate; @@ -369,7 +369,7 @@ ExecTee(Tee * node, Plan * parent) * move the scandesc forward so we don't re-read this * tuple later */ - HeapTuple throwAway; + HeapTuple throwAway; /* Buffer buffer; */ throwAway = heap_getnext(scanDesc, @@ -446,9 +446,9 @@ void ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent) { - EState *estate; - TeeState *teeState; - ScanDirection dir; + EState *estate; + TeeState *teeState; + ScanDirection dir; estate = ((Plan *) node)->state; teeState = node->teestate; @@ -492,13 +492,13 @@ ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent) void ExecEndTee(Tee * node, Plan * parent) { - EState *estate; - TeeState *teeState; - int leftPlace, - rightPlace, - lastPlace; - Relation bufferRel; - MemoryContext orig; + EState *estate; + TeeState *teeState; + int leftPlace, + rightPlace, + lastPlace; + Relation bufferRel; + MemoryContext orig; estate = ((Plan *) node)->state; teeState = node->teestate; diff --git a/src/backend/executor/nodeUnique.c b/src/backend/executor/nodeUnique.c index 75e40ccad96..5a340b8cf55 100644 --- a/src/backend/executor/nodeUnique.c +++ b/src/backend/executor/nodeUnique.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.8 1997/09/07 04:41:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeUnique.c,v 1.9 1997/09/08 02:22:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,15 +47,15 @@ * same ADT value. -cim * ---------------------------------------------------------------- */ -static bool /* true if tuples are identical, false +static bool /* true if tuples are identical, false * otherwise */ ExecIdenticalTuples(TupleTableSlot * t1, TupleTableSlot * t2) { - HeapTuple h1; - HeapTuple h2; - char *d1; - char *d2; - int len; + HeapTuple h1; + HeapTuple h2; + char *d1; + char *d2; + int len; h1 = t1->val; h2 = t2->val; @@ -110,14 +110,14 @@ ExecIdenticalTuples(TupleTableSlot * t1, TupleTableSlot * t2) TupleTableSlot * /* return: a tuple or NULL */ ExecUnique(Unique * node) { - UniqueState *uniquestate; + UniqueState *uniquestate; TupleTableSlot *resultTupleSlot; TupleTableSlot *slot; - Plan *outerPlan; - char *uniqueAttr; - AttrNumber uniqueAttrNum; - TupleDesc tupDesc; - Oid typoutput; + Plan *outerPlan; + char *uniqueAttr; + AttrNumber uniqueAttrNum; + TupleDesc tupDesc; + Oid typoutput; /* ---------------- * get information from the node @@ -180,12 +180,12 @@ ExecUnique(Unique * node) * to check equality, we check to see if the typoutput of the * attributes are equal */ - bool isNull1, - isNull2; - char *attr1, - *attr2; - char *val1, - *val2; + bool isNull1, + isNull2; + char *attr1, + *attr2; + char *val1, + *val2; attr1 = heap_getattr(slot->val, InvalidBuffer, uniqueAttrNum, tupDesc, &isNull1); @@ -245,9 +245,9 @@ ExecUnique(Unique * node) bool /* return: initialization status */ ExecInitUnique(Unique * node, EState * estate, Plan * parent) { - UniqueState *uniquestate; - Plan *outerPlan; - char *uniqueAttr; + UniqueState *uniquestate; + Plan *outerPlan; + char *uniqueAttr; /* ---------------- * assign execution state to node @@ -299,8 +299,8 @@ ExecInitUnique(Unique * node, EState * estate, Plan * parent) if (uniqueAttr) { - TupleDesc tupDesc; - int i = 0; + TupleDesc tupDesc; + int i = 0; tupDesc = ExecGetResultType(uniquestate); @@ -340,7 +340,7 @@ ExecCountSlotsUnique(Unique * node) void ExecEndUnique(Unique * node) { - UniqueState *uniquestate; + UniqueState *uniquestate; uniquestate = node->uniquestate; ExecEndNode(outerPlan((Plan *) node), (Plan *) node); diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index 1d05a752d24..de4915785dc 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -11,39 +11,39 @@ typedef struct { - QueryTreeList *qtlist; /* malloced */ - uint32 processed; /* by Executor */ - SPITupleTable *tuptable; - Portal portal; /* portal per procedure */ - MemoryContext savedcxt; - CommandId savedId; -} _SPI_connection; - -static Portal _SPI_portal = (Portal) NULL; + QueryTreeList *qtlist; /* malloced */ + uint32 processed; /* by Executor */ + SPITupleTable *tuptable; + Portal portal; /* portal per procedure */ + MemoryContext savedcxt; + CommandId savedId; +} _SPI_connection; + +static Portal _SPI_portal = (Portal) NULL; static _SPI_connection *_SPI_stack = NULL; static _SPI_connection *_SPI_current = NULL; -static int _SPI_connected = -1; -static int _SPI_curid = -1; +static int _SPI_connected = -1; +static int _SPI_curid = -1; -uint32 SPI_processed = 0; -SPITupleTable *SPI_tuptable; -int SPI_result; +uint32 SPI_processed = 0; +SPITupleTable *SPI_tuptable; +int SPI_result; -void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); +void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); typedef struct { - QueryTreeList *qtlist; - List *ptlist; - int nargs; - Oid *argtypes; -} _SPI_plan; + QueryTreeList *qtlist; + List *ptlist; + int nargs; + Oid *argtypes; +} _SPI_plan; -static int _SPI_execute(char *src, int tcount, _SPI_plan * plan); -static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount); +static int _SPI_execute(char *src, int tcount, _SPI_plan * plan); +static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount); #if 0 -static void _SPI_fetch(FetchStmt * stmt); +static void _SPI_fetch(FetchStmt * stmt); #endif static int @@ -52,23 +52,23 @@ _SPI_execute_plan(_SPI_plan * plan, static _SPI_plan *_SPI_copy_plan(_SPI_plan * plan, bool local); -static int _SPI_begin_call(bool execmem); -static int _SPI_end_call(bool procmem); +static int _SPI_begin_call(bool execmem); +static int _SPI_end_call(bool procmem); static MemoryContext _SPI_execmem(void); static MemoryContext _SPI_procmem(void); -static bool _SPI_checktuples(bool isRetrieveIntoRelation); +static bool _SPI_checktuples(bool isRetrieveIntoRelation); #ifdef SPI_EXECUTOR_STATS -extern int ShowExecutorStats; -extern void ResetUsage(void); -extern void ShowUsage(void); +extern int ShowExecutorStats; +extern void ResetUsage(void); +extern void ShowUsage(void); #endif int SPI_connect() { - char pname[64]; + char pname[64]; PortalVariableMemory pvmem; /* @@ -141,7 +141,7 @@ SPI_connect() int SPI_finish() { - int res; + int res; res = _SPI_begin_call(false); /* live in procedure memory */ if (res < 0) @@ -179,7 +179,7 @@ SPI_finish() int SPI_exec(char *src, int tcount) { - int res; + int res; if (src == NULL || tcount < 0) return (SPI_ERROR_ARGUMENT); @@ -197,7 +197,7 @@ SPI_exec(char *src, int tcount) int SPI_execp(void *plan, char **Values, char *Nulls, int tcount) { - int res; + int res; if (plan == NULL || tcount < 0) return (SPI_ERROR_ARGUMENT); @@ -216,10 +216,10 @@ SPI_execp(void *plan, char **Values, char *Nulls, int tcount) return (res); } -void * +void * SPI_prepare(char *src, int nargs, Oid * argtypes) { - _SPI_plan *plan; + _SPI_plan *plan; if (nargs < 0 || (nargs > 0 && argtypes == NULL)) { @@ -248,10 +248,10 @@ SPI_prepare(char *src, int nargs, Oid * argtypes) } -void * +void * SPI_saveplan(void *plan) { - _SPI_plan *newplan; + _SPI_plan *newplan; if (plan == NULL) { @@ -275,7 +275,7 @@ SPI_saveplan(void *plan) int SPI_fnumber(TupleDesc tupdesc, char *fname) { - int res; + int res; if (_SPI_curid + 1 != _SPI_connected) return (SPI_ERROR_UNCONNECTED); @@ -289,12 +289,12 @@ SPI_fnumber(TupleDesc tupdesc, char *fname) return (SPI_ERROR_NOATTRIBUTE); } -char * +char * SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) { - char *val; - bool isnull; - Oid foutoid; + char *val; + bool isnull; + Oid foutoid; SPI_result = 0; if (_SPI_curid + 1 != _SPI_connected) @@ -319,10 +319,10 @@ SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber) return (fmgr(foutoid, val, gettypelem(tupdesc->attrs[fnumber - 1]->atttypid))); } -char * +char * SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull) { - char *val; + char *val; *isnull = true; SPI_result = 0; @@ -340,10 +340,10 @@ SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull) return (val); } -char * +char * SPI_gettype(TupleDesc tupdesc, int fnumber) { - HeapTuple typeTuple; + HeapTuple typeTuple; SPI_result = 0; if (_SPI_curid + 1 != _SPI_connected) @@ -391,7 +391,7 @@ SPI_gettypeid(TupleDesc tupdesc, int fnumber) return (tupdesc->attrs[fnumber - 1]->atttypid); } -char * +char * SPI_getrelname(Relation rel) { @@ -414,8 +414,8 @@ SPI_getrelname(Relation rel) void spi_printtup(HeapTuple tuple, TupleDesc tupdesc) { - SPITupleTable *tuptable; - MemoryContext oldcxt; + SPITupleTable *tuptable; + MemoryContext oldcxt; /* * When called by Executor _SPI_curid expected to be equal to @@ -459,18 +459,18 @@ spi_printtup(HeapTuple tuple, TupleDesc tupdesc) static int _SPI_execute(char *src, int tcount, _SPI_plan * plan) { - QueryTreeList *queryTree_list; - List *planTree_list; - List *ptlist; - QueryDesc *qdesc; - Query *queryTree; - Plan *planTree; - EState *state; - int qlen; - int nargs = 0; - Oid *argtypes = NULL; - int res; - int i; + QueryTreeList *queryTree_list; + List *planTree_list; + List *ptlist; + QueryDesc *qdesc; + Query *queryTree; + Plan *planTree; + EState *state; + int qlen; + int nargs = 0; + Oid *argtypes = NULL; + int res; + int i; /* Increment CommandCounter to see changes made by now */ CommandCounterIncrement(); @@ -502,7 +502,7 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan) { if (nodeTag(queryTree->utilityStmt) == T_CopyStmt) { - CopyStmt *stmt = (CopyStmt *) (queryTree->utilityStmt); + CopyStmt *stmt = (CopyStmt *) (queryTree->utilityStmt); if (stmt->filename == NULL) return (SPI_ERROR_COPY); @@ -556,17 +556,17 @@ _SPI_execute(char *src, int tcount, _SPI_plan * plan) static int _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) { - QueryTreeList *queryTree_list = plan->qtlist; - List *planTree_list = plan->ptlist; - QueryDesc *qdesc; - Query *queryTree; - Plan *planTree; - EState *state; - int nargs = plan->nargs; - int qlen = queryTree_list->len; - int res; - int i, - k; + QueryTreeList *queryTree_list = plan->qtlist; + List *planTree_list = plan->ptlist; + QueryDesc *qdesc; + Query *queryTree; + Plan *planTree; + EState *state; + int nargs = plan->nargs; + int qlen = queryTree_list->len; + int res; + int i, + k; /* Increment CommandCounter to see changes made by now */ CommandCounterIncrement(); @@ -598,7 +598,7 @@ _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) state = CreateExecutorState(); if (nargs > 0) { - ParamListInfo paramLI = (ParamListInfo) palloc((nargs + 1) * + ParamListInfo paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData)); state->es_param_list_info = paramLI; @@ -627,14 +627,14 @@ _SPI_execute_plan(_SPI_plan * plan, char **Values, char *Nulls, int tcount) static int _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) { - Query *parseTree; - Plan *plan; - int operation; - TupleDesc tupdesc; - bool isRetrieveIntoPortal = false; - bool isRetrieveIntoRelation = false; - char *intoName = NULL; - int res; + Query *parseTree; + Plan *plan; + int operation; + TupleDesc tupdesc; + bool isRetrieveIntoPortal = false; + bool isRetrieveIntoRelation = false; + char *intoName = NULL; + int res; parseTree = queryDesc->parsetree; plan = queryDesc->plantree; @@ -642,34 +642,34 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) switch (operation) { - case CMD_SELECT: - res = SPI_OK_SELECT; - if (parseTree->isPortal) - { - isRetrieveIntoPortal = true; - intoName = parseTree->into; - parseTree->isBinary = false; /* */ + case CMD_SELECT: + res = SPI_OK_SELECT; + if (parseTree->isPortal) + { + isRetrieveIntoPortal = true; + intoName = parseTree->into; + parseTree->isBinary = false; /* */ - return (SPI_ERROR_CURSOR); + return (SPI_ERROR_CURSOR); - } - else if (parseTree->into != NULL) /* select into table */ - { - res = SPI_OK_SELINTO; - isRetrieveIntoRelation = true; - } - break; - case CMD_INSERT: - res = SPI_OK_INSERT; - break; - case CMD_DELETE: - res = SPI_OK_DELETE; - break; - case CMD_UPDATE: - res = SPI_OK_UPDATE; - break; - default: - return (SPI_ERROR_OPUNKNOWN); + } + else if (parseTree->into != NULL) /* select into table */ + { + res = SPI_OK_SELINTO; + isRetrieveIntoRelation = true; + } + break; + case CMD_INSERT: + res = SPI_OK_INSERT; + break; + case CMD_DELETE: + res = SPI_OK_DELETE; + break; + case CMD_UPDATE: + res = SPI_OK_UPDATE; + break; + default: + return (SPI_ERROR_OPUNKNOWN); } if (state == NULL) /* plan preparation */ @@ -725,13 +725,13 @@ _SPI_pquery(QueryDesc * queryDesc, EState * state, int tcount) static void _SPI_fetch(FetchStmt * stmt) { - char *name = stmt->portalname; - int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK; - int count = stmt->howMany; - Portal portal; - QueryDesc *queryDesc; - EState *state; - MemoryContext context; + char *name = stmt->portalname; + int feature = (stmt->direction == FORWARD) ? EXEC_FOR : EXEC_BACK; + int count = stmt->howMany; + Portal portal; + QueryDesc *queryDesc; + EState *state; + MemoryContext context; if (name == NULL) elog(FATAL, "SPI_fetch from blank portal unsupported"); @@ -761,10 +761,10 @@ _SPI_fetch(FetchStmt * stmt) #endif -static MemoryContext +static MemoryContext _SPI_execmem() { - MemoryContext oldcxt; + MemoryContext oldcxt; PortalHeapMemory phmem; phmem = PortalGetHeapMemory(_SPI_current->portal); @@ -774,10 +774,10 @@ _SPI_execmem() } -static MemoryContext +static MemoryContext _SPI_procmem() { - MemoryContext oldcxt; + MemoryContext oldcxt; PortalVariableMemory pvmem; pvmem = PortalGetVariableMemory(_SPI_current->portal); @@ -834,12 +834,12 @@ _SPI_end_call(bool procmem) return (0); } -static bool +static bool _SPI_checktuples(bool isRetrieveIntoRelation) { - uint32 processed = _SPI_current->processed; - SPITupleTable *tuptable = _SPI_current->tuptable; - bool failed = false; + uint32 processed = _SPI_current->processed; + SPITupleTable *tuptable = _SPI_current->tuptable; + bool failed = false; if (processed == 0) { @@ -866,9 +866,9 @@ _SPI_checktuples(bool isRetrieveIntoRelation) static _SPI_plan * _SPI_copy_plan(_SPI_plan * plan, bool local) { - _SPI_plan *newplan; - MemoryContext oldcxt; - int i; + _SPI_plan *newplan; + MemoryContext oldcxt; + int i; if (local) oldcxt = MemoryContextSwitchTo((MemoryContext) diff --git a/src/backend/lib/dllist.c b/src/backend/lib/dllist.c index 70feee02bb9..8790a844409 100644 --- a/src/backend/lib/dllist.c +++ b/src/backend/lib/dllist.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.6 1997/09/07 04:41:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/dllist.c,v 1.7 1997/09/08 02:22:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,10 +18,10 @@ #include <lib/dllist.h> -Dllist * +Dllist * DLNewList(void) { - Dllist *l; + Dllist *l; l = malloc(sizeof(Dllist)); l->dll_head = 0; @@ -34,7 +34,7 @@ DLNewList(void) void DLFreeList(Dllist * l) { - Dlelem *curr; + Dlelem *curr; while ((curr = DLRemHead(l)) != 0) free(curr); @@ -42,10 +42,10 @@ DLFreeList(Dllist * l) free(l); } -Dlelem * +Dlelem * DLNewElem(void *val) { - Dlelem *e; + Dlelem *e; e = malloc(sizeof(Dlelem)); e->dle_next = 0; @@ -61,7 +61,7 @@ DLFreeElem(Dlelem * e) free(e); } -Dlelem * +Dlelem * DLGetHead(Dllist * l) { return (l ? l->dll_head : 0); @@ -69,17 +69,17 @@ DLGetHead(Dllist * l) /* get the value stored in the first element */ #ifdef NOT_USED -void * +void * DLGetHeadVal(Dllist * l) { - Dlelem *e = DLGetHead(l); + Dlelem *e = DLGetHead(l); return (e ? e->dle_val : 0); } #endif -Dlelem * +Dlelem * DLGetTail(Dllist * l) { return (l ? l->dll_tail : 0); @@ -87,23 +87,23 @@ DLGetTail(Dllist * l) /* get the value stored in the first element */ #ifdef NOT_USED -void * +void * DLGetTailVal(Dllist * l) { - Dlelem *e = DLGetTail(l); + Dlelem *e = DLGetTail(l); return (e ? e->dle_val : 0); } #endif -Dlelem * +Dlelem * DLGetPred(Dlelem * e) /* get predecessor */ { return (e ? e->dle_prev : 0); } -Dlelem * +Dlelem * DLGetSucc(Dlelem * e) /* get successor */ { return (e ? e->dle_next : 0); @@ -112,7 +112,7 @@ DLGetSucc(Dlelem * e) /* get successor */ void DLRemove(Dlelem * e) { - Dllist *l; + Dllist *l; if (e->dle_prev) e->dle_prev->dle_next = e->dle_next; @@ -162,11 +162,11 @@ DLAddTail(Dllist * l, Dlelem * e) l->dll_head = l->dll_tail; } -Dlelem * +Dlelem * DLRemHead(Dllist * l) { /* remove and return the head */ - Dlelem *result; + Dlelem *result; if (l->dll_head == 0) return 0; @@ -188,11 +188,11 @@ DLRemHead(Dllist * l) return result; } -Dlelem * +Dlelem * DLRemTail(Dllist * l) { /* remove and return the tail */ - Dlelem *result; + Dlelem *result; if (l->dll_tail == 0) return 0; diff --git a/src/backend/lib/fstack.c b/src/backend/lib/fstack.c index f97d467fe92..f28f24ae141 100644 --- a/src/backend/lib/fstack.c +++ b/src/backend/lib/fstack.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.5 1997/09/07 04:42:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/fstack.c,v 1.6 1997/09/08 02:22:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ FixedStackInit(FixedStack stack, Offset offset) Pointer FixedStackPop(FixedStack stack) { - Pointer pointer; + Pointer pointer; AssertArg(FixedStackIsValid(stack)); @@ -75,7 +75,7 @@ FixedStackPop(FixedStack stack) void FixedStackPush(FixedStack stack, Pointer pointer) { - FixedItem item = FixedStackGetItem(stack, pointer); + FixedItem item = FixedStackGetItem(stack, pointer); AssertArg(FixedStackIsValid(stack)); AssertArg(PointerIsValid(pointer)); @@ -96,11 +96,11 @@ FixedStackPush(FixedStack stack, Pointer pointer) * BadArg if stack is invalid. * BadArg if pointer is invalid. */ -static bool +static bool FixedStackContains(FixedStack stack, Pointer pointer) { - FixedItem next; - FixedItem item; + FixedItem next; + FixedItem item; AssertArg(FixedStackIsValid(stack)); AssertArg(PointerIsValid(pointer)); @@ -135,7 +135,7 @@ FixedStackGetTop(FixedStack stack) Pointer FixedStackGetNext(FixedStack stack, Pointer pointer) { - FixedItem item; + FixedItem item; /* AssertArg(FixedStackIsValid(stack)); */ /* AssertArg(PointerIsValid(pointer)); */ diff --git a/src/backend/lib/hasht.c b/src/backend/lib/hasht.c index 4e12dcf30eb..3ad58e4e0eb 100644 --- a/src/backend/lib/hasht.c +++ b/src/backend/lib/hasht.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.5 1997/09/07 04:42:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/hasht.c,v 1.6 1997/09/08 02:22:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,9 +28,9 @@ void HashTableWalk(HTAB * hashtable, HashtFunc function, int arg) { - long *hashent; - long *data; - int keysize; + long *hashent; + long *data; + int keysize; keysize = hashtable->hctl->keysize; hash_seq((HTAB *) NULL); diff --git a/src/backend/lib/lispsort.c b/src/backend/lib/lispsort.c index bf346ecc1a6..41c0e934e78 100644 --- a/src/backend/lib/lispsort.c +++ b/src/backend/lib/lispsort.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.5 1997/09/07 04:42:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/lispsort.c,v 1.6 1997/09/08 02:23:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,15 +29,15 @@ ** as passed into lisp_qsort(), and returns a new list with ** the nodes sorted. The old list is *not* freed or modified (?) */ -List * +List * lisp_qsort(List * the_list, /* the list to be sorted */ int (*compare) ()) /* function to compare two nodes */ { - int i; - size_t num; - List **nodearray; - List *tmp, - *output; + int i; + size_t num; + List **nodearray; + List *tmp, + *output; /* find size of list */ num = length(the_list); diff --git a/src/backend/lib/qsort.c b/src/backend/lib/qsort.c index ff2bbfa16d9..14ac14c39d7 100644 --- a/src/backend/lib/qsort.c +++ b/src/backend/lib/qsort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.3 1997/09/07 04:42:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/Attic/qsort.c,v 1.4 1997/09/08 02:23:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,7 +45,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; +static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ @@ -67,8 +67,8 @@ static char sccsid[] = "@(#)qsort.c 5.9 (Berkeley) 2/23/91"; */ #define THRESH 4 -static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()); -static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()); +static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()); +static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()); void pg_qsort(void *bot, @@ -129,15 +129,15 @@ pg_qsort(void *bot, static void quick_sort(char *bot, int nmemb, int size, int (*compar) ()) { - register int cnt; + register int cnt; register u_char ch; - register char *top, - *mid, - *t1, - *t2; - register int n1, - n2; - char *bsv; + register char *top, + *mid, + *t1, + *t2; + register int n1, + n2; + char *bsv; /* bot and nmemb must already be set. */ partition: @@ -277,13 +277,13 @@ swap: SWAP(bot, replace); static void insertion_sort(char *bot, int nmemb, int size, int (*compar) ()) { - register int cnt; + register int cnt; register u_char ch; - register char *s1, - *s2, - *t1, - *t2, - *top; + register char *s1, + *s2, + *t1, + *t2, + *top; /* * A simple insertion sort (see Knuth, Vol. 3, page 81, Algorithm S). diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 34108c04c72..639af1854f0 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.4 1997/09/07 04:42:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/lib/stringinfo.c,v 1.5 1997/09/08 02:23:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,8 +30,8 @@ StringInfo makeStringInfo() { - StringInfo res; - long size; + StringInfo res; + long size; res = (StringInfo) palloc(sizeof(StringInfoData)); if (res == NULL) @@ -72,9 +72,9 @@ makeStringInfo() void appendStringInfo(StringInfo str, char *buffer) { - int buflen, - newlen; - char *s; + int buflen, + newlen; + char *s; Assert((str != NULL)); diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index ff6711d3b5c..f3af7c52ccc 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.15 1997/09/07 04:42:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.16 1997/09/08 02:23:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -72,7 +72,7 @@ #include <libpq/hba.h> #include <libpq/password.h> -static int be_getauthsvc(MsgType msgtype); +static int be_getauthsvc(MsgType msgtype); /*---------------------------------------------------------------- * common definitions for generic fe/be routines @@ -81,9 +81,9 @@ static int be_getauthsvc(MsgType msgtype); struct authsvc { - char name[16]; /* service nickname (for command line) */ - MsgType msgtype; /* startup packet header type */ - int allowed; /* initially allowed (before command line + char name[16]; /* service nickname (for command line) */ + MsgType msgtype; /* startup packet header type */ + int allowed; /* initially allowed (before command line * option parsing)? */ }; @@ -99,10 +99,10 @@ struct authsvc */ #if defined(HBA) -static int useHostBasedAuth = 1; +static int useHostBasedAuth = 1; #else -static int useHostBasedAuth = 0; +static int useHostBasedAuth = 0; #endif @@ -125,7 +125,7 @@ static struct authsvc authsvcs[] = { {"password", STARTUP_PASSWORD_MSG, 1} }; -static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); +static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); #ifdef KRB4 /* This has to be ifdef'd out because krb.h does exist. This needs @@ -157,13 +157,13 @@ pg_krb4_recvauth(int sock, struct sockaddr_in * raddr, char *username) { - long krbopts = 0;/* one-way authentication */ - KTEXT_ST clttkt; - char instance[INST_SZ]; - AUTH_DAT auth_data; - Key_schedule key_sched; - char version[KRB_SENDAUTH_VLEN]; - int status; + long krbopts = 0; /* one-way authentication */ + KTEXT_ST clttkt; + char instance[INST_SZ]; + AUTH_DAT auth_data; + Key_schedule key_sched; + char version[KRB_SENDAUTH_VLEN]; + int status; strcpy(instance, "*"); /* don't care, but arg gets expanded * anyway */ @@ -255,10 +255,10 @@ pg_krb4_recvauth(int sock, * krb5_an_to_ln, except that it punts if multiple components are found, * and we can't afford to punt. */ -static char * +static char * pg_an_to_ln(char *aname) { - char *p; + char *p; if ((p = strchr(aname, '/')) || (p = strchr(aname, '@'))) *p = '\0'; @@ -297,16 +297,16 @@ pg_krb5_recvauth(int sock, struct sockaddr_in * raddr, char *username) { - char servbuf[MAXHOSTNAMELEN + 1 + - sizeof(PG_KRB_SRVNAM)]; - char *hostp, - *kusername = (char *) NULL; + char servbuf[MAXHOSTNAMELEN + 1 + + sizeof(PG_KRB_SRVNAM)]; + char *hostp, + *kusername = (char *) NULL; krb5_error_code code; - krb5_principal client, - server; - krb5_address sender_addr; + krb5_principal client, + server; + krb5_address sender_addr; krb5_rdreq_key_proc keyproc = (krb5_rdreq_key_proc) NULL; - krb5_pointer keyprocarg = (krb5_pointer) NULL; + krb5_pointer keyprocarg = (krb5_pointer) NULL; /* * Set up server side -- since we have no ticket file to make this @@ -426,9 +426,9 @@ pg_krb5_recvauth(int sock, static int pg_password_recvauth(Port * port, char *database, char *DataDir) { - PacketBuf buf; - char *user, - *password; + PacketBuf buf; + char *user, + *password; if (PacketReceive(port, &buf, BLOCKING) != STATUS_OK) { @@ -451,7 +451,7 @@ pg_password_recvauth(Port * port, char *database, char *DataDir) int be_recvauth(MsgType msgtype_arg, Port * port, char *username, StartupInfo * sp) { - MsgType msgtype; + MsgType msgtype; /* * A message type of STARTUP_MSG (which once upon a time was the only @@ -489,93 +489,93 @@ be_recvauth(MsgType msgtype_arg, Port * port, char *username, StartupInfo * sp) switch (msgtype) { - case STARTUP_KRB4_MSG: - if (!be_getauthsvc(msgtype)) - { - sprintf(PQerrormsg, - "be_recvauth: krb4 authentication disallowed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - if (pg_krb4_recvauth(port->sock, &port->laddr, &port->raddr, - username) != STATUS_OK) - { - sprintf(PQerrormsg, - "be_recvauth: krb4 authentication failed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - break; - case STARTUP_KRB5_MSG: - if (!be_getauthsvc(msgtype)) - { - sprintf(PQerrormsg, - "be_recvauth: krb5 authentication disallowed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - if (pg_krb5_recvauth(port->sock, &port->laddr, &port->raddr, - username) != STATUS_OK) - { - sprintf(PQerrormsg, - "be_recvauth: krb5 authentication failed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - break; - case STARTUP_UNAUTH_MSG: - if (!be_getauthsvc(msgtype)) - { - sprintf(PQerrormsg, - "be_recvauth: " - "unauthenticated connections disallowed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - break; - case STARTUP_HBA_MSG: - if (hba_recvauth(port, sp->database, sp->user, DataDir) != STATUS_OK) - { - sprintf(PQerrormsg, - "be_recvauth: host-based authentication failed\n"); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); - } - break; - case STARTUP_PASSWORD_MSG: - if (!be_getauthsvc(msgtype)) - { + case STARTUP_KRB4_MSG: + if (!be_getauthsvc(msgtype)) + { + sprintf(PQerrormsg, + "be_recvauth: krb4 authentication disallowed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + if (pg_krb4_recvauth(port->sock, &port->laddr, &port->raddr, + username) != STATUS_OK) + { + sprintf(PQerrormsg, + "be_recvauth: krb4 authentication failed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + break; + case STARTUP_KRB5_MSG: + if (!be_getauthsvc(msgtype)) + { + sprintf(PQerrormsg, + "be_recvauth: krb5 authentication disallowed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + if (pg_krb5_recvauth(port->sock, &port->laddr, &port->raddr, + username) != STATUS_OK) + { + sprintf(PQerrormsg, + "be_recvauth: krb5 authentication failed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + break; + case STARTUP_UNAUTH_MSG: + if (!be_getauthsvc(msgtype)) + { + sprintf(PQerrormsg, + "be_recvauth: " + "unauthenticated connections disallowed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + break; + case STARTUP_HBA_MSG: + if (hba_recvauth(port, sp->database, sp->user, DataDir) != STATUS_OK) + { + sprintf(PQerrormsg, + "be_recvauth: host-based authentication failed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + break; + case STARTUP_PASSWORD_MSG: + if (!be_getauthsvc(msgtype)) + { + sprintf(PQerrormsg, + "be_recvauth: " + "plaintext password authentication disallowed\n"); + fputs(PQerrormsg, stderr); + pqdebug("%s", PQerrormsg); + return (STATUS_ERROR); + } + if (pg_password_recvauth(port, sp->database, DataDir) != STATUS_OK) + { + + /* + * pg_password_recvauth or lower-level routines have + * already set + */ + /* the error message */ + return (STATUS_ERROR); + } + break; + default: sprintf(PQerrormsg, - "be_recvauth: " - "plaintext password authentication disallowed\n"); + "be_recvauth: unrecognized message type: %d\n", + msgtype); fputs(PQerrormsg, stderr); pqdebug("%s", PQerrormsg); return (STATUS_ERROR); - } - if (pg_password_recvauth(port, sp->database, DataDir) != STATUS_OK) - { - - /* - * pg_password_recvauth or lower-level routines have already - * set - */ - /* the error message */ - return (STATUS_ERROR); - } - break; - default: - sprintf(PQerrormsg, - "be_recvauth: unrecognized message type: %d\n", - msgtype); - fputs(PQerrormsg, stderr); - pqdebug("%s", PQerrormsg); - return (STATUS_ERROR); } return (STATUS_OK); } @@ -596,9 +596,9 @@ be_recvauth(MsgType msgtype_arg, Port * port, char *username, StartupInfo * sp) void be_setauthsvc(char *name) { - int i, - j; - int turnon = 1; + int i, + j; + int turnon = 1; if (!name) return; @@ -631,7 +631,7 @@ be_setauthsvc(char *name) static int be_getauthsvc(MsgType msgtype) { - int i; + int i; for (i = 0; i < n_authsvcs; ++i) if (msgtype == authsvcs[i].msgtype) diff --git a/src/backend/libpq/be-dumpdata.c b/src/backend/libpq/be-dumpdata.c index db0a99141d6..f2a0a71889a 100644 --- a/src/backend/libpq/be-dumpdata.c +++ b/src/backend/libpq/be-dumpdata.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.6 1997/09/07 04:42:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-dumpdata.c,v 1.7 1997/09/08 02:23:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ * backend portal stack for recursive PQexec calls * ---------------- */ -static Dllist *be_portalstack; +static Dllist *be_portalstack; /* ---------------- * be_portalinit - initialize backend portal administration @@ -84,11 +84,11 @@ be_portalpush(PortalEntry * entry) * used by PQexec() * ---------------- */ -PortalEntry * +PortalEntry * be_portalpop(void) { - PortalEntry *p; - Dlelem *elt; + PortalEntry *p; + Dlelem *elt; elt = DLRemTail(be_portalstack); @@ -105,10 +105,10 @@ be_portalpop(void) * used by be_printtup() * ---------------- */ -PortalEntry * +PortalEntry * be_currentportal(void) { - Dlelem *elt; + Dlelem *elt; elt = DLGetTail(be_portalstack); return (elt ? (PortalEntry *) DLE_VAL(elt) : NULL); @@ -126,14 +126,14 @@ be_currentportal(void) * ---------------- */ -static Oid be_portaloid; -static u_int be_portalcnt = 0; +static Oid be_portaloid; +static u_int be_portalcnt = 0; -PortalEntry * +PortalEntry * be_newportal(void) { - PortalEntry *entry; - char buf[PortalNameLength]; + PortalEntry *entry; + char buf[PortalNameLength]; /* ---------------- * generate a new name @@ -170,9 +170,9 @@ be_typeinit(PortalEntry * entry, TupleDesc tupDesc, int natts) { - PortalBuffer *portal; - GroupBuffer *group; - int i; + PortalBuffer *portal; + GroupBuffer *group; + int i; AttributeTupleForm *attrs = tupDesc->attrs; /* ---------------- @@ -212,19 +212,19 @@ be_typeinit(PortalEntry * entry, void be_printtup(HeapTuple tuple, TupleDesc typeinfo) { - int i; - char *attr; - bool isnull; - Oid typoutput; - - PortalEntry *entry = NULL; - PortalBuffer *portal = NULL; - GroupBuffer *group = NULL; - TupleBlock *tuples = NULL; - char **values; - int *lengths; - - MemoryContext savecxt; + int i; + char *attr; + bool isnull; + Oid typoutput; + + PortalEntry *entry = NULL; + PortalBuffer *portal = NULL; + GroupBuffer *group = NULL; + TupleBlock *tuples = NULL; + char **values; + int *lengths; + + MemoryContext savecxt; /* ---------------- * get the current portal and group diff --git a/src/backend/libpq/be-fsstubs.c b/src/backend/libpq/be-fsstubs.c index e3a464b087f..da166ae54a0 100644 --- a/src/backend/libpq/be-fsstubs.c +++ b/src/backend/libpq/be-fsstubs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.13 1997/09/07 04:42:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-fsstubs.c,v 1.14 1997/09/08 02:23:10 momjian Exp $ * * NOTES * This should be moved to a more appropriate place. It is here @@ -49,8 +49,8 @@ static LargeObjectDesc *cookies[MAX_LOBJ_FDS]; static GlobalMemory fscxt = NULL; -static int newLOfd(LargeObjectDesc * lobjCookie); -static void deleteLOfd(int fd); +static int newLOfd(LargeObjectDesc * lobjCookie); +static void deleteLOfd(int fd); /***************************************************************************** @@ -61,8 +61,8 @@ int lo_open(Oid lobjId, int mode) { LargeObjectDesc *lobjDesc; - int fd; - MemoryContext currentContext; + int fd; + MemoryContext currentContext; #if FSDB elog(NOTICE, "LOopen(%d,%d)", lobjId, mode); @@ -96,7 +96,7 @@ lo_open(Oid lobjId, int mode) int lo_close(int fd) { - MemoryContext currentContext; + MemoryContext currentContext; if (fd >= MAX_LOBJ_FDS) { @@ -145,8 +145,8 @@ lo_write(int fd, char *buf, int len) int lo_lseek(int fd, int offset, int whence) { - MemoryContext currentContext; - int ret; + MemoryContext currentContext; + int ret; if (fd >= MAX_LOBJ_FDS) { @@ -167,8 +167,8 @@ Oid lo_creat(int mode) { LargeObjectDesc *lobjDesc; - MemoryContext currentContext; - Oid lobjId; + MemoryContext currentContext; + Oid lobjId; if (fscxt == NULL) { @@ -225,7 +225,7 @@ struct varlena * loread(int fd, int len) { struct varlena *retval; - int totalread = 0; + int totalread = 0; retval = (struct varlena *) palloc(sizeof(int32) + len); totalread = lo_read(fd, VARDATA(retval), len); @@ -237,8 +237,8 @@ loread(int fd, int len) int lowrite(int fd, struct varlena * wbuf) { - int totalwritten; - int bytestowrite; + int totalwritten; + int bytestowrite; bytestowrite = VARSIZE(wbuf) - sizeof(int32); totalwritten = lo_write(fd, VARDATA(wbuf), bytestowrite); @@ -256,15 +256,15 @@ lowrite(int fd, struct varlena * wbuf) Oid lo_import(text * filename) { - int fd; - int nbytes, - tmp; + int fd; + int nbytes, + tmp; #define BUFSIZE 1024 - char buf[BUFSIZE]; - char fnamebuf[8192]; + char buf[BUFSIZE]; + char fnamebuf[8192]; LargeObjectDesc *lobj; - Oid lobjOid; + Oid lobjOid; /* * open the file to be read in @@ -319,15 +319,15 @@ lo_import(text * filename) int4 lo_export(Oid lobjId, text * filename) { - int fd; - int nbytes, - tmp; + int fd; + int nbytes, + tmp; #define BUFSIZE 1024 - char buf[BUFSIZE]; - char fnamebuf[8192]; + char buf[BUFSIZE]; + char fnamebuf[8192]; LargeObjectDesc *lobj; - mode_t oumask; + mode_t oumask; /* * create an inversion "object" @@ -379,7 +379,7 @@ lo_export(Oid lobjId, text * filename) static int newLOfd(LargeObjectDesc * lobjCookie) { - int i; + int i; for (i = 0; i < MAX_LOBJ_FDS; i++) { diff --git a/src/backend/libpq/be-pqexec.c b/src/backend/libpq/be-pqexec.c index 06185e4534f..24f2240d10d 100644 --- a/src/backend/libpq/be-pqexec.c +++ b/src/backend/libpq/be-pqexec.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.5 1997/09/07 04:42:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/be-pqexec.c,v 1.6 1997/09/08 02:23:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ #include <string.h> #endif -static char *strmake(char *str, int len); +static char *strmake(char *str, int len); /* ---------------------------------------------------------------- * PQ interface routines @@ -58,7 +58,7 @@ static char *strmake(char *str, int len); * This code scavanged from HandleFunctionRequest() in tcop/fastpath.h * ---------------- */ -char * +char * PQfn(int fnid, int *result_buf, /* can't use void, dec compiler barfs */ int result_len, @@ -66,9 +66,9 @@ PQfn(int fnid, PQArgBlock * args, int nargs) { - char *retval; /* XXX - should be datum, maybe ? */ - char *arg[8]; - int i; + char *retval; /* XXX - should be datum, maybe ? */ + char *arg[8]; + int i; /* ---------------- * fill args[] array @@ -129,11 +129,11 @@ PQfn(int fnid, * returns because the system longjmp's back to the main loop. * ---------------- */ -char * +char * PQexec(char *query) { - PortalEntry *entry = NULL; - char *result = NULL; + PortalEntry *entry = NULL; + char *result = NULL; /* ---------------- * create a new portal and put it on top of the portal stack. @@ -158,7 +158,7 @@ PQexec(char *query) result = entry->result; if (result == NULL) { - char *PQE = "Cnull PQexec result"; + char *PQE = "Cnull PQexec result"; result = pstrdup(PQE); } @@ -191,9 +191,9 @@ PQexec(char *query) int pqtest_PQexec(char *q) { - PortalBuffer *a; - char *res; - int t; + PortalBuffer *a; + char *res; + int t; /* ---------------- * execute the postgres query @@ -208,19 +208,19 @@ pqtest_PQexec(char *q) t = 0; switch (res[0]) { - case 'P': - a = PQparray(&res[1]); - if (a == NULL) - elog(WARN, "pqtest_PQexec: PQparray could not find portal %s", - res); - - t = PQntuples(a); - break; - case 'C': - break; - default: - elog(NOTICE, "pqtest_PQexec: PQexec(%s) returns %s", q, res); - break; + case 'P': + a = PQparray(&res[1]); + if (a == NULL) + elog(WARN, "pqtest_PQexec: PQparray could not find portal %s", + res); + + t = PQntuples(a); + break; + case 'C': + break; + default: + elog(NOTICE, "pqtest_PQexec: PQexec(%s) returns %s", q, res); + break; } return t; @@ -230,10 +230,10 @@ pqtest_PQexec(char *q) * utilities for pqtest_PQfn() * ---------------- */ -static char * +static char * strmake(char *str, int len) { - char *newstr; + char *newstr; if (str == NULL) return NULL; @@ -249,18 +249,18 @@ strmake(char *str, int len) #define SKIP 0 #define SCAN 1 -static char spacestr[] = " "; +static char spacestr[] = " "; static int strparse(char *s, char **fields, int *offsets, int maxfields) { - int len = strlen(s); - char *cp = s, - *end = cp + len, - *ep; - int parsed = 0; - int mode = SKIP, - i = 0; + int len = strlen(s); + char *cp = s, + *end = cp + len, + *ep; + int parsed = 0; + int mode = SKIP, + i = 0; if (*(end - 1) == '\n') end--; @@ -318,16 +318,16 @@ strparse(char *s, char **fields, int *offsets, int maxfields) int pqtest_PQfn(char *q) { - int k, - j, - i, - v, - f, - offsets; - char *fields[8]; - PQArgBlock pqargs[7]; - int res; - char *pqres; + int k, + j, + i, + v, + f, + offsets; + char *fields[8]; + PQArgBlock pqargs[7]; + int res; + char *pqres; /* ---------------- * parse q into fields @@ -403,7 +403,7 @@ pqtest_PQfn(char *q) int32 pqtest(struct varlena * vlena) { - char *q; + char *q; /* ---------------- * get the query @@ -415,12 +415,12 @@ pqtest(struct varlena * vlena) switch (q[0]) { - case '%': - return pqtest_PQfn(&q[1]); - break; - default: - return pqtest_PQexec(q); - break; + case '%': + return pqtest_PQfn(&q[1]); + break; + default: + return pqtest_PQexec(q); + break; } return (0); } diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 014eca14fa3..8e1a0753b22 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.20 1997/09/07 04:42:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.21 1997/09/08 02:23:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ /* Some standard C libraries, including GNU, have an isblank() function. Others, including Solaris, do not. So we have our own. */ -static bool +static bool isblank(const char c) { return (c == ' ' || c == 9 /* tab */ ); @@ -53,8 +53,8 @@ next_token(FILE * fp, char *buf, const int bufsz) string as *buf and position file to beginning of next line or EOF, whichever comes first. --------------------------------------------------------------------------*/ - int c; - char *eb = buf + (bufsz - 1); + int c; + char *eb = buf + (bufsz - 1); /* Move over inital token-delimiting blanks */ while (isblank(c = getc(fp))); @@ -87,7 +87,7 @@ next_token(FILE * fp, char *buf, const int bufsz) static void read_through_eol(FILE * file) { - int c; + int c; do c = getc(file); @@ -105,9 +105,9 @@ read_hba_entry2(FILE * file, enum Userauth * userauth_p, char usermap_name[], and return the interpretation of it as *userauth_p, usermap_name, and *error_p. ---------------------------------------------------------------------------*/ - char buf[MAX_TOKEN]; + char buf[MAX_TOKEN]; - bool userauth_valid; + bool userauth_valid; /* Get authentication type token. */ next_token(file, buf, sizeof(buf)); @@ -197,7 +197,7 @@ process_hba_record(FILE * file, return *error_p true, after issuing a message to stderr. If no error, leave *error_p as it was. ---------------------------------------------------------------------------*/ - char buf[MAX_TOKEN]; /* A token from the record */ + char buf[MAX_TOKEN]; /* A token from the record */ /* Read the record type field */ next_token(file, buf, sizeof(buf)); @@ -233,14 +233,14 @@ process_hba_record(FILE * file, *matches_p = false; else { - int valid; /* Field is valid dotted + int valid; /* Field is valid dotted * decimal */ /* * Remember the IP address field and go get mask * field */ - struct in_addr file_ip_addr; /* IP address field + struct in_addr file_ip_addr; /* IP address field * value */ valid = inet_aton(buf, &file_ip_addr); @@ -257,7 +257,7 @@ process_hba_record(FILE * file, *matches_p = false; else { - struct in_addr mask; + struct in_addr mask; /* * Got mask. Now see if this record is @@ -320,13 +320,13 @@ process_open_config_file(FILE * file, This function does the same thing as find_hba_entry, only with the config file already open on stream descriptor "file". ----------------------------------------------------------------------------*/ - bool found_entry; + bool found_entry; /* We've processed a record that applies to our connection */ - bool error; + bool error; /* Said record has invalid syntax. */ - bool eof; /* We've reached the end of the file we're + bool eof; /* We've reached the end of the file we're * reading */ found_entry = false; /* initial value */ @@ -336,7 +336,7 @@ process_open_config_file(FILE * file, { /* Process a line from the config file */ - int c; /* a character read from the file */ + int c; /* a character read from the file */ c = getc(file); ungetc(c, file); @@ -392,11 +392,11 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr, system. ---------------------------------------------------------------------------*/ - int fd; + int fd; - FILE *file; /* The config file we have to read */ + FILE *file; /* The config file we have to read */ - char *old_conf_file; + char *old_conf_file; /* The name of old config file that better not exist. */ @@ -423,8 +423,8 @@ find_hba_entry(const char DataDir[], const struct in_addr ip_addr, } else { - char *conf_file; /* The name of the config file we - * have to read */ + char *conf_file; /* The name of the config file we have to + * read */ /* put together the full pathname to the config file */ conf_file = (char *) malloc((strlen(DataDir) + @@ -469,7 +469,7 @@ interpret_ident_response(char ident_response[], *error_p == false and the username as ident_username[]. If it's anything else, return *error_p == true and ident_username[] undefined. ----------------------------------------------------------------------------*/ - char *cursor; /* Cursor into ident_response[] */ + char *cursor; /* Cursor into ident_response[] */ cursor = &ident_response[0]; @@ -491,8 +491,8 @@ interpret_ident_response(char ident_response[], else { /* We're positioned to colon before response type field */ - char response_type[80]; - int i; /* Index into response_type[] */ + char response_type[80]; + int i; /* Index into response_type[] */ cursor++; /* Go over colon */ while (isblank(*cursor)) @@ -526,8 +526,7 @@ interpret_ident_response(char ident_response[], *error_p = true; else { - int i; /* Index into - * ident_username[] */ + int i; /* Index into ident_username[] */ cursor++; /* Go over colon */ while (isblank(*cursor)) @@ -564,11 +563,11 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, *ident_failed == true (and ident_username[] undefined). ----------------------------------------------------------------------------*/ - int sock_fd; + int sock_fd; /* File descriptor for socket on which we talk to Ident */ - int rc; /* Return code from a locally called + int rc; /* Return code from a locally called * function */ sock_fd = socket(AF_INET, SOCK_STREAM, IPPROTO_IP); @@ -608,7 +607,7 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, } else { - char ident_query[80]; + char ident_query[80]; /* The query we send to the Ident server */ sprintf(ident_query, "%d,%d\n", @@ -628,7 +627,7 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, } else { - char ident_response[80 + IDENT_USERNAME_MAX]; + char ident_response[80 + IDENT_USERNAME_MAX]; rc = recv(sock_fd, ident_response, sizeof(ident_response) - 1, 0); if (rc < 0) @@ -647,8 +646,7 @@ ident(const struct in_addr remote_ip_addr, const struct in_addr local_ip_addr, } else { - bool error; /* response from Ident is - * garbage. */ + bool error; /* response from Ident is garbage. */ ident_response[rc] = '\0'; interpret_ident_response(ident_response, &error, ident_username); @@ -674,7 +672,7 @@ parse_map_record(FILE * file, ones. ---------------------------------------------------------------------------*/ - char buf[MAX_TOKEN]; + char buf[MAX_TOKEN]; /* A token read from the file */ @@ -714,9 +712,9 @@ verify_against_open_usermap(FILE * file, This function does the same thing as verify_against_usermap, only with the config file already open on stream descriptor "file". ---------------------------------------------------------------------------*/ - bool match; /* We found a matching entry in the map + bool match; /* We found a matching entry in the map * file */ - bool eof; /* We've reached the end of the file we're + bool eof; /* We've reached the end of the file we're * reading */ match = false; /* initial value */ @@ -725,7 +723,7 @@ verify_against_open_usermap(FILE * file, { /* Process a line from the map file */ - int c; /* a character read from the file */ + int c; /* a character read from the file */ c = getc(file); ungetc(c, file); @@ -738,9 +736,9 @@ verify_against_open_usermap(FILE * file, else { /* The following are fields read from a record of the file */ - char file_map[MAX_TOKEN + 1]; - char file_pguser[MAX_TOKEN + 1]; - char file_iuser[MAX_TOKEN + 1]; + char file_map[MAX_TOKEN + 1]; + char file_pguser[MAX_TOKEN + 1]; + char file_iuser[MAX_TOKEN + 1]; parse_map_record(file, file_map, file_pguser, file_iuser); if (strcmp(file_map, usermap_name) == 0 && @@ -795,10 +793,10 @@ verify_against_usermap(const char DataDir[], } else { - FILE *file; /* The map file we have to read */ + FILE *file; /* The map file we have to read */ - char *map_file; /* The name of the map file we - * have to read */ + char *map_file; /* The name of the map file we have to + * read */ /* put together the full pathname to the map file */ map_file = (char *) malloc((strlen(DataDir) + @@ -850,10 +848,10 @@ authident(const char DataDir[], Return *authentic_p true iff yes. ---------------------------------------------------------------------------*/ - bool ident_failed; + bool ident_failed; /* We were unable to get ident to give us a username */ - char ident_username[IDENT_USERNAME_MAX + 1]; + char ident_username[IDENT_USERNAME_MAX + 1]; /* The username returned by ident */ @@ -865,7 +863,7 @@ authident(const char DataDir[], *authentic_p = false; else { - bool checks_out; + bool checks_out; verify_against_usermap(DataDir, postgres_username, ident_username, usermap_name, @@ -888,25 +886,25 @@ hba_recvauth(const Port * port, const char database[], const char user[], allowed to act as user "user" and access database "database". Return STATUS_OK if yes; STATUS_ERROR if not. ----------------------------------------------------------------------------*/ - bool host_ok; + bool host_ok; /* * There's an entry for this database and remote host in the pg_hba * file */ - char usermap_name[USERMAP_NAME_SIZE + 1]; + char usermap_name[USERMAP_NAME_SIZE + 1]; /* * The name of the map pg_hba specifies for this connection (or * special value "SAMEUSER") */ - enum Userauth userauth; + enum Userauth userauth; /* * The type of user authentication pg_hba specifies for this * connection */ - int retvalue; + int retvalue; /* Our eventual return value */ @@ -922,31 +920,31 @@ hba_recvauth(const Port * port, const char database[], const char user[], { switch (userauth) { - case Trust: - retvalue = STATUS_OK; - break; - case Ident: - { + case Trust: + retvalue = STATUS_OK; + break; + case Ident: + { - /* - * Here's where we need to call up ident and authenticate - * the user - */ + /* + * Here's where we need to call up ident and + * authenticate the user + */ - bool authentic; /* He is who he says he + bool authentic; /* He is who he says he * is. */ - authident(DataDir, *port, user, usermap_name, &authentic); + authident(DataDir, *port, user, usermap_name, &authentic); - if (authentic) - retvalue = STATUS_OK; - else - retvalue = STATUS_ERROR; - } - break; - default: - retvalue = STATUS_ERROR; - Assert(false); + if (authentic) + retvalue = STATUS_OK; + else + retvalue = STATUS_ERROR; + } + break; + default: + retvalue = STATUS_ERROR; + Assert(false); } } return (retvalue); diff --git a/src/backend/libpq/password.c b/src/backend/libpq/password.c index 1efc2e668a3..2553878fc5a 100644 --- a/src/backend/libpq/password.c +++ b/src/backend/libpq/password.c @@ -13,18 +13,18 @@ int verify_password(char *user, char *password, Port * port, char *database, char *DataDir) { - bool host_ok; - enum Userauth userauth; - char pw_file_name[PWFILE_NAME_SIZE + 1]; - - char *pw_file_fullname; - FILE *pw_file; - - char pw_file_line[255]; - char *p, - *test_user, - *test_pw; - char salt[3]; + bool host_ok; + enum Userauth userauth; + char pw_file_name[PWFILE_NAME_SIZE + 1]; + + char *pw_file_fullname; + FILE *pw_file; + + char pw_file_line[255]; + char *p, + *test_user, + *test_pw; + char salt[3]; find_hba_entry(DataDir, port->raddr.sin_addr, database, &host_ok, &userauth, pw_file_name, true); diff --git a/src/backend/libpq/portal.c b/src/backend/libpq/portal.c index c3c8fe55e38..2d213a1f24e 100644 --- a/src/backend/libpq/portal.c +++ b/src/backend/libpq/portal.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.7 1997/09/07 04:42:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portal.c,v 1.8 1997/09/08 02:23:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -111,8 +111,8 @@ valid_pointer(char *msg, void *ptr) int PQnportals(int rule_p) { - int i, - n = 0; + int i, + n = 0; for (i = 0; i < portals_array_size; ++i) { @@ -142,8 +142,8 @@ PQnportals(int rule_p) void PQpnames(char **pnames, int rule_p) { - int i, - cur_pname = 0; + int i, + cur_pname = 0; if (!valid_pointer("PQpnames: invalid name buffer", pnames)) return; @@ -165,10 +165,10 @@ PQpnames(char **pnames, int rule_p) * PQparray - Return the portal buffer given a portal name * -------------------------------- */ -PortalBuffer * +PortalBuffer * PQparray(char *pname) { - int i; + int i; if (!valid_pointer("PQparray: invalid name buffer", pname)) return NULL; @@ -230,7 +230,7 @@ PQngroups(PortalBuffer * portal) int PQntuplesGroup(PortalBuffer * portal, int group_index) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQntuplesGroup: invalid portal pointer", portal) || !in_range("PQntuplesGroup: group index", @@ -256,7 +256,7 @@ PQninstancesGroup(PortalBuffer * portal, int group_index) int PQnfieldsGroup(PortalBuffer * portal, int group_index) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQnfieldsGroup: invalid portal pointer", portal) || !in_range("PQnfieldsGroup: group index", @@ -276,7 +276,7 @@ PQnfieldsGroup(PortalBuffer * portal, int group_index) int PQfnumberGroup(PortalBuffer * portal, int group_index, char *field_name) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfnumberGroup: invalid portal pointer", portal) || !valid_pointer("PQfnumberGroup: invalid field name pointer", @@ -295,10 +295,10 @@ PQfnumberGroup(PortalBuffer * portal, int group_index, char *field_name) * the group index and field index. * -------------------------------- */ -char * +char * PQfnameGroup(PortalBuffer * portal, int group_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfnameGroup: invalid portal pointer", portal) || !in_range("PQfnameGroup: group index", @@ -320,7 +320,7 @@ PQfnameGroup(PortalBuffer * portal, int group_index, int field_number) int PQftypeGroup(PortalBuffer * portal, int group_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQftypeGroup: invalid portal pointer", portal) || !in_range("PQftypeGroup: group index", @@ -341,7 +341,7 @@ PQftypeGroup(PortalBuffer * portal, int group_index, int field_number) int PQfsizeGroup(PortalBuffer * portal, int group_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfsizeGroup: invalid portal pointer", portal) || !in_range("PQfsizeGroup: tuple index", @@ -359,11 +359,11 @@ PQfsizeGroup(PortalBuffer * portal, int group_index, int field_number) * PQgroup - Return the tuple group that a particular tuple is in * -------------------------------- */ -GroupBuffer * +GroupBuffer * PQgroup(PortalBuffer * portal, int tuple_index) { - GroupBuffer *gbp; - int tuple_count = 0; + GroupBuffer *gbp; + int tuple_count = 0; if (!valid_pointer("PQgroup: invalid portal pointer", portal) || !in_range("PQgroup: tuple index", @@ -388,9 +388,9 @@ PQgroup(PortalBuffer * portal, int tuple_index) int PQgetgroup(PortalBuffer * portal, int tuple_index) { - GroupBuffer *gbp; - int tuple_count = 0, - group_count = 0; + GroupBuffer *gbp; + int tuple_count = 0, + group_count = 0; if (!valid_pointer("PQgetgroup: invalid portal pointer", portal) || !in_range("PQgetgroup: tuple index", @@ -414,7 +414,7 @@ PQgetgroup(PortalBuffer * portal, int tuple_index) int PQnfields(PortalBuffer * portal, int tuple_index) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQnfields: invalid portal pointer", portal) || !in_range("PQnfields: tuple index", @@ -434,7 +434,7 @@ PQnfields(PortalBuffer * portal, int tuple_index) int PQfnumber(PortalBuffer * portal, int tuple_index, char *field_name) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfnumber: invalid portal pointer", portal) || !valid_pointer("PQfnumber: invalid field name pointer", field_name) || @@ -451,10 +451,10 @@ PQfnumber(PortalBuffer * portal, int tuple_index, char *field_name) * PQfname - Return the name of a field * -------------------------------- */ -char * +char * PQfname(PortalBuffer * portal, int tuple_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfname: invalid portal pointer", portal) || !in_range("PQfname: tuple index", @@ -475,7 +475,7 @@ PQfname(PortalBuffer * portal, int tuple_index, int field_number) int PQftype(PortalBuffer * portal, int tuple_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQftype: invalid portal pointer", portal) || !in_range("PQfname: tuple index", @@ -495,7 +495,7 @@ PQftype(PortalBuffer * portal, int tuple_index, int field_number) int PQfsize(PortalBuffer * portal, int tuple_index, int field_number) { - GroupBuffer *gbp; + GroupBuffer *gbp; if (!valid_pointer("PQfsize: invalid portal pointer", portal) || !in_range("PQfsize: tuple index", @@ -518,8 +518,8 @@ PQfsize(PortalBuffer * portal, int tuple_index, int field_number) int PQsametype(PortalBuffer * portal, int tuple_index1, int tuple_index2) { - GroupBuffer *gbp1, - *gbp2; + GroupBuffer *gbp1, + *gbp2; if (!valid_pointer("PQsametype: invalid portal pointer", portal) || !in_range("PQsametype: tuple index 1", @@ -540,9 +540,9 @@ PQGetTupleBlock(PortalBuffer * portal, int tuple_index, int *tuple_offset) { - GroupBuffer *gbp; - TupleBlock *tbp; - int tuple_count = 0; + GroupBuffer *gbp; + TupleBlock *tbp; + int tuple_count = 0; if (!valid_pointer("PQGetTupleBlock: invalid portal pointer", portal) || !valid_pointer("PQGetTupleBlock: invalid offset pointer", @@ -578,13 +578,13 @@ PQGetTupleBlock(PortalBuffer * portal, * PQgetvalue - Return an attribute (field) value * -------------------------------- */ -char * +char * PQgetvalue(PortalBuffer * portal, int tuple_index, int field_number) { - TupleBlock *tbp; - int tuple_offset; + TupleBlock *tbp; + int tuple_offset; tbp = PQGetTupleBlock(portal, tuple_index, &tuple_offset); if (tbp) @@ -598,15 +598,15 @@ PQgetvalue(PortalBuffer * portal, * a copy. The CALLER is responsible for free'ing the data returned. * -------------------------------- */ -char * +char * PQgetAttr(PortalBuffer * portal, int tuple_index, int field_number) { - TupleBlock *tbp; - int tuple_offset; - int len; - char *result = NULL; + TupleBlock *tbp; + int tuple_offset; + int len; + char *result = NULL; tbp = PQGetTupleBlock(portal, tuple_index, &tuple_offset); if (tbp) @@ -631,8 +631,8 @@ PQgetlength(PortalBuffer * portal, int tuple_index, int field_number) { - TupleBlock *tbp; - int tuple_offset; + TupleBlock *tbp; + int tuple_offset; tbp = PQGetTupleBlock(portal, tuple_index, &tuple_offset); if (tbp) @@ -657,15 +657,15 @@ PQclear(char *pname) * This is going away with pending rewrite of comm. code... */ /* static SLList pqNotifyList;*/ -static Dllist *pqNotifyList = NULL; +static Dllist *pqNotifyList = NULL; /* remove invalid notifies before returning */ void PQcleanNotify() { - Dlelem *e, - *next; - PQNotifyList *p; + Dlelem *e, + *next; + PQNotifyList *p; e = DLGetHead(pqNotifyList); @@ -686,8 +686,8 @@ PQcleanNotify() void PQnotifies_init() { - Dlelem *e; - PQNotifyList *p; + Dlelem *e; + PQNotifyList *p; if (pqNotifyList == NULL) { @@ -705,10 +705,10 @@ PQnotifies_init() } } -PQNotifyList * +PQNotifyList * PQnotifies() { - Dlelem *e; + Dlelem *e; PQcleanNotify(); e = DLGetHead(pqNotifyList); @@ -724,7 +724,7 @@ PQremoveNotify(PQNotifyList * nPtr) void PQappendNotify(char *relname, int pid) { - PQNotifyList *p; + PQNotifyList *p; if (pqNotifyList == NULL) pqNotifyList = DLNewList(); diff --git a/src/backend/libpq/portalbuf.c b/src/backend/libpq/portalbuf.c index ed2d5bbe615..71db1d1e761 100644 --- a/src/backend/libpq/portalbuf.c +++ b/src/backend/libpq/portalbuf.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.5 1997/09/07 04:42:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/portalbuf.c,v 1.6 1997/09/08 02:23:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,8 +55,8 @@ #include <libpq/libpq.h> /* where the declarations go */ #include <utils/exc.h> -PortalEntry **portals = (PortalEntry **) NULL; -size_t portals_array_size = 0; +PortalEntry **portals = (PortalEntry **) NULL; +size_t portals_array_size = 0; /* portals array memory is malloc'd instead of using MemoryContexts */ /* since it will be used by both front and backend programs*/ @@ -72,9 +72,9 @@ size_t portals_array_size = 0; static void portals_realloc(size_t size) { - size_t oldsize; - int i; - PortalEntry **newp; + size_t oldsize; + int i; + PortalEntry **newp; oldsize = portals_array_size; @@ -106,7 +106,7 @@ portals_realloc(size_t size) caddr_t pbuf_alloc(size_t size) { - caddr_t addr; + caddr_t addr; if (size <= 0) libpq_raise(&MemoryError, form("Invalid argument to pbuf_alloc().")); @@ -139,10 +139,10 @@ pbuf_free(caddr_t pointer) * pbuf_addPortal - Allocate a new portal buffer * -------------------------------- */ -PortalBuffer * +PortalBuffer * pbuf_addPortal() { - PortalBuffer *portal; + PortalBuffer *portal; portal = (PortalBuffer *) pbuf_alloc(sizeof(PortalBuffer)); @@ -159,11 +159,11 @@ pbuf_addPortal() * pbuf_addGroup - Add a new tuple group to the portal * -------------------------------- */ -GroupBuffer * +GroupBuffer * pbuf_addGroup(PortalBuffer * portal) { - GroupBuffer *group, - *group1; + GroupBuffer *group, + *group1; group = (GroupBuffer *) pbuf_alloc(sizeof(GroupBuffer)); @@ -191,10 +191,10 @@ pbuf_addGroup(PortalBuffer * portal) * pbuf_addTypes - Allocate n type blocks * -------------------------------- */ -TypeBlock * +TypeBlock * pbuf_addTypes(int n) { - TypeBlock *types; + TypeBlock *types; types = (TypeBlock *) pbuf_alloc(n * sizeof(TypeBlock)); @@ -206,10 +206,10 @@ pbuf_addTypes(int n) * pbuf_addTuples - Allocate a tuple block * -------------------------------- */ -TupleBlock * +TupleBlock * pbuf_addTuples() { - TupleBlock *tuples; + TupleBlock *tuples; tuples = (TupleBlock *) pbuf_alloc(sizeof(TupleBlock)); @@ -224,7 +224,7 @@ pbuf_addTuples() * pbuf_addTuple - Allocate a tuple of n fields (attributes) * -------------------------------- */ -char ** +char ** pbuf_addTuple(int n) { return (char **) @@ -235,7 +235,7 @@ pbuf_addTuple(int n) * pbuf_addTupleValueLengths - Allocate a tuple of n lengths (attributes) * -------------------------------- */ -int * +int * pbuf_addTupleValueLengths(int n) { return (int *) @@ -246,7 +246,7 @@ pbuf_addTupleValueLengths(int n) * pbuf_addValues - Allocate n bytes for a value * -------------------------------- */ -char * +char * pbuf_addValues(int n) { return @@ -257,7 +257,7 @@ pbuf_addValues(int n) * pbuf_addEntry - Allocate a portal entry * -------------------------------- */ -PortalEntry * +PortalEntry * pbuf_addEntry() { return (PortalEntry *) @@ -299,8 +299,8 @@ pbuf_freeTuples(TupleBlock * tuples, int no_tuples, int no_fields) { - int i, - j; + int i, + j; if (no_tuples > TupleBlockSize) { @@ -363,7 +363,7 @@ pbuf_freePortal(PortalBuffer * portal) int pbuf_getIndex(char *pname) { - int i; + int i; if (portals) { @@ -391,10 +391,10 @@ pbuf_setportalinfo(PortalEntry * entry, char *pname) * pbuf_setup - Set up a portal for dumping data * -------------------------------- */ -PortalEntry * +PortalEntry * pbuf_setup(char *pname) { - int i; + int i; if (!portals) /* the portals array has not been * allocated yet */ @@ -435,7 +435,7 @@ pbuf_setup(char *pname) void pbuf_close(char *pname) { - int i; + int i; if ((i = pbuf_getIndex(pname)) == -1) libpq_raise(&PortalError, form("Portal %s does not exist.", pname)); @@ -448,11 +448,11 @@ pbuf_close(char *pname) * pbuf_findGroup - Return the group given the group_index * -------------------------------- */ -GroupBuffer * +GroupBuffer * pbuf_findGroup(PortalBuffer * portal, int group_index) { - GroupBuffer *group; + GroupBuffer *group; group = portal->groups; while (group_index > 0 && group != NULL) @@ -476,8 +476,8 @@ int pbuf_findFnumber(GroupBuffer * group, char *field_name) { - TypeBlock *types; - int i; + TypeBlock *types; + int i; types = group->types; @@ -510,7 +510,7 @@ pbuf_checkFnumber(GroupBuffer * group, * pbuf_findFname - Find the field name given the field index * -------------------------------- */ -char * +char * pbuf_findFname(GroupBuffer * group, int field_number) { diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index 6a7df5771ac..93e8fa81af2 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.20 1997/09/07 04:42:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/pqcomm.c,v 1.21 1997/09/08 02:23:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,10 +63,10 @@ * declarations * ---------------- */ -FILE *Pfout, - *Pfin; -FILE *Pfdebug; /* debugging libpq */ -int PQAsyncNotifyWaiting; /* for async. notification */ +FILE *Pfout, + *Pfin; +FILE *Pfdebug; /* debugging libpq */ +int PQAsyncNotifyWaiting; /* for async. notification */ /* -------------------------------- * pq_init - open portal file descriptors @@ -102,7 +102,7 @@ pq_init(int fd) static int pq_getc(FILE * fin) { - int c; + int c; c = getc(fin); if (Pfdebug && c != EOF) @@ -127,7 +127,7 @@ pq_gettty(char *tp) int pq_getport() { - char *envport = getenv("PGPORT"); + char *envport = getenv("PGPORT"); if (envport) return (atoi(envport)); @@ -174,7 +174,7 @@ pq_flush() int pq_getstr(char *s, int maxlen) { - int c = '\0'; + int c = '\0'; if (Pfin == (FILE *) NULL) { @@ -268,7 +268,7 @@ pq_getnchar(char *s, int off, int maxlen) return pqGetNBytes(s + off, maxlen, Pfin); #if 0 - int c = '\0'; + int c = '\0'; if (Pfin == (FILE *) NULL) { @@ -300,8 +300,8 @@ pq_getnchar(char *s, int off, int maxlen) int pq_getint(int b) { - int n, - status = 1; + int n, + status = 1; if (!Pfin) return EOF; @@ -313,17 +313,17 @@ pq_getint(int b) switch (b) { - case 1: - status = ((n = fgetc(Pfin)) == EOF); - break; - case 2: - status = pqGetShort(&n, Pfin); - break; - case 4: - status = pqGetLong(&n, Pfin); - break; - default: - fprintf(stderr, "** Unsupported size %d\n", b); + case 1: + status = ((n = fgetc(Pfin)) == EOF); + break; + case 2: + status = pqGetShort(&n, Pfin); + break; + case 4: + status = pqGetLong(&n, Pfin); + break; + default: + fprintf(stderr, "** Unsupported size %d\n", b); } if (status) @@ -381,7 +381,7 @@ pq_putnchar(char *s, int n) void pq_putint(int i, int b) { - int status; + int status; if (!Pfout) return; @@ -389,17 +389,17 @@ pq_putint(int i, int b) status = 1; switch (b) { - case 1: - status = (fputc(i, Pfout) == EOF); - break; - case 2: - status = pqPutShort(i, Pfout); - break; - case 4: - status = pqPutLong(i, Pfout); - break; - default: - fprintf(stderr, "** Unsupported size %d\n", b); + case 1: + status = (fputc(i, Pfout) == EOF); + break; + case 2: + status = pqPutShort(i, Pfout); + break; + case 4: + status = pqPutLong(i, Pfout); + break; + default: + fprintf(stderr, "** Unsupported size %d\n", b); } if (status) @@ -421,7 +421,7 @@ pq_putint(int i, int b) int pq_sendoob(char *msg, int len) { - int fd = fileno(Pfout); + int fd = fileno(Pfout); return (send(fd, msg, len, MSG_OOB)); } @@ -429,8 +429,8 @@ pq_sendoob(char *msg, int len) int pq_recvoob(char *msgPtr, int *lenPtr) { - int fd = fileno(Pfout); - int len = 0; + int fd = fileno(Pfout); + int len = 0; len = recv(fd, msgPtr + len, *lenPtr, MSG_OOB); *lenPtr = len; @@ -510,7 +510,7 @@ pq_getinserv(struct sockaddr_in * sin, char *host, char *serv) void pq_regoob(void (*fptr) ()) { - int fd = fileno(Pfout); + int fd = fileno(Pfout); #if defined(hpux) ioctl(fd, FIOSSAIOOWN, getpid()); @@ -532,10 +532,10 @@ pq_unregoob() void pq_async_notify() { - char msg[20]; + char msg[20]; /* int len = sizeof(msg); */ - int len = 20; + int len = 20; if (pq_recvoob(msg, &len) >= 0) { @@ -546,7 +546,7 @@ pq_async_notify() } else { - extern int errno; + extern int errno; printf("SIGURG but no data: len = %d, err=%d\n", len, errno); } @@ -575,8 +575,8 @@ int StreamServerPort(char *hostName, short portName, int *fdP) { struct sockaddr_in sin; - int fd; - int one = 1; + int fd; + int one = 1; if (!hostName) @@ -645,7 +645,7 @@ StreamServerPort(char *hostName, short portName, int *fdP) int StreamConnection(int server_fd, Port * port) { - int addrlen; + int addrlen; /* accept connection (and fill in the client (remote) address) */ addrlen = sizeof(struct sockaddr_in); @@ -667,7 +667,7 @@ StreamConnection(int server_fd, Port * port) } { struct protoent *pe; - int on = 1; + int on = 1; pe = getprotobyname("TCP"); if (pe == NULL) @@ -715,8 +715,8 @@ int StreamOpen(char *hostName, short portName, Port * port) { struct hostent *hp; - int laddrlen = sizeof(struct sockaddr_in); - extern int errno; + int laddrlen = sizeof(struct sockaddr_in); + extern int errno; if (!hostName) hostName = "localhost"; @@ -774,7 +774,7 @@ StreamOpen(char *hostName, short portName, Port * port) return (STATUS_OK); } -static char *authentication_type_name[] = { +static char *authentication_type_name[] = { 0, 0, 0, 0, 0, 0, 0, "the default authentication type", 0, 0, @@ -785,10 +785,10 @@ static char *authentication_type_name[] = { "plaintext password authentication" }; -char * +char * name_of_authentication_type(int type) { - char *result = 0; + char *result = 0; if (type >= 1 && type <= LAST_AUTHENTICATION_TYPE) { diff --git a/src/backend/libpq/pqcomprim.c b/src/backend/libpq/pqcomprim.c index 8675205d784..d6bdf6f13bb 100644 --- a/src/backend/libpq/pqcomprim.c +++ b/src/backend/libpq/pqcomprim.c @@ -48,9 +48,9 @@ int pqPutShort(int integer, FILE * f) { - int retval = 0; - u_short n, - s; + int retval = 0; + u_short n, + s; s = integer; n = hton_s(s); @@ -64,8 +64,8 @@ pqPutShort(int integer, FILE * f) int pqPutLong(int integer, FILE * f) { - int retval = 0; - u_long n; + int retval = 0; + u_long n; n = hton_l(integer); if (fwrite(&n, sizeof(u_long), 1, f) != 1) @@ -78,8 +78,8 @@ pqPutLong(int integer, FILE * f) int pqGetShort(int *result, FILE * f) { - int retval = 0; - u_short n; + int retval = 0; + u_short n; if (fread(&n, sizeof(u_short), 1, f) != 1) retval = EOF; @@ -92,8 +92,8 @@ pqGetShort(int *result, FILE * f) int pqGetLong(int *result, FILE * f) { - int retval = 0; - u_long n; + int retval = 0; + u_long n; if (fread(&n, sizeof(u_long), 1, f) != 1) retval = EOF; @@ -109,7 +109,7 @@ pqGetLong(int *result, FILE * f) int pqGetNBytes(char *s, size_t len, FILE * f) { - int cnt; + int cnt; if (f == NULL) return EOF; @@ -138,7 +138,7 @@ pqPutNBytes(const char *s, size_t len, FILE * f) int pqGetString(char *s, size_t len, FILE * f) { - int c; + int c; if (f == NULL) return EOF; diff --git a/src/backend/libpq/pqpacket.c b/src/backend/libpq/pqpacket.c index 9f56556537f..fb1f2fbb481 100644 --- a/src/backend/libpq/pqpacket.c +++ b/src/backend/libpq/pqpacket.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.6 1997/09/07 04:42:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/pqpacket.c,v 1.7 1997/09/08 02:23:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,14 +61,14 @@ PacketReceive(Port * port, /* receive port */ PacketBuf * buf, /* MAX_PACKET_SIZE-worth of buffer space */ bool nonBlocking) /* NON_BLOCKING or BLOCKING i/o */ { - PacketLen max_size = sizeof(PacketBuf); - PacketLen cc; /* character count -- bytes recvd */ - PacketLen packetLen; /* remaining packet chars to read */ - Addr tmp; /* curr recv buf pointer */ - int addrLen = sizeof(struct sockaddr_in); - int hdrLen; - int flag; - int decr; + PacketLen max_size = sizeof(PacketBuf); + PacketLen cc; /* character count -- bytes recvd */ + PacketLen packetLen; /* remaining packet chars to read */ + Addr tmp; /* curr recv buf pointer */ + int addrLen = sizeof(struct sockaddr_in); + int hdrLen; + int flag; + int decr; hdrLen = sizeof(buf->len); @@ -224,8 +224,8 @@ PacketSend(Port * port, PacketLen len, bool nonBlocking) { - PacketLen totalLen; - int addrLen = sizeof(struct sockaddr_in); + PacketLen totalLen; + int addrLen = sizeof(struct sockaddr_in); Assert(!nonBlocking); Assert(buf); diff --git a/src/backend/libpq/pqsignal.c b/src/backend/libpq/pqsignal.c index 727a2a7207d..32abbe0a8e0 100644 --- a/src/backend/libpq/pqsignal.c +++ b/src/backend/libpq/pqsignal.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.6 1997/09/07 04:42:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/pqsignal.c,v 1.7 1997/09/08 02:23:19 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -50,7 +50,7 @@ pqsignal(int signo, pqsigfunc func) return signal(signo, func); #else struct sigaction act, - oact; + oact; act.sa_handler = func; sigemptyset(&act.sa_mask); diff --git a/src/backend/libpq/util.c b/src/backend/libpq/util.c index f4efec13f3a..4d573d89d3b 100644 --- a/src/backend/libpq/util.c +++ b/src/backend/libpq/util.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.4 1997/09/07 04:42:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/Attic/util.c,v 1.5 1997/09/08 02:23:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,14 +32,14 @@ * exceptions * ---------------- */ -Exception MemoryError = {"Memory Allocation Error"}; -Exception PortalError = {"Invalid arguments to portal functions"}; -Exception PostquelError = {"Sql Error"}; -Exception ProtocolError = {"Protocol Error"}; -char PQerrormsg[ERROR_MSG_LENGTH]; +Exception MemoryError = {"Memory Allocation Error"}; +Exception PortalError = {"Invalid arguments to portal functions"}; +Exception PostquelError = {"Sql Error"}; +Exception ProtocolError = {"Protocol Error"}; +char PQerrormsg[ERROR_MSG_LENGTH]; -int PQtracep = 0; /* 1 to print out debugging messages */ -FILE *debug_port = (FILE *) NULL; +int PQtracep = 0; /* 1 to print out debugging messages */ +FILE *debug_port = (FILE *) NULL; /* ---------------------------------------------------------------- * PQ utility routines diff --git a/src/backend/main/main.c b/src/backend/main/main.c index b70be2a08c4..2670f2c6ee7 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.8 1997/09/07 04:42:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.9 1997/09/08 02:23:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ echo \"postmaster -B 256 >/var/log/pglog 2>&1 &\" | su - postgres\n\n" int main(int argc, char *argv[]) { - int len; + int len; #ifdef USE_LOCALE setlocale(LC_CTYPE, ""); /* take locale information from an diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index caf9e176ef3..d710ab711c6 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.7 1997/09/07 04:42:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.8 1997/09/08 02:23:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,12 +36,12 @@ * this copy function only copies the "lcons-cells" of the list but not * its contents. (good for list of pointers as well as list of integers). */ -List * +List * listCopy(List * list) { - List *newlist = NIL; - List *l, - *nl = NIL; + List *newlist = NIL; + List *l, + *nl = NIL; foreach(l, list) { @@ -94,10 +94,10 @@ CopyPlanFields(Plan * from, Plan * newnode) * _copyPlan * ---------------- */ -static Plan * +static Plan * _copyPlan(Plan * from) { - Plan *newnode = makeNode(Plan); + Plan *newnode = makeNode(Plan); /* ---------------- * copy the node superclass fields @@ -116,7 +116,7 @@ _copyPlan(Plan * from) static Existential * _copyExistential(Existential * from) { - Existential *newnode = makeNode(Existential); + Existential *newnode = makeNode(Existential); /* ---------------- * copy node superclass fields @@ -131,10 +131,10 @@ _copyExistential(Existential * from) * _copyResult * ---------------- */ -static Result * +static Result * _copyResult(Result * from) { - Result *newnode = makeNode(Result); + Result *newnode = makeNode(Result); /* ---------------- * copy node superclass fields @@ -156,10 +156,10 @@ _copyResult(Result * from) * _copyAppend * ---------------- */ -static Append * +static Append * _copyAppend(Append * from) { - Append *newnode = makeNode(Append); + Append *newnode = makeNode(Append); /* ---------------- * copy node superclass fields @@ -199,10 +199,10 @@ CopyScanFields(Scan * from, Scan * newnode) * _copyScan * ---------------- */ -static Scan * +static Scan * _copyScan(Scan * from) { - Scan *newnode = makeNode(Scan); + Scan *newnode = makeNode(Scan); /* ---------------- * copy node superclass fields @@ -221,7 +221,7 @@ _copyScan(Scan * from) static SeqScan * _copySeqScan(SeqScan * from) { - SeqScan *newnode = makeNode(SeqScan); + SeqScan *newnode = makeNode(SeqScan); /* ---------------- * copy node superclass fields @@ -240,7 +240,7 @@ _copySeqScan(SeqScan * from) static IndexScan * _copyIndexScan(IndexScan * from) { - IndexScan *newnode = makeNode(IndexScan); + IndexScan *newnode = makeNode(IndexScan); /* ---------------- * copy node superclass fields @@ -279,10 +279,10 @@ CopyJoinFields(Join * from, Join * newnode) * _copyJoin * ---------------- */ -static Join * +static Join * _copyJoin(Join * from) { - Join *newnode = makeNode(Join); + Join *newnode = makeNode(Join); /* ---------------- * copy node superclass fields @@ -302,7 +302,7 @@ _copyJoin(Join * from) static NestLoop * _copyNestLoop(NestLoop * from) { - NestLoop *newnode = makeNode(NestLoop); + NestLoop *newnode = makeNode(NestLoop); /* ---------------- * copy node superclass fields @@ -328,8 +328,8 @@ _copyNestLoop(NestLoop * from) static MergeJoin * _copyMergeJoin(MergeJoin * from) { - MergeJoin *newnode = makeNode(MergeJoin); - List *newlist; + MergeJoin *newnode = makeNode(MergeJoin); + List *newlist; /* ---------------- * copy node superclass fields @@ -367,7 +367,7 @@ _copyMergeJoin(MergeJoin * from) static HashJoin * _copyHashJoin(HashJoin * from) { - HashJoin *newnode = makeNode(HashJoin); + HashJoin *newnode = makeNode(HashJoin); /* ---------------- * copy node superclass fields @@ -415,10 +415,10 @@ CopyTempFields(Temp * from, Temp * newnode) * _copyTemp * ---------------- */ -static Temp * +static Temp * _copyTemp(Temp * from) { - Temp *newnode = makeNode(Temp); + Temp *newnode = makeNode(Temp); /* ---------------- * copy node superclass fields @@ -437,7 +437,7 @@ _copyTemp(Temp * from) static Material * _copyMaterial(Material * from) { - Material *newnode = makeNode(Material); + Material *newnode = makeNode(Material); /* ---------------- * copy node superclass fields @@ -460,10 +460,10 @@ _copyMaterial(Material * from) * _copySort * ---------------- */ -static Sort * +static Sort * _copySort(Sort * from) { - Sort *newnode = makeNode(Sort); + Sort *newnode = makeNode(Sort); /* ---------------- * copy node superclass fields @@ -485,11 +485,11 @@ _copySort(Sort * from) * _copyAgg * -------------- */ -static Agg * +static Agg * _copyAgg(Agg * from) { - Agg *newnode = makeNode(Agg); - int i; + Agg *newnode = makeNode(Agg); + int i; CopyPlanFields((Plan *) from, (Plan *) newnode); CopyTempFields((Temp *) from, (Temp *) newnode); @@ -511,10 +511,10 @@ _copyAgg(Agg * from) * _copyUnique * ---------------- */ -static Unique * +static Unique * _copyUnique(Unique * from) { - Unique *newnode = makeNode(Unique); + Unique *newnode = makeNode(Unique); /* ---------------- * copy node superclass fields @@ -537,10 +537,10 @@ _copyUnique(Unique * from) * _copyHash * ---------------- */ -static Hash * +static Hash * _copyHash(Hash * from) { - Hash *newnode = makeNode(Hash); + Hash *newnode = makeNode(Hash); /* ---------------- * copy node superclass fields @@ -571,10 +571,10 @@ _copyHash(Hash * from) * _copyResdom * ---------------- */ -static Resdom * +static Resdom * _copyResdom(Resdom * from) { - Resdom *newnode = makeNode(Resdom); + Resdom *newnode = makeNode(Resdom); newnode->resno = from->resno; newnode->restype = from->restype; @@ -595,10 +595,10 @@ _copyResdom(Resdom * from) return newnode; } -static Fjoin * +static Fjoin * _copyFjoin(Fjoin * from) { - Fjoin *newnode = makeNode(Fjoin); + Fjoin *newnode = makeNode(Fjoin); /* ---------------- * copy node superclass fields @@ -632,10 +632,10 @@ _copyFjoin(Fjoin * from) * _copyExpr * ---------------- */ -static Expr * +static Expr * _copyExpr(Expr * from) { - Expr *newnode = makeNode(Expr); + Expr *newnode = makeNode(Expr); /* ---------------- * copy node superclass fields @@ -654,10 +654,10 @@ _copyExpr(Expr * from) * _copyVar * ---------------- */ -static Var * +static Var * _copyVar(Var * from) { - Var *newnode = makeNode(Var); + Var *newnode = makeNode(Var); /* ---------------- * copy remainder of node @@ -677,10 +677,10 @@ _copyVar(Var * from) * _copyOper * ---------------- */ -static Oper * +static Oper * _copyOper(Oper * from) { - Oper *newnode = makeNode(Oper); + Oper *newnode = makeNode(Oper); /* ---------------- * copy remainder of node @@ -705,13 +705,13 @@ _copyOper(Oper * from) * _copyConst * ---------------- */ -static Const * +static Const * _copyConst(Const * from) { - static Oid cached_type; - static bool cached_typbyval; + static Oid cached_type; + static bool cached_typbyval; - Const *newnode = makeNode(Const); + Const *newnode = makeNode(Const); /* ---------------- * copy remainder of node @@ -727,8 +727,8 @@ _copyConst(Const * from) */ if (cached_type != from->consttype) { - HeapTuple typeTuple; - TypeTupleForm typeStruct; + HeapTuple typeTuple; + TypeTupleForm typeStruct; /* ---------------- * get the type tuple corresponding to the paramList->type, @@ -793,7 +793,7 @@ _copyConst(Const * from) * in the first int pointed to by the constval. * ---------------- */ - int length; + int length; length = *((int *) from->constvalue); newnode->constvalue = PointerGetDatum(palloc(length)); @@ -816,10 +816,10 @@ _copyConst(Const * from) * _copyParam * ---------------- */ -static Param * +static Param * _copyParam(Param * from) { - Param *newnode = makeNode(Param); + Param *newnode = makeNode(Param); /* ---------------- * copy remainder of node @@ -845,10 +845,10 @@ _copyParam(Param * from) * _copyFunc * ---------------- */ -static Func * +static Func * _copyFunc(Func * from) { - Func *newnode = makeNode(Func); + Func *newnode = makeNode(Func); /* ---------------- * copy remainder of node @@ -869,10 +869,10 @@ _copyFunc(Func * from) * _copyAggreg * ---------------- */ -static Aggreg * +static Aggreg * _copyAggreg(Aggreg * from) { - Aggreg *newnode = makeNode(Aggreg); + Aggreg *newnode = makeNode(Aggreg); /* ---------------- * copy remainder of node @@ -889,10 +889,10 @@ _copyAggreg(Aggreg * from) return newnode; } -static Array * +static Array * _copyArray(Array * from) { - Array *newnode = makeNode(Array); + Array *newnode = makeNode(Array); /* ---------------- * copy remainder of node @@ -912,7 +912,7 @@ _copyArray(Array * from) static ArrayRef * _copyArrayRef(ArrayRef * from) { - ArrayRef *newnode = makeNode(ArrayRef); + ArrayRef *newnode = makeNode(ArrayRef); /* ---------------- * copy remainder of node @@ -945,12 +945,12 @@ _copyArrayRef(ArrayRef * from) ** planner/path/xfunc.c accordingly!!! ** -- JMH, 8/2/93 */ -static Rel * +static Rel * _copyRel(Rel * from) { - Rel *newnode = makeNode(Rel); - int i, - len; + Rel *newnode = makeNode(Rel); + int i, + len; /* ---------------- * copy remainder of node @@ -1040,9 +1040,9 @@ CopyPathFields(Path * from, Path * newnode) newnode->p_ordering.ordtype = from->p_ordering.ordtype; if (from->p_ordering.ordtype == SORTOP_ORDER) { - int len, - i; - Oid *ordering = from->p_ordering.ord.sortop; + int len, + i; + Oid *ordering = from->p_ordering.ord.sortop; if (ordering) { @@ -1078,10 +1078,10 @@ CopyPathFields(Path * from, Path * newnode) * _copyPath * ---------------- */ -static Path * +static Path * _copyPath(Path * from) { - Path *newnode = makeNode(Path); + Path *newnode = makeNode(Path); CopyPathFields(from, newnode); @@ -1095,7 +1095,7 @@ _copyPath(Path * from) static IndexPath * _copyIndexPath(IndexPath * from) { - IndexPath *newnode = makeNode(IndexPath); + IndexPath *newnode = makeNode(IndexPath); /* ---------------- * copy the node superclass fields @@ -1112,8 +1112,8 @@ _copyIndexPath(IndexPath * from) if (from->indexkeys) { - int i, - len; + int i, + len; for (len = 0; from->indexkeys[len] != 0; len++) ; @@ -1150,7 +1150,7 @@ CopyJoinPathFields(JoinPath * from, JoinPath * newnode) static JoinPath * _copyJoinPath(JoinPath * from) { - JoinPath *newnode = makeNode(JoinPath); + JoinPath *newnode = makeNode(JoinPath); /* ---------------- * copy the node superclass fields @@ -1169,7 +1169,7 @@ _copyJoinPath(JoinPath * from) static MergePath * _copyMergePath(MergePath * from) { - MergePath *newnode = makeNode(MergePath); + MergePath *newnode = makeNode(MergePath); /* ---------------- * copy the node superclass fields @@ -1196,7 +1196,7 @@ _copyMergePath(MergePath * from) static HashPath * _copyHashPath(HashPath * from) { - HashPath *newnode = makeNode(HashPath); + HashPath *newnode = makeNode(HashPath); /* ---------------- * copy the node superclass fields @@ -1223,7 +1223,7 @@ _copyHashPath(HashPath * from) static OrderKey * _copyOrderKey(OrderKey * from) { - OrderKey *newnode = makeNode(OrderKey); + OrderKey *newnode = makeNode(OrderKey); /* ---------------- * copy remainder of node @@ -1243,7 +1243,7 @@ _copyOrderKey(OrderKey * from) static JoinKey * _copyJoinKey(JoinKey * from) { - JoinKey *newnode = makeNode(JoinKey); + JoinKey *newnode = makeNode(JoinKey); /* ---------------- * copy remainder of node @@ -1262,7 +1262,7 @@ _copyJoinKey(JoinKey * from) static MergeOrder * _copyMergeOrder(MergeOrder * from) { - MergeOrder *newnode = makeNode(MergeOrder); + MergeOrder *newnode = makeNode(MergeOrder); /* ---------------- * copy remainder of node @@ -1281,10 +1281,10 @@ _copyMergeOrder(MergeOrder * from) * _copyCInfo * ---------------- */ -static CInfo * +static CInfo * _copyCInfo(CInfo * from) { - CInfo *newnode = makeNode(CInfo); + CInfo *newnode = makeNode(CInfo); /* ---------------- * copy remainder of node @@ -1325,7 +1325,7 @@ CopyJoinMethodFields(JoinMethod * from, JoinMethod * newnode) static JoinMethod * _copyJoinMethod(JoinMethod * from) { - JoinMethod *newnode = makeNode(JoinMethod); + JoinMethod *newnode = makeNode(JoinMethod); CopyJoinMethodFields(from, newnode); @@ -1336,10 +1336,10 @@ _copyJoinMethod(JoinMethod * from) * _copyHInfo * ---------------- */ -static HInfo * +static HInfo * _copyHInfo(HInfo * from) { - HInfo *newnode = makeNode(HInfo); + HInfo *newnode = makeNode(HInfo); /* ---------------- * copy remainder of node @@ -1354,10 +1354,10 @@ _copyHInfo(HInfo * from) * _copyMInfo * ---------------- */ -static MInfo * +static MInfo * _copyMInfo(MInfo * from) { - MInfo *newnode = makeNode(MInfo); + MInfo *newnode = makeNode(MInfo); /* ---------------- * copy remainder of node @@ -1372,10 +1372,10 @@ _copyMInfo(MInfo * from) * _copyJInfo * ---------------- */ -static JInfo * +static JInfo * _copyJInfo(JInfo * from) { - JInfo *newnode = makeNode(JInfo); + JInfo *newnode = makeNode(JInfo); /* ---------------- * copy remainder of node @@ -1391,10 +1391,10 @@ _copyJInfo(JInfo * from) return newnode; } -static Iter * +static Iter * _copyIter(Iter * from) { - Iter *newnode = makeNode(Iter); + Iter *newnode = makeNode(Iter); Node_Copy(from, newnode, iterexpr); newnode->itertype = from->itertype; @@ -1402,10 +1402,10 @@ _copyIter(Iter * from) return newnode; } -static Stream * +static Stream * _copyStream(Stream * from) { - Stream *newnode = makeNode(Stream); + Stream *newnode = makeNode(Stream); newnode->pathptr = from->pathptr; newnode->cinfo = from->cinfo; @@ -1430,7 +1430,7 @@ _copyStream(Stream * from) static TargetEntry * _copyTargetEntry(TargetEntry * from) { - TargetEntry *newnode = makeNode(TargetEntry); + TargetEntry *newnode = makeNode(TargetEntry); Node_Copy(from, newnode, resdom); Node_Copy(from, newnode, fjoin); @@ -1441,7 +1441,7 @@ _copyTargetEntry(TargetEntry * from) static RangeTblEntry * _copyRangeTblEntry(RangeTblEntry * from) { - RangeTblEntry *newnode = makeNode(RangeTblEntry); + RangeTblEntry *newnode = makeNode(RangeTblEntry); memcpy(newnode, from, sizeof(RangeTblEntry)); if (from->relname) @@ -1470,7 +1470,7 @@ _copyRangeTblEntry(RangeTblEntry * from) static SortClause * _copySortClause(SortClause * from) { - SortClause *newnode = makeNode(SortClause); + SortClause *newnode = makeNode(SortClause); Node_Copy(from, newnode, resdom); newnode->opoid = from->opoid; @@ -1481,7 +1481,7 @@ _copySortClause(SortClause * from) static A_Const * _copyAConst(A_Const * from) { - A_Const *newnode = makeNode(A_Const); + A_Const *newnode = makeNode(A_Const); newnode->val = *((Value *) (copyObject(&(from->val)))); Node_Copy(from, newnode, typename); @@ -1492,7 +1492,7 @@ _copyAConst(A_Const * from) static TypeName * _copyTypeName(TypeName * from) { - TypeName *newnode = makeNode(TypeName); + TypeName *newnode = makeNode(TypeName); if (from->name) { @@ -1509,10 +1509,10 @@ _copyTypeName(TypeName * from) return newnode; } -static Query * +static Query * _copyQuery(Query * from) { - Query *newnode = makeNode(Query); + Query *newnode = makeNode(Query); newnode->commandType = from->commandType; newnode->resultRelation = from->resultRelation; @@ -1530,9 +1530,9 @@ _copyQuery(Query * from) Node_Copy(from, newnode, rtable); if (from->utilityStmt && nodeTag(from->utilityStmt) == T_NotifyStmt) { - NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt; - NotifyStmt *n = makeNode(NotifyStmt); - int length = strlen(from_notify->relname); + NotifyStmt *from_notify = (NotifyStmt *) from->utilityStmt; + NotifyStmt *n = makeNode(NotifyStmt); + int length = strlen(from_notify->relname); n->relname = palloc(length + 1); strcpy(n->relname, from_notify->relname); @@ -1563,25 +1563,25 @@ _copyQuery(Query * from) * **************************************************************** */ -static Value * +static Value * _copyValue(Value * from) { - Value *newnode = makeNode(Value); + Value *newnode = makeNode(Value); newnode->type = from->type; switch (from->type) { - case T_String: - newnode->val.str = pstrdup(from->val.str); - break; - case T_Integer: - newnode->val.ival = from->val.ival; - break; - case T_Float: - newnode->val.dval = from->val.dval; - break; - default: - break; + case T_String: + newnode->val.str = pstrdup(from->val.str); + break; + case T_Integer: + newnode->val.ival = from->val.ival; + break; + case T_Float: + newnode->val.dval = from->val.dval; + break; + default: + break; } return newnode; } @@ -1591,216 +1591,216 @@ _copyValue(Value * from) * recursively copies its items. * ---------------- */ -void * +void * copyObject(void *from) { - void *retval; + void *retval; if (from == NULL) return NULL; switch (nodeTag(from)) { - /* - * PLAN NODES - */ - case T_Plan: - retval = _copyPlan(from); - break; - case T_Existential: - retval = _copyExistential(from); - break; - case T_Result: - retval = _copyResult(from); - break; - case T_Append: - retval = _copyAppend(from); - break; - case T_Scan: - retval = _copyScan(from); - break; - case T_SeqScan: - retval = _copySeqScan(from); - break; - case T_IndexScan: - retval = _copyIndexScan(from); - break; - case T_Join: - retval = _copyJoin(from); - break; - case T_NestLoop: - retval = _copyNestLoop(from); - break; - case T_MergeJoin: - retval = _copyMergeJoin(from); - break; - case T_HashJoin: - retval = _copyHashJoin(from); - break; - case T_Temp: - retval = _copyTemp(from); - break; - case T_Material: - retval = _copyMaterial(from); - break; - case T_Sort: - retval = _copySort(from); - break; - case T_Agg: - retval = _copyAgg(from); - break; - case T_Unique: - retval = _copyUnique(from); - break; - case T_Hash: - retval = _copyHash(from); - break; - - /* - * PRIMITIVE NODES - */ - case T_Resdom: - retval = _copyResdom(from); - break; - case T_Fjoin: - retval = _copyFjoin(from); - break; - case T_Expr: - retval = _copyExpr(from); - break; - case T_Var: - retval = _copyVar(from); - break; - case T_Oper: - retval = _copyOper(from); - break; - case T_Const: - retval = _copyConst(from); - break; - case T_Param: - retval = _copyParam(from); - break; - case T_Func: - retval = _copyFunc(from); - break; - case T_Array: - retval = _copyArray(from); - break; - case T_ArrayRef: - retval = _copyArrayRef(from); - break; - case T_Aggreg: - retval = _copyAggreg(from); - break; - - /* - * RELATION NODES - */ - case T_Rel: - retval = _copyRel(from); - break; - case T_Path: - retval = _copyPath(from); - break; - case T_IndexPath: - retval = _copyIndexPath(from); - break; - case T_JoinPath: - retval = _copyJoinPath(from); - break; - case T_MergePath: - retval = _copyMergePath(from); - break; - case T_HashPath: - retval = _copyHashPath(from); - break; - case T_OrderKey: - retval = _copyOrderKey(from); - break; - case T_JoinKey: - retval = _copyJoinKey(from); - break; - case T_MergeOrder: - retval = _copyMergeOrder(from); - break; - case T_CInfo: - retval = _copyCInfo(from); - break; - case T_JoinMethod: - retval = _copyJoinMethod(from); - break; - case T_HInfo: - retval = _copyHInfo(from); - break; - case T_MInfo: - retval = _copyMInfo(from); - break; - case T_JInfo: - retval = _copyJInfo(from); - break; - case T_Iter: - retval = _copyIter(from); - break; - case T_Stream: - retval = _copyStream(from); - break; - - /* - * PARSE NODES - */ - case T_Query: - retval = _copyQuery(from); - break; - case T_TargetEntry: - retval = _copyTargetEntry(from); - break; - case T_RangeTblEntry: - retval = _copyRangeTblEntry(from); - break; - case T_SortClause: - retval = _copySortClause(from); - break; - case T_A_Const: - retval = _copyAConst(from); - break; - case T_TypeName: - retval = _copyTypeName(from); - break; - - /* - * VALUE NODES - */ - case T_Integer: - case T_String: - case T_Float: - retval = _copyValue(from); - break; - case T_List: - { - List *list = from, + /* + * PLAN NODES + */ + case T_Plan: + retval = _copyPlan(from); + break; + case T_Existential: + retval = _copyExistential(from); + break; + case T_Result: + retval = _copyResult(from); + break; + case T_Append: + retval = _copyAppend(from); + break; + case T_Scan: + retval = _copyScan(from); + break; + case T_SeqScan: + retval = _copySeqScan(from); + break; + case T_IndexScan: + retval = _copyIndexScan(from); + break; + case T_Join: + retval = _copyJoin(from); + break; + case T_NestLoop: + retval = _copyNestLoop(from); + break; + case T_MergeJoin: + retval = _copyMergeJoin(from); + break; + case T_HashJoin: + retval = _copyHashJoin(from); + break; + case T_Temp: + retval = _copyTemp(from); + break; + case T_Material: + retval = _copyMaterial(from); + break; + case T_Sort: + retval = _copySort(from); + break; + case T_Agg: + retval = _copyAgg(from); + break; + case T_Unique: + retval = _copyUnique(from); + break; + case T_Hash: + retval = _copyHash(from); + break; + + /* + * PRIMITIVE NODES + */ + case T_Resdom: + retval = _copyResdom(from); + break; + case T_Fjoin: + retval = _copyFjoin(from); + break; + case T_Expr: + retval = _copyExpr(from); + break; + case T_Var: + retval = _copyVar(from); + break; + case T_Oper: + retval = _copyOper(from); + break; + case T_Const: + retval = _copyConst(from); + break; + case T_Param: + retval = _copyParam(from); + break; + case T_Func: + retval = _copyFunc(from); + break; + case T_Array: + retval = _copyArray(from); + break; + case T_ArrayRef: + retval = _copyArrayRef(from); + break; + case T_Aggreg: + retval = _copyAggreg(from); + break; + + /* + * RELATION NODES + */ + case T_Rel: + retval = _copyRel(from); + break; + case T_Path: + retval = _copyPath(from); + break; + case T_IndexPath: + retval = _copyIndexPath(from); + break; + case T_JoinPath: + retval = _copyJoinPath(from); + break; + case T_MergePath: + retval = _copyMergePath(from); + break; + case T_HashPath: + retval = _copyHashPath(from); + break; + case T_OrderKey: + retval = _copyOrderKey(from); + break; + case T_JoinKey: + retval = _copyJoinKey(from); + break; + case T_MergeOrder: + retval = _copyMergeOrder(from); + break; + case T_CInfo: + retval = _copyCInfo(from); + break; + case T_JoinMethod: + retval = _copyJoinMethod(from); + break; + case T_HInfo: + retval = _copyHInfo(from); + break; + case T_MInfo: + retval = _copyMInfo(from); + break; + case T_JInfo: + retval = _copyJInfo(from); + break; + case T_Iter: + retval = _copyIter(from); + break; + case T_Stream: + retval = _copyStream(from); + break; + + /* + * PARSE NODES + */ + case T_Query: + retval = _copyQuery(from); + break; + case T_TargetEntry: + retval = _copyTargetEntry(from); + break; + case T_RangeTblEntry: + retval = _copyRangeTblEntry(from); + break; + case T_SortClause: + retval = _copySortClause(from); + break; + case T_A_Const: + retval = _copyAConst(from); + break; + case T_TypeName: + retval = _copyTypeName(from); + break; + + /* + * VALUE NODES + */ + case T_Integer: + case T_String: + case T_Float: + retval = _copyValue(from); + break; + case T_List: + { + List *list = from, *l; - List *newlist = NIL, + List *newlist = NIL, *nl = NIL; - foreach(l, list) - { - if (newlist == NIL) - { - newlist = nl = lcons(copyObject(lfirst(l)), NIL); - } - else + foreach(l, list) { - lnext(nl) = lcons(copyObject(lfirst(l)), NIL); - nl = lnext(nl); + if (newlist == NIL) + { + newlist = nl = lcons(copyObject(lfirst(l)), NIL); + } + else + { + lnext(nl) = lcons(copyObject(lfirst(l)), NIL); + nl = lnext(nl); + } } + retval = newlist; } - retval = newlist; - } - break; - default: - elog(NOTICE, "copyObject: don't know how to copy %d", nodeTag(from)); - retval = from; - break; + break; + default: + elog(NOTICE, "copyObject: don't know how to copy %d", nodeTag(from)); + retval = from; + break; } return retval; } diff --git a/src/backend/nodes/equalfuncs.c b/src/backend/nodes/equalfuncs.c index 792c8783f99..21958ca293e 100644 --- a/src/backend/nodes/equalfuncs.c +++ b/src/backend/nodes/equalfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.7 1997/09/07 04:42:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/equalfuncs.c,v 1.8 1997/09/08 02:23:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ #include "utils/elog.h" #include "storage/itemptr.h" -static bool equali(List * a, List * b); +static bool equali(List * a, List * b); /* * Stuff from primnodes.h @@ -35,7 +35,7 @@ static bool equali(List * a, List * b); /* * Resdom is a subclass of Node. */ -static bool +static bool _equalResdom(Resdom * a, Resdom * b) { if (a->resno != b->resno) @@ -54,10 +54,10 @@ _equalResdom(Resdom * a, Resdom * b) return (true); } -static bool +static bool _equalFjoin(Fjoin * a, Fjoin * b) { - int nNodes; + int nNodes; if (a->fj_initialized != b->fj_initialized) return (false); @@ -78,7 +78,7 @@ _equalFjoin(Fjoin * a, Fjoin * b) /* * Expr is a subclass of Node. */ -static bool +static bool _equalExpr(Expr * a, Expr * b) { if (a->opType != b->opType) @@ -91,13 +91,13 @@ _equalExpr(Expr * a, Expr * b) return (true); } -static bool +static bool _equalIter(Iter * a, Iter * b) { return (equal(a->iterexpr, b->iterexpr)); } -static bool +static bool _equalStream(Stream * a, Stream * b) { if (a->clausetype != b->clausetype) @@ -120,7 +120,7 @@ _equalStream(Stream * a, Stream * b) /* * Var is a subclass of Expr. */ -static bool +static bool _equalVar(Var * a, Var * b) { if (a->varno != b->varno) @@ -137,7 +137,7 @@ _equalVar(Var * a, Var * b) return (true); } -static bool +static bool _equalArray(Array * a, Array * b) { if (a->arrayelemtype != b->arrayelemtype) @@ -153,7 +153,7 @@ _equalArray(Array * a, Array * b) return (TRUE); } -static bool +static bool _equalArrayRef(ArrayRef * a, ArrayRef * b) { if (a->refelemtype != b->refelemtype) @@ -176,7 +176,7 @@ _equalArrayRef(ArrayRef * a, ArrayRef * b) /* * Oper is a subclass of Expr. */ -static bool +static bool _equalOper(Oper * a, Oper * b) { if (a->opno != b->opno) @@ -190,7 +190,7 @@ _equalOper(Oper * a, Oper * b) /* * Const is a subclass of Expr. */ -static bool +static bool _equalConst(Const * a, Const * b) { @@ -213,7 +213,7 @@ _equalConst(Const * a, Const * b) /* * Param is a subclass of Expr. */ -static bool +static bool _equalParam(Param * a, Param * b) { if (a->paramkind != b->paramkind) @@ -225,26 +225,26 @@ _equalParam(Param * a, Param * b) switch (a->paramkind) { - case PARAM_NAMED: - case PARAM_NEW: - case PARAM_OLD: - if (strcmp(a->paramname, b->paramname) != 0) - return (false); - break; - case PARAM_NUM: - if (a->paramid != b->paramid) - return (false); - break; - case PARAM_INVALID: - - /* - * XXX: Hmmm... What are we supposed to return in this case ?? - */ - return (true); - break; - default: - elog(WARN, "_equalParam: Invalid paramkind value: %d", - a->paramkind); + case PARAM_NAMED: + case PARAM_NEW: + case PARAM_OLD: + if (strcmp(a->paramname, b->paramname) != 0) + return (false); + break; + case PARAM_NUM: + if (a->paramid != b->paramid) + return (false); + break; + case PARAM_INVALID: + + /* + * XXX: Hmmm... What are we supposed to return in this case ?? + */ + return (true); + break; + default: + elog(WARN, "_equalParam: Invalid paramkind value: %d", + a->paramkind); } return (true); @@ -253,7 +253,7 @@ _equalParam(Param * a, Param * b) /* * Func is a subclass of Expr. */ -static bool +static bool _equalFunc(Func * a, Func * b) { if (a->funcid != b->funcid) @@ -275,7 +275,7 @@ _equalFunc(Func * a, Func * b) /* * CInfo is a subclass of Node. */ -static bool +static bool _equalCInfo(CInfo * a, CInfo * b) { Assert(IsA(a, CInfo)); @@ -297,7 +297,7 @@ _equalCInfo(CInfo * a, CInfo * b) (b->indexids))); } -static bool +static bool _equalJoinMethod(JoinMethod * a, JoinMethod * b) { Assert(IsA(a, JoinMethod)); @@ -312,7 +312,7 @@ _equalJoinMethod(JoinMethod * a, JoinMethod * b) return (true); } -static bool +static bool _equalPath(Path * a, Path * b) { if (a->pathtype != b->pathtype) @@ -325,7 +325,7 @@ _equalPath(Path * a, Path * b) */ if (a->p_ordering.ordtype == SORTOP_ORDER) { - int i = 0; + int i = 0; if (a->p_ordering.ord.sortop == NULL || b->p_ordering.ord.sortop == NULL) @@ -367,7 +367,7 @@ _equalPath(Path * a, Path * b) return (true); } -static bool +static bool _equalIndexPath(IndexPath * a, IndexPath * b) { if (!_equalPath((Path *) a, (Path *) b)) @@ -379,7 +379,7 @@ _equalIndexPath(IndexPath * a, IndexPath * b) return (true); } -static bool +static bool _equalJoinPath(JoinPath * a, JoinPath * b) { Assert(IsA_JoinPath(a)); @@ -396,7 +396,7 @@ _equalJoinPath(JoinPath * a, JoinPath * b) return (true); } -static bool +static bool _equalMergePath(MergePath * a, MergePath * b) { Assert(IsA(a, MergePath)); @@ -413,7 +413,7 @@ _equalMergePath(MergePath * a, MergePath * b) return (true); } -static bool +static bool _equalHashPath(HashPath * a, HashPath * b) { Assert(IsA(a, HashPath)); @@ -430,7 +430,7 @@ _equalHashPath(HashPath * a, HashPath * b) return (true); } -static bool +static bool _equalJoinKey(JoinKey * a, JoinKey * b) { Assert(IsA(a, JoinKey)); @@ -443,7 +443,7 @@ _equalJoinKey(JoinKey * a, JoinKey * b) return (true); } -static bool +static bool _equalMergeOrder(MergeOrder * a, MergeOrder * b) { if (a == (MergeOrder *) NULL && b == (MergeOrder *) NULL) @@ -464,7 +464,7 @@ _equalMergeOrder(MergeOrder * a, MergeOrder * b) return (true); } -static bool +static bool _equalHInfo(HInfo * a, HInfo * b) { Assert(IsA(a, HInfo)); @@ -478,7 +478,7 @@ _equalHInfo(HInfo * a, HInfo * b) /* XXX This equality function is a quick hack, should be * fixed to compare all fields. */ -static bool +static bool _equalIndexScan(IndexScan * a, IndexScan * b) { Assert(IsA(a, IndexScan)); @@ -499,7 +499,7 @@ _equalIndexScan(IndexScan * a, IndexScan * b) return (true); } -static bool +static bool _equalJInfo(JInfo * a, JInfo * b) { Assert(IsA(a, JInfo)); @@ -522,7 +522,7 @@ _equalJInfo(JInfo * a, JInfo * b) /* * EState is a subclass of Node. */ -static bool +static bool _equalEState(EState * a, EState * b) { if (a->es_direction != b->es_direction) @@ -537,7 +537,7 @@ _equalEState(EState * a, EState * b) return (true); } -static bool +static bool _equalTargetEntry(TargetEntry * a, TargetEntry * b) { if (!equal(a->resdom, b->resdom)) @@ -557,7 +557,7 @@ _equalTargetEntry(TargetEntry * a, TargetEntry * b) * This is a comparison by value. It would be simpler to write it * to be recursive, but it should run faster if we iterate. */ -static bool +static bool _equalValue(Value * a, Value * b) { if (a->type != b->type) @@ -565,14 +565,14 @@ _equalValue(Value * a, Value * b) switch (a->type) { - case T_String: - return strcmp(a->val.str, b->val.str); - case T_Integer: - return (a->val.ival == b->val.ival); - case T_Float: - return (a->val.dval == b->val.dval); - default: - break; + case T_String: + return strcmp(a->val.str, b->val.str); + case T_Integer: + return (a->val.ival == b->val.ival); + case T_Float: + return (a->val.dval == b->val.dval); + default: + break; } return (true); @@ -585,7 +585,7 @@ _equalValue(Value * a, Value * b) bool equal(void *a, void *b) { - bool retval = false; + bool retval = false; if (a == b) return (true); @@ -604,112 +604,112 @@ equal(void *a, void *b) switch (nodeTag(a)) { - case T_Resdom: - retval = _equalResdom(a, b); - break; - case T_Fjoin: - retval = _equalFjoin(a, b); - break; - case T_Expr: - retval = _equalExpr(a, b); - break; - case T_TargetEntry: - retval = _equalTargetEntry(a, b); - break; - case T_Iter: - retval = _equalIter(a, b); - break; - case T_Stream: - retval = _equalStream(a, b); - break; - case T_Var: - retval = _equalVar(a, b); - break; - case T_Array: - retval = _equalArray(a, b); - break; - case T_ArrayRef: - retval = _equalArrayRef(a, b); - break; - case T_Oper: - retval = _equalOper(a, b); - break; - case T_Const: - retval = _equalConst(a, b); - break; - case T_Param: - retval = _equalParam(a, b); - break; - case T_Func: - retval = _equalFunc(a, b); - break; - case T_CInfo: - retval = _equalCInfo(a, b); - break; - case T_JoinMethod: - retval = _equalJoinMethod(a, b); - break; - case T_Path: - retval = _equalPath(a, b); - break; - case T_IndexPath: - retval = _equalIndexPath(a, b); - break; - case T_JoinPath: - retval = _equalJoinPath(a, b); - break; - case T_MergePath: - retval = _equalMergePath(a, b); - break; - case T_HashPath: - retval = _equalHashPath(a, b); - break; - case T_JoinKey: - retval = _equalJoinKey(a, b); - break; - case T_MergeOrder: - retval = _equalMergeOrder(a, b); - break; - case T_HInfo: - retval = _equalHInfo(a, b); - break; - case T_IndexScan: - retval = _equalIndexScan(a, b); - break; - case T_JInfo: - retval = _equalJInfo(a, b); - break; - case T_EState: - retval = _equalEState(a, b); - break; - case T_Integer: - case T_String: - case T_Float: - retval = _equalValue(a, b); - break; - case T_List: - { - List *la = (List *) a; - List *lb = (List *) b; - List *l; - - if (a == NULL && b == NULL) - return (true); - if (length(a) != length(b)) - return (false); - foreach(l, la) + case T_Resdom: + retval = _equalResdom(a, b); + break; + case T_Fjoin: + retval = _equalFjoin(a, b); + break; + case T_Expr: + retval = _equalExpr(a, b); + break; + case T_TargetEntry: + retval = _equalTargetEntry(a, b); + break; + case T_Iter: + retval = _equalIter(a, b); + break; + case T_Stream: + retval = _equalStream(a, b); + break; + case T_Var: + retval = _equalVar(a, b); + break; + case T_Array: + retval = _equalArray(a, b); + break; + case T_ArrayRef: + retval = _equalArrayRef(a, b); + break; + case T_Oper: + retval = _equalOper(a, b); + break; + case T_Const: + retval = _equalConst(a, b); + break; + case T_Param: + retval = _equalParam(a, b); + break; + case T_Func: + retval = _equalFunc(a, b); + break; + case T_CInfo: + retval = _equalCInfo(a, b); + break; + case T_JoinMethod: + retval = _equalJoinMethod(a, b); + break; + case T_Path: + retval = _equalPath(a, b); + break; + case T_IndexPath: + retval = _equalIndexPath(a, b); + break; + case T_JoinPath: + retval = _equalJoinPath(a, b); + break; + case T_MergePath: + retval = _equalMergePath(a, b); + break; + case T_HashPath: + retval = _equalHashPath(a, b); + break; + case T_JoinKey: + retval = _equalJoinKey(a, b); + break; + case T_MergeOrder: + retval = _equalMergeOrder(a, b); + break; + case T_HInfo: + retval = _equalHInfo(a, b); + break; + case T_IndexScan: + retval = _equalIndexScan(a, b); + break; + case T_JInfo: + retval = _equalJInfo(a, b); + break; + case T_EState: + retval = _equalEState(a, b); + break; + case T_Integer: + case T_String: + case T_Float: + retval = _equalValue(a, b); + break; + case T_List: { - if (!equal(lfirst(l), lfirst(lb))) + List *la = (List *) a; + List *lb = (List *) b; + List *l; + + if (a == NULL && b == NULL) + return (true); + if (length(a) != length(b)) return (false); - lb = lnext(lb); + foreach(l, la) + { + if (!equal(lfirst(l), lfirst(lb))) + return (false); + lb = lnext(lb); + } + retval = true; } - retval = true; - } - break; - default: - elog(NOTICE, "equal: don't know whether nodes of type %d are equal", - nodeTag(a)); - break; + break; + default: + elog(NOTICE, "equal: don't know whether nodes of type %d are equal", + nodeTag(a)); + break; } return retval; @@ -721,12 +721,12 @@ equal(void *a, void *b) * * XXX temp hack. needs something like T_IntList */ -static bool +static bool equali(List * a, List * b) { - List *la = (List *) a; - List *lb = (List *) b; - List *l; + List *la = (List *) a; + List *lb = (List *) b; + List *l; if (a == NULL && b == NULL) return (true); diff --git a/src/backend/nodes/list.c b/src/backend/nodes/list.c index 334030822f7..abba222b81a 100644 --- a/src/backend/nodes/list.c +++ b/src/backend/nodes/list.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.5 1997/09/07 04:42:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/list.c,v 1.6 1997/09/08 02:23:38 momjian Exp $ * * NOTES * XXX a few of the following functions are duplicated to handle @@ -29,13 +29,13 @@ #include "utils/elog.h" #include "utils/palloc.h" -List * +List * makeList(void *elem,...) { - va_list args; - List *retval = NIL; - List *temp = NIL; - List *tempcons = NIL; + va_list args; + List *retval = NIL; + List *temp = NIL; + List *tempcons = NIL; va_start(args, elem); @@ -57,62 +57,62 @@ makeList(void *elem,...) return (retval); } -List * +List * lcons(void *obj, List * list) { - List *l = makeNode(List); + List *l = makeNode(List); lfirst(l) = obj; lnext(l) = list; return l; } -List * +List * lconsi(int datum, List * list) { - List *l = makeNode(List); + List *l = makeNode(List); lfirsti(l) = datum; lnext(l) = list; return l; } -List * +List * lappend(List * list, void *obj) { return nconc(list, lcons(obj, NIL)); } -List * +List * lappendi(List * list, int datum) { return nconc(list, lconsi(datum, NIL)); } -Value * +Value * makeInteger(long i) { - Value *v = makeNode(Value); + Value *v = makeNode(Value); v->type = T_Integer; v->val.ival = i; return v; } -Value * +Value * makeFloat(double d) { - Value *v = makeNode(Value); + Value *v = makeNode(Value); v->type = T_Float; v->val.dval = d; return v; } -Value * +Value * makeString(char *str) { - Value *v = makeNode(Value); + Value *v = makeNode(Value); v->type = T_String; v->val.str = str; @@ -120,7 +120,7 @@ makeString(char *str) } /* n starts with 0 */ -void * +void * nth(int n, List * l) { /* XXX assume list is long enough */ @@ -161,7 +161,7 @@ set_nth(List * l, int n, void *elem) int length(List * l) { - int i = 0; + int i = 0; while (l != NIL) { @@ -176,7 +176,7 @@ freeList(List * list) { while (list != NIL) { - List *l = list; + List *l = list; list = lnext(list); pfree(l); @@ -186,12 +186,12 @@ freeList(List * list) /* * below are for backwards compatibility */ -List * +List * append(List * l1, List * l2) { - List *newlist, - *newlist2, - *p; + List *newlist, + *newlist2, + *p; if (l1 == NIL) return copyObject(l2); @@ -208,12 +208,12 @@ append(List * l1, List * l2) /* * below are for backwards compatibility */ -List * +List * intAppend(List * l1, List * l2) { - List *newlist, - *newlist2, - *p; + List *newlist, + *newlist2, + *p; if (l1 == NIL) return listCopy(l2); @@ -227,10 +227,10 @@ intAppend(List * l1, List * l2) return newlist; } -List * +List * nconc(List * l1, List * l2) { - List *temp; + List *temp; if (l1 == NIL) return l2; @@ -247,11 +247,11 @@ nconc(List * l1, List * l2) } -List * +List * nreverse(List * list) { - List *rlist = NIL; - List *p = NIL; + List *rlist = NIL; + List *p = NIL; if (list == NULL) return (NIL); @@ -280,7 +280,7 @@ nreverse(List * list) bool same(List * foo, List * bar) { - List *temp = NIL; + List *temp = NIL; if (foo == NULL) return (bar == NULL); @@ -299,12 +299,12 @@ same(List * foo, List * bar) } -List * +List * LispUnion(List * foo, List * bar) { - List *retval = NIL; - List *i = NIL; - List *j = NIL; + List *retval = NIL; + List *i = NIL; + List *j = NIL; if (foo == NIL) return (bar); /* XXX - should be copy of bar */ @@ -331,12 +331,12 @@ LispUnion(List * foo, List * bar) return (retval); } -List * +List * LispUnioni(List * foo, List * bar) { - List *retval = NIL; - List *i = NIL; - List *j = NIL; + List *retval = NIL; + List *i = NIL; + List *j = NIL; if (foo == NIL) return (bar); /* XXX - should be copy of bar */ @@ -371,7 +371,7 @@ LispUnioni(List * foo, List * bar) bool member(void *foo, List * bar) { - List *i; + List *i; foreach(i, bar) if (equal((Node *) (lfirst(i)), (Node *) foo)) @@ -382,7 +382,7 @@ member(void *foo, List * bar) bool intMember(int foo, List * bar) { - List *i; + List *i; foreach(i, bar) if (foo == lfirsti(i)) @@ -394,12 +394,12 @@ intMember(int foo, List * bar) * lremove - * only does pointer comparisons. Removes 'elem' from the the linked list. */ -List * +List * lremove(void *elem, List * list) { - List *l; - List *prev = NIL; - List *result = list; + List *l; + List *prev = NIL; + List *result = list; foreach(l, list) { @@ -421,11 +421,11 @@ lremove(void *elem, List * list) return result; } -List * +List * LispRemove(void *elem, List * list) { - List *temp = NIL; - List *prev = NIL; + List *temp = NIL; + List *prev = NIL; if (equal(elem, lfirst(list))) return lnext(list); @@ -446,11 +446,11 @@ LispRemove(void *elem, List * list) } #ifdef NOT_USED -List * +List * intLispRemove(int elem, List * list) { - List *temp = NIL; - List *prev = NIL; + List *temp = NIL; + List *prev = NIL; if (elem == lfirsti(list)) return lnext(list); @@ -472,11 +472,11 @@ intLispRemove(int elem, List * list) #endif -List * +List * set_difference(List * list1, List * list2) { - List *temp1 = NIL; - List *result = NIL; + List *temp1 = NIL; + List *result = NIL; if (list2 == NIL) return (list1); @@ -489,11 +489,11 @@ set_difference(List * list1, List * list2) return (result); } -List * +List * set_differencei(List * list1, List * list2) { - List *temp1 = NIL; - List *result = NIL; + List *temp1 = NIL; + List *result = NIL; if (list2 == NIL) return (list1); diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index 7c5a9efc1fb..95cce161d66 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.3 1997/09/07 04:42:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.4 1997/09/08 02:23:39 momjian Exp $ * * NOTES * Creator functions in POSTGRES 4.2 are generated automatically. Most of @@ -27,14 +27,14 @@ * makeOper - * creates an Oper node */ -Oper * +Oper * makeOper(Oid opno, Oid opid, Oid opresulttype, int opsize, FunctionCachePtr op_fcache) { - Oper *oper = makeNode(Oper); + Oper *oper = makeNode(Oper); oper->opno = opno; oper->opid = opid; @@ -49,14 +49,14 @@ makeOper(Oid opno, * creates a Var node * */ -Var * +Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, Index varnoold, AttrNumber varoattno) { - Var *var = makeNode(Var); + Var *var = makeNode(Var); var->varno = varno; var->varattno = varattno; @@ -71,7 +71,7 @@ makeVar(Index varno, * makeResdom - * creates a Resdom (Result Domain) node */ -Resdom * +Resdom * makeResdom(AttrNumber resno, Oid restype, int reslen, @@ -80,7 +80,7 @@ makeResdom(AttrNumber resno, Oid reskeyop, int resjunk) { - Resdom *resdom = makeNode(Resdom); + Resdom *resdom = makeNode(Resdom); resdom->resno = resno; resdom->restype = restype; @@ -96,7 +96,7 @@ makeResdom(AttrNumber resno, * makeConst - * creates a Const node */ -Const * +Const * makeConst(Oid consttype, Size constlen, Datum constvalue, @@ -105,7 +105,7 @@ makeConst(Oid consttype, bool constisset, bool constiscast) { - Const *cnst = makeNode(Const); + Const *cnst = makeNode(Const); cnst->consttype = consttype; cnst->constlen = constlen; diff --git a/src/backend/nodes/nodeFuncs.c b/src/backend/nodes/nodeFuncs.c index 081760eaca2..9f343ac6c03 100644 --- a/src/backend/nodes/nodeFuncs.c +++ b/src/backend/nodes/nodeFuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.4 1997/09/07 04:42:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/nodeFuncs.c,v 1.5 1997/09/08 02:23:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #include "nodes/nodeFuncs.h" #include "utils/lsyscache.h" -static bool var_is_inner(Var * var); +static bool var_is_inner(Var * var); /* * single_node - @@ -63,7 +63,7 @@ var_is_outer(Var * var) return ((bool) (var->varno == OUTER)); } -static bool +static bool var_is_inner(Var * var) { return ((bool) (var->varno == INNER)); @@ -89,7 +89,7 @@ var_is_rel(Var * var) * Returns the modified oper node. * */ -Oper * +Oper * replace_opid(Oper * oper) { oper->opid = get_opcode(oper->opno); diff --git a/src/backend/nodes/nodes.c b/src/backend/nodes/nodes.c index 2af057e5a4c..1abee00b845 100644 --- a/src/backend/nodes/nodes.c +++ b/src/backend/nodes/nodes.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.2 1997/09/07 04:42:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/nodes.c,v 1.3 1997/09/08 02:23:40 momjian Exp $ * * HISTORY * Andrew Yu Oct 20, 1994 file creation @@ -31,10 +31,10 @@ * macro makeNode. eg. to create a Resdom node, use makeNode(Resdom) * */ -Node * +Node * newNode(Size size, NodeTag tag) { - Node *newNode; + Node *newNode; Assert(size >= 4); /* need the tag, at least */ diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index a1574c8734f..30c0ff9a6e4 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.7 1997/09/07 04:42:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.8 1997/09/08 02:23:41 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -45,8 +45,8 @@ #include "catalog/pg_type.h" #include "lib/stringinfo.h" -static void _outDatum(StringInfo str, Datum value, Oid type); -static void _outNode(StringInfo str, void *obj); +static void _outDatum(StringInfo str, Datum value, Oid type); +static void _outNode(StringInfo str, void *obj); /* * _outIntList - @@ -55,8 +55,8 @@ static void _outNode(StringInfo str, void *obj); static void _outIntList(StringInfo str, List * list) { - List *l; - char buf[500]; + List *l; + char buf[500]; appendStringInfo(str, "("); foreach(l, list) @@ -70,7 +70,7 @@ _outIntList(StringInfo str, List * list) static void _outQuery(StringInfo str, Query * node) { - char buf[500]; + char buf[500]; sprintf(buf, "QUERY"); appendStringInfo(str, buf); @@ -112,7 +112,7 @@ _outQuery(StringInfo str, Query * node) static void _outPlanInfo(StringInfo str, Plan * node) { - char buf[500]; + char buf[500]; sprintf(buf, " :cost %g", node->cost); appendStringInfo(str, buf); @@ -144,7 +144,7 @@ _outPlanInfo(StringInfo str, Plan * node) static void _outPlan(StringInfo str, Plan * node) { - char buf[500]; + char buf[500]; sprintf(buf, "PLAN"); appendStringInfo(str, buf); @@ -155,7 +155,7 @@ _outPlan(StringInfo str, Plan * node) static void _outResult(StringInfo str, Result * node) { - char buf[500]; + char buf[500]; sprintf(buf, "RESULT"); appendStringInfo(str, buf); @@ -173,7 +173,7 @@ _outResult(StringInfo str, Result * node) static void _outExistential(StringInfo str, Existential * node) { - char buf[500]; + char buf[500]; sprintf(buf, "EXISTENTIAL"); appendStringInfo(str, buf); @@ -188,7 +188,7 @@ _outExistential(StringInfo str, Existential * node) static void _outAppend(StringInfo str, Append * node) { - char buf[500]; + char buf[500]; sprintf(buf, "APPEND"); appendStringInfo(str, buf); @@ -213,7 +213,7 @@ _outAppend(StringInfo str, Append * node) static void _outJoin(StringInfo str, Join * node) { - char buf[500]; + char buf[500]; sprintf(buf, "JOIN"); appendStringInfo(str, buf); @@ -227,7 +227,7 @@ _outJoin(StringInfo str, Join * node) static void _outNestLoop(StringInfo str, NestLoop * node) { - char buf[500]; + char buf[500]; sprintf(buf, "NESTLOOP"); appendStringInfo(str, buf); @@ -240,7 +240,7 @@ _outNestLoop(StringInfo str, NestLoop * node) static void _outMergeJoin(StringInfo str, MergeJoin * node) { - char buf[500]; + char buf[500]; sprintf(buf, "MERGEJOIN"); appendStringInfo(str, buf); @@ -266,7 +266,7 @@ _outMergeJoin(StringInfo str, MergeJoin * node) static void _outHashJoin(StringInfo str, HashJoin * node) { - char buf[500]; + char buf[500]; sprintf(buf, "HASHJOIN"); appendStringInfo(str, buf); @@ -294,7 +294,7 @@ _outHashJoin(StringInfo str, HashJoin * node) static void _outScan(StringInfo str, Scan * node) { - char buf[500]; + char buf[500]; sprintf(buf, "SCAN"); appendStringInfo(str, buf); @@ -311,7 +311,7 @@ _outScan(StringInfo str, Scan * node) static void _outSeqScan(StringInfo str, SeqScan * node) { - char buf[500]; + char buf[500]; sprintf(buf, "SEQSCAN"); appendStringInfo(str, buf); @@ -329,7 +329,7 @@ _outSeqScan(StringInfo str, SeqScan * node) static void _outIndexScan(StringInfo str, IndexScan * node) { - char buf[500]; + char buf[500]; sprintf(buf, "INDEXSCAN"); appendStringInfo(str, buf); @@ -354,7 +354,7 @@ _outIndexScan(StringInfo str, IndexScan * node) static void _outTemp(StringInfo str, Temp * node) { - char buf[500]; + char buf[500]; sprintf(buf, "TEMP"); appendStringInfo(str, buf); @@ -373,7 +373,7 @@ _outTemp(StringInfo str, Temp * node) static void _outSort(StringInfo str, Sort * node) { - char buf[500]; + char buf[500]; sprintf(buf, "SORT"); appendStringInfo(str, buf); @@ -389,7 +389,7 @@ _outSort(StringInfo str, Sort * node) static void _outAgg(StringInfo str, Agg * node) { - char buf[500]; + char buf[500]; sprintf(buf, "AGG"); appendStringInfo(str, buf); @@ -403,7 +403,7 @@ _outAgg(StringInfo str, Agg * node) static void _outGroup(StringInfo str, Group * node) { - char buf[500]; + char buf[500]; sprintf(buf, "GRP"); appendStringInfo(str, buf); @@ -424,7 +424,7 @@ _outGroup(StringInfo str, Group * node) static void _outUnique(StringInfo str, Unique * node) { - char buf[500]; + char buf[500]; sprintf(buf, "UNIQUE"); appendStringInfo(str, buf); @@ -444,7 +444,7 @@ _outUnique(StringInfo str, Unique * node) static void _outHash(StringInfo str, Hash * node) { - char buf[500]; + char buf[500]; sprintf(buf, "HASH"); appendStringInfo(str, buf); @@ -465,7 +465,7 @@ _outHash(StringInfo str, Hash * node) static void _outTee(StringInfo str, Tee * node) { - char buf[500]; + char buf[500]; sprintf(buf, "TEE"); appendStringInfo(str, buf); @@ -496,7 +496,7 @@ _outTee(StringInfo str, Tee * node) static void _outResdom(StringInfo str, Resdom * node) { - char buf[500]; + char buf[500]; sprintf(buf, "RESDOM"); appendStringInfo(str, buf); @@ -521,8 +521,8 @@ _outResdom(StringInfo str, Resdom * node) static void _outFjoin(StringInfo str, Fjoin * node) { - char buf[500]; - int i; + char buf[500]; + int i; sprintf(buf, "FJOIN"); appendStringInfo(str, buf); @@ -552,8 +552,8 @@ _outFjoin(StringInfo str, Fjoin * node) static void _outExpr(StringInfo str, Expr * node) { - char buf[500]; - char *opstr = NULL; + char buf[500]; + char *opstr = NULL; sprintf(buf, "EXPR"); appendStringInfo(str, buf); @@ -562,21 +562,21 @@ _outExpr(StringInfo str, Expr * node) appendStringInfo(str, buf); switch (node->opType) { - case OP_EXPR: - opstr = "op"; - break; - case FUNC_EXPR: - opstr = "func"; - break; - case OR_EXPR: - opstr = "or"; - break; - case AND_EXPR: - opstr = "and"; - break; - case NOT_EXPR: - opstr = "not"; - break; + case OP_EXPR: + opstr = "op"; + break; + case FUNC_EXPR: + opstr = "func"; + break; + case OR_EXPR: + opstr = "or"; + break; + case AND_EXPR: + opstr = "and"; + break; + case NOT_EXPR: + opstr = "not"; + break; } sprintf(buf, " :opType %s", opstr); appendStringInfo(str, buf); @@ -594,7 +594,7 @@ _outExpr(StringInfo str, Expr * node) static void _outVar(StringInfo str, Var * node) { - char buf[500]; + char buf[500]; sprintf(buf, "VAR"); appendStringInfo(str, buf); @@ -616,7 +616,7 @@ _outVar(StringInfo str, Var * node) static void _outConst(StringInfo str, Const * node) { - char buf[500]; + char buf[500]; sprintf(buf, "CONST"); appendStringInfo(str, buf); @@ -648,7 +648,7 @@ _outConst(StringInfo str, Const * node) static void _outAggreg(StringInfo str, Aggreg * node) { - char buf[500]; + char buf[500]; sprintf(buf, "AGGREG"); appendStringInfo(str, buf); @@ -672,8 +672,8 @@ _outAggreg(StringInfo str, Aggreg * node) static void _outArray(StringInfo str, Array * node) { - char buf[500]; - int i; + char buf[500]; + int i; sprintf(buf, "ARRAY"); appendStringInfo(str, buf); @@ -709,7 +709,7 @@ _outArray(StringInfo str, Array * node) static void _outArrayRef(StringInfo str, ArrayRef * node) { - char buf[500]; + char buf[500]; sprintf(buf, "ARRAYREF"); appendStringInfo(str, buf); @@ -745,7 +745,7 @@ _outArrayRef(StringInfo str, ArrayRef * node) static void _outFunc(StringInfo str, Func * node) { - char buf[500]; + char buf[500]; sprintf(buf, "FUNC"); appendStringInfo(str, buf); @@ -774,7 +774,7 @@ _outFunc(StringInfo str, Func * node) static void _outOper(StringInfo str, Oper * node) { - char buf[500]; + char buf[500]; sprintf(buf, "OPER"); appendStringInfo(str, buf); @@ -793,7 +793,7 @@ _outOper(StringInfo str, Oper * node) static void _outParam(StringInfo str, Param * node) { - char buf[500]; + char buf[500]; sprintf(buf, "PARAM"); appendStringInfo(str, buf); @@ -820,7 +820,7 @@ _outParam(StringInfo str, Param * node) static void _outEState(StringInfo str, EState * node) { - char buf[500]; + char buf[500]; sprintf(buf, "ESTATE"); appendStringInfo(str, buf); @@ -843,7 +843,7 @@ _outEState(StringInfo str, EState * node) static void _outRel(StringInfo str, Rel * node) { - char buf[500]; + char buf[500]; sprintf(buf, "REL"); appendStringInfo(str, buf); @@ -919,7 +919,7 @@ _outRel(StringInfo str, Rel * node) static void _outTargetEntry(StringInfo str, TargetEntry * node) { - char buf[500]; + char buf[500]; sprintf(buf, "TLE"); appendStringInfo(str, buf); @@ -942,7 +942,7 @@ _outTargetEntry(StringInfo str, TargetEntry * node) static void _outRangeTblEntry(StringInfo str, RangeTblEntry * node) { - char buf[500]; + char buf[500]; sprintf(buf, "RTE"); appendStringInfo(str, buf); @@ -968,7 +968,7 @@ _outRangeTblEntry(StringInfo str, RangeTblEntry * node) static void _outPath(StringInfo str, Path * node) { - char buf[500]; + char buf[500]; sprintf(buf, "PATH"); appendStringInfo(str, buf); @@ -991,7 +991,7 @@ _outPath(StringInfo str, Path * node) static void _outIndexPath(StringInfo str, IndexPath * node) { - char buf[500]; + char buf[500]; sprintf(buf, "INDEXPATH"); appendStringInfo(str, buf); @@ -1032,7 +1032,7 @@ _outIndexPath(StringInfo str, IndexPath * node) static void _outJoinPath(StringInfo str, JoinPath * node) { - char buf[500]; + char buf[500]; sprintf(buf, "JOINPATH"); appendStringInfo(str, buf); @@ -1086,7 +1086,7 @@ _outJoinPath(StringInfo str, JoinPath * node) static void _outMergePath(StringInfo str, MergePath * node) { - char buf[500]; + char buf[500]; sprintf(buf, "MERGEPATH"); appendStringInfo(str, buf); @@ -1142,7 +1142,7 @@ _outMergePath(StringInfo str, MergePath * node) static void _outHashPath(StringInfo str, HashPath * node) { - char buf[500]; + char buf[500]; sprintf(buf, "HASHPATH"); appendStringInfo(str, buf); @@ -1198,7 +1198,7 @@ _outHashPath(StringInfo str, HashPath * node) static void _outOrderKey(StringInfo str, OrderKey * node) { - char buf[500]; + char buf[500]; sprintf(buf, "ORDERKEY"); appendStringInfo(str, buf); @@ -1215,7 +1215,7 @@ _outOrderKey(StringInfo str, OrderKey * node) static void _outJoinKey(StringInfo str, JoinKey * node) { - char buf[500]; + char buf[500]; sprintf(buf, "JOINKEY"); appendStringInfo(str, buf); @@ -1236,7 +1236,7 @@ _outJoinKey(StringInfo str, JoinKey * node) static void _outMergeOrder(StringInfo str, MergeOrder * node) { - char buf[500]; + char buf[500]; sprintf(buf, "MERGEORDER"); appendStringInfo(str, buf); @@ -1260,7 +1260,7 @@ _outMergeOrder(StringInfo str, MergeOrder * node) static void _outCInfo(StringInfo str, CInfo * node) { - char buf[500]; + char buf[500]; sprintf(buf, "CINFO"); appendStringInfo(str, buf); @@ -1293,7 +1293,7 @@ _outCInfo(StringInfo str, CInfo * node) static void _outJoinMethod(StringInfo str, JoinMethod * node) { - char buf[500]; + char buf[500]; sprintf(buf, "JOINMETHOD"); appendStringInfo(str, buf); @@ -1315,7 +1315,7 @@ _outJoinMethod(StringInfo str, JoinMethod * node) static void _outHInfo(StringInfo str, HInfo * node) { - char buf[500]; + char buf[500]; sprintf(buf, "HASHINFO"); appendStringInfo(str, buf); @@ -1341,7 +1341,7 @@ _outHInfo(StringInfo str, HInfo * node) static void _outJInfo(StringInfo str, JInfo * node) { - char buf[500]; + char buf[500]; sprintf(buf, "JINFO"); appendStringInfo(str, buf); @@ -1369,12 +1369,12 @@ _outJInfo(StringInfo str, JInfo * node) static void _outDatum(StringInfo str, Datum value, Oid type) { - char buf[500]; - Size length, - typeLength; - bool byValue; - int i; - char *s; + char buf[500]; + Size length, + typeLength; + bool byValue; + int i; + char *s; /* * find some information about the type and the "real" length of the @@ -1442,7 +1442,7 @@ _outIter(StringInfo str, Iter * node) static void _outStream(StringInfo str, Stream * node) { - char buf[500]; + char buf[500]; appendStringInfo(str, "STREAM"); @@ -1474,24 +1474,24 @@ _outStream(StringInfo str, Stream * node) static void _outValue(StringInfo str, Value * value) { - char buf[500]; + char buf[500]; switch (value->type) { - case T_String: - sprintf(buf, "\"%s\"", value->val.str); - appendStringInfo(str, buf); - break; - case T_Integer: - sprintf(buf, "%ld", value->val.ival); - appendStringInfo(str, buf); - break; - case T_Float: - sprintf(buf, "%f", value->val.dval); - appendStringInfo(str, buf); - break; - default: - break; + case T_String: + sprintf(buf, "\"%s\"", value->val.str); + appendStringInfo(str, buf); + break; + case T_Integer: + sprintf(buf, "%ld", value->val.ival); + appendStringInfo(str, buf); + break; + case T_Float: + sprintf(buf, "%f", value->val.dval); + appendStringInfo(str, buf); + break; + default: + break; } return; } @@ -1511,7 +1511,7 @@ _outNode(StringInfo str, void *obj) if (nodeTag(obj) == T_List) { - List *l; + List *l; appendStringInfo(str, "("); foreach(l, (List *) obj) @@ -1527,159 +1527,159 @@ _outNode(StringInfo str, void *obj) appendStringInfo(str, "{"); switch (nodeTag(obj)) { - case T_Query: - _outQuery(str, obj); - break; - case T_Plan: - _outPlan(str, obj); - break; - case T_Result: - _outResult(str, obj); - break; - case T_Existential: - _outExistential(str, obj); - break; - case T_Append: - _outAppend(str, obj); - break; - case T_Join: - _outJoin(str, obj); - break; - case T_NestLoop: - _outNestLoop(str, obj); - break; - case T_MergeJoin: - _outMergeJoin(str, obj); - break; - case T_HashJoin: - _outHashJoin(str, obj); - break; - case T_Scan: - _outScan(str, obj); - break; - case T_SeqScan: - _outSeqScan(str, obj); - break; - case T_IndexScan: - _outIndexScan(str, obj); - break; - case T_Temp: - _outTemp(str, obj); - break; - case T_Sort: - _outSort(str, obj); - break; - case T_Agg: - _outAgg(str, obj); - break; - case T_Group: - _outGroup(str, obj); - break; - case T_Unique: - _outUnique(str, obj); - break; - case T_Hash: - _outHash(str, obj); - break; - case T_Tee: - _outTee(str, obj); - break; - case T_Resdom: - _outResdom(str, obj); - break; - case T_Fjoin: - _outFjoin(str, obj); - break; - case T_Expr: - _outExpr(str, obj); - break; - case T_Var: - _outVar(str, obj); - break; - case T_Const: - _outConst(str, obj); - break; - case T_Aggreg: - _outAggreg(str, obj); - break; - case T_Array: - _outArray(str, obj); - break; - case T_ArrayRef: - _outArrayRef(str, obj); - break; - case T_Func: - _outFunc(str, obj); - break; - case T_Oper: - _outOper(str, obj); - break; - case T_Param: - _outParam(str, obj); - break; - case T_EState: - _outEState(str, obj); - break; - case T_Rel: - _outRel(str, obj); - break; - case T_TargetEntry: - _outTargetEntry(str, obj); - break; - case T_RangeTblEntry: - _outRangeTblEntry(str, obj); - break; - case T_Path: - _outPath(str, obj); - break; - case T_IndexPath: - _outIndexPath(str, obj); - break; - case T_JoinPath: - _outJoinPath(str, obj); - break; - case T_MergePath: - _outMergePath(str, obj); - break; - case T_HashPath: - _outHashPath(str, obj); - break; - case T_OrderKey: - _outOrderKey(str, obj); - break; - case T_JoinKey: - _outJoinKey(str, obj); - break; - case T_MergeOrder: - _outMergeOrder(str, obj); - break; - case T_CInfo: - _outCInfo(str, obj); - break; - case T_JoinMethod: - _outJoinMethod(str, obj); - break; - case T_HInfo: - _outHInfo(str, obj); - break; - case T_JInfo: - _outJInfo(str, obj); - break; - case T_Iter: - _outIter(str, obj); - break; - case T_Stream: - _outStream(str, obj); - break; - case T_Integer: - case T_String: - case T_Float: - _outValue(str, obj); - break; - default: - elog(NOTICE, "_outNode: don't know how to print type %d", - nodeTag(obj)); - break; + case T_Query: + _outQuery(str, obj); + break; + case T_Plan: + _outPlan(str, obj); + break; + case T_Result: + _outResult(str, obj); + break; + case T_Existential: + _outExistential(str, obj); + break; + case T_Append: + _outAppend(str, obj); + break; + case T_Join: + _outJoin(str, obj); + break; + case T_NestLoop: + _outNestLoop(str, obj); + break; + case T_MergeJoin: + _outMergeJoin(str, obj); + break; + case T_HashJoin: + _outHashJoin(str, obj); + break; + case T_Scan: + _outScan(str, obj); + break; + case T_SeqScan: + _outSeqScan(str, obj); + break; + case T_IndexScan: + _outIndexScan(str, obj); + break; + case T_Temp: + _outTemp(str, obj); + break; + case T_Sort: + _outSort(str, obj); + break; + case T_Agg: + _outAgg(str, obj); + break; + case T_Group: + _outGroup(str, obj); + break; + case T_Unique: + _outUnique(str, obj); + break; + case T_Hash: + _outHash(str, obj); + break; + case T_Tee: + _outTee(str, obj); + break; + case T_Resdom: + _outResdom(str, obj); + break; + case T_Fjoin: + _outFjoin(str, obj); + break; + case T_Expr: + _outExpr(str, obj); + break; + case T_Var: + _outVar(str, obj); + break; + case T_Const: + _outConst(str, obj); + break; + case T_Aggreg: + _outAggreg(str, obj); + break; + case T_Array: + _outArray(str, obj); + break; + case T_ArrayRef: + _outArrayRef(str, obj); + break; + case T_Func: + _outFunc(str, obj); + break; + case T_Oper: + _outOper(str, obj); + break; + case T_Param: + _outParam(str, obj); + break; + case T_EState: + _outEState(str, obj); + break; + case T_Rel: + _outRel(str, obj); + break; + case T_TargetEntry: + _outTargetEntry(str, obj); + break; + case T_RangeTblEntry: + _outRangeTblEntry(str, obj); + break; + case T_Path: + _outPath(str, obj); + break; + case T_IndexPath: + _outIndexPath(str, obj); + break; + case T_JoinPath: + _outJoinPath(str, obj); + break; + case T_MergePath: + _outMergePath(str, obj); + break; + case T_HashPath: + _outHashPath(str, obj); + break; + case T_OrderKey: + _outOrderKey(str, obj); + break; + case T_JoinKey: + _outJoinKey(str, obj); + break; + case T_MergeOrder: + _outMergeOrder(str, obj); + break; + case T_CInfo: + _outCInfo(str, obj); + break; + case T_JoinMethod: + _outJoinMethod(str, obj); + break; + case T_HInfo: + _outHInfo(str, obj); + break; + case T_JInfo: + _outJInfo(str, obj); + break; + case T_Iter: + _outIter(str, obj); + break; + case T_Stream: + _outStream(str, obj); + break; + case T_Integer: + case T_String: + case T_Float: + _outValue(str, obj); + break; + default: + elog(NOTICE, "_outNode: don't know how to print type %d", + nodeTag(obj)); + break; } appendStringInfo(str, "}"); } @@ -1690,11 +1690,11 @@ _outNode(StringInfo str, void *obj) * nodeToString - * returns the ascii representation of the Node */ -char * +char * nodeToString(void *obj) { - StringInfo str; - char *s; + StringInfo str; + char *s; if (obj == NULL) return ""; diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 9fb61ed3ea7..dfe9d563453 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.7 1997/09/07 04:42:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.8 1997/09/08 02:23:42 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -33,7 +33,7 @@ #include "nodes/plannodes.h" #include "optimizer/clauses.h" -static char *plannode_type(Plan * p); +static char *plannode_type(Plan * p); /* * print-- @@ -42,7 +42,7 @@ static char *plannode_type(Plan * p); void print(void *obj) { - char *s; + char *s; s = nodeToString(obj); printf("%s\n", s); @@ -56,11 +56,11 @@ print(void *obj) void pprint(void *obj) { - char *s; - int i; - char line[80]; - int indentLev; - int j; + char *s; + int i; + char line[80]; + int indentLev; + int j; s = nodeToString(obj); @@ -77,44 +77,44 @@ pprint(void *obj) line[j] = s[i]; switch (line[j]) { - case '}': - if (j != indentLev * 3) - { - line[j] = '\0'; - printf("%s\n", line); - line[indentLev * 3] = '\0'; - printf("%s}\n", line); - } - else - { - line[j] = '\0'; - printf("%s}\n", line); - } - indentLev--; - j = indentLev * 3 - 1; /* print the line before : and - * resets */ - break; - case ')': - line[j + 1] = '\0'; - printf("%s\n", line); - j = indentLev * 3 - 1; - break; - case '{': - indentLev++; - /* !!! FALLS THROUGH */ - case ':': - if (j != 0) - { - line[j] = '\0'; + case '}': + if (j != indentLev * 3) + { + line[j] = '\0'; + printf("%s\n", line); + line[indentLev * 3] = '\0'; + printf("%s}\n", line); + } + else + { + line[j] = '\0'; + printf("%s}\n", line); + } + indentLev--; + j = indentLev * 3 - 1; /* print the line before : + * and resets */ + break; + case ')': + line[j + 1] = '\0'; printf("%s\n", line); - /* print the line before : and resets */ - for (j = 0; j < indentLev * 3; j++) + j = indentLev * 3 - 1; + break; + case '{': + indentLev++; + /* !!! FALLS THROUGH */ + case ':': + if (j != 0) { - line[j] = ' '; + line[j] = '\0'; + printf("%s\n", line); + /* print the line before : and resets */ + for (j = 0; j < indentLev * 3; j++) + { + line[j] = ' '; + } } - } - line[j] = s[i]; - break; + line[j] = s[i]; + break; } } line[j] = '\0'; @@ -137,14 +137,14 @@ pprint(void *obj) void print_rt(List * rtable) { - List *l; - int i = 1; + List *l; + int i = 1; printf("resno\trelname(refname)\trelid\tinFromCl\n"); printf("-----\t----------------\t-----\t--------\n"); foreach(l, rtable) { - RangeTblEntry *rte = lfirst(l); + RangeTblEntry *rte = lfirst(l); printf("%d\t%s(%s)\t%d\t%d\t%s\n", i, rte->relname, rte->refname, rte->relid, @@ -170,44 +170,44 @@ print_expr(Node * expr, List * rtable) if (IsA(expr, Var)) { - Var *var = (Var *) expr; - RangeTblEntry *rt; - char *relname, - *attname; + Var *var = (Var *) expr; + RangeTblEntry *rt; + char *relname, + *attname; switch (var->varno) { - case INNER: - relname = "INNER"; - attname = "?"; - break; - case OUTER: - relname = "OUTER"; - attname = "?"; - break; - default: - { - Relation r; - - rt = rt_fetch(var->varno, rtable); - relname = rt->relname; - r = heap_openr(relname); - if (rt->refname) - relname = rt->refname; /* table renamed */ - attname = getAttrName(r, var->varattno); - heap_close(r); - } - break; + case INNER: + relname = "INNER"; + attname = "?"; + break; + case OUTER: + relname = "OUTER"; + attname = "?"; + break; + default: + { + Relation r; + + rt = rt_fetch(var->varno, rtable); + relname = rt->relname; + r = heap_openr(relname); + if (rt->refname) + relname = rt->refname; /* table renamed */ + attname = getAttrName(r, var->varattno); + heap_close(r); + } + break; } printf("%s.%s", relname, attname); } else if (IsA(expr, Expr)) { - Expr *e = (Expr *) expr; + Expr *e = (Expr *) expr; if (is_opclause(expr)) { - char *opname; + char *opname; print_expr((Node *) get_leftop(e), rtable); opname = get_opname(((Oper *) e->oper)->opno); @@ -232,12 +232,12 @@ print_expr(Node * expr, List * rtable) void print_keys(List * keys, List * rtable) { - List *k; + List *k; printf("("); foreach(k, keys) { - Node *var = lfirst((List *) lfirst(k)); + Node *var = lfirst((List *) lfirst(k)); print_expr(var, rtable); if (lnext(k)) @@ -253,12 +253,12 @@ print_keys(List * keys, List * rtable) void print_tl(List * tlist, List * rtable) { - List *tl; + List *tl; printf("(\n"); foreach(tl, tlist) { - TargetEntry *tle = lfirst(tl); + TargetEntry *tle = lfirst(tl); printf("\t%d %s\t", tle->resdom->resno, tle->resdom->resname); if (tle->resdom->reskey != 0) @@ -296,74 +296,74 @@ print_slot(TupleTableSlot * slot) debugtup(slot->val, slot->ttc_tupleDescriptor); } -static char * +static char * plannode_type(Plan * p) { switch (nodeTag(p)) { - case T_Plan: - return "PLAN"; - break; - case T_Existential: - return "EXISTENTIAL"; - break; - case T_Result: - return "RESULT"; - break; - case T_Append: - return "APPEND"; - break; - case T_Scan: - return "SCAN"; - break; - case T_SeqScan: - return "SEQSCAN"; - break; - case T_IndexScan: - return "INDEXSCAN"; - break; - case T_Join: - return "JOIN"; - break; - case T_NestLoop: - return "NESTLOOP"; - break; - case T_MergeJoin: - return "MERGEJOIN"; - break; - case T_HashJoin: - return "HASHJOIN"; - break; - case T_Temp: - return "TEMP"; - break; - case T_Material: - return "MATERIAL"; - break; - case T_Sort: - return "SORT"; - break; - case T_Agg: - return "AGG"; - break; - case T_Unique: - return "UNIQUE"; - break; - case T_Hash: - return "HASH"; - break; - case T_Tee: - return "TEE"; - break; - case T_Choose: - return "CHOOSE"; - break; - case T_Group: - return "GROUP"; - break; - default: - return "UNKNOWN"; - break; + case T_Plan: + return "PLAN"; + break; + case T_Existential: + return "EXISTENTIAL"; + break; + case T_Result: + return "RESULT"; + break; + case T_Append: + return "APPEND"; + break; + case T_Scan: + return "SCAN"; + break; + case T_SeqScan: + return "SEQSCAN"; + break; + case T_IndexScan: + return "INDEXSCAN"; + break; + case T_Join: + return "JOIN"; + break; + case T_NestLoop: + return "NESTLOOP"; + break; + case T_MergeJoin: + return "MERGEJOIN"; + break; + case T_HashJoin: + return "HASHJOIN"; + break; + case T_Temp: + return "TEMP"; + break; + case T_Material: + return "MATERIAL"; + break; + case T_Sort: + return "SORT"; + break; + case T_Agg: + return "AGG"; + break; + case T_Unique: + return "UNIQUE"; + break; + case T_Hash: + return "HASH"; + break; + case T_Tee: + return "TEE"; + break; + case T_Choose: + return "CHOOSE"; + break; + case T_Group: + return "GROUP"; + break; + default: + return "UNKNOWN"; + break; } } @@ -377,8 +377,8 @@ plannode_type(Plan * p) void print_plan_recursive(Plan * p, Query * parsetree, int indentLevel, char *label) { - int i; - char extraInfo[100]; + int i; + char extraInfo[100]; if (!p) return; @@ -388,7 +388,7 @@ print_plan_recursive(Plan * p, Query * parsetree, int indentLevel, char *label) p->cost, p->plan_size, p->plan_width); if (IsA(p, Scan) || IsA(p, SeqScan)) { - RangeTblEntry *rte; + RangeTblEntry *rte; rte = rt_fetch(((Scan *) p)->scanrelid, parsetree->rtable); strNcpy(extraInfo, rte->relname, NAMEDATALEN - 1); diff --git a/src/backend/nodes/read.c b/src/backend/nodes/read.c index f0baa4f14d7..60b45822eb6 100644 --- a/src/backend/nodes/read.c +++ b/src/backend/nodes/read.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.4 1997/09/07 04:42:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/read.c,v 1.5 1997/09/08 02:23:43 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -28,10 +28,10 @@ * stringToNode - * returns a Node with a given legal ascii representation */ -void * +void * stringToNode(char *str) { - void *retval; + void *retval; lsptok(str, NULL); /* set the string used in lsptok */ retval = nodeRead(true); /* start reading */ @@ -61,10 +61,10 @@ stringToNode(char *str) * * Assumption: the ascii representation is legal */ -static NodeTag +static NodeTag nodeTokenType(char *token, int length) { - NodeTag retval = 0; + NodeTag retval = 0; /* * Check if the token is a number (decimal or integer, positive or @@ -116,11 +116,11 @@ nodeTokenType(char *token, int length) * returning a token by calling lsptok with length == NULL. * */ -char * +char * lsptok(char *string, int *length) { - static char *local_str; - char *ret_string; + static char *local_str; + char *ret_string; if (string != NULL) { @@ -174,16 +174,16 @@ lsptok(char *string, int *length) * Secrets: He assumes that lsptok already has the string (see below). * Any callers should set read_car_only to true. */ -void * +void * nodeRead(bool read_car_only) { - char *token; - NodeTag type; - Node *this_value = NULL, - *return_value = NULL; - int tok_len; - char tmp; - bool make_dotted_pair_cell = false; + char *token; + NodeTag type; + Node *this_value = NULL, + *return_value = NULL; + int tok_len; + char tmp; + bool make_dotted_pair_cell = false; token = lsptok(NULL, &tok_len); @@ -194,93 +194,93 @@ nodeRead(bool read_car_only) switch (type) { - case PLAN_SYM: - this_value = parsePlanString(); - token = lsptok(NULL, &tok_len); - if (token[0] != '}') - return (NULL); + case PLAN_SYM: + this_value = parsePlanString(); + token = lsptok(NULL, &tok_len); + if (token[0] != '}') + return (NULL); - if (!read_car_only) - make_dotted_pair_cell = true; - else - make_dotted_pair_cell = false; - break; - case LEFT_PAREN: - if (!read_car_only) - { - List *l = makeNode(List); + if (!read_car_only) + make_dotted_pair_cell = true; + else + make_dotted_pair_cell = false; + break; + case LEFT_PAREN: + if (!read_car_only) + { + List *l = makeNode(List); - lfirst(l) = nodeRead(false); - lnext(l) = nodeRead(false); - this_value = (Node *) l; - } - else - { - this_value = nodeRead(false); - } - break; - case RIGHT_PAREN: - this_value = NULL; - break; - case AT_SYMBOL: - break; - case ATOM_TOKEN: - if (!strncmp(token, "nil", 3)) - { + lfirst(l) = nodeRead(false); + lnext(l) = nodeRead(false); + this_value = (Node *) l; + } + else + { + this_value = nodeRead(false); + } + break; + case RIGHT_PAREN: this_value = NULL; - - /* - * It might be "nil" but it is an atom! - */ - if (read_car_only) + break; + case AT_SYMBOL: + break; + case ATOM_TOKEN: + if (!strncmp(token, "nil", 3)) { - make_dotted_pair_cell = false; + this_value = NULL; + + /* + * It might be "nil" but it is an atom! + */ + if (read_car_only) + { + make_dotted_pair_cell = false; + } + else + { + make_dotted_pair_cell = true; + } } else { + tmp = token[tok_len]; + token[tok_len] = '\0'; + this_value = (Node *) pstrdup(token); /* !attention! not a + * Node. use with + * caution */ + token[tok_len] = tmp; make_dotted_pair_cell = true; } - } - else - { + break; + case T_Float: tmp = token[tok_len]; token[tok_len] = '\0'; - this_value = (Node *) pstrdup(token); /* !attention! not a - * Node. use with - * caution */ + this_value = (Node *) makeFloat(atof(token)); token[tok_len] = tmp; make_dotted_pair_cell = true; - } - break; - case T_Float: - tmp = token[tok_len]; - token[tok_len] = '\0'; - this_value = (Node *) makeFloat(atof(token)); - token[tok_len] = tmp; - make_dotted_pair_cell = true; - break; - case T_Integer: - tmp = token[tok_len]; - token[tok_len] = '\0'; - this_value = (Node *) makeInteger(atoi(token)); - token[tok_len] = tmp; - make_dotted_pair_cell = true; - break; - case T_String: - tmp = token[tok_len - 1]; - token[tok_len - 1] = '\0'; - token++; - this_value = (Node *) makeString(token); /* !! not strdup'd */ - token[tok_len - 2] = tmp; - make_dotted_pair_cell = true; - break; - default: - elog(WARN, "nodeRead: Bad type %d", type); - break; + break; + case T_Integer: + tmp = token[tok_len]; + token[tok_len] = '\0'; + this_value = (Node *) makeInteger(atoi(token)); + token[tok_len] = tmp; + make_dotted_pair_cell = true; + break; + case T_String: + tmp = token[tok_len - 1]; + token[tok_len - 1] = '\0'; + token++; + this_value = (Node *) makeString(token); /* !! not strdup'd */ + token[tok_len - 2] = tmp; + make_dotted_pair_cell = true; + break; + default: + elog(WARN, "nodeRead: Bad type %d", type); + break; } if (make_dotted_pair_cell) { - List *l = makeNode(List); + List *l = makeNode(List); lfirst(l) = this_value; if (!read_car_only) diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index f42d5d536ee..eca6c480a22 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.7 1997/09/07 04:42:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.8 1997/09/08 02:23:45 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -51,12 +51,12 @@ * ---------------- */ -static Datum readDatum(Oid type); +static Datum readDatum(Oid type); -static List * +static List * toIntList(List * list) { - List *l; + List *l; foreach(l, list) { @@ -70,12 +70,12 @@ toIntList(List * list) * _readQuery * ---------------- */ -static Query * +static Query * _readQuery() { - Query *local_node; - char *token; - int length; + Query *local_node; + char *token; + int length; local_node = makeNode(Query); @@ -89,7 +89,7 @@ _readQuery() local_node->utilityStmt = NULL; else { - NotifyStmt *n = makeNode(NotifyStmt); + NotifyStmt *n = makeNode(NotifyStmt); n->relname = palloc(length + 1); strNcpy(n->relname, token, length); @@ -130,8 +130,8 @@ _readQuery() static void _getPlan(Plan * node) { - char *token; - int length; + char *token; + int length; token = lsptok(NULL, &length); /* first token is :cost */ token = lsptok(NULL, &length); /* next is the actual cost */ @@ -181,10 +181,10 @@ _getPlan(Plan * node) * _readPlan * ---------------- */ -static Plan * +static Plan * _readPlan() { - Plan *local_node; + Plan *local_node; local_node = makeNode(Plan); @@ -200,12 +200,12 @@ _readPlan() * sizes of things. * ---------------- */ -static Result * +static Result * _readResult() { - Result *local_node; - char *token; - int length; + Result *local_node; + char *token; + int length; local_node = makeNode(Result); @@ -226,7 +226,7 @@ _readResult() static Existential * _readExistential() { - Existential *local_node; + Existential *local_node; local_node = makeNode(Existential); @@ -242,12 +242,12 @@ _readExistential() * ---------------- */ -static Append * +static Append * _readAppend() { - Append *local_node; - char *token; - int length; + Append *local_node; + char *token; + int length; local_node = makeNode(Append); @@ -285,10 +285,10 @@ _getJoin(Join * node) * Join is a subclass of Plan * ---------------- */ -static Join * +static Join * _readJoin() { - Join *local_node; + Join *local_node; local_node = makeNode(Join); @@ -307,7 +307,7 @@ _readJoin() static NestLoop * _readNestLoop() { - NestLoop *local_node; + NestLoop *local_node; local_node = makeNode(NestLoop); @@ -325,9 +325,9 @@ _readNestLoop() static MergeJoin * _readMergeJoin() { - MergeJoin *local_node; - char *token; - int length; + MergeJoin *local_node; + char *token; + int length; local_node = makeNode(MergeJoin); @@ -351,9 +351,9 @@ _readMergeJoin() static HashJoin * _readHashJoin() { - HashJoin *local_node; - char *token; - int length; + HashJoin *local_node; + char *token; + int length; local_node = makeNode(HashJoin); @@ -398,8 +398,8 @@ _readHashJoin() static void _getScan(Scan * node) { - char *token; - int length; + char *token; + int length; _getPlan((Plan *) node); @@ -414,10 +414,10 @@ _getScan(Scan * node) * Scan is a subclass of Plan (Not Node, see above). * ---------------- */ -static Scan * +static Scan * _readScan() { - Scan *local_node; + Scan *local_node; local_node = makeNode(Scan); @@ -435,7 +435,7 @@ _readScan() static SeqScan * _readSeqScan() { - SeqScan *local_node; + SeqScan *local_node; local_node = makeNode(SeqScan); @@ -453,9 +453,9 @@ _readSeqScan() static IndexScan * _readIndexScan() { - IndexScan *local_node; - char *token; - int length; + IndexScan *local_node; + char *token; + int length; local_node = makeNode(IndexScan); @@ -477,12 +477,12 @@ _readIndexScan() * Temp is a subclass of Plan * ---------------- */ -static Temp * +static Temp * _readTemp() { - Temp *local_node; - char *token; - int length; + Temp *local_node; + char *token; + int length; local_node = makeNode(Temp); @@ -505,12 +505,12 @@ _readTemp() * Sort is a subclass of Temp * ---------------- */ -static Sort * +static Sort * _readSort() { - Sort *local_node; - char *token; - int length; + Sort *local_node; + char *token; + int length; local_node = makeNode(Sort); @@ -527,12 +527,12 @@ _readSort() return (local_node); } -static Agg * +static Agg * _readAgg() { - Agg *local_node; - char *token; - int length; + Agg *local_node; + char *token; + int length; local_node = makeNode(Agg); _getPlan((Plan *) local_node); @@ -549,12 +549,12 @@ _readAgg() * * For some reason, unique is a subclass of Temp. */ -static Unique * +static Unique * _readUnique() { - Unique *local_node; - char *token; - int length; + Unique *local_node; + char *token; + int length; local_node = makeNode(Unique); @@ -577,12 +577,12 @@ _readUnique() * Hash is a subclass of Temp * ---------------- */ -static Hash * +static Hash * _readHash() { - Hash *local_node; - char *token; - int length; + Hash *local_node; + char *token; + int length; local_node = makeNode(Hash); @@ -616,12 +616,12 @@ _readHash() * Resdom is a subclass of Node * ---------------- */ -static Resdom * +static Resdom * _readResdom() { - Resdom *local_node; - char *token; - int length; + Resdom *local_node; + char *token; + int length; local_node = makeNode(Resdom); @@ -680,12 +680,12 @@ _readResdom() * Expr is a subclass of Node * ---------------- */ -static Expr * +static Expr * _readExpr() { - Expr *local_node; - char *token; - int length; + Expr *local_node; + char *token; + int length; local_node = makeNode(Expr); @@ -731,12 +731,12 @@ _readExpr() * Var is a subclass of Expr * ---------------- */ -static Var * +static Var * _readVar() { - Var *local_node; - char *token; - int length; + Var *local_node; + char *token; + int length; local_node = makeNode(Var); @@ -769,12 +769,12 @@ _readVar() * Array is a subclass of Expr * ---------------- */ -static Array * +static Array * _readArray() { - Array *local_node; - char *token; - int length; + Array *local_node; + char *token; + int length; local_node = makeNode(Array); @@ -814,9 +814,9 @@ _readArray() static ArrayRef * _readArrayRef() { - ArrayRef *local_node; - char *token; - int length; + ArrayRef *local_node; + char *token; + int length; local_node = makeNode(ArrayRef); @@ -857,12 +857,12 @@ _readArrayRef() * Const is a subclass of Expr * ---------------- */ -static Const * +static Const * _readConst() { - Const *local_node; - char *token; - int length; + Const *local_node; + char *token; + int length; local_node = makeNode(Const); @@ -924,12 +924,12 @@ _readConst() * Func is a subclass of Expr * ---------------- */ -static Func * +static Func * _readFunc() { - Func *local_node; - char *token; - int length; + Func *local_node; + char *token; + int length; local_node = makeNode(Func); @@ -978,12 +978,12 @@ _readFunc() * Oper is a subclass of Expr * ---------------- */ -static Oper * +static Oper * _readOper() { - Oper *local_node; - char *token; - int length; + Oper *local_node; + char *token; + int length; local_node = makeNode(Oper); @@ -1014,12 +1014,12 @@ _readOper() * Param is a subclass of Expr * ---------------- */ -static Param * +static Param * _readParam() { - Param *local_node; - char *token; - int length; + Param *local_node; + char *token; + int length; local_node = makeNode(Param); @@ -1055,12 +1055,12 @@ _readParam() * Aggreg is a subclass of Node * ---------------- */ -static Aggreg * +static Aggreg * _readAggreg() { - Aggreg *local_node; - char *token; - int length; + Aggreg *local_node; + char *token; + int length; local_node = makeNode(Aggreg); @@ -1097,12 +1097,12 @@ _readAggreg() * EState is a subclass of Node. * ---------------- */ -static EState * +static EState * _readEState() { - EState *local_node; - char *token; - int length; + EState *local_node; + char *token; + int length; local_node = makeNode(EState); @@ -1132,12 +1132,12 @@ _readEState() * _readRel * ---------------- */ -static Rel * +static Rel * _readRel() { - Rel *local_node; - char *token; - int length; + Rel *local_node; + char *token; + int length; local_node = makeNode(Rel); @@ -1217,9 +1217,9 @@ _readRel() static TargetEntry * _readTargetEntry() { - TargetEntry *local_node; - char *token; - int length; + TargetEntry *local_node; + char *token; + int length; local_node = makeNode(TargetEntry); @@ -1239,9 +1239,9 @@ _readTargetEntry() static RangeTblEntry * _readRangeTblEntry() { - RangeTblEntry *local_node; - char *token; - int length; + RangeTblEntry *local_node; + char *token; + int length; local_node = makeNode(RangeTblEntry); @@ -1303,12 +1303,12 @@ _readRangeTblEntry() * Path is a subclass of Node. * ---------------- */ -static Path * +static Path * _readPath() { - Path *local_node; - char *token; - int length; + Path *local_node; + char *token; + int length; local_node = makeNode(Path); @@ -1341,9 +1341,9 @@ _readPath() static IndexPath * _readIndexPath() { - IndexPath *local_node; - char *token; - int length; + IndexPath *local_node; + char *token; + int length; local_node = makeNode(IndexPath); @@ -1382,9 +1382,9 @@ _readIndexPath() static JoinPath * _readJoinPath() { - JoinPath *local_node; - char *token; - int length; + JoinPath *local_node; + char *token; + int length; local_node = makeNode(JoinPath); @@ -1449,9 +1449,9 @@ _readJoinPath() static MergePath * _readMergePath() { - MergePath *local_node; - char *token; - int length; + MergePath *local_node; + char *token; + int length; local_node = makeNode(MergePath); @@ -1526,9 +1526,9 @@ _readMergePath() static HashPath * _readHashPath() { - HashPath *local_node; - char *token; - int length; + HashPath *local_node; + char *token; + int length; local_node = makeNode(HashPath); @@ -1603,9 +1603,9 @@ _readHashPath() static OrderKey * _readOrderKey() { - OrderKey *local_node; - char *token; - int length; + OrderKey *local_node; + char *token; + int length; local_node = makeNode(OrderKey); @@ -1631,9 +1631,9 @@ _readOrderKey() static JoinKey * _readJoinKey() { - JoinKey *local_node; - char *token; - int length; + JoinKey *local_node; + char *token; + int length; local_node = makeNode(JoinKey); @@ -1655,9 +1655,9 @@ _readJoinKey() static MergeOrder * _readMergeOrder() { - MergeOrder *local_node; - char *token; - int length; + MergeOrder *local_node; + char *token; + int length; local_node = makeNode(MergeOrder); token = lsptok(NULL, &length); /* get :join_operator */ @@ -1694,12 +1694,12 @@ _readMergeOrder() * CInfo is a subclass of Node. * ---------------- */ -static CInfo * +static CInfo * _readCInfo() { - CInfo *local_node; - char *token; - int length; + CInfo *local_node; + char *token; + int length; local_node = makeNode(CInfo); @@ -1746,9 +1746,9 @@ _readCInfo() static JoinMethod * _readJoinMethod() { - JoinMethod *local_node; - char *token; - int length; + JoinMethod *local_node; + char *token; + int length; local_node = makeNode(JoinMethod); @@ -1767,12 +1767,12 @@ _readJoinMethod() * HInfo is a subclass of JoinMethod. * ---------------- */ -static HInfo * +static HInfo * _readHInfo() { - HInfo *local_node; - char *token; - int length; + HInfo *local_node; + char *token; + int length; local_node = makeNode(HInfo); @@ -1796,12 +1796,12 @@ _readHInfo() * JInfo is a subclass of Node. * ---------------- */ -static JInfo * +static JInfo * _readJInfo() { - JInfo *local_node; - char *token; - int length; + JInfo *local_node; + char *token; + int length; local_node = makeNode(JInfo); @@ -1842,12 +1842,12 @@ _readJInfo() * * ---------------- */ -static Iter * +static Iter * _readIter() { - Iter *local_node; - char *token; - int length; + Iter *local_node; + char *token; + int length; local_node = makeNode(Iter); @@ -1867,12 +1867,12 @@ _readIter() * The string passed to parsePlanString must be null-terminated. * ---------------- */ -Node * +Node * parsePlanString(void) { - char *token; - int length; - void *return_value = NULL; + char *token; + int length; + void *return_value = NULL; token = lsptok(NULL, &length); @@ -2070,16 +2070,16 @@ parsePlanString(void) * create the appropriate Datum * ---------------- */ -static Datum +static Datum readDatum(Oid type) { - int length; - int tokenLength; - char *token; - bool byValue; - Datum res; - char *s; - int i; + int length; + int tokenLength; + char *token; + bool byValue; + Datum res; + char *s; + int i; byValue = get_typbyval(type); diff --git a/src/backend/optimizer/geqo/geqo_copy.c b/src/backend/optimizer/geqo/geqo_copy.c index 4c35f99f9f5..3a61f5d315e 100644 --- a/src/backend/optimizer/geqo/geqo_copy.c +++ b/src/backend/optimizer/geqo/geqo_copy.c @@ -4,7 +4,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_copy.c,v 1.2 1997/09/07 04:43:01 momjian Exp $ + * $Id: geqo_copy.c,v 1.3 1997/09/08 02:23:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,7 +58,7 @@ void geqo_copy(Chromosome * chromo1, Chromosome * chromo2, int string_length) { - int i; + int i; for (i = 0; i < string_length; i++) chromo1->string[i] = chromo2->string[i]; diff --git a/src/backend/optimizer/geqo/geqo_cx.c b/src/backend/optimizer/geqo/geqo_cx.c index dfde1bdc530..37f49584caf 100644 --- a/src/backend/optimizer/geqo/geqo_cx.c +++ b/src/backend/optimizer/geqo/geqo_cx.c @@ -6,7 +6,7 @@ * CX operator according to Oliver et al * (Proc 2nd Int'l Conf on GA's) * -* $Id: geqo_cx.c,v 1.2 1997/09/07 04:43:02 momjian Exp $ +* $Id: geqo_cx.c,v 1.3 1997/09/08 02:23:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,11 +63,11 @@ int cx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table) { - int i, - start_pos, - curr_pos; - int count = 0; - int num_diffs = 0; + int i, + start_pos, + curr_pos; + int count = 0; + int num_diffs = 0; /* initialize city table */ for (i = 1; i <= num_gene; i++) diff --git a/src/backend/optimizer/geqo/geqo_erx.c b/src/backend/optimizer/geqo/geqo_erx.c index 9d0f93efe8c..05381cf4da0 100644 --- a/src/backend/optimizer/geqo/geqo_erx.c +++ b/src/backend/optimizer/geqo/geqo_erx.c @@ -3,7 +3,7 @@ * geqo_erx.c-- * edge recombination crossover [ER] * -* $Id: geqo_erx.c,v 1.3 1997/09/07 04:43:04 momjian Exp $ +* $Id: geqo_erx.c,v 1.4 1997/09/08 02:23:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,11 +52,11 @@ #include "optimizer/geqo_random.h" -static int gimme_edge(Gene gene1, Gene gene2, Edge * edge_table); -static void remove_gene(Gene gene, Edge edge, Edge * edge_table); -static Gene gimme_gene(Edge edge, Edge * edge_table); +static int gimme_edge(Gene gene1, Gene gene2, Edge * edge_table); +static void remove_gene(Gene gene, Edge edge, Edge * edge_table); +static Gene gimme_gene(Edge edge, Edge * edge_table); -static Gene edge_failure(Gene * gene, int index, Edge * edge_table, int num_gene); +static Gene edge_failure(Gene * gene, int index, Edge * edge_table, int num_gene); /* alloc_edge_table-- @@ -65,10 +65,10 @@ static Gene edge_failure(Gene * gene, int index, Edge * edge_table, int num_gen * */ -Edge * +Edge * alloc_edge_table(int num_gene) { - Edge *edge_table; + Edge *edge_table; /* * palloc one extra location so that nodes numbered 1..n can be @@ -107,10 +107,10 @@ free_edge_table(Edge * edge_table) float gimme_edge_table(Gene * tour1, Gene * tour2, int num_gene, Edge * edge_table) { - int i, - index1, - index2; - int edge_total; /* total number of unique edges in two + int i, + index1, + index2; + int edge_total; /* total number of unique edges in two * genes */ /* at first clear the edge table's old data */ @@ -167,10 +167,10 @@ gimme_edge_table(Gene * tour1, Gene * tour2, int num_gene, Edge * edge_table) static int gimme_edge(Gene gene1, Gene gene2, Edge * edge_table) { - int i; - int edges; - int city1 = (int) gene1; - int city2 = (int) gene2; + int i; + int edges; + int city1 = (int) gene1; + int city2 = (int) gene2; /* check whether edge city1->city2 already exists */ @@ -209,8 +209,8 @@ gimme_edge(Gene gene1, Gene gene2, Edge * edge_table) int gimme_tour(Edge * edge_table, Gene * new_gene, int num_gene) { - int i; - int edge_failures = 0; + int i; + int edge_failures = 0; new_gene[0] = (Gene) geqo_randint(num_gene, 1); /* choose int between 1 * and num_gene */ @@ -258,10 +258,10 @@ gimme_tour(Edge * edge_table, Gene * new_gene, int num_gene) static void remove_gene(Gene gene, Edge edge, Edge * edge_table) { - int i, - j; - int possess_edge; - int genes_remaining; + int i, + j; + int possess_edge; + int genes_remaining; /* * do for every gene known to have an edge to input gene (i.e. in @@ -297,14 +297,14 @@ remove_gene(Gene gene, Edge edge, Edge * edge_table) * (i.e. edges which both genes possess) * */ -static Gene +static Gene gimme_gene(Edge edge, Edge * edge_table) { - int i; - Gene friend; - int minimum_edges; - int minimum_count = -1; - int rand_decision; + int i; + Gene friend; + int minimum_edges; + int minimum_count = -1; + int rand_decision; /* * no point has edges to more than 4 other points thus, this contrived @@ -388,14 +388,14 @@ gimme_gene(Edge edge, Edge * edge_table) * routine for handling edge failure * */ -static Gene +static Gene edge_failure(Gene * gene, int index, Edge * edge_table, int num_gene) { - int i; - Gene fail_gene = gene[index]; - int remaining_edges = 0; - int four_count = 0; - int rand_decision; + int i; + Gene fail_gene = gene[index]; + int remaining_edges = 0; + int four_count = 0; + int rand_decision; /* diff --git a/src/backend/optimizer/geqo/geqo_eval.c b/src/backend/optimizer/geqo/geqo_eval.c index ba34d8f3e02..731b1c4fcd0 100644 --- a/src/backend/optimizer/geqo/geqo_eval.c +++ b/src/backend/optimizer/geqo/geqo_eval.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_eval.c,v 1.13 1997/09/07 04:43:06 momjian Exp $ + * $Id: geqo_eval.c,v 1.14 1997/09/08 02:23:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,13 +50,13 @@ #include "optimizer/geqo_paths.h" -static List *gimme_clause_joins(Query * root, Rel * outer_rel, Rel * inner_rel); -static Rel *gimme_clauseless_join(Rel * outer_rel, Rel * inner_rel); -static Rel *init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo); -static List *new_join_tlist(List * tlist, List * other_relids, int first_resdomno); -static List *new_joininfo_list(List * joininfo_list, List * join_relids); -static void geqo_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel); -static Rel *geqo_nth(int stop, List * rels); +static List *gimme_clause_joins(Query * root, Rel * outer_rel, Rel * inner_rel); +static Rel *gimme_clauseless_join(Rel * outer_rel, Rel * inner_rel); +static Rel *init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo); +static List *new_join_tlist(List * tlist, List * other_relids, int first_resdomno); +static List *new_joininfo_list(List * joininfo_list, List * join_relids); +static void geqo_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel); +static Rel *geqo_nth(int stop, List * rels); /* * geqo_eval-- @@ -66,9 +66,9 @@ static Rel *geqo_nth(int stop, List * rels); Cost geqo_eval(Query * root, Gene * tour, int num_gene) { - Rel *joinrel; - Cost fitness; - List *temp; + Rel *joinrel; + Cost fitness; + List *temp; /* remember root->join_relation_list_ ... */ @@ -98,14 +98,14 @@ geqo_eval(Query * root, Gene * tour, int num_gene) * * Returns a new join relation incorporating all joins in a left-sided tree. */ -Rel * +Rel * gimme_tree(Query * root, Gene * tour, int rel_count, int num_gene, Rel * outer_rel) { - Rel *inner_rel; /* current relation */ - int base_rel_index; + Rel *inner_rel; /* current relation */ + int base_rel_index; - List *new_rels = NIL; - Rel *new_rel = NULL; + List *new_rels = NIL; + Rel *new_rel = NULL; if (rel_count < num_gene) { /* tree not yet finished */ @@ -190,21 +190,21 @@ gimme_tree(Query * root, Gene * tour, int rel_count, int num_gene, Rel * outer_r * Returns a list of new join relations. */ -static List * +static List * gimme_clause_joins(Query * root, Rel * outer_rel, Rel * inner_rel) { - List *join_list = NIL; - List *i = NIL; - List *joininfo_list = (List *) outer_rel->joininfo; + List *join_list = NIL; + List *i = NIL; + List *joininfo_list = (List *) outer_rel->joininfo; foreach(i, joininfo_list) { - JInfo *joininfo = (JInfo *) lfirst(i); - Rel *rel = NULL; + JInfo *joininfo = (JInfo *) lfirst(i); + Rel *rel = NULL; if (!joininfo->inactive) { - List *other_rels = (List *) joininfo->otherrels; + List *other_rels = (List *) joininfo->otherrels; if (other_rels != NIL) { @@ -243,7 +243,7 @@ gimme_clause_joins(Query * root, Rel * outer_rel, Rel * inner_rel) * Returns a new join relation. */ -static Rel * +static Rel * gimme_clauseless_join(Rel * outer_rel, Rel * inner_rel) { return (init_join_rel(outer_rel, inner_rel, (JInfo *) NULL)); @@ -260,13 +260,13 @@ gimme_clauseless_join(Rel * outer_rel, Rel * inner_rel) * * Returns the new join relation node. */ -static Rel * +static Rel * init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo) { - Rel *joinrel = makeNode(Rel); - List *joinrel_joininfo_list = NIL; - List *new_outer_tlist; - List *new_inner_tlist; + Rel *joinrel = makeNode(Rel); + List *joinrel_joininfo_list = NIL; + List *new_outer_tlist; + List *new_inner_tlist; /* * Create a new tlist by removing irrelevant elements from both tlists @@ -338,18 +338,18 @@ init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo) * * Returns the new target list. */ -static List * +static List * new_join_tlist(List * tlist, List * other_relids, int first_resdomno) { - int resdomno = first_resdomno - 1; - TargetEntry *xtl = NULL; - List *temp_node = NIL; - List *t_list = NIL; - List *i = NIL; - List *join_list = NIL; - bool in_final_tlist = false; + int resdomno = first_resdomno - 1; + TargetEntry *xtl = NULL; + List *temp_node = NIL; + List *t_list = NIL; + List *i = NIL; + List *join_list = NIL; + bool in_final_tlist = false; foreach(i, tlist) @@ -388,18 +388,18 @@ new_join_tlist(List * tlist, * * Returns a list of joininfo nodes, new and old. */ -static List * +static List * new_joininfo_list(List * joininfo_list, List * join_relids) { - List *current_joininfo_list = NIL; - List *new_otherrels = NIL; - JInfo *other_joininfo = (JInfo *) NULL; - List *xjoininfo = NIL; + List *current_joininfo_list = NIL; + List *new_otherrels = NIL; + JInfo *other_joininfo = (JInfo *) NULL; + List *xjoininfo = NIL; foreach(xjoininfo, joininfo_list) { - List *or; - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + List *or; + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); new_otherrels = joininfo->otherrels; foreach(or, new_otherrels) @@ -456,21 +456,21 @@ new_joininfo_list(List * joininfo_list, List * join_relids) static void geqo_add_new_joininfos(Query * root, List * joinrels, List * outerrels) { - List *xjoinrel = NIL; - List *xrelid = NIL; - List *xrel = NIL; - List *xjoininfo = NIL; + List *xjoinrel = NIL; + List *xrelid = NIL; + List *xrel = NIL; + List *xjoininfo = NIL; - Rel *rel; - List *relids; + Rel *rel; + List *relids; - List *super_rels; - List *xsuper_rel = NIL; - JInfo *new_joininfo; + List *super_rels; + List *xsuper_rel = NIL; + JInfo *new_joininfo; foreach(xjoinrel, joinrels) { - Rel *joinrel = (Rel *) lfirst(xjoinrel); + Rel *joinrel = (Rel *) lfirst(xjoinrel); foreach(xrelid, joinrel->relids) { @@ -506,15 +506,15 @@ geqo_add_new_joininfos(Query * root, List * joinrels, List * outerrels) } foreach(xjoinrel, joinrels) { - Rel *joinrel = (Rel *) lfirst(xjoinrel); + Rel *joinrel = (Rel *) lfirst(xjoinrel); foreach(xjoininfo, joinrel->joininfo) { - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); - List *other_rels = joininfo->otherrels; - List *clause_info = joininfo->jinfoclauseinfo; - bool mergesortable = joininfo->mergesortable; - bool hashjoinable = joininfo->hashjoinable; + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + List *other_rels = joininfo->otherrels; + List *clause_info = joininfo->jinfoclauseinfo; + bool mergesortable = joininfo->mergesortable; + bool hashjoinable = joininfo->hashjoinable; foreach(xrelid, other_rels) { @@ -553,12 +553,12 @@ geqo_add_new_joininfos(Query * root, List * joinrels, List * outerrels) foreach(xsuper_rel, super_rels) { - Rel *super_rel = (Rel *) lfirst(xsuper_rel); + Rel *super_rel = (Rel *) lfirst(xsuper_rel); if (nonoverlap_rels(super_rel, joinrel)) { - List *new_relids = super_rel->relids; - JInfo *other_joininfo = + List *new_relids = super_rel->relids; + JInfo *other_joininfo = joininfo_member(new_relids, joinrel->joininfo); @@ -570,7 +570,7 @@ geqo_add_new_joininfos(Query * root, List * joinrels, List * outerrels) } else { - JInfo *new_joininfo = makeNode(JInfo); + JInfo *new_joininfo = makeNode(JInfo); new_joininfo->otherrels = new_relids; new_joininfo->jinfoclauseinfo = clause_info; @@ -602,12 +602,12 @@ geqo_add_new_joininfos(Query * root, List * joinrels, List * outerrels) * * Returns the list of final join relations. */ -static List * +static List * geqo_final_join_rels(List * join_rel_list) { - List *xrel = NIL; - List *temp = NIL; - List *t_list = NIL; + List *xrel = NIL; + List *temp = NIL; + List *t_list = NIL; /* * find the relations that has no further joins, i.e., its joininfos @@ -615,13 +615,13 @@ geqo_final_join_rels(List * join_rel_list) */ foreach(xrel, join_rel_list) { - Rel *rel = (Rel *) lfirst(xrel); - List *xjoininfo = NIL; - bool final = true; + Rel *rel = (Rel *) lfirst(xrel); + List *xjoininfo = NIL; + bool final = true; foreach(xjoininfo, rel->joininfo) { - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); if (joininfo->otherrels != NIL) { @@ -663,20 +663,20 @@ add_superrels(Rel * rel, Rel * super_rel) * * Returns non-nil if rel1 and rel2 do not overlap. */ -static bool +static bool nonoverlap_rels(Rel * rel1, Rel * rel2) { return (nonoverlap_sets(rel1->relids, rel2->relids)); } -static bool +static bool nonoverlap_sets(List * s1, List * s2) { - List *x = NIL; + List *x = NIL; foreach(x, s1) { - int e = lfirsti(x); + int e = lfirsti(x); if (intMember(e, s2)) return (false); @@ -694,8 +694,8 @@ nonoverlap_sets(List * s1, List * s2) static void geqo_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel) { - Cost temp; - int ntuples; + Cost temp; + int ntuples; temp = (Cost) inner_rel->tuples * (Cost) outer_rel->tuples; /* cartesian product */ @@ -725,11 +725,11 @@ geqo_log(double x, double b) return (log(x) / log(b)); } -static Rel * +static Rel * geqo_nth(int stop, List * rels) { - List *r; - int i = 1; + List *r; + int i = 1; foreach(r, rels) { diff --git a/src/backend/optimizer/geqo/geqo_main.c b/src/backend/optimizer/geqo/geqo_main.c index eab939c03e6..cfaa3237705 100644 --- a/src/backend/optimizer/geqo/geqo_main.c +++ b/src/backend/optimizer/geqo/geqo_main.c @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_main.c,v 1.4 1997/09/07 04:43:09 momjian Exp $ + * $Id: geqo_main.c,v 1.5 1997/09/08 02:23:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,42 +63,42 @@ * similar to a constrained Traveling Salesman Problem (TSP) */ -Rel * +Rel * geqo(Query * root) { - int generation; - Chromosome *momma; - Chromosome *daddy; - Chromosome *kid; + int generation; + Chromosome *momma; + Chromosome *daddy; + Chromosome *kid; #if defined(ERX) - Edge *edge_table; /* list of edges */ - int edge_failures = 0; - float difference; + Edge *edge_table; /* list of edges */ + int edge_failures = 0; + float difference; #endif #if defined(CX) || defined(PX) || defined(OX1) || defined(OX2) - City *city_table; /* list of cities */ + City *city_table; /* list of cities */ #endif #if defined(CX) - int cycle_diffs = 0; - int mutations = 0; + int cycle_diffs = 0; + int mutations = 0; #endif - int number_of_rels; + int number_of_rels; - Pool *pool; - int pool_size, - number_generations, - status_interval; + Pool *pool; + int pool_size, + number_generations, + status_interval; - Gene *best_tour; - Rel *best_rel; + Gene *best_tour; + Rel *best_rel; /* Plan *best_plan; */ diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c index 67e810d87ca..5e72f46ac34 100644 --- a/src/backend/optimizer/geqo/geqo_misc.c +++ b/src/backend/optimizer/geqo/geqo_misc.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.c,v 1.3 1997/09/07 04:43:10 momjian Exp $ + * $Id: geqo_misc.c,v 1.4 1997/09/08 02:23:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ #include "optimizer/geqo_recombination.h" #include "optimizer/geqo_misc.h" -static float avg_pool(Pool * pool); +static float avg_pool(Pool * pool); /* avg_pool-- * @@ -49,8 +49,8 @@ static float avg_pool(Pool * pool); static float avg_pool(Pool * pool) { - int i; - double cumulative = 0.0; + int i; + double cumulative = 0.0; if (pool->size == 0) elog(WARN, "avg_pool: pool_size of zero"); @@ -66,8 +66,8 @@ avg_pool(Pool * pool) void print_pool(FILE * fp, Pool * pool, int start, int stop) { - int i, - j; + int i, + j; /* be extra careful that start and stop are valid inputs */ @@ -99,7 +99,7 @@ print_pool(FILE * fp, Pool * pool, int start, int stop) void print_gen(FILE * fp, Pool * pool, int generation) { - int lowest; + int lowest; /* Get index to lowest ranking gene in poplulation. */ /* Use 2nd to last since last is buffer. */ @@ -118,8 +118,8 @@ print_gen(FILE * fp, Pool * pool, int generation) void print_edge_table(FILE * fp, Edge * edge_table, int num_gene) { - int i, - j; + int i, + j; fprintf(fp, "\nEDGE TABLE\n"); @@ -141,12 +141,12 @@ print_edge_table(FILE * fp, Edge * edge_table, int num_gene) void geqo_print_joinclauses(Query * root, List * clauses) { - List *l; - extern void print_expr(Node * expr, List * rtable); /* in print.c */ + List *l; + extern void print_expr(Node * expr, List * rtable); /* in print.c */ foreach(l, clauses) { - CInfo *c = lfirst(l); + CInfo *c = lfirst(l); print_expr((Node *) c->clause, root->rtable); if (lnext(l)) @@ -157,88 +157,88 @@ geqo_print_joinclauses(Query * root, List * clauses) void geqo_print_path(Query * root, Path * path, int indent) { - char *ptype = NULL; - JoinPath *jp; - bool join = false; - int i; + char *ptype = NULL; + JoinPath *jp; + bool join = false; + int i; for (i = 0; i < indent; i++) printf("\t"); switch (nodeTag(path)) { - case T_Path: - ptype = "SeqScan"; - join = false; - break; - case T_IndexPath: - ptype = "IdxScan"; - join = false; - break; - case T_JoinPath: - ptype = "Nestloop"; - join = true; - break; - case T_MergePath: - ptype = "MergeJoin"; - join = true; - break; - case T_HashPath: - ptype = "HashJoin"; - join = true; - break; - default: - break; + case T_Path: + ptype = "SeqScan"; + join = false; + break; + case T_IndexPath: + ptype = "IdxScan"; + join = false; + break; + case T_JoinPath: + ptype = "Nestloop"; + join = true; + break; + case T_MergePath: + ptype = "MergeJoin"; + join = true; + break; + case T_HashPath: + ptype = "HashJoin"; + join = true; + break; + default: + break; } if (join) { - int size = path->parent->size; + int size = path->parent->size; jp = (JoinPath *) path; printf("%s size=%d cost=%f\n", ptype, size, path->path_cost); switch (nodeTag(path)) { - case T_MergePath: - case T_HashPath: - for (i = 0; i < indent + 1; i++) - printf("\t"); - printf(" clauses=("); - geqo_print_joinclauses(root, - ((JoinPath *) path)->pathclauseinfo); - printf(")\n"); - - if (nodeTag(path) == T_MergePath) - { - MergePath *mp = (MergePath *) path; - - if (mp->outersortkeys || mp->innersortkeys) + case T_MergePath: + case T_HashPath: + for (i = 0; i < indent + 1; i++) + printf("\t"); + printf(" clauses=("); + geqo_print_joinclauses(root, + ((JoinPath *) path)->pathclauseinfo); + printf(")\n"); + + if (nodeTag(path) == T_MergePath) { - for (i = 0; i < indent + 1; i++) - printf("\t"); - printf(" sortouter=%d sortinner=%d\n", - ((mp->outersortkeys) ? 1 : 0), - ((mp->innersortkeys) ? 1 : 0)); + MergePath *mp = (MergePath *) path; + + if (mp->outersortkeys || mp->innersortkeys) + { + for (i = 0; i < indent + 1; i++) + printf("\t"); + printf(" sortouter=%d sortinner=%d\n", + ((mp->outersortkeys) ? 1 : 0), + ((mp->innersortkeys) ? 1 : 0)); + } } - } - break; - default: - break; + break; + default: + break; } geqo_print_path(root, jp->outerjoinpath, indent + 1); geqo_print_path(root, jp->innerjoinpath, indent + 1); } else { - int size = path->parent->size; - int relid = lfirsti(path->parent->relids); + int size = path->parent->size; + int relid = lfirsti(path->parent->relids); printf("%s(%d) size=%d cost=%f", ptype, relid, size, path->path_cost); if (nodeTag(path) == T_IndexPath) { - List *k, - *l; + List *k, + *l; printf(" keys="); foreach(k, path->keys) @@ -246,7 +246,7 @@ geqo_print_path(Query * root, Path * path, int indent) printf("("); foreach(l, lfirst(k)) { - Var *var = lfirst(l); + Var *var = lfirst(l); printf("%d.%d", var->varnoold, var->varoattno); if (lnext(l)) @@ -264,7 +264,7 @@ geqo_print_path(Query * root, Path * path, int indent) void geqo_print_rel(Query * root, Rel * rel) { - List *l; + List *l; printf("______________________________\n"); printf("("); diff --git a/src/backend/optimizer/geqo/geqo_mutation.c b/src/backend/optimizer/geqo/geqo_mutation.c index a5a43e6e2b9..a6078c731a9 100644 --- a/src/backend/optimizer/geqo/geqo_mutation.c +++ b/src/backend/optimizer/geqo/geqo_mutation.c @@ -4,7 +4,7 @@ * * TSP mutation routines * -* $Id: geqo_mutation.c,v 1.2 1997/09/07 04:43:13 momjian Exp $ +* $Id: geqo_mutation.c,v 1.3 1997/09/08 02:23:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,10 +53,10 @@ void geqo_mutation(Gene * tour, int num_gene) { - int swap1; - int swap2; - int num_swaps = geqo_randint(num_gene / 3, 0); - Gene temp; + int swap1; + int swap2; + int num_swaps = geqo_randint(num_gene / 3, 0); + Gene temp; while (num_swaps > 0) diff --git a/src/backend/optimizer/geqo/geqo_ox1.c b/src/backend/optimizer/geqo/geqo_ox1.c index b88b8950673..bb3d0450108 100644 --- a/src/backend/optimizer/geqo/geqo_ox1.c +++ b/src/backend/optimizer/geqo/geqo_ox1.c @@ -6,7 +6,7 @@ * OX1 operator according to Davis * (Proc Int'l Joint Conf on AI) * -* $Id: geqo_ox1.c,v 1.2 1997/09/07 04:43:14 momjian Exp $ +* $Id: geqo_ox1.c,v 1.3 1997/09/08 02:23:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,11 +61,11 @@ void ox1(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table) { - int left, - right, - k, - p, - temp; + int left, + right, + k, + p, + temp; /* initialize city table */ for (k = 1; k <= num_gene; k++) diff --git a/src/backend/optimizer/geqo/geqo_ox2.c b/src/backend/optimizer/geqo/geqo_ox2.c index ef09925b4fa..2490fb3051d 100644 --- a/src/backend/optimizer/geqo/geqo_ox2.c +++ b/src/backend/optimizer/geqo/geqo_ox2.c @@ -6,7 +6,7 @@ * OX2 operator according to Syswerda * (The Genetic Algorithms Handbook, ed L Davis) * -* $Id: geqo_ox2.c,v 1.2 1997/09/07 04:43:15 momjian Exp $ +* $Id: geqo_ox2.c,v 1.3 1997/09/08 02:23:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,12 +61,12 @@ void ox2(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table) { - int k, - j, - count, - pos, - select, - num_positions; + int k, + j, + count, + pos, + select, + num_positions; /* initialize city table */ for (k = 1; k <= num_gene; k++) diff --git a/src/backend/optimizer/geqo/geqo_params.c b/src/backend/optimizer/geqo/geqo_params.c index 45f7dfd5ddc..9ef969a2289 100644 --- a/src/backend/optimizer/geqo/geqo_params.c +++ b/src/backend/optimizer/geqo/geqo_params.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * -* $Id: geqo_params.c,v 1.6 1997/09/07 04:43:16 momjian Exp $ +* $Id: geqo_params.c,v 1.7 1997/09/08 02:24:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,9 +58,9 @@ #define MAX_TOKEN 80 /* Maximum size of one token in the * * configuration file */ -static int gimme_pool_size(int string_length); -static int gimme_number_generations(int pool_size, int effort); -static int next_token(FILE *, char *, int); +static int gimme_pool_size(int string_length); +static int gimme_number_generations(int pool_size, int effort); +static int next_token(FILE *, char *, int); /* * geqo_param-- @@ -69,19 +69,19 @@ static int next_token(FILE *, char *, int); void geqo_params(int string_length) { - int i; + int i; - char buf[MAX_TOKEN]; - FILE *file; + char buf[MAX_TOKEN]; + FILE *file; - char *conf_file; + char *conf_file; /* these static variables are used to signal that a value has been set */ - int pool_size = 0; - int number_trials = 0; - int random_seed = 0; - int selection_bias = 0; - int effort = 0; + int pool_size = 0; + int number_trials = 0; + int random_seed = 0; + int selection_bias = 0; + int effort = 0; /* put together the full pathname to the config file */ @@ -272,8 +272,8 @@ geqo_params(int string_length) static int next_token(FILE * fp, char *buf, int bufsz) { - int c; - char *eb = buf + (bufsz - 1); + int c; + char *eb = buf + (bufsz - 1); /* Discard inital whitespace */ while (isspace(c = getc(fp))); @@ -309,8 +309,8 @@ next_token(FILE * fp, char *buf, int bufsz) static int gimme_pool_size(int string_length) { - double exponent; - double size; + double exponent; + double size; exponent = (double) string_length + 1.0; @@ -335,7 +335,7 @@ gimme_pool_size(int string_length) static int gimme_number_generations(int pool_size, int effort) { - int number_gens; + int number_gens; number_gens = (int) ceil(geqo_log((double) pool_size, 2.0)); diff --git a/src/backend/optimizer/geqo/geqo_paths.c b/src/backend/optimizer/geqo/geqo_paths.c index d98855d2887..931b38985bf 100644 --- a/src/backend/optimizer/geqo/geqo_paths.c +++ b/src/backend/optimizer/geqo/geqo_paths.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_paths.c,v 1.5 1997/09/07 04:43:17 momjian Exp $ + * $Id: geqo_paths.c,v 1.6 1997/09/08 02:24:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,8 +28,8 @@ #include "optimizer/geqo_paths.h" -static List *geqo_prune_rel(Rel * rel, List * other_rels); -static Path *set_paths(Rel * rel, Path * unorderedpath); +static List *geqo_prune_rel(Rel * rel, List * other_rels); +static Path *set_paths(Rel * rel, Path * unorderedpath); /* * geqo-prune-rels-- @@ -39,10 +39,10 @@ static Path *set_paths(Rel * rel, Path * unorderedpath); * Returns the resulting list. * */ -List * +List * geqo_prune_rels(List * rel_list) { - List *temp_list = NIL; + List *temp_list = NIL; if (rel_list != NIL) { @@ -64,13 +64,13 @@ geqo_prune_rels(List * rel_list) * of 'rel' appropriately. * */ -static List * +static List * geqo_prune_rel(Rel * rel, List * other_rels) { - List *i = NIL; - List *t_list = NIL; - List *temp_node = NIL; - Rel *other_rel = (Rel *) NULL; + List *i = NIL; + List *t_list = NIL; + List *temp_node = NIL; + Rel *other_rel = (Rel *) NULL; foreach(i, other_rels) { @@ -104,9 +104,9 @@ geqo_prune_rel(Rel * rel, List * other_rels) void geqo_rel_paths(Rel * rel) { - List *y = NIL; - Path *path = (Path *) NULL; - JoinPath *cheapest = (JoinPath *) NULL; + List *y = NIL; + Path *path = (Path *) NULL; + JoinPath *cheapest = (JoinPath *) NULL; rel->size = 0; foreach(y, rel->pathlist) @@ -133,10 +133,10 @@ geqo_rel_paths(Rel * rel) * Returns the cheapest path. * */ -static Path * +static Path * set_paths(Rel * rel, Path * unorderedpath) { - Path *cheapest = set_cheapest(rel, rel->pathlist); + Path *cheapest = set_cheapest(rel, rel->pathlist); /* don't prune if not pruneable -- JMH, 11/23/92 */ if (unorderedpath != cheapest diff --git a/src/backend/optimizer/geqo/geqo_pmx.c b/src/backend/optimizer/geqo/geqo_pmx.c index c9187fec54b..af4234a56e2 100644 --- a/src/backend/optimizer/geqo/geqo_pmx.c +++ b/src/backend/optimizer/geqo/geqo_pmx.c @@ -6,7 +6,7 @@ * PMX operator according to Goldberg & Lingle * (Proc Int'l Conf on GA's) * -* $Id: geqo_pmx.c,v 1.2 1997/09/07 04:43:18 momjian Exp $ +* $Id: geqo_pmx.c,v 1.3 1997/09/08 02:24:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,20 +61,20 @@ void pmx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene) { - int *failed = (int *) palloc((num_gene + 1) * sizeof(int)); - int *from = (int *) palloc((num_gene + 1) * sizeof(int)); - int *indx = (int *) palloc((num_gene + 1) * sizeof(int)); - int *check_list = (int *) palloc((num_gene + 1) * sizeof(int)); - - int left, - right, - temp, - i, - j, - k; - int mx_fail, - found, - mx_hold; + int *failed = (int *) palloc((num_gene + 1) * sizeof(int)); + int *from = (int *) palloc((num_gene + 1) * sizeof(int)); + int *indx = (int *) palloc((num_gene + 1) * sizeof(int)); + int *check_list = (int *) palloc((num_gene + 1) * sizeof(int)); + + int left, + right, + temp, + i, + j, + k; + int mx_fail, + found, + mx_hold; /* no mutation so start up the pmx replacement algorithm */ diff --git a/src/backend/optimizer/geqo/geqo_pool.c b/src/backend/optimizer/geqo/geqo_pool.c index 89c945d4ef4..5e8a32d42dc 100644 --- a/src/backend/optimizer/geqo/geqo_pool.c +++ b/src/backend/optimizer/geqo/geqo_pool.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_pool.c,v 1.2 1997/09/07 04:43:19 momjian Exp $ + * $Id: geqo_pool.c,v 1.3 1997/09/08 02:24:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,18 +44,18 @@ #include "optimizer/geqo_recombination.h" -static int compare(void *arg1, void *arg2); +static int compare(void *arg1, void *arg2); /* * alloc-pool-- * allocates memory for GA pool */ -Pool * +Pool * alloc_pool(int pool_size, int string_length) { - Pool *new_pool; - Chromosome *chromo; - int i; + Pool *new_pool; + Chromosome *chromo; + int i; /* pool */ new_pool = (Pool *) palloc(sizeof(Pool)); @@ -82,8 +82,8 @@ alloc_pool(int pool_size, int string_length) void free_pool(Pool * pool) { - Chromosome *chromo; - int i; + Chromosome *chromo; + int i; /* all gene */ chromo = (Chromosome *) pool->data; /* vector of all chromos */ @@ -104,14 +104,14 @@ free_pool(Pool * pool) void random_init_pool(Query * root, Pool * pool, int strt, int stp) { - Chromosome *chromo = (Chromosome *) pool->data; - int i; + Chromosome *chromo = (Chromosome *) pool->data; + int i; for (i = strt; i < stp; i++) { init_tour(chromo[i].string, pool->string_length); /* from * "geqo_recombination.c" - * */ + * */ pool->data[i].worth = geqo_eval(root, chromo[i].string, pool->string_length); /* "from geqo_eval.c" */ @@ -141,8 +141,8 @@ sort_pool(Pool * pool) static int compare(void *arg1, void *arg2) { - Chromosome chromo1 = *(Chromosome *) arg1; - Chromosome chromo2 = *(Chromosome *) arg2; + Chromosome chromo1 = *(Chromosome *) arg1; + Chromosome chromo2 = *(Chromosome *) arg2; if (chromo1.worth == chromo2.worth) return (0); @@ -155,10 +155,10 @@ compare(void *arg1, void *arg2) /* alloc_chromo-- * allocates a chromosome and string space */ -Chromosome * +Chromosome * alloc_chromo(int string_length) { - Chromosome *chromo; + Chromosome *chromo; chromo = (Chromosome *) palloc(sizeof(Chromosome)); chromo->string = (Gene *) palloc((string_length + 1) * sizeof(Gene)); @@ -183,13 +183,13 @@ free_chromo(Chromosome * chromo) void spread_chromo(Chromosome * chromo, Pool * pool) { - int top, - mid, - bot; - int i, - index; - Chromosome swap_chromo, - tmp_chromo; + int top, + mid, + bot; + int i, + index; + Chromosome swap_chromo, + tmp_chromo; /* new chromo is so bad we can't use it */ if (chromo->worth > pool->data[pool->size - 1].worth) diff --git a/src/backend/optimizer/geqo/geqo_px.c b/src/backend/optimizer/geqo/geqo_px.c index 71aa2415b55..4cd1ad3aec4 100644 --- a/src/backend/optimizer/geqo/geqo_px.c +++ b/src/backend/optimizer/geqo/geqo_px.c @@ -6,7 +6,7 @@ * PX operator according to Syswerda * (The Genetic Algorithms Handbook, L Davis, ed) * -* $Id: geqo_px.c,v 1.2 1997/09/07 04:43:20 momjian Exp $ +* $Id: geqo_px.c,v 1.3 1997/09/08 02:24:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,11 +62,11 @@ void px(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table) { - int num_positions; - int i, - pos, - tour2_index, - offspring_index; + int num_positions; + int i, + pos, + tour2_index, + offspring_index; /* initialize city table */ for (i = 1; i <= num_gene; i++) diff --git a/src/backend/optimizer/geqo/geqo_recombination.c b/src/backend/optimizer/geqo/geqo_recombination.c index 53803079819..400afc50d4f 100644 --- a/src/backend/optimizer/geqo/geqo_recombination.c +++ b/src/backend/optimizer/geqo/geqo_recombination.c @@ -3,7 +3,7 @@ * geqo_recombination.c-- * misc recombination procedures * -* $Id: geqo_recombination.c,v 1.2 1997/09/07 04:43:21 momjian Exp $ +* $Id: geqo_recombination.c,v 1.3 1997/09/08 02:24:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,10 +53,10 @@ void init_tour(Gene * tour, int num_gene) { - Gene *tmp; - int remainder; - int next, - i; + Gene *tmp; + int remainder; + int next, + i; tmp = (Gene *) palloc(num_gene * sizeof(Gene)); @@ -84,10 +84,10 @@ init_tour(Gene * tour, int num_gene) * allocate memory for city table * */ -City * +City * alloc_city_table(int num_gene) { - City *city_table; + City *city_table; /* * palloc one extra location so that nodes numbered 1..n can be diff --git a/src/backend/optimizer/geqo/geqo_selection.c b/src/backend/optimizer/geqo/geqo_selection.c index 820de485fe4..ed0727cbfb0 100644 --- a/src/backend/optimizer/geqo/geqo_selection.c +++ b/src/backend/optimizer/geqo/geqo_selection.c @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_selection.c,v 1.2 1997/09/07 04:43:24 momjian Exp $ + * $Id: geqo_selection.c,v 1.3 1997/09/08 02:24:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ #include "optimizer/geqo_copy.h" #include "optimizer/geqo_random.h" -static int linear(int max, double bias); +static int linear(int max, double bias); /* geqo_selection-- * @@ -65,8 +65,8 @@ static int linear(int max, double bias); void geqo_selection(Chromosome * momma, Chromosome * daddy, Pool * pool, double bias) { - int first, - second; + int first, + second; first = (int) linear(pool->size, bias); second = (int) linear(pool->size, bias); @@ -94,8 +94,8 @@ static int linear(int pool_size, double bias) /* bias is y-intercept of linear * distribution */ { - double index; /* index between 0 and pop_size */ - double max = (double) pool_size; + double index; /* index between 0 and pop_size */ + double max = (double) pool_size; index = max * (bias - sqrt((bias * bias) - 4.0 * (bias - 1.0) * geqo_rand())) diff --git a/src/backend/optimizer/geqo/minspantree.c b/src/backend/optimizer/geqo/minspantree.c index 1fcc2569478..716e1943950 100644 --- a/src/backend/optimizer/geqo/minspantree.c +++ b/src/backend/optimizer/geqo/minspantree.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION -* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.2 1997/09/07 04:43:25 momjian Exp $ +* $Header: /cvsroot/pgsql/src/backend/optimizer/geqo/Attic/minspantree.c,v 1.3 1997/09/08 02:24:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,35 +43,35 @@ void minspantree(Query * root, List * join_rels, Rel * garel) { - int number_of_rels = length(root->base_relation_list_); - int number_of_joins = length(join_rels); - int *connectto; + int number_of_rels = length(root->base_relation_list_); + int number_of_joins = length(join_rels); + int *connectto; /* connectto[i] = 0, if node i is already connected */ /* to the tree, otherwise connectto[i] is the node */ /* nearest to i, which is already connected. */ - Cost *disttoconnect; /* disttoconnect[i]: distance - * between i and connectto[i] */ + Cost *disttoconnect; /* disttoconnect[i]: distance between i + * and connectto[i] */ - Cost dist, /* temporary */ - mindist; /* minimal distance between connected and + Cost dist, /* temporary */ + mindist; /* minimal distance between connected and * unconnected node */ - Cost mstlength = 0.0; /* the total length of the minimum - * spanning tree */ + Cost mstlength = 0.0;/* the total length of the minimum + * spanning tree */ - int count; - int n, /* newly attached node */ - nextn, /* next node to be attached */ - tempn; + int count; + int n, /* newly attached node */ + nextn, /* next node to be attached */ + tempn; - int i, - id1, - id2; - List *r = NIL; - Rel *joinrel = NULL; - Rel **tmprel_array; + int i, + id1, + id2; + List *r = NIL; + Rel *joinrel = NULL; + Rel **tmprel_array; /* allocate memory for matrix tmprel_array[x][y] */ @@ -113,9 +113,9 @@ minspantree(Query * root, List * join_rels, Rel * garel) else if (number_of_joins == 3) { - Rel *rel12 = (Rel *) & tmprel_array[1][2]; - Rel *rel13 = (Rel *) & tmprel_array[1][3]; - Rel *rel23 = (Rel *) & tmprel_array[2][3]; + Rel *rel12 = (Rel *) & tmprel_array[1][2]; + Rel *rel13 = (Rel *) & tmprel_array[1][3]; + Rel *rel23 = (Rel *) & tmprel_array[2][3]; if (rel12->cheapestpath->path_cost > rel13->cheapestpath->path_cost) { diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index 7c4576d6f02..ca4485fbd1f 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.11 1997/09/07 04:43:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.12 1997/09/08 02:24:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,17 +34,17 @@ #include "optimizer/geqo.h" #ifdef GEQO -bool _use_geqo_ = true; +bool _use_geqo_ = true; #else -bool _use_geqo_ = false; +bool _use_geqo_ = false; #endif -int32 _use_geqo_rels_ = GEQO_RELS; +int32 _use_geqo_rels_ = GEQO_RELS; -static void find_rel_paths(Query * root, List * rels); -static List *find_join_paths(Query * root, List * outer_rels, int levels_left); +static void find_rel_paths(Query * root, List * rels); +static List *find_join_paths(Query * root, List * outer_rels, int levels_left); /* * find-paths-- @@ -53,10 +53,10 @@ static List *find_join_paths(Query * root, List * outer_rels, int levels_left * * 'rels' is the list of single relation entries appearing in the query */ -List * +List * find_paths(Query * root, List * rels) { - int levels_left; + int levels_left; /* * Set the number of join (not nesting) levels yet to be processed. @@ -104,15 +104,15 @@ find_paths(Query * root, List * rels) static void find_rel_paths(Query * root, List * rels) { - List *temp; - Rel *rel; - List *lastpath; + List *temp; + Rel *rel; + List *lastpath; foreach(temp, rels) { - List *sequential_scan_list; - List *rel_index_scan_list; - List *or_index_scan_list; + List *sequential_scan_list; + List *rel_index_scan_list; + List *or_index_scan_list; rel = (Rel *) lfirst(temp); sequential_scan_list = lcons(create_seqscan_path(rel), @@ -171,12 +171,12 @@ find_rel_paths(Query * root, List * rels) * Returns the final level of join relations, i.e., the relation that is * the result of joining all the original relations togehter. */ -static List * +static List * find_join_paths(Query * root, List * outer_rels, int levels_left) { - List *x; - List *new_rels; - Rel *rel; + List *x; + List *new_rels; + Rel *rel; /******************************************* * genetic query optimizer entry point * @@ -283,12 +283,12 @@ find_join_paths(Query * root, List * outer_rels, int levels_left) static void print_joinclauses(Query * root, List * clauses) { - List *l; - extern void print_expr(Node * expr, List * rtable); /* in print.c */ + List *l; + extern void print_expr(Node * expr, List * rtable); /* in print.c */ foreach(l, clauses) { - CInfo *c = lfirst(l); + CInfo *c = lfirst(l); print_expr((Node *) c->clause, root->rtable); if (lnext(l)) @@ -299,88 +299,88 @@ print_joinclauses(Query * root, List * clauses) static void print_path(Query * root, Path * path, int indent) { - char *ptype = NULL; - JoinPath *jp; - bool join = false; - int i; + char *ptype = NULL; + JoinPath *jp; + bool join = false; + int i; for (i = 0; i < indent; i++) printf("\t"); switch (nodeTag(path)) { - case T_Path: - ptype = "SeqScan"; - join = false; - break; - case T_IndexPath: - ptype = "IdxScan"; - join = false; - break; - case T_JoinPath: - ptype = "Nestloop"; - join = true; - break; - case T_MergePath: - ptype = "MergeJoin"; - join = true; - break; - case T_HashPath: - ptype = "HashJoin"; - join = true; - break; - default: - break; + case T_Path: + ptype = "SeqScan"; + join = false; + break; + case T_IndexPath: + ptype = "IdxScan"; + join = false; + break; + case T_JoinPath: + ptype = "Nestloop"; + join = true; + break; + case T_MergePath: + ptype = "MergeJoin"; + join = true; + break; + case T_HashPath: + ptype = "HashJoin"; + join = true; + break; + default: + break; } if (join) { - int size = path->parent->size; + int size = path->parent->size; jp = (JoinPath *) path; printf("%s size=%d cost=%f\n", ptype, size, path->path_cost); switch (nodeTag(path)) { - case T_MergePath: - case T_HashPath: - for (i = 0; i < indent + 1; i++) - printf("\t"); - printf(" clauses=("); - print_joinclauses(root, - ((JoinPath *) path)->pathclauseinfo); - printf(")\n"); - - if (nodeTag(path) == T_MergePath) - { - MergePath *mp = (MergePath *) path; - - if (mp->outersortkeys || mp->innersortkeys) + case T_MergePath: + case T_HashPath: + for (i = 0; i < indent + 1; i++) + printf("\t"); + printf(" clauses=("); + print_joinclauses(root, + ((JoinPath *) path)->pathclauseinfo); + printf(")\n"); + + if (nodeTag(path) == T_MergePath) { - for (i = 0; i < indent + 1; i++) - printf("\t"); - printf(" sortouter=%d sortinner=%d\n", - ((mp->outersortkeys) ? 1 : 0), - ((mp->innersortkeys) ? 1 : 0)); + MergePath *mp = (MergePath *) path; + + if (mp->outersortkeys || mp->innersortkeys) + { + for (i = 0; i < indent + 1; i++) + printf("\t"); + printf(" sortouter=%d sortinner=%d\n", + ((mp->outersortkeys) ? 1 : 0), + ((mp->innersortkeys) ? 1 : 0)); + } } - } - break; - default: - break; + break; + default: + break; } print_path(root, jp->outerjoinpath, indent + 1); print_path(root, jp->innerjoinpath, indent + 1); } else { - int size = path->parent->size; - int relid = lfirsti(path->parent->relids); + int size = path->parent->size; + int relid = lfirsti(path->parent->relids); printf("%s(%d) size=%d cost=%f", ptype, relid, size, path->path_cost); if (nodeTag(path) == T_IndexPath) { - List *k, - *l; + List *k, + *l; printf(" keys="); foreach(k, path->keys) @@ -388,7 +388,7 @@ print_path(Query * root, Path * path, int indent) printf("("); foreach(l, lfirst(k)) { - Var *var = lfirst(l); + Var *var = lfirst(l); printf("%d.%d", var->varnoold, var->varoattno); if (lnext(l)) @@ -406,7 +406,7 @@ print_path(Query * root, Path * path, int indent) static void debug_print_rel(Query * root, Rel * rel) { - List *l; + List *l; printf("("); foreach(l, rel->relids) diff --git a/src/backend/optimizer/path/clausesel.c b/src/backend/optimizer/path/clausesel.c index 0ce580754e3..7ae190f7fd7 100644 --- a/src/backend/optimizer/path/clausesel.c +++ b/src/backend/optimizer/path/clausesel.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.2 1997/09/07 04:43:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/clausesel.c,v 1.3 1997/09/08 02:24:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ #include "utils/elog.h" #include "utils/lsyscache.h" -static Cost compute_selec(Query * root, List * clauses, List * or_selectivities); +static Cost compute_selec(Query * root, List * clauses, List * or_selectivities); /**************************************************************************** * ROUTINES TO SET CLAUSE SELECTIVITIES @@ -49,9 +49,9 @@ static Cost compute_selec(Query * root, List * clauses, List * or_selectivities void set_clause_selectivities(List * clauseinfo_list, Cost new_selectivity) { - List *temp; - CInfo *clausenode; - Cost cost_clause; + List *temp; + CInfo *clausenode; + Cost cost_clause; foreach(temp, clauseinfo_list) { @@ -73,12 +73,12 @@ set_clause_selectivities(List * clauseinfo_list, Cost new_selectivity) Cost product_selec(List * clauseinfo_list) { - Cost result = 1.0; + Cost result = 1.0; if (clauseinfo_list != NIL) { - List *xclausenode = NIL; - Cost temp; + List *xclausenode = NIL; + Cost temp; foreach(xclausenode, clauseinfo_list) { @@ -101,8 +101,8 @@ product_selec(List * clauseinfo_list) void set_rest_relselec(Query * root, List * rel_list) { - Rel *rel; - List *x; + Rel *rel; + List *x; foreach(x, rel_list) { @@ -122,9 +122,9 @@ set_rest_relselec(Query * root, List * rel_list) void set_rest_selec(Query * root, List * clauseinfo_list) { - List *temp = NIL; - CInfo *clausenode = (CInfo *) NULL; - Cost cost_clause; + List *temp = NIL; + CInfo *clausenode = (CInfo *) NULL; + Cost cost_clause; foreach(temp, clauseinfo_list) { @@ -222,11 +222,11 @@ compute_clause_selec(Query * root, Node * clause, List * or_selectivities) * Returns the clause selectivity as a flonum. * */ -static Cost +static Cost compute_selec(Query * root, List * clauses, List * or_selectivities) { - Cost s1 = 0; - List *clause = lfirst(clauses); + Cost s1 = 0; + List *clause = lfirst(clauses); if (clauses == NULL) { @@ -243,8 +243,8 @@ compute_selec(Query * root, List * clauses, List * or_selectivities) } else if (IsA(clause, Var)) { - Oid relid = getrelid(((Var *) clause)->varno, - root->rtable); + Oid relid = getrelid(((Var *) clause)->varno, + root->rtable); /* * we have a bool Var. This is exactly equivalent to the clause: @@ -264,7 +264,7 @@ compute_selec(Query * root, List * clauses, List * or_selectivities) else if (or_selectivities) { /* If s1 has already been assigned by an index, use that value. */ - List *this_sel = lfirst(or_selectivities); + List *this_sel = lfirst(or_selectivities); s1 = floatVal(this_sel); } @@ -288,13 +288,13 @@ compute_selec(Query * root, List * clauses, List * or_selectivities) * clause selectivity will be based on the operator selectivity * and operand values. */ - Oid opno = ((Oper *) ((Expr *) clause)->oper)->opno; - RegProcedure oprrest = get_oprrest(opno); - Oid relid; - int relidx; - AttrNumber attno; - Datum constval; - int flag; + Oid opno = ((Oper *) ((Expr *) clause)->oper)->opno; + RegProcedure oprrest = get_oprrest(opno); + Oid relid; + int relidx; + AttrNumber attno; + Datum constval; + int flag; get_relattval((Node *) clause, &relidx, &attno, &constval, &flag); relid = getrelid(relidx, root->rtable); @@ -332,12 +332,12 @@ compute_selec(Query * root, List * clauses, List * or_selectivities) * be based on the relations to be scanned and the attributes they * are to be joined on. */ - Oid opno = ((Oper *) ((Expr *) clause)->oper)->opno; - RegProcedure oprjoin = get_oprjoin(opno); - int relid1, - relid2; - AttrNumber attno1, - attno2; + Oid opno = ((Oper *) ((Expr *) clause)->oper)->opno; + RegProcedure oprjoin = get_oprjoin(opno); + int relid1, + relid2; + AttrNumber attno1, + attno2; get_rels_atts((Node *) clause, &relid1, &attno1, &relid2, &attno2); relid1 = getrelid(relid1, root->rtable); @@ -372,7 +372,7 @@ compute_selec(Query * root, List * clauses, List * or_selectivities) { /* Compute selectivity of the 'or'ed subclauses. */ /* Added check for taking lnext(NIL). -- JMH 3/9/92 */ - Cost s2; + Cost s2; if (or_selectivities != NIL) s2 = compute_selec(root, lnext(clauses), lnext(or_selectivities)); diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 2873e62c48c..6badd4780ef 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.17 1997/09/07 04:43:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.18 1997/09/08 02:24:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,24 +37,24 @@ #include "storage/bufmgr.h" /* for BLCKSZ */ -extern int NBuffers; +extern int NBuffers; -static int compute_attribute_width(TargetEntry * tlistentry); -static double base_log(double x, double b); -static int compute_targetlist_width(List * targetlist); +static int compute_attribute_width(TargetEntry * tlistentry); +static double base_log(double x, double b); +static int compute_targetlist_width(List * targetlist); -int _disable_cost_ = 30000000; +int _disable_cost_ = 30000000; -bool _enable_seqscan_ = true; -bool _enable_indexscan_ = true; -bool _enable_sort_ = true; -bool _enable_hash_ = true; -bool _enable_nestloop_ = true; -bool _enable_mergesort_ = true; -bool _enable_hashjoin_ = true; +bool _enable_seqscan_ = true; +bool _enable_indexscan_ = true; +bool _enable_sort_ = true; +bool _enable_hash_ = true; +bool _enable_nestloop_ = true; +bool _enable_mergesort_ = true; +bool _enable_hashjoin_ = true; -Cost _cpu_page_wight_ = _CPU_PAGE_WEIGHT_; -Cost _cpu_index_page_wight_ = _CPU_INDEX_PAGE_WEIGHT_; +Cost _cpu_page_wight_ = _CPU_PAGE_WEIGHT_; +Cost _cpu_index_page_wight_ = _CPU_INDEX_PAGE_WEIGHT_; /* * cost_seqscan-- @@ -79,7 +79,7 @@ Cost _cpu_index_page_wight_ = _CPU_INDEX_PAGE_WEIGHT_; Cost cost_seqscan(int relid, int relpages, int reltuples) { - Cost temp = 0; + Cost temp = 0; if (!_enable_seqscan_) temp += _disable_cost_; @@ -131,8 +131,8 @@ cost_index(Oid indexid, int indextuples, bool is_injoin) { - Cost temp; - double temp2; + Cost temp; + double temp2; temp = (Cost) 0; @@ -179,10 +179,10 @@ cost_index(Oid indexid, Cost cost_sort(List * keys, int tuples, int width, bool noread) { - Cost temp = 0; - int npages = page_size(tuples, width); - Cost pages = (Cost) npages; - Cost numTuples = tuples; + Cost temp = 0; + int npages = page_size(tuples, width); + Cost pages = (Cost) npages; + Cost numTuples = tuples; if (!_enable_sort_) temp += _disable_cost_; @@ -220,7 +220,7 @@ cost_sort(List * keys, int tuples, int width, bool noread) Cost cost_result(int tuples, int width) { - Cost temp = 0; + Cost temp = 0; temp = temp + page_size(tuples, width); temp = temp + _cpu_page_wight_ * tuples; @@ -250,7 +250,7 @@ cost_nestloop(Cost outercost, int outerpages, bool is_indexjoin) { - Cost temp = 0; + Cost temp = 0; if (!_enable_nestloop_) temp += _disable_cost_; @@ -285,7 +285,7 @@ cost_mergesort(Cost outercost, int outerwidth, int innerwidth) { - Cost temp = 0; + Cost temp = 0; if (!_enable_mergesort_) temp += _disable_cost_; @@ -323,10 +323,10 @@ cost_hashjoin(Cost outercost, int outerwidth, int innerwidth) { - Cost temp = 0; - int outerpages = page_size(outersize, outerwidth); - int innerpages = page_size(innersize, innerwidth); - int nrun = ceil((double) outerpages / (double) NBuffers); + Cost temp = 0; + int outerpages = page_size(outersize, outerwidth); + int innerpages = page_size(innersize, innerwidth); + int nrun = ceil((double) outerpages / (double) NBuffers); if (outerpages < innerpages) return _disable_cost_; @@ -365,8 +365,8 @@ cost_hashjoin(Cost outercost, int compute_rel_size(Rel * rel) { - Cost temp; - int temp1; + Cost temp; + int temp1; temp = rel->tuples * product_selec(rel->clauseinfo); Assert(temp >= 0); @@ -404,8 +404,8 @@ compute_rel_width(Rel * rel) static int compute_targetlist_width(List * targetlist) { - List *temp_tl; - int tuple_width = 0; + List *temp_tl; + int tuple_width = 0; foreach(temp_tl, targetlist) { @@ -427,7 +427,7 @@ compute_targetlist_width(List * targetlist) static int compute_attribute_width(TargetEntry * tlistentry) { - int width = get_typlen(tlistentry->resdom->restype); + int width = get_typlen(tlistentry->resdom->restype); if (width < 0) return (_DEFAULT_ATTRIBUTE_WIDTH_); @@ -444,8 +444,8 @@ compute_attribute_width(TargetEntry * tlistentry) int compute_joinrel_size(JoinPath * joinpath) { - Cost temp = 1.0; - int temp1 = 0; + Cost temp = 1.0; + int temp1 = 0; temp *= ((Path *) joinpath->outerjoinpath)->parent->size; temp *= ((Path *) joinpath->innerjoinpath)->parent->size; @@ -477,7 +477,7 @@ compute_joinrel_size(JoinPath * joinpath) int page_size(int tuples, int width) { - int temp = 0; + int temp = 0; temp = ceil((double) (tuples * (width + sizeof(HeapTupleData))) / BLCKSZ); diff --git a/src/backend/optimizer/path/hashutils.c b/src/backend/optimizer/path/hashutils.c index 5ec592ad1f9..ea6089355a0 100644 --- a/src/backend/optimizer/path/hashutils.c +++ b/src/backend/optimizer/path/hashutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.2 1997/09/07 04:43:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/hashutils.c,v 1.3 1997/09/08 02:24:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ #include "optimizer/clauses.h" -static HInfo *match_hashop_hashinfo(Oid hashop, List * hashinfo_list); +static HInfo *match_hashop_hashinfo(Oid hashop, List * hashinfo_list); /* * group-clauses-by-hashop-- @@ -34,14 +34,14 @@ static HInfo *match_hashop_hashinfo(Oid hashop, List * hashinfo_list); * Returns the new list of hashinfo nodes. * */ -List * +List * group_clauses_by_hashop(List * clauseinfo_list, int inner_relid) { - List *hashinfo_list = NIL; - CInfo *clauseinfo = (CInfo *) NULL; - List *i = NIL; - Oid hashjoinop = 0; + List *hashinfo_list = NIL; + CInfo *clauseinfo = (CInfo *) NULL; + List *i = NIL; + Oid hashjoinop = 0; foreach(i, clauseinfo_list) { @@ -54,11 +54,11 @@ group_clauses_by_hashop(List * clauseinfo_list, */ if (hashjoinop) { - HInfo *xhashinfo = (HInfo *) NULL; - Expr *clause = clauseinfo->clause; - Var *leftop = get_leftop(clause); - Var *rightop = get_rightop(clause); - JoinKey *keys = (JoinKey *) NULL; + HInfo *xhashinfo = (HInfo *) NULL; + Expr *clause = clauseinfo->clause; + Var *leftop = get_leftop(clause); + Var *rightop = get_rightop(clause); + JoinKey *keys = (JoinKey *) NULL; xhashinfo = match_hashop_hashinfo(hashjoinop, hashinfo_list); @@ -108,12 +108,12 @@ group_clauses_by_hashop(List * clauseinfo_list, * Returns the node if it exists. * */ -static HInfo * +static HInfo * match_hashop_hashinfo(Oid hashop, List * hashinfo_list) { - Oid key = 0; - HInfo *xhashinfo = (HInfo *) NULL; - List *i = NIL; + Oid key = 0; + HInfo *xhashinfo = (HInfo *) NULL; + List *i = NIL; foreach(i, hashinfo_list) { diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index bd9bc15ace0..6018ad775df 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.9 1997/09/07 04:43:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.10 1997/09/08 02:24:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,37 +52,37 @@ match_index_orclauses(Rel * rel, Rel * index, int indexkey, static bool match_index_to_operand(int indexkey, Expr * operand, Rel * rel, Rel * index); -static List * +static List * match_index_orclause(Rel * rel, Rel * index, int indexkey, int xclass, List * or_clauses, List * other_matching_indices); -static List * +static List * group_clauses_by_indexkey(Rel * rel, Rel * index, int *indexkeys, Oid * classes, List * clauseinfo_list); -static List * +static List * group_clauses_by_ikey_for_joins(Rel * rel, Rel * index, int *indexkeys, Oid * classes, List * join_cinfo_list, List * restr_cinfo_list); -static CInfo * +static CInfo * match_clause_to_indexkey(Rel * rel, Rel * index, int indexkey, int xclass, CInfo * clauseInfo, bool join); static bool pred_test(List * predicate_list, List * clauseinfo_list, List * joininfo_list); -static bool one_pred_test(Expr * predicate, List * clauseinfo_list); -static bool one_pred_clause_expr_test(Expr * predicate, Node * clause); -static bool one_pred_clause_test(Expr * predicate, Node * clause); -static bool clause_pred_clause_test(Expr * predicate, Node * clause); -static List * +static bool one_pred_test(Expr * predicate, List * clauseinfo_list); +static bool one_pred_clause_expr_test(Expr * predicate, Node * clause); +static bool one_pred_clause_test(Expr * predicate, Node * clause); +static bool clause_pred_clause_test(Expr * predicate, Node * clause); +static List * indexable_joinclauses(Rel * rel, Rel * index, List * joininfo_list, List * clauseinfo_list); -static List * +static List * index_innerjoin(Query * root, Rel * rel, List * clausegroup_list, Rel * index); -static List * +static List * create_index_paths(Query * root, Rel * rel, Rel * index, List * clausegroup_list, bool join); -static List *add_index_paths(List * indexpaths, List * new_indexpaths); -static bool function_index_operand(Expr * funcOpnd, Rel * rel, Rel * index); -static bool SingleAttributeIndex(Rel * index); +static List *add_index_paths(List * indexpaths, List * new_indexpaths); +static bool function_index_operand(Expr * funcOpnd, Rel * rel, Rel * index); +static bool SingleAttributeIndex(Rel * index); /* If Spyros can use a constant PRS2_BOOL_TYPEID, I can use this */ #define BOOL_TYPEID ((Oid) 16) @@ -113,19 +113,19 @@ static bool SingleAttributeIndex(Rel * index); * Returns a list of index nodes. * */ -List * +List * find_index_paths(Query * root, Rel * rel, List * indices, List * clauseinfo_list, List * joininfo_list) { - List *scanclausegroups = NIL; - List *scanpaths = NIL; - Rel *index = (Rel *) NULL; - List *joinclausegroups = NIL; - List *joinpaths = NIL; - List *retval = NIL; + List *scanclausegroups = NIL; + List *scanpaths = NIL; + Rel *index = (Rel *) NULL; + List *joinclausegroups = NIL; + List *joinpaths = NIL; + List *retval = NIL; if (indices == NIL) return (NULL); @@ -193,11 +193,11 @@ find_index_paths(Query * root, if (joinclausegroups != NIL) { - List *new_join_paths = create_index_paths(root, rel, - index, + List *new_join_paths = create_index_paths(root, rel, + index, joinclausegroups, - true); - List *innerjoin_paths = index_innerjoin(root, rel, joinclausegroups, index); + true); + List *innerjoin_paths = index_innerjoin(root, rel, joinclausegroups, index); rel->innerjoin = nconc(rel->innerjoin, innerjoin_paths); joinpaths = new_join_paths; @@ -246,8 +246,8 @@ match_index_orclauses(Rel * rel, int xclass, List * clauseinfo_list) { - CInfo *clauseinfo = (CInfo *) NULL; - List *i = NIL; + CInfo *clauseinfo = (CInfo *) NULL; + List *i = NIL; foreach(i, clauseinfo_list) { @@ -275,7 +275,7 @@ match_index_orclauses(Rel * rel, * and the operand on the rhs of a restriction clause. Now check * for functional indices as well. */ -static bool +static bool match_index_to_operand(int indexkey, Expr * operand, Rel * rel, @@ -315,7 +315,7 @@ match_index_to_operand(int indexkey, * 'or-clauses', d,e,f match the second subclause, no indices * match the third, g,h match the fourth, etc. */ -static List * +static List * match_index_orclause(Rel * rel, Rel * index, int indexkey, @@ -323,11 +323,11 @@ match_index_orclause(Rel * rel, List * or_clauses, List * other_matching_indices) { - Node *clause = NULL; - List *matched_indices = other_matching_indices; - List *index_list = NIL; - List *clist; - List *ind; + Node *clause = NULL; + List *matched_indices = other_matching_indices; + List *index_list = NIL; + List *clist; + List *ind; if (!matched_indices) matched_indices = lcons(NIL, NIL); @@ -397,32 +397,32 @@ match_index_orclause(Rel * rel, * returned for an index with 2 keys. * */ -static List * +static List * group_clauses_by_indexkey(Rel * rel, Rel * index, int *indexkeys, Oid * classes, List * clauseinfo_list) { - List *curCinfo = NIL; - CInfo *matched_clause = (CInfo *) NULL; - List *clausegroup = NIL; - int curIndxKey; - Oid curClass; + List *curCinfo = NIL; + CInfo *matched_clause = (CInfo *) NULL; + List *clausegroup = NIL; + int curIndxKey; + Oid curClass; if (clauseinfo_list == NIL) return NIL; while (!DoneMatchingIndexKeys(indexkeys, index)) { - List *tempgroup = NIL; + List *tempgroup = NIL; curIndxKey = indexkeys[0]; curClass = classes[0]; foreach(curCinfo, clauseinfo_list) { - CInfo *temp = (CInfo *) lfirst(curCinfo); + CInfo *temp = (CInfo *) lfirst(curCinfo); matched_clause = match_clause_to_indexkey(rel, index, @@ -459,7 +459,7 @@ group_clauses_by_indexkey(Rel * rel, * - vadim 03/18/97 * */ -static List * +static List * group_clauses_by_ikey_for_joins(Rel * rel, Rel * index, int *indexkeys, @@ -467,26 +467,26 @@ group_clauses_by_ikey_for_joins(Rel * rel, List * join_cinfo_list, List * restr_cinfo_list) { - List *curCinfo = NIL; - CInfo *matched_clause = (CInfo *) NULL; - List *clausegroup = NIL; - int curIndxKey; - Oid curClass; - bool jfound = false; + List *curCinfo = NIL; + CInfo *matched_clause = (CInfo *) NULL; + List *clausegroup = NIL; + int curIndxKey; + Oid curClass; + bool jfound = false; if (join_cinfo_list == NIL) return NIL; while (!DoneMatchingIndexKeys(indexkeys, index)) { - List *tempgroup = NIL; + List *tempgroup = NIL; curIndxKey = indexkeys[0]; curClass = classes[0]; foreach(curCinfo, join_cinfo_list) { - CInfo *temp = (CInfo *) lfirst(curCinfo); + CInfo *temp = (CInfo *) lfirst(curCinfo); matched_clause = match_clause_to_indexkey(rel, index, @@ -502,7 +502,7 @@ group_clauses_by_ikey_for_joins(Rel * rel, } foreach(curCinfo, restr_cinfo_list) { - CInfo *temp = (CInfo *) lfirst(curCinfo); + CInfo *temp = (CInfo *) lfirst(curCinfo); matched_clause = match_clause_to_indexkey(rel, index, @@ -582,7 +582,7 @@ group_clauses_by_ikey_for_joins(Rel * rel, * NOTE: returns nil if clause is an or_clause. * */ -static CInfo * +static CInfo * match_clause_to_indexkey(Rel * rel, Rel * index, int indexkey, @@ -590,12 +590,12 @@ match_clause_to_indexkey(Rel * rel, CInfo * clauseInfo, bool join) { - Expr *clause = clauseInfo->clause; - Var *leftop, - *rightop; - Oid join_op = InvalidOid; - Oid restrict_op = InvalidOid; - bool isIndexable = false; + Expr *clause = clauseInfo->clause; + Var *leftop, + *rightop; + Oid join_op = InvalidOid; + Oid restrict_op = InvalidOid; + bool isIndexable = false; if (or_clause((Node *) clause) || not_clause((Node *) clause) || single_node((Node *) clause)) @@ -719,12 +719,12 @@ match_clause_to_indexkey(Rel * rel, * succeed whenever possible (assuming the predicate has been * successfully cnfify()-ed). --Nels, Jan '93 */ -static bool +static bool pred_test(List * predicate_list, List * clauseinfo_list, List * joininfo_list) { - List *pred, - *items, - *item; + List *pred, + *items, + *item; /* * Note: if Postgres tried to optimize queries by forming equivalence @@ -770,11 +770,11 @@ pred_test(List * predicate_list, List * clauseinfo_list, List * joininfo_list) * Does the "predicate inclusion test" for one conjunct of a predicate * expression. */ -static bool +static bool one_pred_test(Expr * predicate, List * clauseinfo_list) { - CInfo *clauseinfo; - List *item; + CInfo *clauseinfo; + List *item; Assert(predicate != NULL); foreach(item, clauseinfo_list) @@ -793,11 +793,11 @@ one_pred_test(Expr * predicate, List * clauseinfo_list) * Does the "predicate inclusion test" for a general restriction-clause * expression. */ -static bool +static bool one_pred_clause_expr_test(Expr * predicate, Node * clause) { - List *items, - *item; + List *items, + *item; if (is_opclause(clause)) return one_pred_clause_test(predicate, clause); @@ -840,11 +840,11 @@ one_pred_clause_expr_test(Expr * predicate, Node * clause) * Does the "predicate inclusion test" for one conjunct of a predicate * expression for a simple restriction clause. */ -static bool +static bool one_pred_clause_test(Expr * predicate, Node * clause) { - List *items, - *item; + List *items, + *item; if (is_opclause((Node *) predicate)) return clause_pred_clause_test(predicate, clause); @@ -903,7 +903,7 @@ one_pred_clause_test(Expr * predicate, Node * clause) * this test should always be considered false. */ -StrategyNumber BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = { +StrategyNumber BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = { {2, 2, 0, 0, 0}, {1, 2, 0, 0, 0}, {1, 2, 3, 4, 5}, @@ -922,29 +922,29 @@ StrategyNumber BT_implic_table[BTMaxStrategyNumber][BTMaxStrategyNumber] = { * Eventually, rtree operators could also be handled by defining an * appropriate "RT_implic_table" array. */ -static bool +static bool clause_pred_clause_test(Expr * predicate, Node * clause) { - Var *pred_var, - *clause_var; - Const *pred_const, - *clause_const; - Oid pred_op, - clause_op, - test_op; - Oid opclass_id; - StrategyNumber pred_strategy, - clause_strategy, - test_strategy; - Oper *test_oper; - Expr *test_expr; - bool test_result, - isNull; - Relation relation; - HeapScanDesc scan; - HeapTuple tuple; - ScanKeyData entry[3]; - Form_pg_amop form; + Var *pred_var, + *clause_var; + Const *pred_const, + *clause_const; + Oid pred_op, + clause_op, + test_op; + Oid opclass_id; + StrategyNumber pred_strategy, + clause_strategy, + test_strategy; + Oper *test_oper; + Expr *test_expr; + bool test_result, + isNull; + Relation relation; + HeapScanDesc scan; + HeapTuple tuple; + ScanKeyData entry[3]; + Form_pg_amop form; pred_var = (Var *) get_leftop(predicate); pred_const = (Const *) get_rightop(predicate); @@ -1120,14 +1120,14 @@ clause_pred_clause_test(Expr * predicate, Node * clause) * when a key is in both join & restriction clauses. - vadim 03/18/97 * */ -static List * +static List * indexable_joinclauses(Rel * rel, Rel * index, List * joininfo_list, List * clauseinfo_list) { - JInfo *joininfo = (JInfo *) NULL; - List *cg_list = NIL; - List *i = NIL; - List *clausegroups = NIL; + JInfo *joininfo = (JInfo *) NULL; + List *cg_list = NIL; + List *i = NIL; + List *clausegroups = NIL; foreach(i, joininfo_list) { @@ -1145,7 +1145,7 @@ indexable_joinclauses(Rel * rel, Rel * index, if (clausegroups != NIL) { - List *clauses = lfirst(clausegroups); + List *clauses = lfirst(clausegroups); ((CInfo *) lfirst(clauses))->cinfojoinid = joininfo->otherrels; @@ -1165,15 +1165,15 @@ indexable_joinclauses(Rel * rel, Rel * index, * This routine returns the restriction clauses only. */ #ifdef NOT_USED -static List * +static List * extract_restrict_clauses(List * clausegroup) { - List *restrict_cls = NIL; - List *l; + List *restrict_cls = NIL; + List *l; foreach(l, clausegroup) { - CInfo *cinfo = lfirst(l); + CInfo *cinfo = lfirst(l); if (!join_clause_p((Node *) cinfo->clause)) { @@ -1196,21 +1196,21 @@ extract_restrict_clauses(List * clausegroup) * Returns a list of index pathnodes. * */ -static List * +static List * index_innerjoin(Query * root, Rel * rel, List * clausegroup_list, Rel * index) { - List *clausegroup = NIL; - List *cg_list = NIL; - List *i = NIL; - IndexPath *pathnode = (IndexPath *) NULL; - Cost temp_selec; - float temp_pages; + List *clausegroup = NIL; + List *cg_list = NIL; + List *i = NIL; + IndexPath *pathnode = (IndexPath *) NULL; + Cost temp_selec; + float temp_pages; foreach(i, clausegroup_list) { - List *attnos, - *values, - *flags; + List *attnos, + *values, + *flags; clausegroup = lfirst(i); pathnode = makeNode(IndexPath); @@ -1281,24 +1281,24 @@ index_innerjoin(Query * root, Rel * rel, List * clausegroup_list, Rel * index) * Returns a list of new index path nodes. * */ -static List * +static List * create_index_paths(Query * root, Rel * rel, Rel * index, List * clausegroup_list, bool join) { - List *clausegroup = NIL; - List *ip_list = NIL; - List *i = NIL; - List *j = NIL; - IndexPath *temp_path; + List *clausegroup = NIL; + List *ip_list = NIL; + List *i = NIL; + List *j = NIL; + IndexPath *temp_path; foreach(i, clausegroup_list) { - CInfo *clauseinfo; - List *temp_node = NIL; - bool temp = true; + CInfo *clauseinfo; + List *temp_node = NIL; + bool temp = true; clausegroup = lfirst(i); @@ -1324,21 +1324,21 @@ create_index_paths(Query * root, return (ip_list); } -static List * +static List * add_index_paths(List * indexpaths, List * new_indexpaths) { return append(indexpaths, new_indexpaths); } -static bool +static bool function_index_operand(Expr * funcOpnd, Rel * rel, Rel * index) { - Oid heapRelid = (Oid) lfirsti(rel->relids); - Func *function; - List *funcargs; - int *indexKeys = index->indexkeys; - List *arg; - int i; + Oid heapRelid = (Oid) lfirsti(rel->relids); + Func *function; + List *funcargs; + int *indexKeys = index->indexkeys; + List *arg; + int i; /* * sanity check, make sure we know what we're dealing with here. @@ -1390,7 +1390,7 @@ function_index_operand(Expr * funcOpnd, Rel * rel, Rel * index) return true; } -static bool +static bool SingleAttributeIndex(Rel * index) { diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index c20558cf42b..fe685aaaf17 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.3 1997/09/07 04:43:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.4 1997/09/08 02:24:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,19 +29,19 @@ #include "optimizer/cost.h" /* for _enable_{hashjoin, * _enable_mergesort} */ -static Path *best_innerjoin(List * join_paths, List * outer_relid); -static List * +static Path *best_innerjoin(List * join_paths, List * outer_relid); +static List * sort_inner_and_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * mergeinfo_list); -static List * +static List * match_unsorted_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * outerpath_list, Path * cheapest_inner, Path * best_innerjoin, List * mergeinfo_list); -static List * +static List * match_unsorted_inner(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * innerpath_list, List * mergeinfo_list); -static bool EnoughMemoryForHashjoin(Rel * hashrel); -static List * +static bool EnoughMemoryForHashjoin(Rel * hashrel); +static List * hash_inner_and_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * hashinfo_list); @@ -69,20 +69,20 @@ hash_inner_and_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, void find_all_join_paths(Query * root, List * joinrels) { - List *mergeinfo_list = NIL; - List *hashinfo_list = NIL; - List *temp_list = NIL; - List *path = NIL; + List *mergeinfo_list = NIL; + List *hashinfo_list = NIL; + List *temp_list = NIL; + List *path = NIL; while (joinrels != NIL) { - Rel *joinrel = (Rel *) lfirst(joinrels); - List *innerrelids; - List *outerrelids; - Rel *innerrel; - Rel *outerrel; - Path *bestinnerjoin; - List *pathlist = NIL; + Rel *joinrel = (Rel *) lfirst(joinrels); + List *innerrelids; + List *outerrelids; + Rel *innerrel; + Rel *outerrel; + Path *bestinnerjoin; + List *pathlist = NIL; innerrelids = lsecond(joinrel->relids); outerrelids = lfirst(joinrel->relids); @@ -205,15 +205,15 @@ find_all_join_paths(Query * root, List * joinrels) * * Returns the pathnode of the selected path. */ -static Path * +static Path * best_innerjoin(List * join_paths, List * outer_relids) { - Path *cheapest = (Path *) NULL; - List *join_path; + Path *cheapest = (Path *) NULL; + List *join_path; foreach(join_path, join_paths) { - Path *path = (Path *) lfirst(join_path); + Path *path = (Path *) lfirst(join_path); if (intMember(lfirsti(path->joinid), outer_relids) && ((cheapest == NULL || @@ -239,19 +239,19 @@ best_innerjoin(List * join_paths, List * outer_relids) * * Returns a list of mergesort paths. */ -static List * +static List * sort_inner_and_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * mergeinfo_list) { - List *ms_list = NIL; - MInfo *xmergeinfo = (MInfo *) NULL; - MergePath *temp_node = (MergePath *) NULL; - List *i; - List *outerkeys = NIL; - List *innerkeys = NIL; - List *merge_pathkeys = NIL; + List *ms_list = NIL; + MInfo *xmergeinfo = (MInfo *) NULL; + MergePath *temp_node = (MergePath *) NULL; + List *i; + List *outerkeys = NIL; + List *innerkeys = NIL; + List *merge_pathkeys = NIL; foreach(i, mergeinfo_list) { @@ -317,7 +317,7 @@ sort_inner_and_outer(Rel * joinrel, * * Returns a list of possible join path nodes. */ -static List * +static List * match_unsorted_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, @@ -326,21 +326,21 @@ match_unsorted_outer(Rel * joinrel, Path * best_innerjoin, List * mergeinfo_list) { - Path *outerpath = (Path *) NULL; - List *jp_list = NIL; - List *temp_node = NIL; - List *merge_pathkeys = NIL; - Path *nestinnerpath = (Path *) NULL; - List *paths = NIL; - List *i = NIL; - PathOrder *outerpath_ordering = NULL; + Path *outerpath = (Path *) NULL; + List *jp_list = NIL; + List *temp_node = NIL; + List *merge_pathkeys = NIL; + Path *nestinnerpath = (Path *) NULL; + List *paths = NIL; + List *i = NIL; + PathOrder *outerpath_ordering = NULL; foreach(i, outerpath_list) { - List *clauses = NIL; - List *matchedJoinKeys = NIL; - List *matchedJoinClauses = NIL; - MInfo *xmergeinfo = (MInfo *) NULL; + List *clauses = NIL; + List *matchedJoinKeys = NIL; + List *matchedJoinClauses = NIL; + MInfo *xmergeinfo = (MInfo *) NULL; outerpath = (Path *) lfirst(i); @@ -360,8 +360,8 @@ match_unsorted_outer(Rel * joinrel, if (clauses) { - List *keys = xmergeinfo->jmethod.jmkeys; - List *clauses = xmergeinfo->jmethod.clauses; + List *keys = xmergeinfo->jmethod.jmkeys; + List *clauses = xmergeinfo->jmethod.clauses; matchedJoinKeys = match_pathkeys_joinkeys(outerpath->keys, @@ -397,9 +397,9 @@ match_unsorted_outer(Rel * joinrel, if (clauses && matchedJoinKeys) { - bool path_is_cheaper_than_sort; - List *varkeys = NIL; - Path *mergeinnerpath = + bool path_is_cheaper_than_sort; + List *varkeys = NIL; + Path *mergeinnerpath = match_paths_joinkeys(matchedJoinKeys, outerpath_ordering, innerrel->pathlist, @@ -484,27 +484,27 @@ match_unsorted_outer(Rel * joinrel, * * Returns a list of possible merge paths. */ -static List * +static List * match_unsorted_inner(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * innerpath_list, List * mergeinfo_list) { - Path *innerpath = (Path *) NULL; - List *mp_list = NIL; - List *temp_node = NIL; - PathOrder *innerpath_ordering = NULL; - Cost temp1 = 0.0; - bool temp2 = false; - List *i = NIL; + Path *innerpath = (Path *) NULL; + List *mp_list = NIL; + List *temp_node = NIL; + PathOrder *innerpath_ordering = NULL; + Cost temp1 = 0.0; + bool temp2 = false; + List *i = NIL; foreach(i, innerpath_list) { - MInfo *xmergeinfo = (MInfo *) NULL; - List *clauses = NIL; - List *matchedJoinKeys = NIL; - List *matchedJoinClauses = NIL; + MInfo *xmergeinfo = (MInfo *) NULL; + List *clauses = NIL; + List *matchedJoinKeys = NIL; + List *matchedJoinClauses = NIL; innerpath = (Path *) lfirst(i); @@ -524,8 +524,8 @@ match_unsorted_inner(Rel * joinrel, if (clauses) { - List *keys = xmergeinfo->jmethod.jmkeys; - List *cls = xmergeinfo->jmethod.clauses; + List *keys = xmergeinfo->jmethod.jmkeys; + List *cls = xmergeinfo->jmethod.clauses; matchedJoinKeys = match_pathkeys_joinkeys(innerpath->keys, @@ -550,11 +550,11 @@ match_unsorted_inner(Rel * joinrel, if (temp2) { - List *outerkeys = + List *outerkeys = extract_path_keys(matchedJoinKeys, outerrel->targetlist, OUTER); - List *merge_pathkeys = + List *merge_pathkeys = new_join_pathkeys(outerkeys, joinrel->targetlist, clauses); @@ -582,12 +582,12 @@ match_unsorted_inner(Rel * joinrel, } -static bool +static bool EnoughMemoryForHashjoin(Rel * hashrel) { - int ntuples; - int tupsize; - int pages; + int ntuples; + int tupsize; + int pages; ntuples = hashrel->size; if (ntuples == 0) @@ -616,19 +616,19 @@ EnoughMemoryForHashjoin(Rel * hashrel) * * Returns a list of hashjoin paths. */ -static List * +static List * hash_inner_and_outer(Rel * joinrel, Rel * outerrel, Rel * innerrel, List * hashinfo_list) { - HInfo *xhashinfo = (HInfo *) NULL; - List *hjoin_list = NIL; - HashPath *temp_node = (HashPath *) NULL; - List *i = NIL; - List *outerkeys = NIL; - List *innerkeys = NIL; - List *hash_pathkeys = NIL; + HInfo *xhashinfo = (HInfo *) NULL; + List *hjoin_list = NIL; + HashPath *temp_node = (HashPath *) NULL; + List *i = NIL; + List *outerkeys = NIL; + List *innerkeys = NIL; + List *hash_pathkeys = NIL; foreach(i, hashinfo_list) { diff --git a/src/backend/optimizer/path/joinrels.c b/src/backend/optimizer/path/joinrels.c index 98762f9800c..b1c1f0cb091 100644 --- a/src/backend/optimizer/path/joinrels.c +++ b/src/backend/optimizer/path/joinrels.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.5 1997/09/07 04:43:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinrels.c,v 1.6 1997/09/08 02:24:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,23 +24,23 @@ #include "optimizer/pathnode.h" #ifdef USE_RIGHT_SIDED_PLANS -bool _use_right_sided_plans_ = true; +bool _use_right_sided_plans_ = true; #else -bool _use_right_sided_plans_ = false; +bool _use_right_sided_plans_ = false; #endif -static List *find_clause_joins(Query * root, Rel * outer_rel, List * joininfo_list); -static List *find_clauseless_joins(Rel * outer_rel, List * inner_rels); -static Rel *init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo); -static List * +static List *find_clause_joins(Query * root, Rel * outer_rel, List * joininfo_list); +static List *find_clauseless_joins(Rel * outer_rel, List * inner_rels); +static Rel *init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo); +static List * new_join_tlist(List * tlist, List * other_relids, int first_resdomno); -static List *new_joininfo_list(List * joininfo_list, List * join_relids); -static void add_superrels(Rel * rel, Rel * super_rel); -static bool nonoverlap_rels(Rel * rel1, Rel * rel2); -static bool nonoverlap_sets(List * s1, List * s2); +static List *new_joininfo_list(List * joininfo_list, List * join_relids); +static void add_superrels(Rel * rel, Rel * super_rel); +static bool nonoverlap_rels(Rel * rel1, Rel * rel2); +static bool nonoverlap_sets(List * s1, List * s2); static void set_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel, JInfo * jinfo); @@ -58,16 +58,16 @@ set_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel, * * Returns a list of rel nodes corresponding to the new join relations. */ -List * +List * find_join_rels(Query * root, List * outer_rels) { - List *joins = NIL; - List *join_list = NIL; - List *r = NIL; + List *joins = NIL; + List *join_list = NIL; + List *r = NIL; foreach(r, outer_rels) { - Rel *outer_rel = (Rel *) lfirst(r); + Rel *outer_rel = (Rel *) lfirst(r); if (!(joins = find_clause_joins(root, outer_rel, outer_rel->joininfo))) if (BushyPlanFlag) @@ -96,20 +96,20 @@ find_join_rels(Query * root, List * outer_rels) * * Returns a list of new join relations. */ -static List * +static List * find_clause_joins(Query * root, Rel * outer_rel, List * joininfo_list) { - List *join_list = NIL; - List *i = NIL; + List *join_list = NIL; + List *i = NIL; foreach(i, joininfo_list) { - JInfo *joininfo = (JInfo *) lfirst(i); - Rel *rel; + JInfo *joininfo = (JInfo *) lfirst(i); + Rel *rel; if (!joininfo->inactive) { - List *other_rels = joininfo->otherrels; + List *other_rels = joininfo->otherrels; if (other_rels != NIL) { @@ -157,13 +157,13 @@ find_clause_joins(Query * root, Rel * outer_rel, List * joininfo_list) * * Returns a list of new join relations. */ -static List * +static List * find_clauseless_joins(Rel * outer_rel, List * inner_rels) { - Rel *inner_rel; - List *t_list = NIL; - List *temp_node = NIL; - List *i = NIL; + Rel *inner_rel; + List *t_list = NIL; + List *temp_node = NIL; + List *i = NIL; foreach(i, inner_rels) { @@ -192,13 +192,13 @@ find_clauseless_joins(Rel * outer_rel, List * inner_rels) * * Returns the new join relation node. */ -static Rel * +static Rel * init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo) { - Rel *joinrel = makeNode(Rel); - List *joinrel_joininfo_list = NIL; - List *new_outer_tlist; - List *new_inner_tlist; + Rel *joinrel = makeNode(Rel); + List *joinrel_joininfo_list = NIL; + List *new_outer_tlist; + List *new_inner_tlist; /* * Create a new tlist by removing irrelevant elements from both tlists @@ -272,18 +272,18 @@ init_join_rel(Rel * outer_rel, Rel * inner_rel, JInfo * joininfo) * * Returns the new target list. */ -static List * +static List * new_join_tlist(List * tlist, List * other_relids, int first_resdomno) { - int resdomno = first_resdomno - 1; - TargetEntry *xtl = NULL; - List *temp_node = NIL; - List *t_list = NIL; - List *i = NIL; - List *join_list = NIL; - bool in_final_tlist = false; + int resdomno = first_resdomno - 1; + TargetEntry *xtl = NULL; + List *temp_node = NIL; + List *t_list = NIL; + List *i = NIL; + List *join_list = NIL; + bool in_final_tlist = false; foreach(i, tlist) @@ -322,18 +322,18 @@ new_join_tlist(List * tlist, * * Returns a list of joininfo nodes, new and old. */ -static List * +static List * new_joininfo_list(List * joininfo_list, List * join_relids) { - List *current_joininfo_list = NIL; - List *new_otherrels = NIL; - JInfo *other_joininfo = (JInfo *) NULL; - List *xjoininfo = NIL; + List *current_joininfo_list = NIL; + List *new_otherrels = NIL; + JInfo *other_joininfo = (JInfo *) NULL; + List *xjoininfo = NIL; foreach(xjoininfo, joininfo_list) { - List *or; - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + List *or; + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); new_otherrels = joininfo->otherrels; foreach(or, new_otherrels) @@ -389,42 +389,42 @@ new_joininfo_list(List * joininfo_list, List * join_relids) void add_new_joininfos(Query * root, List * joinrels, List * outerrels) { - List *xjoinrel = NIL; - List *xrelid = NIL; - List *xrel = NIL; - List *xjoininfo = NIL; + List *xjoinrel = NIL; + List *xrelid = NIL; + List *xrel = NIL; + List *xjoininfo = NIL; foreach(xjoinrel, joinrels) { - Rel *joinrel = (Rel *) lfirst(xjoinrel); + Rel *joinrel = (Rel *) lfirst(xjoinrel); foreach(xrelid, joinrel->relids) { - Relid relid = (Relid) lfirst(xrelid); - Rel *rel = get_join_rel(root, relid); + Relid relid = (Relid) lfirst(xrelid); + Rel *rel = get_join_rel(root, relid); add_superrels(rel, joinrel); } } foreach(xjoinrel, joinrels) { - Rel *joinrel = (Rel *) lfirst(xjoinrel); + Rel *joinrel = (Rel *) lfirst(xjoinrel); foreach(xjoininfo, joinrel->joininfo) { - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); - List *other_rels = joininfo->otherrels; - List *clause_info = joininfo->jinfoclauseinfo; - bool mergesortable = joininfo->mergesortable; - bool hashjoinable = joininfo->hashjoinable; + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + List *other_rels = joininfo->otherrels; + List *clause_info = joininfo->jinfoclauseinfo; + bool mergesortable = joininfo->mergesortable; + bool hashjoinable = joininfo->hashjoinable; foreach(xrelid, other_rels) { - Relid relid = (Relid) lfirst(xrelid); - Rel *rel = get_join_rel(root, relid); - List *super_rels = rel->superrels; - List *xsuper_rel = NIL; - JInfo *new_joininfo = makeNode(JInfo); + Relid relid = (Relid) lfirst(xrelid); + Rel *rel = get_join_rel(root, relid); + List *super_rels = rel->superrels; + List *xsuper_rel = NIL; + JInfo *new_joininfo = makeNode(JInfo); new_joininfo->otherrels = joinrel->relids; new_joininfo->jinfoclauseinfo = clause_info; @@ -436,12 +436,12 @@ add_new_joininfos(Query * root, List * joinrels, List * outerrels) foreach(xsuper_rel, super_rels) { - Rel *super_rel = (Rel *) lfirst(xsuper_rel); + Rel *super_rel = (Rel *) lfirst(xsuper_rel); if (nonoverlap_rels(super_rel, joinrel)) { - List *new_relids = super_rel->relids; - JInfo *other_joininfo = + List *new_relids = super_rel->relids; + JInfo *other_joininfo = joininfo_member(new_relids, joinrel->joininfo); @@ -453,7 +453,7 @@ add_new_joininfos(Query * root, List * joinrels, List * outerrels) } else { - JInfo *new_joininfo = makeNode(JInfo); + JInfo *new_joininfo = makeNode(JInfo); new_joininfo->otherrels = new_relids; new_joininfo->jinfoclauseinfo = clause_info; @@ -471,7 +471,7 @@ add_new_joininfos(Query * root, List * joinrels, List * outerrels) } foreach(xrel, outerrels) { - Rel *rel = (Rel *) lfirst(xrel); + Rel *rel = (Rel *) lfirst(xrel); rel->superrels = NIL; } @@ -486,12 +486,12 @@ add_new_joininfos(Query * root, List * joinrels, List * outerrels) * * Returns the list of final join relations. */ -List * +List * final_join_rels(List * join_rel_list) { - List *xrel = NIL; - List *temp = NIL; - List *t_list = NIL; + List *xrel = NIL; + List *temp = NIL; + List *t_list = NIL; /* * find the relations that has no further joins, i.e., its joininfos @@ -499,13 +499,13 @@ final_join_rels(List * join_rel_list) */ foreach(xrel, join_rel_list) { - Rel *rel = (Rel *) lfirst(xrel); - List *xjoininfo = NIL; - bool final = true; + Rel *rel = (Rel *) lfirst(xrel); + List *xjoininfo = NIL; + bool final = true; foreach(xjoininfo, rel->joininfo) { - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); if (joininfo->otherrels != NIL) { @@ -547,20 +547,20 @@ add_superrels(Rel * rel, Rel * super_rel) * * Returns non-nil if rel1 and rel2 do not overlap. */ -static bool +static bool nonoverlap_rels(Rel * rel1, Rel * rel2) { return (nonoverlap_sets(rel1->relids, rel2->relids)); } -static bool +static bool nonoverlap_sets(List * s1, List * s2) { - List *x = NIL; + List *x = NIL; foreach(x, s1) { - int e = lfirsti(x); + int e = lfirsti(x); if (intMember(e, s2)) return (false); @@ -571,8 +571,8 @@ nonoverlap_sets(List * s1, List * s2) static void set_joinrel_size(Rel * joinrel, Rel * outer_rel, Rel * inner_rel, JInfo * jinfo) { - int ntuples; - float selec; + int ntuples; + float selec; /* * voodoo magic. but better than a size of 0. I have no idea why we diff --git a/src/backend/optimizer/path/joinutils.c b/src/backend/optimizer/path/joinutils.c index c88d3cf19e8..1e297eee077 100644 --- a/src/backend/optimizer/path/joinutils.c +++ b/src/backend/optimizer/path/joinutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.2 1997/09/07 04:43:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/joinutils.c,v 1.3 1997/09/08 02:24:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,11 +32,11 @@ match_pathkey_joinkeys(List * pathkey, List * joinkeys, static bool every_func(List * joinkeys, List * pathkey, int which_subkey); -static List * +static List * new_join_pathkey(List * subkeys, List * considered_subkeys, List * join_rel_tlist, List * joinclauses); -static List * +static List * new_matching_subkeys(Var * subkey, List * considered_subkeys, List * join_rel_tlist, List * joinclauses); @@ -73,18 +73,18 @@ new_matching_subkeys(Var * subkey, List * considered_subkeys, * Returns a list of matched join keys and a list of matched join clauses * in matchedJoinClausesPtr. - ay 11/94 */ -List * +List * match_pathkeys_joinkeys(List * pathkeys, List * joinkeys, List * joinclauses, int which_subkey, List ** matchedJoinClausesPtr) { - List *matched_joinkeys = NIL; - List *matched_joinclauses = NIL; - List *pathkey = NIL; - List *i = NIL; - int matched_joinkey_index = -1; + List *matched_joinkeys = NIL; + List *matched_joinclauses = NIL; + List *pathkey = NIL; + List *i = NIL; + int matched_joinkey_index = -1; foreach(i, pathkeys) { @@ -94,8 +94,8 @@ match_pathkeys_joinkeys(List * pathkeys, if (matched_joinkey_index != -1) { - List *xjoinkey = nth(matched_joinkey_index, joinkeys); - List *joinclause = nth(matched_joinkey_index, joinclauses); + List *xjoinkey = nth(matched_joinkey_index, joinkeys); + List *joinclause = nth(matched_joinkey_index, joinclauses); /* XXX was "push" function */ matched_joinkeys = lappend(matched_joinkeys, xjoinkey); @@ -131,11 +131,11 @@ match_pathkey_joinkeys(List * pathkey, List * joinkeys, int which_subkey) { - Var *path_subkey; - int pos; - List *i = NIL; - List *x = NIL; - JoinKey *jk; + Var *path_subkey; + int pos; + List *i = NIL; + List *x = NIL; + JoinKey *jk; foreach(i, pathkey) { @@ -174,15 +174,15 @@ match_pathkey_joinkeys(List * pathkey, * * Returns the matching path node if one exists, nil otherwise. */ -static bool +static bool every_func(List * joinkeys, List * pathkey, int which_subkey) { - JoinKey *xjoinkey; - Var *temp; - Var *tempkey = NULL; - bool found = false; - List *i = NIL; - List *j = NIL; + JoinKey *xjoinkey; + Var *temp; + Var *tempkey = NULL; + bool found = false; + List *i = NIL; + List *j = NIL; foreach(i, joinkeys) { @@ -211,19 +211,19 @@ every_func(List * joinkeys, List * pathkey, int which_subkey) * match_paths_joinkeys - * find the cheapest path that matches the join keys */ -Path * +Path * match_paths_joinkeys(List * joinkeys, PathOrder * ordering, List * paths, int which_subkey) { - Path *matched_path = NULL; - bool key_match = false; - List *i = NIL; + Path *matched_path = NULL; + bool key_match = false; + List *i = NIL; foreach(i, paths) { - Path *path = (Path *) lfirst(i); + Path *path = (Path *) lfirst(i); key_match = every_func(joinkeys, path->keys, which_subkey); @@ -263,20 +263,20 @@ match_paths_joinkeys(List * joinkeys, * Returns a list of pathkeys: ((tlvar1)(tlvar2)...(tlvarN)). * [I've no idea why they have to be list of lists. Should be fixed. -ay 12/94] */ -List * +List * extract_path_keys(List * joinkeys, List * tlist, int which_subkey) { - List *pathkeys = NIL; - List *jk; + List *pathkeys = NIL; + List *jk; foreach(jk, joinkeys) { - JoinKey *jkey = (JoinKey *) lfirst(jk); - Var *var, - *key; - List *p; + JoinKey *jkey = (JoinKey *) lfirst(jk); + Var *var, + *key; + List *p; /* * find the right Var in the target list for this key @@ -289,7 +289,7 @@ extract_path_keys(List * joinkeys, */ foreach(p, pathkeys) { - Var *pkey = lfirst((List *) lfirst(p)); /* XXX fix me */ + Var *pkey = lfirst((List *) lfirst(p)); /* XXX fix me */ if (key == pkey) break; @@ -325,15 +325,15 @@ extract_path_keys(List * joinkeys, * Returns the list of new path keys. * */ -List * +List * new_join_pathkeys(List * outer_pathkeys, List * join_rel_tlist, List * joinclauses) { - List *outer_pathkey = NIL; - List *t_list = NIL; - List *x; - List *i = NIL; + List *outer_pathkey = NIL; + List *t_list = NIL; + List *x; + List *i = NIL; foreach(i, outer_pathkeys) { @@ -365,18 +365,18 @@ new_join_pathkeys(List * outer_pathkeys, * Returns a new pathkey(list of subkeys). * */ -static List * +static List * new_join_pathkey(List * subkeys, List * considered_subkeys, List * join_rel_tlist, List * joinclauses) { - List *t_list = NIL; - Var *subkey; - List *i = NIL; - List *matched_subkeys = NIL; - Expr *tlist_key = (Expr *) NULL; - List *newly_considered_subkeys = NIL; + List *t_list = NIL; + Var *subkey; + List *i = NIL; + List *matched_subkeys = NIL; + Expr *tlist_key = (Expr *) NULL; + List *newly_considered_subkeys = NIL; foreach(i, subkeys) { @@ -425,17 +425,17 @@ new_join_pathkey(List * subkeys, * Returns a list of new subkeys. * */ -static List * +static List * new_matching_subkeys(Var * subkey, List * considered_subkeys, List * join_rel_tlist, List * joinclauses) { - Expr *joinclause = NULL; - List *t_list = NIL; - List *temp = NIL; - List *i = NIL; - Expr *tlist_other_var = (Expr *) NULL; + Expr *joinclause = NULL; + List *t_list = NIL; + List *temp = NIL; + List *i = NIL; + Expr *tlist_other_var = (Expr *) NULL; foreach(i, joinclauses) { diff --git a/src/backend/optimizer/path/mergeutils.c b/src/backend/optimizer/path/mergeutils.c index 93004a6741e..be5cc79d8dc 100644 --- a/src/backend/optimizer/path/mergeutils.c +++ b/src/backend/optimizer/path/mergeutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.2 1997/09/07 04:43:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/mergeutils.c,v 1.3 1997/09/08 02:24:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,17 +33,17 @@ * Returns the new list of mergeinfo nodes. * */ -List * +List * group_clauses_by_order(List * clauseinfo_list, int inner_relid) { - List *mergeinfo_list = NIL; - List *xclauseinfo = NIL; + List *mergeinfo_list = NIL; + List *xclauseinfo = NIL; foreach(xclauseinfo, clauseinfo_list) { - CInfo *clauseinfo = (CInfo *) lfirst(xclauseinfo); - MergeOrder *merge_ordering = clauseinfo->mergesortorder; + CInfo *clauseinfo = (CInfo *) lfirst(xclauseinfo); + MergeOrder *merge_ordering = clauseinfo->mergesortorder; if (merge_ordering) { @@ -52,12 +52,12 @@ group_clauses_by_order(List * clauseinfo_list, * Create a new mergeinfo node and add it to 'mergeinfo-list' * if one does not yet exist for this merge ordering. */ - PathOrder p_ordering; - MInfo *xmergeinfo; - Expr *clause = clauseinfo->clause; - Var *leftop = get_leftop(clause); - Var *rightop = get_rightop(clause); - JoinKey *keys; + PathOrder p_ordering; + MInfo *xmergeinfo; + Expr *clause = clauseinfo->clause; + Var *leftop = get_leftop(clause); + Var *rightop = get_rightop(clause); + JoinKey *keys; p_ordering.ordtype = MERGE_ORDER; p_ordering.ord.merge = merge_ordering; @@ -105,15 +105,15 @@ group_clauses_by_order(List * clauseinfo_list, * Returns the node if it exists. * */ -MInfo * +MInfo * match_order_mergeinfo(PathOrder * ordering, List * mergeinfo_list) { - MergeOrder *xmergeorder; - List *xmergeinfo = NIL; + MergeOrder *xmergeorder; + List *xmergeinfo = NIL; foreach(xmergeinfo, mergeinfo_list) { - MInfo *mergeinfo = (MInfo *) lfirst(xmergeinfo); + MInfo *mergeinfo = (MInfo *) lfirst(xmergeinfo); xmergeorder = mergeinfo->m_ordering; diff --git a/src/backend/optimizer/path/orindxpath.c b/src/backend/optimizer/path/orindxpath.c index 96408b78905..7b2da6c182e 100644 --- a/src/backend/optimizer/path/orindxpath.c +++ b/src/backend/optimizer/path/orindxpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.2 1997/09/07 04:43:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/orindxpath.c,v 1.3 1997/09/08 02:24:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,15 +50,15 @@ best_or_subclause_index(Query * root, Rel * rel, Expr * subclause, * Returns a list of these index path nodes. * */ -List * +List * create_or_index_paths(Query * root, Rel * rel, List * clauses) { - List *t_list = NIL; + List *t_list = NIL; if (clauses != NIL) { - CInfo *clausenode = (CInfo *) (lfirst(clauses)); + CInfo *clausenode = (CInfo *) (lfirst(clauses)); /* * Check to see if this clause is an 'or' clause, and, if so, @@ -70,9 +70,9 @@ create_or_index_paths(Query * root, if (valid_or_clause(clausenode) && clausenode->indexids) { - List *temp = NIL; - List *index_list = NIL; - bool index_flag = true; + List *temp = NIL; + List *index_list = NIL; + bool index_flag = true; index_list = clausenode->indexids; foreach(temp, index_list) @@ -82,10 +82,10 @@ create_or_index_paths(Query * root, } if (index_flag) { /* used to be a lisp every function */ - IndexPath *pathnode = makeNode(IndexPath); - List *indexids; - Cost cost; - List *selecs; + IndexPath *pathnode = makeNode(IndexPath); + List *indexids; + Cost cost; + List *selecs; best_or_subclause_indices(root, rel, @@ -177,9 +177,9 @@ best_or_subclause_indices(Query * root, } else { - int best_indexid; - Cost best_cost; - Cost best_selec; + int best_indexid; + Cost best_cost; + Cost best_selec; best_or_subclause_index(root, rel, lfirst(subclauses), lfirst(indices), &best_indexid, &best_cost, &best_selec); @@ -223,18 +223,18 @@ best_or_subclause_index(Query * root, { if (indices != NIL) { - Datum value; - int flag = 0; - Cost subcost; - Rel *index = (Rel *) lfirst(indices); - AttrNumber attno = (get_leftop(subclause))->varattno; - Oid opno = ((Oper *) subclause->oper)->opno; - bool constant_on_right = non_null((Expr *) get_rightop(subclause)); - float npages, - selec; - int subclause_indexid; - Cost subclause_cost; - Cost subclause_selec; + Datum value; + int flag = 0; + Cost subcost; + Rel *index = (Rel *) lfirst(indices); + AttrNumber attno = (get_leftop(subclause))->varattno; + Oid opno = ((Oper *) subclause->oper)->opno; + bool constant_on_right = non_null((Expr *) get_rightop(subclause)); + float npages, + selec; + int subclause_indexid; + Cost subclause_cost; + Cost subclause_selec; if (constant_on_right) { diff --git a/src/backend/optimizer/path/predmig.c b/src/backend/optimizer/path/predmig.c index c302af3b581..f1990e13a02 100644 --- a/src/backend/optimizer/path/predmig.c +++ b/src/backend/optimizer/path/predmig.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.3 1997/09/07 04:43:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/predmig.c,v 1.4 1997/09/08 02:24:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,28 +57,28 @@ static void xfunc_predmig(JoinPath pathnode, Stream streamroot, Stream laststream, bool * progressp); -static bool xfunc_series_llel(Stream stream); -static bool xfunc_llel_chains(Stream root, Stream bottom); -static Stream xfunc_complete_stream(Stream stream); +static bool xfunc_series_llel(Stream stream); +static bool xfunc_llel_chains(Stream root, Stream bottom); +static Stream xfunc_complete_stream(Stream stream); static bool xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath); -static void xfunc_form_groups(Stream root, Stream bottom); -static void xfunc_free_stream(Stream root); -static Stream xfunc_add_clauses(Stream current); -static void xfunc_setup_group(Stream node, Stream bottom); +static void xfunc_form_groups(Stream root, Stream bottom); +static void xfunc_free_stream(Stream root); +static Stream xfunc_add_clauses(Stream current); +static void xfunc_setup_group(Stream node, Stream bottom); static Stream xfunc_streaminsert(CInfo clauseinfo, Stream current, int clausetype); -static int xfunc_num_relids(Stream node); +static int xfunc_num_relids(Stream node); static StreamPtr xfunc_get_downjoin(Stream node); static StreamPtr xfunc_get_upjoin(Stream node); -static Stream xfunc_stream_qsort(Stream root, Stream bottom); -static int xfunc_stream_compare(void *arg1, void *arg2); -static bool xfunc_check_stream(Stream node); -static bool xfunc_in_stream(Stream node, Stream stream); +static Stream xfunc_stream_qsort(Stream root, Stream bottom); +static int xfunc_stream_compare(void *arg1, void *arg2); +static bool xfunc_check_stream(Stream node); +static bool xfunc_in_stream(Stream node, Stream stream); -/* ----------------- MAIN FUNCTIONS ------------------------ */ +/* ----------------- MAIN FUNCTIONS ------------------------ */ /* ** xfunc_do_predmig ** wrapper for Predicate Migration. It calls xfunc_predmig until no @@ -88,8 +88,8 @@ static bool xfunc_in_stream(Stream node, Stream stream); bool xfunc_do_predmig(Path root) { - bool progress, - changed = false; + bool progress, + changed = false; if (is_join(root)) do @@ -122,7 +122,7 @@ xfunc_predmig(JoinPath pathnode,/* root of the join tree */ * and the lowest node created so far */ bool * progressp) { - Stream newstream; + Stream newstream; /* * * traverse the join tree dfs-style, constructing a stream as you @@ -153,7 +153,7 @@ xfunc_predmig(JoinPath pathnode,/* root of the join tree */ if (!is_join(pathnode)) { /* form a fleshed-out copy of the stream */ - Stream fullstream = xfunc_complete_stream(streamroot); + Stream fullstream = xfunc_complete_stream(streamroot); /* sort it via series-llel */ if (xfunc_series_llel(fullstream)) @@ -188,9 +188,9 @@ xfunc_predmig(JoinPath pathnode,/* root of the join tree */ static bool xfunc_series_llel(Stream stream) { - Stream temp, - next; - bool progress = false; + Stream temp, + next; + bool progress = false; for (temp = stream; temp != (Stream) NULL; temp = next) { @@ -219,11 +219,11 @@ xfunc_series_llel(Stream stream) static bool xfunc_llel_chains(Stream root, Stream bottom) { - bool progress = false; - Stream origstream; - Stream tmpstream, - pathstream; - Stream rootcopy = root; + bool progress = false; + Stream origstream; + Stream tmpstream, + pathstream; + Stream rootcopy = root; Assert(xfunc_check_stream(root)); @@ -282,9 +282,9 @@ xfunc_llel_chains(Stream root, Stream bottom) static Stream xfunc_complete_stream(Stream stream) { - Stream tmpstream, - copystream, - curstream = (Stream) NULL; + Stream tmpstream, + copystream, + curstream = (Stream) NULL; copystream = (Stream) copyObject((Node) stream); Assert(xfunc_check_stream(copystream)); @@ -316,15 +316,15 @@ xfunc_complete_stream(Stream stream) ** nodes. We use the original stream to find out what joins are ** above the clause. */ -static bool +static bool xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath) { - CInfo clauseinfo = get_cinfo(pullme); - bool progress = false; - Stream upjoin, - orignode, - temp; - int whichchild; + CInfo clauseinfo = get_cinfo(pullme); + bool progress = false; + Stream upjoin, + orignode, + temp; + int whichchild; /* find node in origstream that contains clause */ for (orignode = origstream; @@ -412,12 +412,12 @@ xfunc_prdmig_pullup(Stream origstream, Stream pullme, JoinPath joinpath) static void xfunc_form_groups(Query * queryInfo, Stream root, Stream bottom) { - Stream temp, - parent; - int lowest = xfunc_num_relids((Stream) xfunc_get_upjoin(bottom)); - bool progress; - LispValue primjoin; - int whichchild; + Stream temp, + parent; + int lowest = xfunc_num_relids((Stream) xfunc_get_upjoin(bottom)); + bool progress; + LispValue primjoin; + int whichchild; if (!lowest) return; /* no joins in stream, so no groups */ @@ -495,7 +495,7 @@ xfunc_form_groups(Query * queryInfo, Stream root, Stream bottom) } -/* ------------------- UTILITY FUNCTIONS ------------------------- */ +/* ------------------- UTILITY FUNCTIONS ------------------------- */ /* ** xfunc_free_stream -- @@ -504,8 +504,8 @@ xfunc_form_groups(Query * queryInfo, Stream root, Stream bottom) static void xfunc_free_stream(Stream root) { - Stream cur, - next; + Stream cur, + next; Assert(xfunc_check_stream(root)); @@ -525,9 +525,9 @@ xfunc_free_stream(Stream root) static Stream xfunc_add_clauses(Stream current) { - Stream topnode = current; - LispValue temp; - LispValue primjoin; + Stream topnode = current; + LispValue temp; + LispValue primjoin; /* first add in the local clauses */ foreach(temp, get_locclauseinfo((Path) get_pathptr(current))) @@ -561,7 +561,7 @@ xfunc_add_clauses(Stream current) static void xfunc_setup_group(Stream node, Stream bottom) { - Stream temp; + Stream temp; if (node != bottom) /* traverse downwards */ @@ -598,12 +598,12 @@ xfunc_setup_group(Stream node, Stream bottom) ** Make a new Stream node to hold clause, and insert it above current. ** Return new node. */ -static Stream +static Stream xfunc_streaminsert(CInfo clauseinfo, Stream current, int clausetype) /* XFUNC_LOCPRD or XFUNC_JOINPRD */ { - Stream newstream = RMakeStream(); + Stream newstream = RMakeStream(); set_upstream(newstream, get_upstream(current)); if (get_upstream(current)) @@ -640,7 +640,7 @@ xfunc_num_relids(Stream node) static StreamPtr xfunc_get_downjoin(Stream node) { - Stream temp; + Stream temp; if (!is_clause(node)) /* if this is a join */ node = (Stream) get_downstream(node); @@ -658,7 +658,7 @@ xfunc_get_downjoin(Stream node) static StreamPtr xfunc_get_upjoin(Stream node) { - Stream temp; + Stream temp; if (!is_clause(node)) /* if this is a join */ node = (Stream) get_upstream(node); @@ -677,11 +677,11 @@ xfunc_get_upjoin(Stream node) static Stream xfunc_stream_qsort(Stream root, Stream bottom) { - int i; - size_t num; - Stream *nodearray, - output; - Stream tmp; + int i; + size_t num; + Stream *nodearray, + output; + Stream tmp; /* find size of list */ for (num = 0, tmp = root; tmp != bottom; @@ -725,10 +725,10 @@ xfunc_stream_qsort(Stream root, Stream bottom) static int xfunc_stream_compare(void *arg1, void *arg2) { - Stream stream1 = *(Stream *) arg1; - Stream stream2 = *(Stream *) arg2; - Cost rank1, - rank2; + Stream stream1 = *(Stream *) arg1; + Stream stream2 = *(Stream *) arg2; + Cost rank1, + rank2; rank1 = get_grouprank(stream1); rank2 = get_grouprank(stream2); @@ -765,7 +765,7 @@ xfunc_stream_compare(void *arg1, void *arg2) } } -/* ------------------ DEBUGGING ROUTINES ---------------------------- */ +/* ------------------ DEBUGGING ROUTINES ---------------------------- */ /* ** Make sure all pointers in stream make sense. Make sure no joins are @@ -774,9 +774,9 @@ xfunc_stream_compare(void *arg1, void *arg2) static bool xfunc_check_stream(Stream node) { - Stream temp; - int numrelids, - tmp; + Stream temp; + int numrelids, + tmp; /* set numrelids higher than max */ if (!is_clause(node)) @@ -814,7 +814,7 @@ xfunc_check_stream(Stream node) static bool xfunc_in_stream(Stream node, Stream stream) { - Stream temp; + Stream temp; for (temp = stream; temp; temp = (Stream) get_downstream(temp)) if (temp == node) diff --git a/src/backend/optimizer/path/prune.c b/src/backend/optimizer/path/prune.c index 4f3ae2d15de..209644c2478 100644 --- a/src/backend/optimizer/path/prune.c +++ b/src/backend/optimizer/path/prune.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.4 1997/09/07 04:43:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/prune.c,v 1.5 1997/09/08 02:24:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ #include "utils/elog.h" -static List *prune_joinrel(Rel * rel, List * other_rels); +static List *prune_joinrel(Rel * rel, List * other_rels); /* * prune-joinrels-- @@ -34,10 +34,10 @@ static List *prune_joinrel(Rel * rel, List * other_rels); * Returns the resulting list. * */ -List * +List * prune_joinrels(List * rel_list) { - List *temp_list = NIL; + List *temp_list = NIL; if (rel_list != NIL) { @@ -59,13 +59,13 @@ prune_joinrels(List * rel_list) * of 'rel' appropriately. * */ -static List * +static List * prune_joinrel(Rel * rel, List * other_rels) { - List *i = NIL; - List *t_list = NIL; - List *temp_node = NIL; - Rel *other_rel = (Rel *) NULL; + List *i = NIL; + List *t_list = NIL; + List *temp_node = NIL; + Rel *other_rel = (Rel *) NULL; foreach(i, other_rels) { @@ -99,11 +99,11 @@ prune_joinrel(Rel * rel, List * other_rels) void prune_rel_paths(List * rel_list) { - List *x = NIL; - List *y = NIL; - Path *path = NULL; - Rel *rel = (Rel *) NULL; - JoinPath *cheapest = (JoinPath *) NULL; + List *x = NIL; + List *y = NIL; + Path *path = NULL; + Rel *rel = (Rel *) NULL; + JoinPath *cheapest = (JoinPath *) NULL; foreach(x, rel_list) { @@ -139,10 +139,10 @@ prune_rel_paths(List * rel_list) * Returns the cheapest path. * */ -Path * +Path * prune_rel_path(Rel * rel, Path * unorderedpath) { - Path *cheapest = set_cheapest(rel, rel->pathlist); + Path *cheapest = set_cheapest(rel, rel->pathlist); /* don't prune if not pruneable -- JMH, 11/23/92 */ if (unorderedpath != cheapest @@ -170,14 +170,14 @@ prune_rel_path(Rel * rel, Path * unorderedpath) * * Returns one pruned rel node list */ -List * +List * merge_joinrels(List * rel_list1, List * rel_list2) { - List *xrel = NIL; + List *xrel = NIL; foreach(xrel, rel_list1) { - Rel *rel = (Rel *) lfirst(xrel); + Rel *rel = (Rel *) lfirst(xrel); rel_list2 = prune_joinrel(rel, rel_list2); } @@ -196,12 +196,12 @@ merge_joinrels(List * rel_list1, List * rel_list2) * * Returns a new list of rel nodes */ -List * +List * prune_oldrels(List * old_rels) { - Rel *rel; - List *joininfo_list, - *xjoininfo; + Rel *rel; + List *joininfo_list, + *xjoininfo; if (old_rels == NIL) return (NIL); @@ -213,7 +213,7 @@ prune_oldrels(List * old_rels) foreach(xjoininfo, joininfo_list) { - JInfo *joininfo = (JInfo *) lfirst(xjoininfo); + JInfo *joininfo = (JInfo *) lfirst(xjoininfo); if (!joininfo->inactive) return (lcons(rel, prune_oldrels(lnext(old_rels)))); diff --git a/src/backend/optimizer/path/xfunc.c b/src/backend/optimizer/path/xfunc.c index 36135d4a823..061a2996c80 100644 --- a/src/backend/optimizer/path/xfunc.c +++ b/src/backend/optimizer/path/xfunc.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.4 1997/09/07 04:43:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/Attic/xfunc.c,v 1.5 1997/09/08 02:24:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,13 +62,13 @@ xfunc_card_unreferenced(Query * queryInfo, void xfunc_trypullup(Rel rel) { - LispValue y; /* list ptr */ - CInfo maxcinfo; /* The CInfo to pull up, as calculated by + LispValue y; /* list ptr */ + CInfo maxcinfo; /* The CInfo to pull up, as calculated by * xfunc_shouldpull() */ - JoinPath curpath; /* current path in list */ - int progress; /* has progress been made this time + JoinPath curpath; /* current path in list */ + int progress; /* has progress been made this time * through? */ - int clausetype; + int clausetype; do { @@ -153,17 +153,16 @@ xfunc_shouldpull(Query * queryInfo, CInfo * maxcinfopt) /* Out: pointer to clause to * pullup */ { - LispValue clauselist, - tmplist; /* lists of clauses */ - CInfo maxcinfo; /* clause to pullup */ - LispValue primjoinclause /* primary join clause */ + LispValue clauselist, + tmplist; /* lists of clauses */ + CInfo maxcinfo; /* clause to pullup */ + LispValue primjoinclause /* primary join clause */ = xfunc_primary_join(parentpath); - Cost tmprank, - maxrank = (-1 * MAXFLOAT); /* ranks of clauses */ - Cost joinselec = 0; /* selectivity of the join - * predicate */ - Cost joincost = 0; /* join cost + primjoinclause cost */ - int retval = XFUNC_LOCPRD; + Cost tmprank, + maxrank = (-1 * MAXFLOAT); /* ranks of clauses */ + Cost joinselec = 0; /* selectivity of the join predicate */ + Cost joincost = 0; /* join cost + primjoinclause cost */ + int retval = XFUNC_LOCPRD; clauselist = get_locclauseinfo(childpath); @@ -275,11 +274,11 @@ xfunc_pullup(Query * queryInfo, int whichchild, /* whether child is INNER or OUTER of join */ int clausetype) /* whether clause to pull is join or local */ { - Path newkid; - Rel newrel; - Cost pulled_selec; - Cost cost; - CInfo newinfo; + Path newkid; + Rel newrel; + Cost pulled_selec; + Cost cost; + CInfo newinfo; /* remove clause from childpath */ newkid = (Path) copyObject((Node) childpath); @@ -363,8 +362,8 @@ xfunc_pullup(Query * queryInfo, Cost xfunc_rank(Query * queryInfo, LispValue clause) { - Cost selec = compute_clause_selec(queryInfo, clause, LispNil); - Cost cost = xfunc_expense(queryInfo, clause); + Cost selec = compute_clause_selec(queryInfo, clause, LispNil); + Cost cost = xfunc_expense(queryInfo, clause); if (cost == 0) if (selec > 1) @@ -381,13 +380,13 @@ xfunc_rank(Query * queryInfo, LispValue clause) */ Cost xfunc_expense(Query * queryInfo, clause) -LispValue clause; +LispValue clause; { - Cost cost = xfunc_local_expense(clause); + Cost cost = xfunc_local_expense(clause); if (cost) { - Count card = xfunc_card_unreferenced(queryInfo, clause, LispNil); + Count card = xfunc_card_unreferenced(queryInfo, clause, LispNil); if (card) cost /= card; @@ -403,15 +402,15 @@ LispValue clause; Cost xfunc_join_expense(Query * queryInfo, JoinPath path, int whichchild) { - LispValue primjoinclause = xfunc_primary_join(path); + LispValue primjoinclause = xfunc_primary_join(path); /* * * the second argument to xfunc_card_unreferenced reflects all the * * relations involved in the join clause, i.e. all the relids in the * Rel * of the join clause */ - Count card = 0; - Cost cost = xfunc_expense_per_tuple(path, whichchild); + Count card = 0; + Cost cost = xfunc_expense_per_tuple(path, whichchild); card = xfunc_card_unreferenced(queryInfo, primjoinclause, @@ -432,8 +431,8 @@ xfunc_join_expense(Query * queryInfo, JoinPath path, int whichchild) Cost xfunc_local_expense(LispValue clause) { - Cost cost = 0; /* running expense */ - LispValue tmpclause; + Cost cost = 0; /* running expense */ + LispValue tmpclause; /* First handle the base case */ if (IsA(clause, Const) || IsA(clause, Var) || IsA(clause, Param)) @@ -484,15 +483,15 @@ xfunc_local_expense(LispValue clause) Cost xfunc_func_expense(LispValue node, LispValue args) { - HeapTuple tupl; /* the pg_proc tuple for each function */ - Form_pg_proc proc; /* a data structure to hold the pg_proc + HeapTuple tupl; /* the pg_proc tuple for each function */ + Form_pg_proc proc; /* a data structure to hold the pg_proc * tuple */ - int width = 0; /* byte width of the field referenced by + int width = 0; /* byte width of the field referenced by * each clause */ - RegProcedure funcid; /* ID of function associate with node */ - Cost cost = 0; /* running expense */ - LispValue tmpclause; - LispValue operand; /* one operand of an operator */ + RegProcedure funcid; /* ID of function associate with node */ + Cost cost = 0; /* running expense */ + LispValue tmpclause; + LispValue operand; /* one operand of an operator */ if (IsA(node, Oper)) { @@ -517,15 +516,15 @@ xfunc_func_expense(LispValue node, LispValue args) */ if (proc->prolang == SQLlanguageId) { - LispValue tmpplan; - List planlist; + LispValue tmpplan; + List planlist; if (IsA(node, Oper) || get_func_planlist((Func) node) == LispNil) { - Oid *argOidVect; /* vector of argtypes */ - char *pq_src; /* text of PQ function */ - int nargs; /* num args to PQ function */ - QueryTreeList *queryTree_list; /* dummy variable */ + Oid *argOidVect; /* vector of argtypes */ + char *pq_src; /* text of PQ function */ + int nargs; /* num args to PQ function */ + QueryTreeList *queryTree_list; /* dummy variable */ /* * * plan the function, storing it in the Func node for later * @@ -599,10 +598,10 @@ xfunc_func_expense(LispValue node, LispValue args) int xfunc_width(LispValue clause) { - Relation rd; /* Relation Descriptor */ - HeapTuple tupl; /* structure to hold a cached tuple */ - TypeTupleForm type; /* structure to hold a type tuple */ - int retval = 0; + Relation rd; /* Relation Descriptor */ + HeapTuple tupl; /* structure to hold a cached tuple */ + TypeTupleForm type; /* structure to hold a type tuple */ + int retval = 0; if (IsA(clause, Const)) { @@ -695,7 +694,7 @@ xfunc_width(LispValue clause) } else if (fast_is_funcclause(clause)) { - Func func = (Func) get_function(clause); + Func func = (Func) get_function(clause); if (get_func_tlist(func) != LispNil) { @@ -735,13 +734,13 @@ exit: ** User may pass in referenced list, if they know it (useful ** for joins). */ -static Count +static Count xfunc_card_unreferenced(Query * queryInfo, LispValue clause, Relid referenced) { - Relid unreferenced, - allrelids = LispNil; - LispValue temp; + Relid unreferenced, + allrelids = LispNil; + LispValue temp; /* find all relids of base relations referenced in query */ foreach(temp, queryInfo->base_relation_list_) @@ -766,11 +765,11 @@ xfunc_card_unreferenced(Query * queryInfo, Count xfunc_card_product(Query * queryInfo, Relid relids) { - LispValue cinfonode; - LispValue temp; - Rel currel; - Cost tuples; - Count retval = 0; + LispValue cinfonode; + LispValue temp; + Rel currel; + Cost tuples; + Count retval = 0; foreach(temp, relids) { @@ -808,8 +807,8 @@ xfunc_card_product(Query * queryInfo, Relid relids) List xfunc_find_references(LispValue clause) { - List retval = (List) LispNil; - LispValue tmpclause; + List retval = (List) LispNil; + LispValue tmpclause; /* Base cases */ if (IsA(clause, Var)) @@ -870,12 +869,12 @@ xfunc_find_references(LispValue clause) LispValue xfunc_primary_join(JoinPath pathnode) { - LispValue joinclauselist = get_pathclauseinfo(pathnode); - CInfo mincinfo; - LispValue tmplist; - LispValue minclause = LispNil; - Cost minrank, - tmprank; + LispValue joinclauselist = get_pathclauseinfo(pathnode); + CInfo mincinfo; + LispValue tmplist; + LispValue minclause = LispNil; + Cost minrank, + tmprank; if (IsA(pathnode, MergePath)) { @@ -932,9 +931,9 @@ xfunc_primary_join(JoinPath pathnode) Cost xfunc_get_path_cost(Query * queryInfo, Path pathnode) { - Cost cost = 0; - LispValue tmplist; - Cost selec = 1.0; + Cost cost = 0; + LispValue tmplist; + Cost selec = 1.0; /* * * first add in the expensive local function costs. * We ensure that @@ -1025,12 +1024,12 @@ xfunc_get_path_cost(Query * queryInfo, Path pathnode) Cost xfunc_total_path_cost(JoinPath pathnode) { - Cost cost = xfunc_get_path_cost((Path) pathnode); + Cost cost = xfunc_get_path_cost((Path) pathnode); Assert(IsA(pathnode, JoinPath)); if (IsA(pathnode, MergePath)) { - MergePath mrgnode = (MergePath) pathnode; + MergePath mrgnode = (MergePath) pathnode; cost += cost_mergesort(get_path_cost((Path) get_outerjoinpath(mrgnode)), get_path_cost((Path) get_innerjoinpath(mrgnode)), @@ -1049,7 +1048,7 @@ xfunc_total_path_cost(JoinPath pathnode) } else if (IsA(pathnode, HashPath)) { - HashPath hashnode = (HashPath) pathnode; + HashPath hashnode = (HashPath) pathnode; cost += cost_hashjoin(get_path_cost((Path) get_outerjoinpath(hashnode)), get_path_cost((Path) get_innerjoinpath(hashnode)), @@ -1105,10 +1104,10 @@ xfunc_total_path_cost(JoinPath pathnode) Cost xfunc_expense_per_tuple(JoinPath joinnode, int whichchild) { - Rel outerrel = get_parent((Path) get_outerjoinpath(joinnode)); - Rel innerrel = get_parent((Path) get_innerjoinpath(joinnode)); - Count outerwidth = get_width(outerrel); - Count outers_per_page = ceil(BLCKSZ / (outerwidth + sizeof(HeapTupleData))); + Rel outerrel = get_parent((Path) get_outerjoinpath(joinnode)); + Rel innerrel = get_parent((Path) get_innerjoinpath(joinnode)); + Count outerwidth = get_width(outerrel); + Count outers_per_page = ceil(BLCKSZ / (outerwidth + sizeof(HeapTupleData))); if (IsA(joinnode, HashPath)) { @@ -1150,8 +1149,8 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */ Rel rel, /* rel it's being pulled from */ int varno) /* whether rel is INNER or OUTER of join */ { - LispValue tmpclause; /* temporary variable */ - TargetEntry *tle; /* tlist member corresponding to var */ + LispValue tmpclause; /* temporary variable */ + TargetEntry *tle; /* tlist member corresponding to var */ if (IsA(clause, Const) || IsA(clause, Param)) @@ -1205,11 +1204,11 @@ xfunc_fixvars(LispValue clause, /* clause being pulled up */ int xfunc_cinfo_compare(void *arg1, void *arg2) { - CInfo info1 = *(CInfo *) arg1; - CInfo info2 = *(CInfo *) arg2; + CInfo info1 = *(CInfo *) arg1; + CInfo info2 = *(CInfo *) arg2; - LispValue clause1 = (LispValue) get_clause(info1), - clause2 = (LispValue) get_clause(info2); + LispValue clause1 = (LispValue) get_clause(info1), + clause2 = (LispValue) get_clause(info2); return (xfunc_clause_compare((void *) &clause1, (void *) &clause2)); } @@ -1222,10 +1221,10 @@ xfunc_cinfo_compare(void *arg1, void *arg2) int xfunc_clause_compare(void *arg1, void *arg2) { - LispValue clause1 = *(LispValue *) arg1; - LispValue clause2 = *(LispValue *) arg2; - Cost rank1, /* total xfunc rank of clause1 */ - rank2; /* total xfunc rank of clause2 */ + LispValue clause1 = *(LispValue *) arg1; + LispValue clause2 = *(LispValue *) arg2; + Cost rank1, /* total xfunc rank of clause1 */ + rank2; /* total xfunc rank of clause2 */ rank1 = xfunc_rank(clause1); rank2 = xfunc_rank(clause2); @@ -1247,7 +1246,7 @@ xfunc_clause_compare(void *arg1, void *arg2) void xfunc_disjunct_sort(LispValue clause_list) { - LispValue temp; + LispValue temp; foreach(temp, clause_list) if (or_clause(lfirst(temp))) @@ -1264,14 +1263,14 @@ xfunc_disjunct_sort(LispValue clause_list) int xfunc_disjunct_compare(Query * queryInfo, void *arg1, void *arg2) { - LispValue disjunct1 = *(LispValue *) arg1; - LispValue disjunct2 = *(LispValue *) arg2; - Cost cost1, /* total cost of disjunct1 */ - cost2, /* total cost of disjunct2 */ - selec1, - selec2; - Cost rank1, - rank2; + LispValue disjunct1 = *(LispValue *) arg1; + LispValue disjunct2 = *(LispValue *) arg2; + Cost cost1, /* total cost of disjunct1 */ + cost2, /* total cost of disjunct2 */ + selec1, + selec2; + Cost rank1, + rank2; cost1 = xfunc_expense(queryInfo, disjunct1); cost2 = xfunc_expense(queryInfo, disjunct2); @@ -1310,12 +1309,12 @@ xfunc_disjunct_compare(Query * queryInfo, void *arg1, void *arg2) int xfunc_func_width(RegProcedure funcid, LispValue args) { - Relation rd; /* Relation Descriptor */ - HeapTuple tupl; /* structure to hold a cached tuple */ - Form_pg_proc proc; /* structure to hold the pg_proc tuple */ - TypeTupleForm type; /* structure to hold the pg_type tuple */ - LispValue tmpclause; - int retval; + Relation rd; /* Relation Descriptor */ + HeapTuple tupl; /* structure to hold a cached tuple */ + Form_pg_proc proc; /* structure to hold the pg_proc tuple */ + TypeTupleForm type; /* structure to hold the pg_type tuple */ + LispValue tmpclause; + int retval; /* lookup function and find its return type */ Assert(RegProcedureIsValid(funcid)); @@ -1370,9 +1369,9 @@ exit: int xfunc_tuple_width(Relation rd) { - int i; - int retval = 0; - TupleDesc tdesc = RelationGetTupleDescriptor(rd); + int i; + int retval = 0; + TupleDesc tdesc = RelationGetTupleDescriptor(rd); for (i = 0; i < tdesc->natts; i++) { @@ -1392,7 +1391,7 @@ xfunc_tuple_width(Relation rd) int xfunc_num_join_clauses(JoinPath path) { - int num = length(get_pathclauseinfo(path)); + int num = length(get_pathclauseinfo(path)); if (IsA(path, MergePath)) return (num + length(get_path_mergeclauses((MergePath) path))); @@ -1409,9 +1408,9 @@ xfunc_num_join_clauses(JoinPath path) LispValue xfunc_LispRemove(LispValue foo, List bar) { - LispValue temp = LispNil; - LispValue result = LispNil; - int sanity = false; + LispValue temp = LispNil; + LispValue result = LispNil; + int sanity = false; for (temp = bar; !null(temp); temp = lnext(temp)) if (!equal((Node) (foo), (Node) (lfirst(temp)))) @@ -1439,7 +1438,7 @@ xfunc_LispRemove(LispValue foo, List bar) bool xfunc_copyrel(Rel from, Rel * to) { - Rel newnode; + Rel newnode; Pointer(*alloc) () = palloc; diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index bdceec18be3..413389f4756 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.12 1997/09/07 04:43:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.13 1997/09/08 02:24:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,9 +44,9 @@ #define TEMP_SORT 1 #define TEMP_MATERIAL 2 -static List *switch_outer(List * clauses); -static Scan *create_scan_node(Path * best_path, List * tlist); -static Join *create_join_node(JoinPath * best_path, List * tlist); +static List *switch_outer(List * clauses); +static Scan *create_scan_node(Path * best_path, List * tlist); +static Join *create_join_node(JoinPath * best_path, List * tlist); static SeqScan * create_seqscan_node(Path * best_path, List * tlist, List * scan_clauses); @@ -65,8 +65,8 @@ static HashJoin * create_hashjoin_node(HashPath * best_path, List * tlist, List * clauses, Plan * outer_node, List * outer_tlist, Plan * inner_node, List * inner_tlist); -static Node *fix_indxqual_references(Node * clause, Path * index_path); -static Temp * +static Node *fix_indxqual_references(Node * clause, Path * index_path); +static Temp * make_temp(List * tlist, List * keys, Oid * operators, Plan * plan_node, int temptype); static IndexScan * @@ -78,7 +78,7 @@ make_nestloop(List * qptlist, List * qpqual, Plan * lefttree, static HashJoin * make_hashjoin(List * tlist, List * qpqual, List * hashclauses, Plan * lefttree, Plan * righttree); -static Hash *make_hash(List * tlist, Var * hashkey, Plan * lefttree); +static Hash *make_hash(List * tlist, Var * hashkey, Plan * lefttree); static MergeJoin * make_mergesort(List * tlist, List * qpqual, List * mergeclauses, Oid opcode, Oid * rightorder, @@ -102,16 +102,16 @@ make_material(List * tlist, Oid tempid, Plan * lefttree, * * Returns the optimal(?) access plan. */ -Plan * +Plan * create_plan(Path * best_path) { - List *tlist; - Plan *plan_node = (Plan *) NULL; - Rel *parent_rel; - int size; - int width; - int pages; - int tuples; + List *tlist; + Plan *plan_node = (Plan *) NULL; + Rel *parent_rel; + int size; + int width; + int pages; + int tuples; parent_rel = best_path->parent; tlist = get_actual_tlist(parent_rel->targetlist); @@ -122,18 +122,18 @@ create_plan(Path * best_path) switch (best_path->pathtype) { - case T_IndexScan: - case T_SeqScan: - plan_node = (Plan *) create_scan_node(best_path, tlist); - break; - case T_HashJoin: - case T_MergeJoin: - case T_NestLoop: - plan_node = (Plan *) create_join_node((JoinPath *) best_path, tlist); - break; - default: - /* do nothing */ - break; + case T_IndexScan: + case T_SeqScan: + plan_node = (Plan *) create_scan_node(best_path, tlist); + break; + case T_HashJoin: + case T_MergeJoin: + case T_NestLoop: + plan_node = (Plan *) create_join_node((JoinPath *) best_path, tlist); + break; + default: + /* do nothing */ + break; } plan_node->plan_size = size; @@ -166,12 +166,12 @@ create_plan(Path * best_path) * * Returns the scan node. */ -static Scan * +static Scan * create_scan_node(Path * best_path, List * tlist) { - Scan *node = NULL; - List *scan_clauses; + Scan *node = NULL; + List *scan_clauses; /* * Extract the relevant clauses from the parent relation and replace @@ -186,20 +186,20 @@ create_scan_node(Path * best_path, List * tlist) switch (best_path->pathtype) { - case T_SeqScan: - node = (Scan *) create_seqscan_node(best_path, tlist, scan_clauses); - break; - - case T_IndexScan: - node = (Scan *) create_indexscan_node((IndexPath *) best_path, - tlist, - scan_clauses); - break; - - default: - elog(WARN, "create_scan_node: unknown node type", - best_path->pathtype); - break; + case T_SeqScan: + node = (Scan *) create_seqscan_node(best_path, tlist, scan_clauses); + break; + + case T_IndexScan: + node = (Scan *) create_indexscan_node((IndexPath *) best_path, + tlist, + scan_clauses); + break; + + default: + elog(WARN, "create_scan_node: unknown node type", + best_path->pathtype); + break; } return node; @@ -215,15 +215,15 @@ create_scan_node(Path * best_path, List * tlist) * * Returns the join node. */ -static Join * +static Join * create_join_node(JoinPath * best_path, List * tlist) { - Plan *outer_node; - List *outer_tlist; - Plan *inner_node; - List *inner_tlist; - List *clauses; - Join *retval = NULL; + Plan *outer_node; + List *outer_tlist; + Plan *inner_node; + List *inner_tlist; + List *clauses; + Join *retval = NULL; outer_node = create_plan((Path *) best_path->outerjoinpath); outer_tlist = outer_node->targetlist; @@ -235,45 +235,45 @@ create_join_node(JoinPath * best_path, List * tlist) switch (best_path->path.pathtype) { - case T_MergeJoin: - retval = (Join *) create_mergejoin_node((MergePath *) best_path, - tlist, - clauses, - outer_node, - outer_tlist, - inner_node, - inner_tlist); - break; - case T_HashJoin: - retval = (Join *) create_hashjoin_node((HashPath *) best_path, - tlist, - clauses, - outer_node, - outer_tlist, - inner_node, - inner_tlist); - break; - case T_NestLoop: - retval = (Join *) create_nestloop_node((JoinPath *) best_path, - tlist, - clauses, - outer_node, - outer_tlist, - inner_node, - inner_tlist); - break; - default: - /* do nothing */ - elog(WARN, "create_join_node: unknown node type", - best_path->path.pathtype); + case T_MergeJoin: + retval = (Join *) create_mergejoin_node((MergePath *) best_path, + tlist, + clauses, + outer_node, + outer_tlist, + inner_node, + inner_tlist); + break; + case T_HashJoin: + retval = (Join *) create_hashjoin_node((HashPath *) best_path, + tlist, + clauses, + outer_node, + outer_tlist, + inner_node, + inner_tlist); + break; + case T_NestLoop: + retval = (Join *) create_nestloop_node((JoinPath *) best_path, + tlist, + clauses, + outer_node, + outer_tlist, + inner_node, + inner_tlist); + break; + default: + /* do nothing */ + elog(WARN, "create_join_node: unknown node type", + best_path->path.pathtype); } #if 0 /* * * Expensive function pullups may have pulled local predicates * - * into this path node. Put them in the qpqual of the plan node. * - * -- JMH, 6/15/92 + * into this path node. Put them in the qpqual of the plan node. * -- + * JMH, 6/15/92 */ if (get_locclauseinfo(best_path) != NIL) set_qpqual((Plan) retval, @@ -300,9 +300,9 @@ create_join_node(JoinPath * best_path, List * tlist) static SeqScan * create_seqscan_node(Path * best_path, List * tlist, List * scan_clauses) { - SeqScan *scan_node = (SeqScan *) NULL; - Index scan_relid = -1; - List *temp; + SeqScan *scan_node = (SeqScan *) NULL; + Index scan_relid = -1; + List *temp; temp = best_path->parent->relids; if (temp == NULL) @@ -335,15 +335,15 @@ create_indexscan_node(IndexPath * best_path, * Extract the(first if conjunct, only if disjunct) clause from the * clauseinfo list. */ - Expr *index_clause = (Expr *) NULL; - List *indxqual = NIL; - List *qpqual = NIL; - List *fixed_indxqual = NIL; - List *ixid; - IndexScan *scan_node = (IndexScan *) NULL; - bool lossy = FALSE; - HeapTuple indexTuple; - IndexTupleForm index; + Expr *index_clause = (Expr *) NULL; + List *indxqual = NIL; + List *qpqual = NIL; + List *fixed_indxqual = NIL; + List *ixid; + IndexScan *scan_node = (IndexScan *) NULL; + bool lossy = FALSE; + HeapTuple indexTuple; + IndexTupleForm index; /* * If an 'or' clause is to be used with this index, the indxqual field @@ -358,7 +358,7 @@ create_indexscan_node(IndexPath * best_path, if (or_clause((Node *) index_clause)) { - List *temp = NIL; + List *temp = NIL; foreach(temp, index_clause->args) indxqual = lappend(indxqual, lcons(lfirst(temp), NIL)); @@ -438,7 +438,7 @@ create_nestloop_node(JoinPath * best_path, Plan * inner_node, List * inner_tlist) { - NestLoop *join_node = (NestLoop *) NULL; + NestLoop *join_node = (NestLoop *) NULL; if (IsA(inner_node, IndexScan)) { @@ -453,9 +453,9 @@ create_nestloop_node(JoinPath * best_path, * case of multi-column indices. - vadim 03/18/97 */ - List *inner_indxqual = lfirst(((IndexScan *) inner_node)->indxqual); - List *inner_qual; - bool found = false; + List *inner_indxqual = lfirst(((IndexScan *) inner_node)->indxqual); + List *inner_qual; + bool found = false; foreach(inner_qual, inner_indxqual) { @@ -479,7 +479,7 @@ create_nestloop_node(JoinPath * best_path, */ if (found) { - List *new_inner_qual = NIL; + List *new_inner_qual = NIL; clauses = set_difference(clauses, inner_indxqual); /* XXX */ new_inner_qual = @@ -520,12 +520,12 @@ create_mergejoin_node(MergePath * best_path, Plan * inner_node, List * inner_tlist) { - List *qpqual, - *mergeclauses; - RegProcedure opcode; - Oid *outer_order, - *inner_order; - MergeJoin *join_node; + List *qpqual, + *mergeclauses; + RegProcedure opcode; + Oid *outer_order, + *inner_order; + MergeJoin *join_node; /* @@ -564,11 +564,11 @@ create_mergejoin_node(MergePath * best_path, */ if (best_path->outersortkeys) { - Temp *sorted_outer_node = make_temp(outer_tlist, + Temp *sorted_outer_node = make_temp(outer_tlist, best_path->outersortkeys, - outer_order, - outer_node, - TEMP_SORT); + outer_order, + outer_node, + TEMP_SORT); sorted_outer_node->plan.cost = outer_node->cost; outer_node = (Plan *) sorted_outer_node; @@ -576,11 +576,11 @@ create_mergejoin_node(MergePath * best_path, if (best_path->innersortkeys) { - Temp *sorted_inner_node = make_temp(inner_tlist, + Temp *sorted_inner_node = make_temp(inner_tlist, best_path->innersortkeys, - inner_order, - inner_node, - TEMP_SORT); + inner_order, + inner_node, + TEMP_SORT); sorted_inner_node->plan.cost = outer_node->cost; inner_node = (Plan *) sorted_inner_node; @@ -617,11 +617,11 @@ create_hashjoin_node(HashPath * best_path, Plan * inner_node, List * inner_tlist) { - List *qpqual; - List *hashclauses; - HashJoin *join_node; - Hash *hash_node; - Var *innerhashkey; + List *qpqual; + List *hashclauses; + HashJoin *join_node; + Hash *hash_node; + Var *innerhashkey; /* * Separate the hashclauses from the other join qualification clauses @@ -662,18 +662,18 @@ create_hashjoin_node(HashPath * best_path, * *****************************************************************************/ -static Node * +static Node * fix_indxqual_references(Node * clause, Path * index_path) { - Node *newclause; + Node *newclause; if (IsA(clause, Var)) { if (lfirsti(index_path->parent->relids) == ((Var *) clause)->varno) { - int pos = 0; - int varatt = ((Var *) clause)->varattno; - int *indexkeys = ((IndexPath *) index_path)->indexkeys; + int pos = 0; + int varatt = ((Var *) clause)->varattno; + int *indexkeys = ((IndexPath *) index_path)->indexkeys; if (indexkeys) { @@ -710,7 +710,7 @@ fix_indxqual_references(Node * clause, Path * index_path) is_funcclause((Node *) get_leftop((Expr *) clause)) && ((Func *) ((Expr *) get_leftop((Expr *) clause))->oper)->funcisindex) { - Var *newvar = + Var *newvar = makeVar((Index) lfirsti(index_path->parent->relids), 1, /* func indices have one key */ ((Func *) ((Expr *) clause)->oper)->functype, @@ -725,10 +725,10 @@ fix_indxqual_references(Node * clause, Path * index_path) } else if (IsA(clause, Expr)) { - Expr *expr = (Expr *) clause; - List *new_subclauses = NIL; - Node *subclause = NULL; - List *i = NIL; + Expr *expr = (Expr *) clause; + List *new_subclauses = NIL; + Node *subclause = NULL; + List *i = NIL; foreach(i, expr->args) { @@ -757,10 +757,10 @@ fix_indxqual_references(Node * clause, Path * index_path) } else { - List *oldclauses = (List *) clause; - List *new_subclauses = NIL; - Node *subclause = NULL; - List *i = NIL; + List *oldclauses = (List *) clause; + List *new_subclauses = NIL; + Node *subclause = NULL; + List *i = NIL; foreach(i, oldclauses) { @@ -799,14 +799,14 @@ fix_indxqual_references(Node * clause, Path * index_path) * * XXX Shouldn't the operator be commuted?! */ -static List * +static List * switch_outer(List * clauses) { - List *t_list = NIL; - Expr *temp = NULL; - List *i = NIL; - Expr *clause; - Node *op; + List *t_list = NIL; + Expr *temp = NULL; + List *i = NIL; + Expr *clause; + Node *op; foreach(i, clauses) { @@ -843,13 +843,13 @@ switch_outer(List * clauses) * * Returns the modified target list. */ -static List * +static List * set_temp_tlist_operators(List * tlist, List * pathkeys, Oid * operators) { - Node *keys = NULL; - int keyno = 1; - Resdom *resdom = (Resdom *) NULL; - List *i = NIL; + Node *keys = NULL; + int keyno = 1; + Resdom *resdom = (Resdom *) NULL; + List *i = NIL; foreach(i, pathkeys) { @@ -891,15 +891,15 @@ set_temp_tlist_operators(List * tlist, List * pathkeys, Oid * operators) * 'plan-node' is the node which yields tuples for the sort * 'temptype' indicates which operation(sort or hash) to perform */ -static Temp * +static Temp * make_temp(List * tlist, List * keys, Oid * operators, Plan * plan_node, int temptype) { - List *temp_tlist; - Temp *retval = NULL; + List *temp_tlist; + Temp *retval = NULL; /* Create a new target list for the temporary, with keys set. */ temp_tlist = set_temp_tlist_operators(new_unsorted_tlist(tlist), @@ -907,42 +907,42 @@ make_temp(List * tlist, operators); switch (temptype) { - case TEMP_SORT: - retval = (Temp *) make_seqscan(tlist, - NIL, - _TEMP_RELATION_ID_, - (Plan *) make_sort(temp_tlist, + case TEMP_SORT: + retval = (Temp *) make_seqscan(tlist, + NIL, + _TEMP_RELATION_ID_, + (Plan *) make_sort(temp_tlist, _TEMP_RELATION_ID_, - plan_node, + plan_node, length(keys))); - break; + break; - case TEMP_MATERIAL: - retval = (Temp *) make_seqscan(tlist, - NIL, - _TEMP_RELATION_ID_, + case TEMP_MATERIAL: + retval = (Temp *) make_seqscan(tlist, + NIL, + _TEMP_RELATION_ID_, (Plan *) make_material(temp_tlist, _TEMP_RELATION_ID_, plan_node, length(keys))); - break; + break; - default: - elog(WARN, "make_temp: unknown temp type %d", temptype); + default: + elog(WARN, "make_temp: unknown temp type %d", temptype); } return (retval); } -SeqScan * +SeqScan * make_seqscan(List * qptlist, List * qpqual, Index scanrelid, Plan * lefttree) { - SeqScan *node = makeNode(SeqScan); - Plan *plan = &node->plan; + SeqScan *node = makeNode(SeqScan); + Plan *plan = &node->plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -963,8 +963,8 @@ make_indexscan(List * qptlist, List * indxid, List * indxqual) { - IndexScan *node = makeNode(IndexScan); - Plan *plan = &node->scan.plan; + IndexScan *node = makeNode(IndexScan); + Plan *plan = &node->scan.plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -987,8 +987,8 @@ make_nestloop(List * qptlist, Plan * lefttree, Plan * righttree) { - NestLoop *node = makeNode(NestLoop); - Plan *plan = &node->join; + NestLoop *node = makeNode(NestLoop); + Plan *plan = &node->join; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1008,8 +1008,8 @@ make_hashjoin(List * tlist, Plan * lefttree, Plan * righttree) { - HashJoin *node = makeNode(HashJoin); - Plan *plan = &node->join; + HashJoin *node = makeNode(HashJoin); + Plan *plan = &node->join; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1026,11 +1026,11 @@ make_hashjoin(List * tlist, return (node); } -static Hash * +static Hash * make_hash(List * tlist, Var * hashkey, Plan * lefttree) { - Hash *node = makeNode(Hash); - Plan *plan = &node->plan; + Hash *node = makeNode(Hash); + Plan *plan = &node->plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1056,8 +1056,8 @@ make_mergesort(List * tlist, Plan * righttree, Plan * lefttree) { - MergeJoin *node = makeNode(MergeJoin); - Plan *plan = &node->join; + MergeJoin *node = makeNode(MergeJoin); + Plan *plan = &node->join; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1073,11 +1073,11 @@ make_mergesort(List * tlist, return (node); } -Sort * +Sort * make_sort(List * tlist, Oid tempid, Plan * lefttree, int keycount) { - Sort *node = makeNode(Sort); - Plan *plan = &node->plan; + Sort *node = makeNode(Sort); + Plan *plan = &node->plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1097,8 +1097,8 @@ make_material(List * tlist, Plan * lefttree, int keycount) { - Material *node = makeNode(Material); - Plan *plan = &node->plan; + Material *node = makeNode(Material); + Plan *plan = &node->plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1112,10 +1112,10 @@ make_material(List * tlist, return (node); } -Agg * +Agg * make_agg(List * tlist, int nagg, Aggreg ** aggs) { - Agg *node = makeNode(Agg); + Agg *node = makeNode(Agg); node->plan.cost = 0.0; node->plan.state = (EState *) NULL; @@ -1129,14 +1129,14 @@ make_agg(List * tlist, int nagg, Aggreg ** aggs) return (node); } -Group * +Group * make_group(List * tlist, bool tuplePerGroup, int ngrp, AttrNumber * grpColIdx, Sort * lefttree) { - Group *node = makeNode(Group); + Group *node = makeNode(Group); node->plan.cost = 0.0; node->plan.state = (EState *) NULL; @@ -1159,11 +1159,11 @@ make_group(List * tlist, * or "*" */ -Unique * +Unique * make_unique(List * tlist, Plan * lefttree, char *uniqueAttr) { - Unique *node = makeNode(Unique); - Plan *plan = &node->plan; + Unique *node = makeNode(Unique); + Plan *plan = &node->plan; plan->cost = 0.0; plan->state = (EState *) NULL; @@ -1182,14 +1182,14 @@ make_unique(List * tlist, Plan * lefttree, char *uniqueAttr) return (node); } -List * +List * generate_fjoin(List * tlist) { #if 0 - List tlistP; - List newTlist = NIL; - List fjoinList = NIL; - int nIters = 0; + List tlistP; + List newTlist = NIL; + List fjoinList = NIL; + int nIters = 0; /* * Break the target list into elements with Iter nodes, and those @@ -1197,7 +1197,7 @@ generate_fjoin(List * tlist) */ foreach(tlistP, tlist) { - List tlistElem; + List tlistElem; tlistElem = lfirst(tlistP); if (IsA(lsecond(tlistElem), Iter)) @@ -1216,11 +1216,11 @@ generate_fjoin(List * tlist) */ if (nIters > 0) { - List *inner; - List *tempList; - Fjoin *fjoinNode; - DatumPtr results = (DatumPtr) palloc(nIters * sizeof(Datum)); - BoolPtr alwaysDone = (BoolPtr) palloc(nIters * sizeof(bool)); + List *inner; + List *tempList; + Fjoin *fjoinNode; + DatumPtr results = (DatumPtr) palloc(nIters * sizeof(Datum)); + BoolPtr alwaysDone = (BoolPtr) palloc(nIters * sizeof(bool)); inner = lfirst(fjoinList); fjoinList = lnext(fjoinList); diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index 62ff23f207e..ebc2324d7f5 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.6 1997/09/07 04:44:00 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.7 1997/09/08 02:24:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,16 +33,16 @@ #include "optimizer/clauses.h" #include "optimizer/cost.h" -extern int Quiet; +extern int Quiet; -static void add_clause_to_rels(Query * root, List * clause); +static void add_clause_to_rels(Query * root, List * clause); static void add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo, List * join_relids); -static void add_vars_to_rels(Query * root, List * vars, List * join_relids); +static void add_vars_to_rels(Query * root, List * vars, List * join_relids); static MergeOrder *mergesortop(Expr * clause); -static Oid hashjoinop(Expr * clause); +static Oid hashjoinop(Expr * clause); /***************************************************************************** @@ -63,13 +63,13 @@ static Oid hashjoinop(Expr * clause); void initialize_base_rels_list(Query * root, List * tlist) { - List *tlist_vars = NIL; - List *l = NIL; - List *tvar = NIL; + List *tlist_vars = NIL; + List *l = NIL; + List *tvar = NIL; foreach(l, tlist) { - TargetEntry *entry = (TargetEntry *) lfirst(l); + TargetEntry *entry = (TargetEntry *) lfirst(l); tlist_vars = append(tlist_vars, pull_var_clause(entry->expr)); } @@ -77,9 +77,9 @@ initialize_base_rels_list(Query * root, List * tlist) /* now, the target list only contains Var nodes */ foreach(tvar, tlist_vars) { - Var *var; - Index varno; - Rel *result; + Var *var; + Index varno; + Rel *result; var = (Var *) lfirst(tvar); varno = var->varno; @@ -100,16 +100,16 @@ initialize_base_rels_list(Query * root, List * tlist) void add_missing_vars_to_base_rels(Query * root, List * tlist) { - List *l; - int varno; + List *l; + int varno; varno = 1; foreach(l, root->rtable) { - RangeTblEntry *rte = (RangeTblEntry *) lfirst(l); - List *relids; - Rel *result; - Var *var; + RangeTblEntry *rte = (RangeTblEntry *) lfirst(l); + List *relids; + Rel *result; + Var *var; relids = lconsi(varno, NIL); if (rte->inFromCl && @@ -147,7 +147,7 @@ add_missing_vars_to_base_rels(Query * root, List * tlist) void initialize_base_rels_jinfo(Query * root, List * clauses) { - List *clause; + List *clause; foreach(clause, clauses) { @@ -168,9 +168,9 @@ initialize_base_rels_jinfo(Query * root, List * clauses) static void add_clause_to_rels(Query * root, List * clause) { - List *relids; - List *vars; - CInfo *clauseinfo = makeNode(CInfo); + List *relids; + List *vars; + CInfo *clauseinfo = makeNode(CInfo); /* * Retrieve all relids and vars contained within the clause. @@ -189,7 +189,7 @@ add_clause_to_rels(Query * root, List * clause) if (length(relids) == 1) { - Rel *rel = get_base_rel(root, lfirsti(relids)); + Rel *rel = get_base_rel(root, lfirsti(relids)); /* * There is only one relation participating in 'clause', so @@ -261,13 +261,13 @@ add_clause_to_rels(Query * root, List * clause) static void add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo, List * join_relids) { - List *join_relid; + List *join_relid; foreach(join_relid, join_relids) { - JInfo *joininfo; - List *other_rels = NIL; - List *rel; + JInfo *joininfo; + List *other_rels = NIL; + List *rel; foreach(rel, join_relids) { @@ -302,10 +302,10 @@ add_join_clause_info_to_rels(Query * root, CInfo * clauseinfo, List * join_relid static void add_vars_to_rels(Query * root, List * vars, List * join_relids) { - Var *var; - List *temp = NIL; - Rel *rel = (Rel *) NULL; - TargetEntry *tlistentry; + Var *var; + List *temp = NIL; + Rel *rel = (Rel *) NULL; + TargetEntry *tlistentry; foreach(temp, vars) { @@ -336,13 +336,13 @@ add_vars_to_rels(Query * root, List * vars, List * join_relids) void initialize_join_clause_info(List * rel_list) { - List *x, - *y, - *z; - Rel *rel; - JInfo *joininfo; - CInfo *clauseinfo; - Expr *clause; + List *x, + *y, + *z; + Rel *rel; + JInfo *joininfo; + CInfo *clauseinfo; + Expr *clause; foreach(x, rel_list) { @@ -356,8 +356,8 @@ initialize_join_clause_info(List * rel_list) clause = clauseinfo->clause; if (join_clause_p((Node *) clause)) { - MergeOrder *sortop = (MergeOrder *) NULL; - Oid hashop = (Oid) NULL; + MergeOrder *sortop = (MergeOrder *) NULL; + Oid hashop = (Oid) NULL; if (_enable_mergesort_) sortop = mergesortop(clause); @@ -389,9 +389,9 @@ initialize_join_clause_info(List * rel_list) static MergeOrder * mergesortop(Expr * clause) { - Oid leftOp, - rightOp; - bool sortable; + Oid leftOp, + rightOp; + bool sortable; sortable = op_mergesortable(((Oper *) clause->oper)->opno, (get_leftop(clause))->vartype, @@ -401,7 +401,7 @@ mergesortop(Expr * clause) if (sortable) { - MergeOrder *morder = makeNode(MergeOrder); + MergeOrder *morder = makeNode(MergeOrder); morder->join_operator = ((Oper *) clause->oper)->opno; morder->left_operator = leftOp; @@ -420,7 +420,7 @@ mergesortop(Expr * clause) * hashjoinable, i.e., both operands are single vars and the operator is * a hashjoinable operator. */ -static Oid +static Oid hashjoinop(Expr * clause) { return (op_hashjoinable(((Oper *) clause->oper)->opno, diff --git a/src/backend/optimizer/plan/planmain.c b/src/backend/optimizer/plan/planmain.c index 630ed12d2a1..029b34a24e7 100644 --- a/src/backend/optimizer/plan/planmain.c +++ b/src/backend/optimizer/plan/planmain.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.5 1997/09/07 04:44:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planmain.c,v 1.6 1997/09/08 02:24:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,10 +38,10 @@ #include "utils/mcxt.h" #include "utils/lsyscache.h" -static Plan *subplanner(Query * root, List * flat_tlist, List * qual); -static Result *make_result(List * tlist, Node * resconstantqual, Plan * subplan); +static Plan *subplanner(Query * root, List * flat_tlist, List * qual); +static Result *make_result(List * tlist, Node * resconstantqual, Plan * subplan); -static Plan * +static Plan * make_groupPlan(List ** tlist, bool tuplePerGroup, List * groupClause, Plan * subplan); @@ -62,17 +62,17 @@ make_groupPlan(List ** tlist, bool tuplePerGroup, * * Returns a query plan. */ -Plan * +Plan * query_planner(Query * root, int command_type, List * tlist, List * qual) { - List *constant_qual = NIL; - List *flattened_tlist = NIL; - List *level_tlist = NIL; - Plan *subplan = (Plan *) NULL; - Agg *aggplan = NULL; + List *constant_qual = NIL; + List *flattened_tlist = NIL; + List *level_tlist = NIL; + Plan *subplan = (Plan *) NULL; + Agg *aggplan = NULL; /* * A command without a target list or qualification is an error, @@ -132,36 +132,36 @@ query_planner(Query * root, switch (command_type) { - case CMD_SELECT: - case CMD_INSERT: - return ((Plan *) make_result(tlist, - (Node *) constant_qual, - (Plan *) NULL)); - break; - - case CMD_DELETE: - case CMD_UPDATE: - { - SeqScan *scan = make_seqscan(tlist, + case CMD_SELECT: + case CMD_INSERT: + return ((Plan *) make_result(tlist, + (Node *) constant_qual, + (Plan *) NULL)); + break; + + case CMD_DELETE: + case CMD_UPDATE: + { + SeqScan *scan = make_seqscan(tlist, (List *) NULL, root->resultRelation, (Plan *) NULL); - if (constant_qual != NULL) - { - return ((Plan *) make_result(tlist, - (Node *) constant_qual, - (Plan *) scan)); + if (constant_qual != NULL) + { + return ((Plan *) make_result(tlist, + (Node *) constant_qual, + (Plan *) scan)); + } + else + { + return ((Plan *) scan); + } } - else - { - return ((Plan *) scan); - } - } - break; + break; - default: - return ((Plan *) NULL); + default: + return ((Plan *) NULL); } } @@ -180,7 +180,7 @@ query_planner(Query * root, */ if (root->groupClause != NULL) { - bool tuplePerGroup; + bool tuplePerGroup; /* * decide whether how many tuples per group the Group node needs @@ -223,7 +223,7 @@ query_planner(Query * root, */ if (constant_qual) { - Plan *plan; + Plan *plan; plan = (Plan *) make_result(tlist, (Node *) constant_qual, @@ -277,13 +277,13 @@ query_planner(Query * root, * Returns a subplan. * */ -static Plan * +static Plan * subplanner(Query * root, List * flat_tlist, List * qual) { - Rel *final_relation; - List *final_relation_list; + Rel *final_relation; + List *final_relation_list; /* * Initialize the targetlist and qualification, adding entries to @@ -323,7 +323,7 @@ subplanner(Query * root, if (XfuncMode != XFUNC_OFF && XfuncMode != XFUNC_NOPM && XfuncMode != XFUNC_NOPULL && !final_relation->pruneable) { - List *pathnode; + List *pathnode; foreach(pathnode, final_relation->pathlist) { @@ -353,13 +353,13 @@ subplanner(Query * root, * *****************************************************************************/ -static Result * +static Result * make_result(List * tlist, Node * resconstantqual, Plan * subplan) { - Result *node = makeNode(Result); - Plan *plan = &node->plan; + Result *node = makeNode(Result); + Plan *plan = &node->plan; tlist = generate_fjoin(tlist); plan->cost = 0.0; @@ -377,25 +377,25 @@ make_result(List * tlist, * *****************************************************************************/ -static Plan * +static Plan * make_groupPlan(List ** tlist, bool tuplePerGroup, List * groupClause, Plan * subplan) { - List *sort_tlist; - List *sl, - *gl; - List *glc = listCopy(groupClause); - List *otles = NIL;/* list of removed non-GroupBy entries */ - List *otlvars = NIL; /* list of var in them */ - int otlvcnt; - Sort *sortplan; - Group *grpplan; - int numCols; - AttrNumber *grpColIdx; - int keyno = 1; - int last_resno = 1; + List *sort_tlist; + List *sl, + *gl; + List *glc = listCopy(groupClause); + List *otles = NIL; /* list of removed non-GroupBy entries */ + List *otlvars = NIL; /* list of var in them */ + int otlvcnt; + Sort *sortplan; + Group *grpplan; + int numCols; + AttrNumber *grpColIdx; + int keyno = 1; + int last_resno = 1; numCols = length(groupClause); grpColIdx = (AttrNumber *) palloc(sizeof(AttrNumber) * numCols); @@ -412,12 +412,12 @@ make_groupPlan(List ** tlist, */ foreach(sl, sort_tlist) { - Resdom *resdom = NULL; - TargetEntry *te = (TargetEntry *) lfirst(sl); + Resdom *resdom = NULL; + TargetEntry *te = (TargetEntry *) lfirst(sl); foreach(gl, glc) { - GroupClause *grpcl = (GroupClause *) lfirst(gl); + GroupClause *grpcl = (GroupClause *) lfirst(gl); if (grpcl->entry->resdom->resno == te->resdom->resno) { @@ -463,7 +463,7 @@ make_groupPlan(List ** tlist, otlvcnt = length(otlvars); foreach(gl, otlvars) { - Var *v = (Var *) lfirst(gl); + Var *v = (Var *) lfirst(gl); if (tlist_member(v, sort_tlist) == NULL) { @@ -490,15 +490,15 @@ make_groupPlan(List ** tlist, */ foreach(sl, sort_tlist) { - TargetEntry *te = (TargetEntry *) lfirst(sl); - Resdom *resdom = te->resdom; - Node *expr = te->expr; + TargetEntry *te = (TargetEntry *) lfirst(sl); + Resdom *resdom = te->resdom; + Node *expr = te->expr; if (IsA(expr, Var)) { #if 0 /* subplanVar->resdom->resno expected to * be = te->resdom->resno */ - TargetEntry *subplanVar; + TargetEntry *subplanVar; subplanVar = match_varid((Var *) expr, subplan->targetlist); ((Var *) expr)->varattno = subplanVar->resdom->resno; @@ -533,12 +533,12 @@ make_groupPlan(List ** tlist, sort_tlist = NIL; /* to be new parent TL */ foreach(gl, *tlist) { - List *temp = NIL; - TargetEntry *te = (TargetEntry *) lfirst(gl); + List *temp = NIL; + TargetEntry *te = (TargetEntry *) lfirst(gl); foreach(temp, otles) /* Is it removed non-GroupBy entry ? */ { - TargetEntry *ote = (TargetEntry *) lfirst(temp); + TargetEntry *ote = (TargetEntry *) lfirst(temp); if (ote->resdom->resno == te->resdom->resno) { @@ -548,7 +548,7 @@ make_groupPlan(List ** tlist, } if (temp == NIL) /* It's "our" TLE - we're to return */ { /* it from Sort/Group plans */ - TargetEntry *my = (TargetEntry *) lfirst(sl); /* get it */ + TargetEntry *my = (TargetEntry *) lfirst(sl); /* get it */ sl = sl->next; /* prepare for the next "our" */ my = copyObject(my); diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index 43441a3b7ff..72352646b71 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.7 1997/09/07 04:44:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.8 1997/09/08 02:24:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,8 +47,8 @@ #include "executor/executor.h" -static Plan *make_sortplan(List * tlist, List * sortcls, Plan * plannode); -static Plan *init_query_planner(Query * parse); +static Plan *make_sortplan(List * tlist, List * sortcls, Plan * plannode); +static Plan *init_query_planner(Query * parse); static Existential *make_existential(Plan * left, Plan * right); /***************************************************************************** @@ -68,18 +68,18 @@ static Existential *make_existential(Plan * left, Plan * right); * Returns a query plan. * */ -Plan * +Plan * planner(Query * parse) { - List *tlist = parse->targetList; - List *rangetable = parse->rtable; - char *uniqueflag = parse->uniqueFlag; - List *sortclause = parse->sortClause; - Plan *special_plans = (Plan *) NULL; + List *tlist = parse->targetList; + List *rangetable = parse->rtable; + char *uniqueflag = parse->uniqueFlag; + List *sortclause = parse->sortClause; + Plan *special_plans = (Plan *) NULL; - Plan *result_plan = (Plan *) NULL; + Plan *result_plan = (Plan *) NULL; - int rt_index; + int rt_index; /* * plan inheritance @@ -119,7 +119,7 @@ planner(Query * parse) if (uniqueflag) { - Plan *sortplan = make_sortplan(tlist, sortclause, result_plan); + Plan *sortplan = make_sortplan(tlist, sortclause, result_plan); return ((Plan *) make_unique(tlist, sortplan, uniqueflag)); } @@ -142,15 +142,15 @@ planner(Query * parse) * sortkeys: ( resdom1 resdom2 resdom3 ...) * sortops: (sortop1 sortop2 sortop3 ...) */ -static Plan * +static Plan * make_sortplan(List * tlist, List * sortcls, Plan * plannode) { - Plan *sortplan = (Plan *) NULL; - List *temp_tlist = NIL; - List *i = NIL; - Resdom *resnode = (Resdom *) NULL; - Resdom *resdom = (Resdom *) NULL; - int keyno = 1; + Plan *sortplan = (Plan *) NULL; + List *temp_tlist = NIL; + List *i = NIL; + Resdom *resnode = (Resdom *) NULL; + Resdom *resdom = (Resdom *) NULL; + int keyno = 1; /* * First make a copy of the tlist so that we don't corrupt the the @@ -161,7 +161,7 @@ make_sortplan(List * tlist, List * sortcls, Plan * plannode) foreach(i, sortcls) { - SortClause *sortcl = (SortClause *) lfirst(i); + SortClause *sortcl = (SortClause *) lfirst(i); resnode = sortcl->resdom; resdom = tlist_resdom(temp_tlist, resnode); @@ -203,13 +203,13 @@ make_sortplan(List * tlist, List * sortcls, Plan * plannode) * MODIFIES: tlist,qual * */ -static Plan * +static Plan * init_query_planner(Query * root) { - List *primary_qual; - List *existential_qual; - Existential *exist_plan; - List *tlist = root->targetList; + List *primary_qual; + List *existential_qual; + Existential *exist_plan; + List *tlist = root->targetList; tlist = preprocess_targetlist(tlist, root->commandType, @@ -230,8 +230,8 @@ init_query_planner(Query * root) } else { - int temp = root->commandType; - Plan *existential_plan; + int temp = root->commandType; + Plan *existential_plan; root->commandType = CMD_SELECT; existential_plan = query_planner(root, @@ -256,7 +256,7 @@ init_query_planner(Query * root) static Existential * make_existential(Plan * left, Plan * right) { - Existential *node = makeNode(Existential); + Existential *node = makeNode(Existential); node->lefttree = left; node->righttree = left; @@ -275,17 +275,17 @@ make_existential(Plan * left, Plan * right) void pg_checkretval(Oid rettype, QueryTreeList * queryTreeList) { - Query *parse; - List *tlist; - List *rt; - int cmd; - Type typ; - Resdom *resnode; - Relation reln; - Oid relid; - Oid tletype; - int relnatts; - int i; + Query *parse; + List *tlist; + List *rt; + int cmd; + Type typ; + Resdom *resnode; + Relation reln; + Oid relid; + Oid tletype; + int relnatts; + int i; /* find the final query */ parse = queryTreeList->qtrees[queryTreeList->len - 1]; @@ -383,8 +383,8 @@ pg_checkretval(Oid rettype, QueryTreeList * queryTreeList) /* expect attributes 1 .. n in order */ for (i = 1; i <= relnatts; i++) { - TargetEntry *tle = lfirst(tlist); - Node *thenode = tle->expr; + TargetEntry *tle = lfirst(tlist); + Node *thenode = tle->expr; tlist = lnext(tlist); tletype = exprType(thenode); diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index 19cee246a58..5a6e4da3440 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.5 1997/09/07 04:44:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.6 1997/09/08 02:24:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,20 +33,20 @@ #include "optimizer/var.h" #include "optimizer/tlist.h" -static void set_join_tlist_references(Join * join); -static void set_tempscan_tlist_references(SeqScan * tempscan); -static void set_temp_tlist_references(Temp * temp); -static List * +static void set_join_tlist_references(Join * join); +static void set_tempscan_tlist_references(SeqScan * tempscan); +static void set_temp_tlist_references(Temp * temp); +static List * replace_clause_joinvar_refs(Expr * clause, List * outer_tlist, List * inner_tlist); -static List * +static List * replace_subclause_joinvar_refs(List * clauses, List * outer_tlist, List * inner_tlist); -static Var *replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist); -static List *tlist_temp_references(Oid tempid, List * tlist); -static void replace_result_clause(List * clause, List * subplanTargetList); -static bool OperandIsInner(Node * opnd, int inner_relid); -static void replace_agg_clause(Node * expr, List * targetlist); +static Var *replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist); +static List *tlist_temp_references(Oid tempid, List * tlist); +static void replace_result_clause(List * clause, List * subplanTargetList); +static bool OperandIsInner(Node * opnd, int inner_relid); +static void replace_agg_clause(Node * expr, List * targetlist); /***************************************************************************** * @@ -94,7 +94,7 @@ set_tlist_references(Plan * plan) } else if (IsA(plan, Choose)) { - List *x; + List *x; foreach(x, ((Choose *) plan)->chooseplanlist) { @@ -122,19 +122,19 @@ set_tlist_references(Plan * plan) static void set_join_tlist_references(Join * join) { - Plan *outer = ((Plan *) join)->lefttree; - Plan *inner = ((Plan *) join)->righttree; - List *new_join_targetlist = NIL; - TargetEntry *temp = (TargetEntry *) NULL; - List *entry = NIL; - List *inner_tlist = NULL; - List *outer_tlist = NULL; - TargetEntry *xtl = (TargetEntry *) NULL; - List *qptlist = ((Plan *) join)->targetlist; + Plan *outer = ((Plan *) join)->lefttree; + Plan *inner = ((Plan *) join)->righttree; + List *new_join_targetlist = NIL; + TargetEntry *temp = (TargetEntry *) NULL; + List *entry = NIL; + List *inner_tlist = NULL; + List *outer_tlist = NULL; + TargetEntry *xtl = (TargetEntry *) NULL; + List *qptlist = ((Plan *) join)->targetlist; foreach(entry, qptlist) { - List *joinvar; + List *joinvar; xtl = (TargetEntry *) lfirst(entry); inner_tlist = ((inner == NULL) ? NIL : inner->targetlist); @@ -167,7 +167,7 @@ set_join_tlist_references(Join * join) static void set_tempscan_tlist_references(SeqScan * tempscan) { - Temp *temp = (Temp *) ((Plan *) tempscan)->lefttree; + Temp *temp = (Temp *) ((Plan *) tempscan)->lefttree; ((Plan *) tempscan)->targetlist = tlist_temp_references(temp->tempid, @@ -189,7 +189,7 @@ set_tempscan_tlist_references(SeqScan * tempscan) static void set_temp_tlist_references(Temp * temp) { - Plan *source = ((Plan *) temp)->lefttree; + Plan *source = ((Plan *) temp)->lefttree; if (source != NULL) { @@ -217,7 +217,7 @@ set_temp_tlist_references(Temp * temp) * Returns the new join clauses. * */ -List * +List * join_references(List * clauses, List * outer_tlist, List * inner_tlist) @@ -243,15 +243,15 @@ join_references(List * clauses, * Returns the new list of clauses. * */ -List * +List * index_outerjoin_references(List * inner_indxqual, List * outer_tlist, Index inner_relid) { - List *t_list = NIL; - Expr *temp = NULL; - List *t_clause = NIL; - Expr *clause = NULL; + List *t_list = NIL; + Expr *temp = NULL; + List *t_clause = NIL; + Expr *clause = NULL; foreach(t_clause, inner_indxqual) { @@ -262,7 +262,7 @@ index_outerjoin_references(List * inner_indxqual, */ if (OperandIsInner((Node *) get_rightop(clause), inner_relid)) { - Var *joinvar = (Var *) + Var *joinvar = (Var *) replace_clause_joinvar_refs((Expr *) get_leftop(clause), outer_tlist, NIL); @@ -275,7 +275,7 @@ index_outerjoin_references(List * inner_indxqual, else { /* inner scan on left */ - Var *joinvar = (Var *) + Var *joinvar = (Var *) replace_clause_joinvar_refs((Expr *) get_rightop(clause), outer_tlist, NIL); @@ -306,12 +306,12 @@ index_outerjoin_references(List * inner_indxqual, * Returns the new join clause. * */ -static List * +static List * replace_clause_joinvar_refs(Expr * clause, List * outer_tlist, List * inner_tlist) { - List *temp = NULL; + List *temp = NULL; if (IsA(clause, Var)) { @@ -330,7 +330,7 @@ replace_clause_joinvar_refs(Expr * clause, } else if (or_clause((Node *) clause)) { - List *orclause = + List *orclause = replace_subclause_joinvar_refs(((Expr *) clause)->args, outer_tlist, inner_tlist); @@ -339,7 +339,7 @@ replace_clause_joinvar_refs(Expr * clause, } else if (IsA(clause, ArrayRef)) { - ArrayRef *aref = (ArrayRef *) clause; + ArrayRef *aref = (ArrayRef *) clause; temp = replace_subclause_joinvar_refs(aref->refupperindexpr, outer_tlist, @@ -365,7 +365,7 @@ replace_clause_joinvar_refs(Expr * clause, } else if (is_funcclause((Node *) clause)) { - List *funcclause = + List *funcclause = replace_subclause_joinvar_refs(((Expr *) clause)->args, outer_tlist, inner_tlist); @@ -375,7 +375,7 @@ replace_clause_joinvar_refs(Expr * clause, } else if (not_clause((Node *) clause)) { - List *notclause = + List *notclause = replace_clause_joinvar_refs(get_notclausearg(clause), outer_tlist, inner_tlist); @@ -384,11 +384,11 @@ replace_clause_joinvar_refs(Expr * clause, } else if (is_opclause((Node *) clause)) { - Var *leftvar = + Var *leftvar = (Var *) replace_clause_joinvar_refs((Expr *) get_leftop(clause), outer_tlist, inner_tlist); - Var *rightvar = + Var *rightvar = (Var *) replace_clause_joinvar_refs((Expr *) get_rightop(clause), outer_tlist, inner_tlist); @@ -401,14 +401,14 @@ replace_clause_joinvar_refs(Expr * clause, return NULL; } -static List * +static List * replace_subclause_joinvar_refs(List * clauses, List * outer_tlist, List * inner_tlist) { - List *t_list = NIL; - List *temp = NIL; - List *clause = NIL; + List *t_list = NIL; + List *temp = NIL; + List *clause = NIL; foreach(clause, clauses) { @@ -420,10 +420,10 @@ replace_subclause_joinvar_refs(List * clauses, return (t_list); } -static Var * +static Var * replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist) { - Resdom *outer_resdom = (Resdom *) NULL; + Resdom *outer_resdom = (Resdom *) NULL; outer_resdom = tlist_member(var, outer_tlist); @@ -437,7 +437,7 @@ replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist) } else { - Resdom *inner_resdom; + Resdom *inner_resdom; inner_resdom = tlist_member(var, inner_tlist); if (inner_resdom != NULL && IsA(inner_resdom, Resdom)) @@ -466,18 +466,18 @@ replace_joinvar_refs(Var * var, List * outer_tlist, List * inner_tlist) * Returns new target list * */ -static List * +static List * tlist_temp_references(Oid tempid, List * tlist) { - List *t_list = NIL; - TargetEntry *temp = (TargetEntry *) NULL; - TargetEntry *xtl = NULL; - List *entry; + List *t_list = NIL; + TargetEntry *temp = (TargetEntry *) NULL; + TargetEntry *xtl = NULL; + List *entry; foreach(entry, tlist) { - AttrNumber oattno; + AttrNumber oattno; xtl = lfirst(entry); if (IsA(get_expr(xtl), Var)) @@ -513,12 +513,12 @@ tlist_temp_references(Oid tempid, void set_result_tlist_references(Result * resultNode) { - Plan *subplan; - List *resultTargetList; - List *subplanTargetList; - List *t; - TargetEntry *entry; - Expr *expr; + Plan *subplan; + List *resultTargetList; + List *subplanTargetList; + List *t; + TargetEntry *entry; + Expr *expr; resultTargetList = ((Plan *) resultNode)->targetlist; @@ -564,9 +564,9 @@ replace_result_clause(List * clause, List * subplanTargetList) /* target list of the * subplan */ { - List *t; - List *subClause; - TargetEntry *subplanVar; + List *t; + List *subClause; + TargetEntry *subplanVar; if (IsA(clause, Var)) { @@ -598,7 +598,7 @@ replace_result_clause(List * clause, } else if (IsA(clause, ArrayRef)) { - ArrayRef *aref = (ArrayRef *) clause; + ArrayRef *aref = (ArrayRef *) clause; /* * This is an arrayref. Recursively call this routine for its @@ -646,7 +646,7 @@ replace_result_clause(List * clause, } static -bool + bool OperandIsInner(Node * opnd, int inner_relid) { @@ -663,7 +663,7 @@ OperandIsInner(Node * opnd, int inner_relid) } if (is_funcclause(opnd)) { - List *firstArg = lfirst(((Expr *) opnd)->args); + List *firstArg = lfirst(((Expr *) opnd)->args); if (IsA(firstArg, Var) && (inner_relid == ((Var *) firstArg)->varno)) @@ -688,16 +688,16 @@ OperandIsInner(Node * opnd, int inner_relid) void set_agg_tlist_references(Agg * aggNode) { - List *aggTargetList; - List *subplanTargetList; - List *tl; + List *aggTargetList; + List *subplanTargetList; + List *tl; aggTargetList = aggNode->plan.targetlist; subplanTargetList = aggNode->plan.lefttree->targetlist; foreach(tl, aggTargetList) { - TargetEntry *tle = lfirst(tl); + TargetEntry *tle = lfirst(tl); replace_agg_clause(tle->expr, subplanTargetList); } @@ -706,9 +706,9 @@ set_agg_tlist_references(Agg * aggNode) void set_agg_agglist_references(Agg * aggNode) { - List *subplanTargetList; - Aggreg **aggs; - int i; + List *subplanTargetList; + Aggreg **aggs; + int i; aggs = aggNode->aggs; subplanTargetList = aggNode->plan.lefttree->targetlist; @@ -722,8 +722,8 @@ set_agg_agglist_references(Agg * aggNode) static void replace_agg_clause(Node * clause, List * subplanTargetList) { - List *t; - TargetEntry *subplanVar; + List *t; + TargetEntry *subplanVar; if (IsA(clause, Var)) { @@ -757,7 +757,7 @@ replace_agg_clause(Node * clause, List * subplanTargetList) } else if (IsA(clause, ArrayRef)) { - ArrayRef *aref = (ArrayRef *) clause; + ArrayRef *aref = (ArrayRef *) clause; /* * This is an arrayref. Recursively call this routine for its @@ -781,8 +781,8 @@ replace_agg_clause(Node * clause, List * subplanTargetList) * This is an operator. Recursively call this routine for both its * left and right operands */ - Node *left = (Node *) get_leftop((Expr *) clause); - Node *right = (Node *) get_rightop((Expr *) clause); + Node *left = (Node *) get_leftop((Expr *) clause); + Node *right = (Node *) get_rightop((Expr *) clause); if (left != (Node *) NULL) replace_agg_clause(left, subplanTargetList); diff --git a/src/backend/optimizer/prep/archive.c b/src/backend/optimizer/prep/archive.c index bbc797234ac..64a1b1c84d9 100644 --- a/src/backend/optimizer/prep/archive.c +++ b/src/backend/optimizer/prep/archive.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/Attic/archive.c,v 1.2 1997/09/07 04:44:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/Attic/archive.c,v 1.3 1997/09/08 02:24:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,11 +28,11 @@ void plan_archive(List * rt) { - List *rtitem; - RangeTblEntry *rte; - TimeRange *trange; - Relation r; - Oid reloid; + List *rtitem; + RangeTblEntry *rte; + TimeRange *trange; + Relation r; + Oid reloid; foreach(rtitem, rt) { @@ -55,11 +55,11 @@ plan_archive(List * rt) * find_archive_rels -- Given a particular relid, find the archive * relation's relid. */ -List * +List * find_archive_rels(Oid relid) { - Relation arel; - char *arelName; + Relation arel; + char *arelName; arelName = MakeArchiveName(relid); arel = RelationNameGetRelation(arelName); diff --git a/src/backend/optimizer/prep/prepqual.c b/src/backend/optimizer/prep/prepqual.c index eac1eafa44f..47a44d01967 100644 --- a/src/backend/optimizer/prep/prepqual.c +++ b/src/backend/optimizer/prep/prepqual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.4 1997/09/07 04:44:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepqual.c,v 1.5 1997/09/08 02:24:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,17 +24,17 @@ #include "utils/lsyscache.h" -static Expr *pull_args(Expr * qual); -static List *pull_ors(List * orlist); -static List *pull_ands(List * andlist); -static Expr *find_nots(Expr * qual); -static Expr *push_nots(Expr * qual); -static Expr *normalize(Expr * qual); -static List *or_normalize(List * orlist); -static List *distribute_args(List * item, List * args); -static List *qualcleanup(Expr * qual); -static List *remove_ands(Expr * qual); -static List *remove_duplicates(List * list); +static Expr *pull_args(Expr * qual); +static List *pull_ors(List * orlist); +static List *pull_ands(List * andlist); +static Expr *find_nots(Expr * qual); +static Expr *push_nots(Expr * qual); +static Expr *normalize(Expr * qual); +static List *or_normalize(List * orlist); +static List *distribute_args(List * item, List * args); +static List *qualcleanup(Expr * qual); +static List *remove_ands(Expr * qual); +static List *remove_duplicates(List * list); /* * preprocess-qualification-- @@ -47,10 +47,10 @@ static List *remove_duplicates(List * list); * preprocess-qualification simply converts the qual in conjunctive * normal form (see cnfify() below ) */ -List * +List * preprocess_qualification(Expr * qual, List * tlist, List ** existentialQualPtr) { - List *cnf_qual = cnfify(qual, true); + List *cnf_qual = cnfify(qual, true); /* List *existential_qual = @@ -100,10 +100,10 @@ preprocess_qualification(Expr * qual, List * tlist, List ** existentialQualPtr) * and from the rule manager (removeAndFlag = false). * */ -List * +List * cnfify(Expr * qual, bool removeAndFlag) { - Expr *newqual = NULL; + Expr *newqual = NULL; if (qual != NULL) { @@ -133,7 +133,7 @@ cnfify(Expr * qual, bool removeAndFlag) * Returns the modified qualification. * */ -static Expr * +static Expr * pull_args(Expr * qual) { if (qual == NULL) @@ -148,8 +148,8 @@ pull_args(Expr * qual) } else if (and_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) t_list = lappend(t_list, pull_args(lfirst(temp))); @@ -157,8 +157,8 @@ pull_args(Expr * qual) } else if (or_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) t_list = lappend(t_list, pull_args(lfirst(temp))); @@ -181,7 +181,7 @@ pull_args(Expr * qual) * * Returns the modified list. */ -static List * +static List * pull_ors(List * orlist) { if (orlist == NIL) @@ -189,7 +189,7 @@ pull_ors(List * orlist) if (or_clause(lfirst(orlist))) { - List *args = ((Expr *) lfirst(orlist))->args; + List *args = ((Expr *) lfirst(orlist))->args; return (pull_ors(nconc(copyObject((Node *) args), copyObject((Node *) lnext(orlist))))); @@ -207,7 +207,7 @@ pull_ors(List * orlist) * * Returns the modified list. */ -static List * +static List * pull_ands(List * andlist) { if (andlist == NIL) @@ -215,7 +215,7 @@ pull_ands(List * andlist) if (and_clause(lfirst(andlist))) { - List *args = ((Expr *) lfirst(andlist))->args; + List *args = ((Expr *) lfirst(andlist))->args; return (pull_ands(nconc(copyObject((Node *) args), copyObject((Node *) lnext(andlist))))); @@ -236,7 +236,7 @@ pull_ands(List * andlist) * Returns the modified qualification. * */ -static Expr * +static Expr * find_nots(Expr * qual) { if (qual == NULL) @@ -251,8 +251,8 @@ find_nots(Expr * qual) } else if (and_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) { @@ -263,8 +263,8 @@ find_nots(Expr * qual) } else if (or_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) { @@ -285,7 +285,7 @@ find_nots(Expr * qual) * Returns the modified qualification. * */ -static Expr * +static Expr * push_nots(Expr * qual) { if (qual == NULL) @@ -298,15 +298,15 @@ push_nots(Expr * qual) */ if (is_opclause((Node *) qual)) { - Oper *oper = (Oper *) ((Expr *) qual)->oper; - Oid negator = get_negator(oper->opno); + Oper *oper = (Oper *) ((Expr *) qual)->oper; + Oid negator = get_negator(oper->opno); if (negator) { - Oper *op = (Oper *) makeOper(negator, - InvalidOid, - oper->opresulttype, - 0, NULL); + Oper *op = (Oper *) makeOper(negator, + InvalidOid, + oper->opresulttype, + 0, NULL); op->op_fcache = (FunctionCache *) NULL; return @@ -325,8 +325,8 @@ push_nots(Expr * qual) * ("NOT" B)) ("NOT" ("OR" A B)) => ("AND" ("NOT" A) ("NOT" B)) * i.e., continue negating down through the clause's descendants. */ - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) { @@ -336,8 +336,8 @@ push_nots(Expr * qual) } else if (or_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) { @@ -372,7 +372,7 @@ push_nots(Expr * qual) * Returns the modified qualification. * */ -static Expr * +static Expr * normalize(Expr * qual) { if (qual == NULL) @@ -380,7 +380,7 @@ normalize(Expr * qual) if (is_opclause((Node *) qual)) { - Expr *expr = (Expr *) qual; + Expr *expr = (Expr *) qual; return (make_clause(expr->opType, expr->oper, lcons(normalize((Expr *) get_leftop(qual)), @@ -389,8 +389,8 @@ normalize(Expr * qual) } else if (and_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; + List *temp = NIL; + List *t_list = NIL; foreach(temp, qual->args) { @@ -401,9 +401,9 @@ normalize(Expr * qual) else if (or_clause((Node *) qual)) { /* XXX - let form, maybe incorrect */ - List *orlist = NIL; - List *temp = NIL; - bool has_andclause = FALSE; + List *orlist = NIL; + List *temp = NIL; + bool has_andclause = FALSE; foreach(temp, qual->args) { @@ -437,12 +437,12 @@ normalize(Expr * qual) * Returns the modified list. * */ -static List * +static List * or_normalize(List * orlist) { - List *distributable = NIL; - List *new_orlist = NIL; - List *temp = NIL; + List *distributable = NIL; + List *new_orlist = NIL; + List *temp = NIL; if (orlist == NIL) return NIL; @@ -476,13 +476,13 @@ or_normalize(List * orlist) * Returns an 'and' clause. * */ -static List * +static List * distribute_args(List * item, List * args) { - List *or_list = NIL; - List *n_list = NIL; - List *temp = NIL; - List *t_list = NIL; + List *or_list = NIL; + List *n_list = NIL; + List *temp = NIL; + List *t_list = NIL; if (args == NULL) return (item); @@ -506,7 +506,7 @@ distribute_args(List * item, List * args) * Returns the modified qualfication. * */ -static List * +static List * qualcleanup(Expr * qual) { if (qual == NULL) @@ -521,9 +521,9 @@ qualcleanup(Expr * qual) } else if (and_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; - List *new_and_args = NIL; + List *temp = NIL; + List *t_list = NIL; + List *new_and_args = NIL; foreach(temp, qual->args) t_list = lappend(t_list, qualcleanup(lfirst(temp))); @@ -537,9 +537,9 @@ qualcleanup(Expr * qual) } else if (or_clause((Node *) qual)) { - List *temp = NIL; - List *t_list = NIL; - List *new_or_args = NIL; + List *temp = NIL; + List *t_list = NIL; + List *new_or_args = NIL; foreach(temp, qual->args) t_list = lappend(t_list, qualcleanup(lfirst(temp))); @@ -567,10 +567,10 @@ qualcleanup(Expr * qual) * RETURNS : qual * MODIFIES: qual */ -static List * +static List * remove_ands(Expr * qual) { - List *t_list = NIL; + List *t_list = NIL; if (qual == NULL) return (NIL); @@ -583,7 +583,7 @@ remove_ands(Expr * qual) } else if (and_clause((Node *) qual)) { - List *temp = NIL; + List *temp = NIL; foreach(temp, qual->args) t_list = lappend(t_list, remove_ands(lfirst(temp))); @@ -591,7 +591,7 @@ remove_ands(Expr * qual) } else if (or_clause((Node *) qual)) { - List *temp = NIL; + List *temp = NIL; foreach(temp, qual->args) t_list = lappend(t_list, remove_ands(lfirst(temp))); @@ -620,7 +620,7 @@ remove_ands(Expr * qual) * */ #ifdef NOT_USED -static List * +static List * update_relations(List * tlist) { return (NIL); @@ -634,13 +634,13 @@ update_relations(List * tlist) * *****************************************************************************/ -static List * +static List * remove_duplicates(List * list) { - List *i; - List *j; - List *result = NIL; - bool there_exists_duplicate = false; + List *i; + List *j; + List *result = NIL; + bool there_exists_duplicate = false; if (length(list) == 1) return (list); diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 8b94fb4cbba..550dad8f94b 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.3 1997/09/07 04:44:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.4 1997/09/08 02:24:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,13 +33,13 @@ #include "optimizer/clauses.h" #include "optimizer/tlist.h" -static List * +static List * expand_targetlist(List * tlist, Oid relid, int command_type, Index result_relation); -static List * +static List * replace_matching_resname(List * new_tlist, List * old_tlist); -static List * +static List * new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type); @@ -54,16 +54,16 @@ new_relation_targetlist(Oid relid, Index rt_index, * * Returns the new targetlist. */ -List * +List * preprocess_targetlist(List * tlist, int command_type, Index result_relation, List * range_table) { - List *expanded_tlist = NIL; - Oid relid = InvalidOid; - List *t_list = NIL; - List *temp = NIL; + List *expanded_tlist = NIL; + Oid relid = InvalidOid; + List *t_list = NIL; + List *temp = NIL; if (result_relation >= 1 && command_type != CMD_SELECT) { @@ -82,7 +82,7 @@ preprocess_targetlist(List * tlist, /* was mapCAR */ foreach(temp, expanded_tlist) { - TargetEntry *tle = lfirst(temp); + TargetEntry *tle = lfirst(temp); if (tle->expr) fix_opid(tle->expr); @@ -101,9 +101,9 @@ preprocess_targetlist(List * tlist, */ if (command_type == CMD_UPDATE || command_type == CMD_DELETE) { - TargetEntry *ctid; - Resdom *resdom; - Var *var; + TargetEntry *ctid; + Resdom *resdom; + Var *var; resdom = makeResdom(length(t_list) + 1, 27, @@ -143,29 +143,29 @@ preprocess_targetlist(List * tlist, * * Returns the expanded target list, sorted in resno order. */ -static List * +static List * expand_targetlist(List * tlist, Oid relid, int command_type, Index result_relation) { - NodeTag node_type = T_Invalid; + NodeTag node_type = T_Invalid; switch (command_type) { - case CMD_INSERT: - node_type = (NodeTag) T_Const; - break; - case CMD_UPDATE: - node_type = (NodeTag) T_Var; - break; + case CMD_INSERT: + node_type = (NodeTag) T_Const; + break; + case CMD_UPDATE: + node_type = (NodeTag) T_Var; + break; } if (node_type != T_Invalid) { - List *ntlist = new_relation_targetlist(relid, - result_relation, - node_type); + List *ntlist = new_relation_targetlist(relid, + result_relation, + node_type); return (replace_matching_resname(ntlist, tlist)); } @@ -177,21 +177,21 @@ expand_targetlist(List * tlist, } -static List * +static List * replace_matching_resname(List * new_tlist, List * old_tlist) { - List *temp, - *i; - List *t_list = NIL; + List *temp, + *i; + List *t_list = NIL; foreach(i, new_tlist) { - TargetEntry *new_tle = (TargetEntry *) lfirst(i); - TargetEntry *matching_old_tl = NULL; + TargetEntry *new_tle = (TargetEntry *) lfirst(i); + TargetEntry *matching_old_tl = NULL; foreach(temp, old_tlist) { - TargetEntry *old_tle = (TargetEntry *) lfirst(temp); + TargetEntry *old_tle = (TargetEntry *) lfirst(temp); old_tle = lfirst(temp); if (!strcmp(old_tle->resdom->resname, @@ -228,9 +228,9 @@ replace_matching_resname(List * new_tlist, List * old_tlist) */ foreach(temp, old_tlist) { - TargetEntry *old_tle, - *new_tl; - Resdom *newresno; + TargetEntry *old_tle, + *new_tl; + Resdom *newresno; old_tle = lfirst(temp); if (old_tle->resdom->resno < 0) @@ -253,15 +253,15 @@ replace_matching_resname(List * new_tlist, List * old_tlist) * * Returns the new targetlist. */ -static List * +static List * new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) { - AttrNumber attno; - List *t_list = NIL; - char *attname; - Oid atttype = 0; - int16 typlen = 0; - bool attisset = false; + AttrNumber attno; + List *t_list = NIL; + char *attname; + Oid atttype = 0; + int16 typlen = 0; + bool attisset = false; /* Oid type_id; */ /* type_id = RelationIdGetTypeId(relid); */ @@ -287,59 +287,59 @@ new_relation_targetlist(Oid relid, Index rt_index, NodeTag node_type) switch (node_type) { - case T_Const: - { - struct varlena *typedefault = get_typdefault(atttype); - int temp = 0; - Const *temp2 = (Const *) NULL; - TargetEntry *temp3 = (TargetEntry *) NULL; - - if (typedefault == NULL) - temp = 0; - else - temp = typlen; - - temp2 = makeConst(atttype, - temp, - (Datum) typedefault, + case T_Const: + { + struct varlena *typedefault = get_typdefault(atttype); + int temp = 0; + Const *temp2 = (Const *) NULL; + TargetEntry *temp3 = (TargetEntry *) NULL; + + if (typedefault == NULL) + temp = 0; + else + temp = typlen; + + temp2 = makeConst(atttype, + temp, + (Datum) typedefault, (typedefault == (struct varlena *) NULL), - /* XXX this is bullshit */ - false, - false, /* not a set */ - false); - - temp3 = MakeTLE(makeResdom(attno, - atttype, - typlen, - attname, - 0, - (Oid) 0, - 0), - (Node *) temp2); - t_list = lappend(t_list, temp3); - break; - } - case T_Var: - { - Var *temp_var = (Var *) NULL; - TargetEntry *temp_list = NULL; - - temp_var = - makeVar(rt_index, attno, atttype, rt_index, attno); + /* XXX this is bullshit */ + false, + false, /* not a set */ + false); - temp_list = MakeTLE(makeResdom(attno, + temp3 = MakeTLE(makeResdom(attno, atttype, typlen, attname, 0, (Oid) 0, 0), - (Node *) temp_var); - t_list = lappend(t_list, temp_list); + (Node *) temp2); + t_list = lappend(t_list, temp3); + break; + } + case T_Var: + { + Var *temp_var = (Var *) NULL; + TargetEntry *temp_list = NULL; + + temp_var = + makeVar(rt_index, attno, atttype, rt_index, attno); + + temp_list = MakeTLE(makeResdom(attno, + atttype, + typlen, + attname, + 0, + (Oid) 0, + 0), + (Node *) temp_var); + t_list = lappend(t_list, temp_list); + break; + } + default: /* do nothing */ break; - } - default: /* do nothing */ - break; } } diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 9bf282f8cc3..39e539b223b 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.4 1997/09/07 04:44:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.5 1997/09/08 02:24:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,20 +34,20 @@ #include "optimizer/planner.h" #include "optimizer/prep.h" -static List * +static List * plan_union_query(List * relids, Index rt_index, RangeTblEntry * rt_entry, Query * parse, UnionFlag flag, List ** union_rtentriesPtr); static RangeTblEntry * new_rangetable_entry(Oid new_relid, RangeTblEntry * old_entry); -static Query * +static Query * subst_rangetable(Query * root, Index index, RangeTblEntry * new_entry); static void fix_parsetree_attnums(Index rt_index, Oid old_relid, Oid new_relid, Query * parsetree); -static Append * +static Append * make_append(List * unionplans, Index rt_index, List * union_rt_entries, List * tlist); @@ -58,20 +58,20 @@ make_append(List * unionplans, Index rt_index, * attributes from any relations listed in either of the argument relid * lists. */ -List * +List * find_all_inheritors(List * unexamined_relids, List * examined_relids) { - List *new_inheritors = NIL; - List *new_examined_relids = NIL; - List *new_unexamined_relids = NIL; + List *new_inheritors = NIL; + List *new_examined_relids = NIL; + List *new_unexamined_relids = NIL; /* * Find all relations which inherit from members of * 'unexamined-relids' and store them in 'new-inheritors'. */ - List *rels = NIL; - List *newrels = NIL; + List *rels = NIL; + List *newrels = NIL; foreach(rels, unexamined_relids) { @@ -105,25 +105,25 @@ find_all_inheritors(List * unexamined_relids, int first_matching_rt_entry(List * rangetable, UnionFlag flag) { - int count = 0; - List *temp = NIL; + int count = 0; + List *temp = NIL; foreach(temp, rangetable) { - RangeTblEntry *rt_entry = lfirst(temp); + RangeTblEntry *rt_entry = lfirst(temp); switch (flag) { - case INHERITS_FLAG: - if (rt_entry->inh) - return count + 1; - break; - case ARCHIVE_FLAG: - if (rt_entry->archive) - return count + 1; - break; - default: - break; + case INHERITS_FLAG: + if (rt_entry->inh) + return count + 1; + break; + case ARCHIVE_FLAG: + if (rt_entry->archive) + return count + 1; + break; + default: + break; } count++; } @@ -141,50 +141,50 @@ first_matching_rt_entry(List * rangetable, UnionFlag flag) * entries to be inserted into an APPEND node. * XXX - what exactly does this mean, look for make_append */ -Append * +Append * plan_union_queries(Index rt_index, Query * parse, UnionFlag flag) { - List *rangetable = parse->rtable; - RangeTblEntry *rt_entry = rt_fetch(rt_index, rangetable); - List *union_relids = NIL; - List *union_plans = NIL; - List *union_rt_entries = NIL; + List *rangetable = parse->rtable; + RangeTblEntry *rt_entry = rt_fetch(rt_index, rangetable); + List *union_relids = NIL; + List *union_plans = NIL; + List *union_rt_entries = NIL; switch (flag) { - case INHERITS_FLAG: - union_relids = - find_all_inheritors(lconsi(rt_entry->relid, - NIL), - NIL); - break; + case INHERITS_FLAG: + union_relids = + find_all_inheritors(lconsi(rt_entry->relid, + NIL), + NIL); + break; #if 0 - case UNION_FLAG: - { - Index rt_index = 0; + case UNION_FLAG: + { + Index rt_index = 0; - union_plans = handleunion(root, rangetable, tlist, qual); - return (make_append(union_plans, - rt_index, rangetable, + union_plans = handleunion(root, rangetable, tlist, qual); + return (make_append(union_plans, + rt_index, rangetable, ((Plan *) lfirst(union_plans))->targetlist)); - } - break; + } + break; #endif - case VERSION_FLAG: - union_relids = VersionGetParents(rt_entry->relid); - break; + case VERSION_FLAG: + union_relids = VersionGetParents(rt_entry->relid); + break; - case ARCHIVE_FLAG: - union_relids = find_archive_rels(rt_entry->relid); - break; + case ARCHIVE_FLAG: + union_relids = find_archive_rels(rt_entry->relid); + break; - default: - /* do nothing */ - break; + default: + /* do nothing */ + break; } /* @@ -193,14 +193,14 @@ plan_union_queries(Index rt_index, */ switch (flag) { - case INHERITS_FLAG: - rt_fetch(rt_index, rangetable)->inh = false; - break; - case ARCHIVE_FLAG: - rt_fetch(rt_index, rangetable)->archive = false; - break; - default: - break; + case INHERITS_FLAG: + rt_fetch(rt_index, rangetable)->inh = false; + break; + case ARCHIVE_FLAG: + rt_fetch(rt_index, rangetable)->archive = false; + break; + default: + break; } /* @@ -225,7 +225,7 @@ plan_union_queries(Index rt_index, * Returns a list of plans for 'relids' and a list of range table entries * in union_rtentries. */ -static List * +static List * plan_union_query(List * relids, Index rt_index, RangeTblEntry * rt_entry, @@ -233,18 +233,18 @@ plan_union_query(List * relids, UnionFlag flag, List ** union_rtentriesPtr) { - List *i; - List *union_plans = NIL; - List *union_rtentries = NIL; + List *i; + List *union_plans = NIL; + List *union_rtentries = NIL; foreach(i, relids) { - int relid = lfirsti(i); - RangeTblEntry *new_rt_entry = new_rangetable_entry(relid, - rt_entry); - Query *new_root = subst_rangetable(root, - rt_index, - new_rt_entry); + int relid = lfirsti(i); + RangeTblEntry *new_rt_entry = new_rangetable_entry(relid, + rt_entry); + Query *new_root = subst_rangetable(root, + rt_index, + new_rt_entry); /* * reset the uniqueflag and sortclause in parse tree root, so that @@ -288,7 +288,7 @@ plan_union_query(List * relids, static RangeTblEntry * new_rangetable_entry(Oid new_relid, RangeTblEntry * old_entry) { - RangeTblEntry *new_entry = copyObject(old_entry); + RangeTblEntry *new_entry = copyObject(old_entry); /* ??? someone tell me what the following is doing! - ay 11/94 */ if (!strcmp(new_entry->refname, "*CURRENT*") || @@ -307,12 +307,12 @@ new_rangetable_entry(Oid new_relid, RangeTblEntry * old_entry) * * Returns a new copy of 'root'. */ -static Query * +static Query * subst_rangetable(Query * root, Index index, RangeTblEntry * new_entry) { - Query *new_root = copyObject(root); - List *temp = NIL; - int i = 0; + Query *new_root = copyObject(root); + List *temp = NIL; + int i = 0; for (temp = new_root->rtable, i = 1; i < index; temp = lnext(temp), i++) ; @@ -332,54 +332,54 @@ fix_parsetree_attnums_nodes(Index rt_index, switch (nodeTag(node)) { - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, - tle->expr); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; + fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, + tle->expr); + } + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, - (Node *) expr->args); - } - break; - case T_Var: - { - Var *var = (Var *) node; - Oid old_typeid, + fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, + (Node *) expr->args); + } + break; + case T_Var: + { + Var *var = (Var *) node; + Oid old_typeid, new_typeid; /* old_typeid = RelationIdGetTypeId(old_relid);*/ /* new_typeid = RelationIdGetTypeId(new_relid);*/ - old_typeid = old_relid; - new_typeid = new_relid; - - if (var->varno == rt_index && var->varattno != 0) - { - var->varattno = - get_attnum(new_typeid, - get_attname(old_typeid, var->varattno)); + old_typeid = old_relid; + new_typeid = new_relid; + + if (var->varno == rt_index && var->varattno != 0) + { + var->varattno = + get_attnum(new_typeid, + get_attname(old_typeid, var->varattno)); + } } - } - break; - case T_List: - { - List *l; - - foreach(l, (List *) node) + break; + case T_List: { - fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, - (Node *) lfirst(l)); + List *l; + + foreach(l, (List *) node) + { + fix_parsetree_attnums_nodes(rt_index, old_relid, new_relid, + (Node *) lfirst(l)); + } } - } - break; - default: - break; + break; + default: + break; } } @@ -407,13 +407,13 @@ fix_parsetree_attnums(Index rt_index, parsetree->qual); } -static Append * +static Append * make_append(List * unionplans, Index rt_index, List * union_rt_entries, List * tlist) { - Append *node = makeNode(Append); + Append *node = makeNode(Append); node->unionplans = unionplans; node->unionrelid = rt_index; diff --git a/src/backend/optimizer/util/clauseinfo.c b/src/backend/optimizer/util/clauseinfo.c index e5fd2b7e5bb..09ea9ae898c 100644 --- a/src/backend/optimizer/util/clauseinfo.c +++ b/src/backend/optimizer/util/clauseinfo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/clauseinfo.c,v 1.4 1997/09/07 04:44:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/clauseinfo.c,v 1.5 1997/09/08 02:24:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,12 +44,12 @@ valid_or_clause(CInfo * clauseinfo) * Returns a list containing the clauses from 'clauseinfo-list'. * */ -List * +List * get_actual_clauses(List * clauseinfo_list) { - List *temp = NIL; - List *result = NIL; - CInfo *clause = (CInfo *) NULL; + List *temp = NIL; + List *result = NIL; + CInfo *clause = (CInfo *) NULL; foreach(temp, clauseinfo_list) { @@ -90,18 +90,18 @@ get_relattvals(List * clauseinfo_list, List ** values, List ** flags) { - List *result1 = NIL; - List *result2 = NIL; - List *result3 = NIL; - CInfo *temp = (CInfo *) NULL; - List *i = NIL; + List *result1 = NIL; + List *result2 = NIL; + List *result3 = NIL; + CInfo *temp = (CInfo *) NULL; + List *i = NIL; foreach(i, clauseinfo_list) { - int dummy; - AttrNumber attno; - Datum constval; - int flag; + int dummy; + AttrNumber attno; + Datum constval; + int flag; temp = (CInfo *) lfirst(i); get_relattval((Node *) temp->clause, &dummy, &attno, &constval, &flag); @@ -137,15 +137,15 @@ get_joinvars(Oid relid, List ** values, List ** flags) { - List *result1 = NIL; - List *result2 = NIL; - List *result3 = NIL; - List *temp; + List *result1 = NIL; + List *result2 = NIL; + List *result3 = NIL; + List *temp; foreach(temp, clauseinfo_list) { - CInfo *clauseinfo = lfirst(temp); - Expr *clause = clauseinfo->clause; + CInfo *clauseinfo = lfirst(temp); + Expr *clause = clauseinfo->clause; if (IsA(get_leftop(clause), Var) && (relid == (get_leftop(clause))->varno)) @@ -173,12 +173,12 @@ get_joinvars(Oid relid, * of a list of clauseinfo nodes to be used with an index. * */ -List * +List * get_opnos(List * clauseinfo_list) { - CInfo *temp = (CInfo *) NULL; - List *result = NIL; - List *i = NIL; + CInfo *temp = (CInfo *) NULL; + List *result = NIL; + List *i = NIL; foreach(i, clauseinfo_list) { diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 03e0856ef09..17a97a55eef 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.8 1997/09/07 04:44:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.9 1997/09/08 02:24:52 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -34,16 +34,16 @@ #include "optimizer/internal.h" #include "optimizer/var.h" -static bool agg_clause(Node * clause); +static bool agg_clause(Node * clause); -Expr * +Expr * make_clause(int type, Node * oper, List * args) { if (type == AND_EXPR || type == OR_EXPR || type == NOT_EXPR || type == OP_EXPR || type == FUNC_EXPR) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); /* * assume type checking already done and we don't need the type of @@ -92,10 +92,10 @@ is_opclause(Node * clause) * operand (if it is non-null). * */ -Expr * +Expr * make_opclause(Oper * op, Var * leftop, Var * rightop) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); expr->typeOid = InvalidOid; /* assume type checking done */ expr->opType = OP_EXPR; @@ -111,7 +111,7 @@ make_opclause(Oper * op, Var * leftop, Var * rightop) * or (op expr) * NB: it is assumed (for now) that all expr must be Var nodes */ -Var * +Var * get_leftop(Expr * clause) { if (clause->args != NULL) @@ -126,7 +126,7 @@ get_leftop(Expr * clause) * Returns the right operand in a clause of the form (op expr expr). * */ -Var * +Var * get_rightop(Expr * clause) { if (clause->args != NULL && lnext(clause->args) != NULL) @@ -139,7 +139,7 @@ get_rightop(Expr * clause) * AGG clause functions *****************************************************************************/ -static bool +static bool agg_clause(Node * clause) { return @@ -171,10 +171,10 @@ is_funcclause(Node * clause) * arguments. * */ -Expr * +Expr * make_funcclause(Func * func, List * funcargs) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); expr->typeOid = InvalidOid; /* assume type checking done */ expr->opType = FUNC_EXPR; @@ -207,10 +207,10 @@ or_clause(Node * clause) * Creates an 'or' clause given a list of its subclauses. * */ -Expr * +Expr * make_orclause(List * orclauses) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); expr->typeOid = InvalidOid; /* assume type checking done */ expr->opType = OR_EXPR; @@ -243,10 +243,10 @@ not_clause(Node * clause) * Create a 'not' clause given the expression to be negated. * */ -Expr * +Expr * make_notclause(Expr * notclause) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); expr->typeOid = InvalidOid; /* assume type checking done */ expr->opType = NOT_EXPR; @@ -261,7 +261,7 @@ make_notclause(Expr * notclause) * Retrieve the clause within a 'not' clause * */ -Expr * +Expr * get_notclausearg(Expr * notclause) { return (lfirst(notclause->args)); @@ -292,10 +292,10 @@ and_clause(Node * clause) * Create an 'and' clause given its arguments in a list. * */ -Expr * +Expr * make_andclause(List * andclauses) { - Expr *expr = makeNode(Expr); + Expr *expr = makeNode(Expr); expr->typeOid = InvalidOid; /* assume type checking done */ expr->opType = AND_EXPR; @@ -320,12 +320,12 @@ make_andclause(List * andclauses) * quals as the return value. * */ -List * +List * pull_constant_clauses(List * quals, List ** constantQual) { - List *q; - List *constqual = NIL; - List *restqual = NIL; + List *q; + List *constqual = NIL; + List *restqual = NIL; foreach(q, quals) { @@ -358,15 +358,15 @@ pull_constant_clauses(List * quals, List ** constantQual) void clause_relids_vars(Node * clause, List ** relids, List ** vars) { - List *clvars = pull_var_clause(clause); - List *var_list = NIL; - List *varno_list = NIL; - List *i = NIL; + List *clvars = pull_var_clause(clause); + List *var_list = NIL; + List *varno_list = NIL; + List *i = NIL; foreach(i, clvars) { - Var *var = (Var *) lfirst(i); - List *vi; + Var *var = (Var *) lfirst(i); + List *vi; if (!intMember(var->varno, varno_list)) { @@ -374,7 +374,7 @@ clause_relids_vars(Node * clause, List ** relids, List ** vars) } foreach(vi, var_list) { - Var *in_list = (Var *) lfirst(vi); + Var *in_list = (Var *) lfirst(vi); if (in_list->varno == var->varno && in_list->varattno == var->varattno) @@ -398,13 +398,13 @@ clause_relids_vars(Node * clause, List ** relids, List ** vars) int NumRelids(Node * clause) { - List *vars = pull_var_clause(clause); - List *i = NIL; - List *var_list = NIL; + List *vars = pull_var_clause(clause); + List *i = NIL; + List *var_list = NIL; foreach(i, vars) { - Var *var = (Var *) lfirst(i); + Var *var = (Var *) lfirst(i); if (!intMember(var->varno, var_list)) { @@ -433,7 +433,7 @@ contains_not(Node * clause) if (or_clause(clause)) { - List *a; + List *a; foreach(a, ((Expr *) clause)->args) { @@ -454,8 +454,8 @@ contains_not(Node * clause) bool join_clause_p(Node * clause) { - Node *leftop, - *rightop; + Node *leftop, + *rightop; if (!is_opclause(clause)) return false; @@ -528,7 +528,7 @@ fix_opid(Node * clause) } else if (IsA(clause, ArrayRef)) { - ArrayRef *aref = (ArrayRef *) clause; + ArrayRef *aref = (ArrayRef *) clause; fix_opids(aref->refupperindexpr); fix_opids(aref->reflowerindexpr); @@ -559,10 +559,10 @@ fix_opid(Node * clause) * Returns its argument. * */ -List * +List * fix_opids(List * clauses) { - List *clause; + List *clause; foreach(clause, clauses) fix_opid(lfirst(clause)); @@ -601,8 +601,8 @@ get_relattval(Node * clause, Datum * constval, int *flag) { - Var *left = get_leftop((Expr *) clause); - Var *right = get_rightop((Expr *) clause); + Var *left = get_leftop((Expr *) clause); + Var *right = get_rightop((Expr *) clause); if (is_opclause(clause) && IsA(left, Var) && IsA(right, Const)) @@ -641,7 +641,7 @@ get_relattval(Node * clause, is_funcclause((Node *) left) && IsA(right, Const)) { - List *args = ((Expr *) left)->args; + List *args = ((Expr *) left)->args; *relid = ((Var *) lfirst(args))->varno; @@ -662,7 +662,7 @@ get_relattval(Node * clause, is_funcclause((Node *) right) && IsA(left, Const)) { - List *args = ((Expr *) right)->args; + List *args = ((Expr *) right)->args; *relid = ((Var *) lfirst(args))->varno; *attno = InvalidAttrNumber; @@ -732,13 +732,13 @@ get_rels_atts(Node * clause, int *relid2, AttrNumber * attno2) { - Var *left = get_leftop((Expr *) clause); - Var *right = get_rightop((Expr *) clause); - bool var_left = (IsA(left, Var)); - bool var_right = (IsA(right, Var)); - bool varexpr_left = (bool) ((IsA(left, Func) || IsA(left, Oper)) && - contain_var_clause((Node *) left)); - bool varexpr_right = (bool) ((IsA(right, Func) || IsA(right, Oper)) && + Var *left = get_leftop((Expr *) clause); + Var *right = get_rightop((Expr *) clause); + bool var_left = (IsA(left, Var)); + bool var_right = (IsA(right, Var)); + bool varexpr_left = (bool) ((IsA(left, Func) || IsA(left, Oper)) && + contain_var_clause((Node *) left)); + bool varexpr_right = (bool) ((IsA(right, Func) || IsA(right, Oper)) && contain_var_clause((Node *) right)); if (is_opclause(clause)) @@ -782,10 +782,10 @@ get_rels_atts(Node * clause, void CommuteClause(Node * clause) { - Node *temp; - Oper *commu; + Node *temp; + Oper *commu; OperatorTupleForm commuTup; - HeapTuple heapTup; + HeapTuple heapTup; if (!is_opclause(clause)) return; diff --git a/src/backend/optimizer/util/indexnode.c b/src/backend/optimizer/util/indexnode.c index e6a1902f8b9..9714038a8b6 100644 --- a/src/backend/optimizer/util/indexnode.c +++ b/src/backend/optimizer/util/indexnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.3 1997/09/07 04:44:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/indexnode.c,v 1.4 1997/09/08 02:24:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ #include "optimizer/pathnode.h" /* where the decls go */ -static List *find_secondary_index(Query * root, Oid relid); +static List *find_secondary_index(Query * root, Oid relid); /* * find-relation-indices-- @@ -32,7 +32,7 @@ static List *find_secondary_index(Query * root, Oid relid); * each (secondary) index defined on a relation. * */ -List * +List * find_relation_indices(Query * root, Rel * rel) { if (rel->indexed) @@ -56,16 +56,16 @@ find_relation_indices(Query * root, Rel * rel) * Returns a list of new index nodes. * */ -static List * +static List * find_secondary_index(Query * root, Oid relid) { - IdxInfoRetval indexinfo; - List *indexes = NIL; - bool first = TRUE; + IdxInfoRetval indexinfo; + List *indexes = NIL; + bool first = TRUE; while (index_info(root, first, relid, &indexinfo)) { - Rel *indexnode = makeNode(Rel); + Rel *indexnode = makeNode(Rel); indexnode->relids = lconsi(indexinfo.relid, NIL); indexnode->relam = indexinfo.relam; diff --git a/src/backend/optimizer/util/internal.c b/src/backend/optimizer/util/internal.c index d1af2062fce..31fe034dbb7 100644 --- a/src/backend/optimizer/util/internal.c +++ b/src/backend/optimizer/util/internal.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/internal.c,v 1.4 1997/09/07 04:44:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/internal.c,v 1.5 1997/09/08 02:24:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,17 +38,17 @@ /* the following should probably be moved elsewhere -ay */ -TargetEntry * +TargetEntry * MakeTLE(Resdom * resdom, Node * expr) { - TargetEntry *rt = makeNode(TargetEntry); + TargetEntry *rt = makeNode(TargetEntry); rt->resdom = resdom; rt->expr = expr; return rt; } -Var * +Var * get_expr(TargetEntry * tle) { Assert(tle != NULL); diff --git a/src/backend/optimizer/util/joininfo.c b/src/backend/optimizer/util/joininfo.c index cf206d80094..3f4f990a76f 100644 --- a/src/backend/optimizer/util/joininfo.c +++ b/src/backend/optimizer/util/joininfo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.3 1997/09/07 04:44:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/joininfo.c,v 1.4 1997/09/08 02:24:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,11 +35,11 @@ * exists. * */ -JInfo * +JInfo * joininfo_member(List * join_relids, List * joininfo_list) { - List *i = NIL; - List *other_rels = NIL; + List *i = NIL; + List *other_rels = NIL; foreach(i, joininfo_list) { @@ -61,11 +61,11 @@ joininfo_member(List * join_relids, List * joininfo_list) * Returns a joininfo node. * */ -JInfo * +JInfo * find_joininfo_node(Rel * this_rel, List * join_relids) { - JInfo *joininfo = joininfo_member(join_relids, - this_rel->joininfo); + JInfo *joininfo = joininfo_member(join_relids, + this_rel->joininfo); if (joininfo == NULL) { @@ -88,12 +88,12 @@ find_joininfo_node(Rel * this_rel, List * join_relids) * Returns the other var node in the joinclause if it is, nil if not. * */ -Var * +Var * other_join_clause_var(Var * var, Expr * clause) { - Var *retval; - Var *l, - *r; + Var *retval; + Var *l, + *r; retval = (Var *) NULL; diff --git a/src/backend/optimizer/util/keys.c b/src/backend/optimizer/util/keys.c index 0c3a3569eb5..82d8c6010b5 100644 --- a/src/backend/optimizer/util/keys.c +++ b/src/backend/optimizer/util/keys.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.3 1997/09/07 04:44:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/keys.c,v 1.4 1997/09/08 02:24:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,8 +22,8 @@ #include "optimizer/tlist.h" -static Expr *matching2_tlvar(int var, List * tlist, bool(*test) ()); -static bool equal_indexkey_var(int index_key, Var * var); +static Expr *matching2_tlvar(int var, List * tlist, bool(*test) ()); +static bool equal_indexkey_var(int index_key, Var * var); /* * 1. index key @@ -70,7 +70,7 @@ match_indexkey_operand(int indexkey, Var * operand, Rel * rel) * fields of var node 'var'. * */ -static bool +static bool equal_indexkey_var(int index_key, Var * var) { if (index_key == var->varattno) @@ -85,22 +85,22 @@ equal_indexkey_var(int index_key, Var * var) * lelation. * */ -Var * +Var * extract_subkey(JoinKey * jk, int which_subkey) { - Var *retval; + Var *retval; switch (which_subkey) { - case OUTER: - retval = jk->outer; - break; - case INNER: - retval = jk->inner; - break; - default: /* do nothing */ - elog(DEBUG, "extract_subkey with neither INNER or OUTER"); - retval = NULL; + case OUTER: + retval = jk->outer; + break; + case INNER: + retval = jk->inner; + break; + default: /* do nothing */ + elog(DEBUG, "extract_subkey with neither INNER or OUTER"); + retval = NULL; } return (retval); } @@ -120,9 +120,9 @@ extract_subkey(JoinKey * jk, int which_subkey) bool samekeys(List * keys1, List * keys2) { - bool allmember = true; - List *key1, - *key2; + bool allmember = true; + List *key1, + *key2; for (key1 = keys1, key2 = keys2; key1 != NIL && key2 != NIL; key1 = lnext(key1), key2 = lnext(key2)) @@ -152,14 +152,14 @@ samekeys(List * keys1, List * keys2) /* This function is identical to matching_tlvar and tlistentry_member. * They should be merged. */ -static Expr * +static Expr * matching2_tlvar(int var, List * tlist, bool(*test) ()) { - TargetEntry *tlentry = NULL; + TargetEntry *tlentry = NULL; if (var) { - List *temp; + List *temp; foreach(temp, tlist) { @@ -178,16 +178,16 @@ matching2_tlvar(int var, List * tlist, bool(*test) ()) } -List * +List * collect_index_pathkeys(int *index_keys, List * tlist) { - List *retval = NIL; + List *retval = NIL; Assert(index_keys != NULL); while (index_keys[0] != 0) { - Expr *mvar; + Expr *mvar; mvar = matching2_tlvar(index_keys[0], tlist, diff --git a/src/backend/optimizer/util/ordering.c b/src/backend/optimizer/util/ordering.c index 504d48bdce5..f14d3762183 100644 --- a/src/backend/optimizer/util/ordering.c +++ b/src/backend/optimizer/util/ordering.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.4 1997/09/07 04:44:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/Attic/ordering.c,v 1.5 1997/09/08 02:24:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,7 +18,7 @@ #include "optimizer/internal.h" #include "optimizer/ordering.h" -static bool equal_sortops_order(Oid * ordering1, Oid * ordering2); +static bool equal_sortops_order(Oid * ordering1, Oid * ordering2); /* * equal-path-path-ordering-- @@ -110,10 +110,10 @@ equal_merge_merge_ordering(MergeOrder * merge_ordering1, * equal_sort_ops_order - * Returns true iff the sort operators are in the same order. */ -static bool +static bool equal_sortops_order(Oid * ordering1, Oid * ordering2) { - int i = 0; + int i = 0; if (ordering1 == NULL || ordering2 == NULL) return (ordering1 == ordering2); diff --git a/src/backend/optimizer/util/pathnode.c b/src/backend/optimizer/util/pathnode.c index 6b37d2f36d4..f6242e852ab 100644 --- a/src/backend/optimizer/util/pathnode.c +++ b/src/backend/optimizer/util/pathnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.4 1997/09/07 04:44:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/pathnode.c,v 1.5 1997/09/08 02:24:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ #include "parser/parsetree.h" /* for getrelid() */ -static Path *better_path(Path * new_path, List * unique_paths, bool * noOther); +static Path *better_path(Path * new_path, List * unique_paths, bool * noOther); /***************************************************************************** @@ -44,8 +44,8 @@ static Path *better_path(Path * new_path, List * unique_paths, bool * noOther bool path_is_cheaper(Path * path1, Path * path2) { - Cost cost1 = path1->path_cost; - Cost cost2 = path2->path_cost; + Cost cost1 = path1->path_cost; + Cost cost2 = path2->path_cost; return ((bool) (cost1 < cost2)); } @@ -61,11 +61,11 @@ path_is_cheaper(Path * path1, Path * path2) * is minimum. * */ -Path * +Path * set_cheapest(Rel * parent_rel, List * pathlist) { - List *p; - Path *cheapest_so_far; + List *p; + Path *cheapest_so_far; Assert(pathlist != NIL); Assert(IsA(parent_rel, Rel)); @@ -74,7 +74,7 @@ set_cheapest(Rel * parent_rel, List * pathlist) foreach(p, lnext(pathlist)) { - Path *path = (Path *) lfirst(p); + Path *path = (Path *) lfirst(p); if (path_is_cheaper(path, cheapest_so_far)) { @@ -100,13 +100,13 @@ set_cheapest(Rel * parent_rel, List * pathlist) * Returns the list of unique pathnodes. * */ -List * +List * add_pathlist(Rel * parent_rel, List * unique_paths, List * new_paths) { - List *x; - Path *new_path; - Path *old_path; - bool noOther; + List *x; + Path *new_path; + Path *old_path; + bool noOther; foreach(x, new_paths) { @@ -153,13 +153,13 @@ add_pathlist(Rel * parent_rel, List * unique_paths, List * new_paths) * t - if there is no path in the list with the same ordering and keys * */ -static Path * +static Path * better_path(Path * new_path, List * unique_paths, bool * noOther) { - Path *old_path = (Path *) NULL; - Path *path = (Path *) NULL; - List *temp = NIL; - Path *retval = NULL; + Path *old_path = (Path *) NULL; + Path *path = (Path *) NULL; + List *temp = NIL; + Path *retval = NULL; /* * XXX - added the following two lines which weren't int the lisp @@ -207,12 +207,12 @@ better_path(Path * new_path, List * unique_paths, bool * noOther) * pathnode. * */ -Path * +Path * create_seqscan_path(Rel * rel) { - int relid = 0; + int relid = 0; - Path *pathnode = makeNode(Path); + Path *pathnode = makeNode(Path); pathnode->pathtype = T_SeqScan; pathnode->parent = rel; @@ -257,14 +257,14 @@ create_seqscan_path(Rel * rel) * Returns the new path node. * */ -IndexPath * +IndexPath * create_index_path(Query * root, Rel * rel, Rel * index, List * restriction_clauses, bool is_join_scan) { - IndexPath *pathnode = makeNode(IndexPath); + IndexPath *pathnode = makeNode(IndexPath); pathnode->path.pathtype = T_IndexScan; pathnode->path.parent = rel; @@ -344,12 +344,12 @@ create_index_path(Query * root, * Compute scan cost for the case when 'index' is used with a * restriction clause. */ - List *attnos; - List *values; - List *flags; - float npages; - float selec; - Cost clausesel; + List *attnos; + List *values; + List *flags; + float npages; + float selec; + Cost clausesel; get_relattvals(restriction_clauses, &attnos, @@ -417,14 +417,14 @@ create_index_path(Query * root, * Returns the resulting path node. * */ -JoinPath * +JoinPath * create_nestloop_path(Rel * joinrel, Rel * outer_rel, Path * outer_path, Path * inner_path, List * keys) { - JoinPath *pathnode = makeNode(JoinPath); + JoinPath *pathnode = makeNode(JoinPath); pathnode->path.pathtype = T_NestLoop; pathnode->path.parent = joinrel; @@ -494,7 +494,7 @@ create_nestloop_path(Rel * joinrel, * 'innersortkeys' are the sort varkeys for the inner relation * */ -MergePath * +MergePath * create_mergesort_path(Rel * joinrel, int outersize, int innersize, @@ -508,7 +508,7 @@ create_mergesort_path(Rel * joinrel, List * outersortkeys, List * innersortkeys) { - MergePath *pathnode = makeNode(MergePath); + MergePath *pathnode = makeNode(MergePath); pathnode->jpath.path.pathtype = T_MergeJoin; pathnode->jpath.path.parent = joinrel; @@ -560,7 +560,7 @@ create_mergesort_path(Rel * joinrel, * 'innerkeys' are the sort varkeys for the inner relation * */ -HashPath * +HashPath * create_hashjoin_path(Rel * joinrel, int outersize, int innersize, @@ -574,7 +574,7 @@ create_hashjoin_path(Rel * joinrel, List * outerkeys, List * innerkeys) { - HashPath *pathnode = makeNode(HashPath); + HashPath *pathnode = makeNode(HashPath); pathnode->jpath.path.pathtype = T_HashJoin; pathnode->jpath.path.parent = joinrel; diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index 0e88a72c4eb..0957775df0d 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.7 1997/09/07 04:44:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.8 1997/09/08 02:25:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -59,9 +59,9 @@ void relation_info(Query * root, Index relid, bool * hasindex, int *pages, int *tuples) { - HeapTuple relationTuple; - Form_pg_class relation; - Oid relationObjectId; + HeapTuple relationTuple; + Form_pg_class relation; + Oid relationObjectId; relationObjectId = getrelid(relid, root->rtable); relationTuple = SearchSysCacheTuple(RELOID, @@ -103,14 +103,14 @@ relation_info(Query * root, Index relid, bool index_info(Query * root, bool first, int relid, IdxInfoRetval * info) { - register i; - HeapTuple indexTuple, - amopTuple; - IndexTupleForm index; - Relation indexRelation; - uint16 amstrategy; - Oid relam; - Oid indrelid; + register i; + HeapTuple indexTuple, + amopTuple; + IndexTupleForm index; + Relation indexRelation; + uint16 amstrategy; + Oid relam; + Oid indrelid; static Relation relation = (Relation) NULL; static HeapScanDesc scan = (HeapScanDesc) NULL; @@ -183,7 +183,7 @@ index_info(Query * root, bool first, int relid, IdxInfoRetval * info) * which is all within a command, so the automatic pfree at end of * transaction should be ok. */ - char *predString; + char *predString; predString = fmgr(F_TEXTOUT, &index->indpred); info->indpred = (Node *) stringToNode(predString); @@ -256,15 +256,15 @@ index_selectivity(Oid indid, float *idxPages, float *idxSelec) { - Oid *opno_array; - int *attno_array, - *flag_array; - char **value_array; - int i = 0; - List *xopno, - *xattno, - *value, - *flag; + Oid *opno_array; + int *attno_array, + *flag_array; + char **value_array; + int i = 0; + List *xopno, + *xattno, + *value, + *flag; if (length(opnos) != nkeys || length(attnos) != nkeys || length(values) != nkeys || length(flags) != nkeys) @@ -339,7 +339,7 @@ restriction_selectivity(Oid functionObjectId, char *constValue, int32 constFlag) { - float64 result; + float64 result; result = (float64) fmgr(functionObjectId, (char *) operatorObjectId, @@ -378,7 +378,7 @@ join_selectivity(Oid functionObjectId, Oid relationObjectId2, AttrNumber attributeNumber2) { - float64 result; + float64 result; result = (float64) fmgr(functionObjectId, (char *) operatorObjectId, @@ -403,18 +403,18 @@ join_selectivity(Oid functionObjectId, * Returns a LISP list containing the OIDs of all relations which * inherits from the relation with OID 'inhparent'. */ -List * +List * find_inheritance_children(Oid inhparent) { static ScanKeyData key[1] = { {0, Anum_pg_inherits_inhparent, F_OIDEQ} }; - HeapTuple inheritsTuple; - Relation relation; - HeapScanDesc scan; - List *list = NIL; - Oid inhrelid; + HeapTuple inheritsTuple; + Relation relation; + HeapScanDesc scan; + List *list = NIL; + Oid inhrelid; fmgr_info(F_OIDEQ, &key[0].sk_func, &key[0].sk_nargs); @@ -439,18 +439,18 @@ find_inheritance_children(Oid inhparent) * Returns a LISP list containing the OIDs of all relations which are * base relations of the relation with OID 'verrelid'. */ -List * +List * VersionGetParents(Oid verrelid) { static ScanKeyData key[1] = { {0, Anum_pg_version_verrelid, F_OIDEQ} }; - HeapTuple versionTuple; - Relation relation; - HeapScanDesc scan; - Oid verbaseid; - List *list = NIL; + HeapTuple versionTuple; + Relation relation; + HeapScanDesc scan; + Oid verbaseid; + List *list = NIL; fmgr_info(F_OIDEQ, &key[0].sk_func, &key[0].sk_nargs); relation = heap_openr(VersionRelationName); @@ -512,21 +512,21 @@ IndexSelectivity(Oid indexrelid, float *idxPages, float *idxSelec) { - register i, - n; - HeapTuple indexTuple, - amopTuple, - indRel; - IndexTupleForm index; - Form_pg_amop amop; - Oid indclass; - float64data npages, - select; - float64 amopnpages, - amopselect; - Oid relam; - bool nphack = false; - float64data fattr_select = 1.0; + register i, + n; + HeapTuple indexTuple, + amopTuple, + indRel; + IndexTupleForm index; + Form_pg_amop amop; + Oid indclass; + float64data npages, + select; + float64 amopnpages, + amopselect; + Oid relam; + bool nphack = false; + float64data fattr_select = 1.0; indRel = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid), diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 229dff98092..98f3de94399 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.2 1997/09/07 04:44:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.3 1997/09/08 02:25:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,11 +27,11 @@ * necessary. This is for base relations. * */ -Rel * +Rel * get_base_rel(Query * root, int relid) { - List *relids; - Rel *rel; + List *relids; + Rel *rel; relids = lconsi(relid, NIL); rel = rel_member(relids, root->base_relation_list_); @@ -77,9 +77,9 @@ get_base_rel(Query * root, int relid) } else { - bool hasindex; - int pages, - tuples; + bool hasindex; + int pages, + tuples; /* * Otherwise, retrieve relation characteristics from the @@ -100,7 +100,7 @@ get_base_rel(Query * root, int relid) * creating a new one if necessary. This is for join relations. * */ -Rel * +Rel * get_join_rel(Query * root, List * relid) { return rel_member(relid, root->join_relation_list_); @@ -114,11 +114,11 @@ get_join_rel(Query * root, List * relid) * Returns the corresponding entry in 'rels' if it is there. * */ -Rel * +Rel * rel_member(List * relid, List * rels) { - List *temp = NIL; - List *temprelid = NIL; + List *temp = NIL; + List *temprelid = NIL; if (relid != NIL && rels != NIL) { diff --git a/src/backend/optimizer/util/tlist.c b/src/backend/optimizer/util/tlist.c index 7e8563d31ab..d9307e6d5bb 100644 --- a/src/backend/optimizer/util/tlist.c +++ b/src/backend/optimizer/util/tlist.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.5 1997/09/07 04:44:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/tlist.c,v 1.6 1997/09/08 02:25:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ #include "nodes/makefuncs.h" #include "parser/catalog_utils.h" -static Node *flatten_tlistentry(Node * tlistentry, List * flat_tlist); +static Node *flatten_tlistentry(Node * tlistentry, List * flat_tlist); /***************************************************************************** * ---------- RELATION node target list routines ---------- @@ -44,12 +44,12 @@ static Node *flatten_tlistentry(Node * tlistentry, List * flat_tlist); * var = valid var-node * targetlist = valid sequence */ -TargetEntry * +TargetEntry * tlistentry_member(Var * var, List * targetlist) { if (var) { - List *temp = NIL; + List *temp = NIL; foreach(temp, targetlist) { @@ -69,10 +69,10 @@ tlistentry_member(Var * var, List * targetlist) * REQUIRES: "test" operates on lispval unions, * */ -Expr * +Expr * matching_tlvar(Var * var, List * targetlist) { - TargetEntry *tlentry; + TargetEntry *tlentry; tlentry = tlistentry_member(var, targetlist); if (tlentry) @@ -96,7 +96,7 @@ matching_tlvar(Var * var, List * targetlist) void add_tl_element(Rel * rel, Var * var) { - Expr *oldvar = (Expr *) NULL; + Expr *oldvar = (Expr *) NULL; oldvar = matching_tlvar(var, rel->targetlist); @@ -105,12 +105,12 @@ add_tl_element(Rel * rel, Var * var) */ if (oldvar == NULL) { - List *tlist = rel->targetlist; - Var *newvar = makeVar(var->varno, - var->varattno, - var->vartype, - var->varno, - var->varoattno); + List *tlist = rel->targetlist; + Var *newvar = makeVar(var->varno, + var->varattno, + var->vartype, + var->varno, + var->varoattno); rel->targetlist = lappend(tlist, @@ -129,10 +129,10 @@ add_tl_element(Rel * rel, Var * var) * RETURNS: newly created tlist-entry * CREATES: new targetlist entry (always). */ -TargetEntry * +TargetEntry * create_tl_element(Var * var, int resdomno) { - TargetEntry *tlelement = makeNode(TargetEntry); + TargetEntry *tlelement = makeNode(TargetEntry); tlelement->resdom = makeResdom(resdomno, @@ -152,7 +152,7 @@ create_tl_element(Var * var, int resdomno) * Returns the targetlist elements from a relation tlist. * */ -List * +List * get_actual_tlist(List * tlist) { @@ -160,8 +160,8 @@ get_actual_tlist(List * tlist) * this function is not making sense. - ay 10/94 */ #if 0 - List *element = NIL; - List *result = NIL; + List *element = NIL; + List *result = NIL; if (tlist == NULL) { @@ -199,12 +199,12 @@ get_actual_tlist(List * tlist) * Returns the resdom entry of the matching var node. * */ -Resdom * +Resdom * tlist_member(Var * var, List * tlist) { - List *i = NIL; - TargetEntry *temp_tle = (TargetEntry *) NULL; - TargetEntry *tl_elt = (TargetEntry *) NULL; + List *i = NIL; + TargetEntry *temp_tle = (TargetEntry *) NULL; + TargetEntry *tl_elt = (TargetEntry *) NULL; if (var) { @@ -229,12 +229,12 @@ tlist_member(Var * var, List * tlist) /* * Routine to get the resdom out of a targetlist. */ -Resdom * +Resdom * tlist_resdom(List * tlist, Resdom * resnode) { - Resdom *resdom = (Resdom *) NULL; - List *i = NIL; - TargetEntry *temp_tle = (TargetEntry *) NULL; + Resdom *resdom = (Resdom *) NULL; + List *i = NIL; + TargetEntry *temp_tle = (TargetEntry *) NULL; foreach(i, tlist) { @@ -264,18 +264,18 @@ tlist_resdom(List * tlist, Resdom * resnode) * [what used to be varid is now broken up into two fields varnoold and * varoattno. Also, nested attnos are long gone. - ay 2/95] */ -TargetEntry * +TargetEntry * match_varid(Var * test_var, List * tlist) { - List *tl; - Oid type_var; + List *tl; + Oid type_var; type_var = (Oid) test_var->vartype; foreach(tl, tlist) { - TargetEntry *entry; - Var *tlvar; + TargetEntry *entry; + Var *tlvar; entry = lfirst(tl); tlvar = get_expr(entry); @@ -310,15 +310,15 @@ match_varid(Var * test_var, List * tlist) * Returns the resulting target list. * */ -List * +List * new_unsorted_tlist(List * targetlist) { - List *new_targetlist = (List *) copyObject((Node *) targetlist); - List *x = NIL; + List *new_targetlist = (List *) copyObject((Node *) targetlist); + List *x = NIL; foreach(x, new_targetlist) { - TargetEntry *tle = (TargetEntry *) lfirst(x); + TargetEntry *tle = (TargetEntry *) lfirst(x); tle->resdom->reskey = 0; tle->resdom->reskeyop = (Oid) 0; @@ -338,18 +338,18 @@ new_unsorted_tlist(List * targetlist) * Returns a new target list. * */ -List * +List * copy_vars(List * target, List * source) { - List *result = NIL; - List *src = NIL; - List *dest = NIL; + List *result = NIL; + List *src = NIL; + List *dest = NIL; for (src = source, dest = target; src != NIL && dest != NIL; src = lnext(src), dest = lnext(dest)) { - TargetEntry *temp = MakeTLE(((TargetEntry *) lfirst(dest))->resdom, - (Node *) get_expr(lfirst(src))); + TargetEntry *temp = MakeTLE(((TargetEntry *) lfirst(dest))->resdom, + (Node *) get_expr(lfirst(src))); result = lappend(result, temp); } @@ -366,18 +366,18 @@ copy_vars(List * target, List * source) * Returns the "flattened" new target list. * */ -List * +List * flatten_tlist(List * tlist) { - int last_resdomno = 1; - List *new_tlist = NIL; - List *tlist_vars = NIL; - List *temp; + int last_resdomno = 1; + List *new_tlist = NIL; + List *tlist_vars = NIL; + List *temp; foreach(temp, tlist) { - TargetEntry *temp_entry = NULL; - List *vars; + TargetEntry *temp_entry = NULL; + List *vars; temp_entry = lfirst(temp); vars = pull_var_clause((Node *) get_expr(temp_entry)); @@ -389,11 +389,11 @@ flatten_tlist(List * tlist) foreach(temp, tlist_vars) { - Var *var = lfirst(temp); + Var *var = lfirst(temp); if (!(tlist_member(var, new_tlist))) { - Resdom *r; + Resdom *r; r = makeResdom(last_resdomno, var->vartype, @@ -422,15 +422,15 @@ flatten_tlist(List * tlist) * Returns the modified actual target list. * */ -List * +List * flatten_tlist_vars(List * full_tlist, List * flat_tlist) { - List *x = NIL; - List *result = NIL; + List *x = NIL; + List *result = NIL; foreach(x, full_tlist) { - TargetEntry *tle = lfirst(x); + TargetEntry *tle = lfirst(x); result = lappend(result, @@ -453,7 +453,7 @@ flatten_tlist_vars(List * full_tlist, List * flat_tlist) * Returns the (modified) target_list entry from the target list. * */ -static Node * +static Node * flatten_tlistentry(Node * tlistentry, List * flat_tlist) { if (tlistentry == NULL) @@ -486,9 +486,9 @@ flatten_tlistentry(Node * tlistentry, List * flat_tlist) } else if (is_funcclause(tlistentry)) { - Expr *expr = (Expr *) tlistentry; - List *temp_result = NIL; - List *elt = NIL; + Expr *expr = (Expr *) tlistentry; + List *temp_result = NIL; + List *elt = NIL; foreach(elt, expr->args) temp_result = lappend(temp_result, @@ -506,9 +506,9 @@ flatten_tlistentry(Node * tlistentry, List * flat_tlist) } else if (IsA(tlistentry, ArrayRef)) { - ArrayRef *aref = (ArrayRef *) tlistentry; - List *temp = NIL; - List *elt = NIL; + ArrayRef *aref = (ArrayRef *) tlistentry; + List *temp = NIL; + List *elt = NIL; foreach(elt, aref->refupperindexpr) temp = lappend(temp, flatten_tlistentry(lfirst(elt), flat_tlist)); @@ -529,11 +529,11 @@ flatten_tlistentry(Node * tlistentry, List * flat_tlist) } else { - Expr *expr = (Expr *) tlistentry; - Var *left = + Expr *expr = (Expr *) tlistentry; + Var *left = (Var *) flatten_tlistentry((Node *) get_leftop(expr), flat_tlist); - Var *right = + Var *right = (Var *) flatten_tlistentry((Node *) get_rightop(expr), flat_tlist); @@ -543,17 +543,17 @@ flatten_tlistentry(Node * tlistentry, List * flat_tlist) } -TargetEntry * +TargetEntry * MakeTLE(Resdom * resdom, Node * expr) { - TargetEntry *rt = makeNode(TargetEntry); + TargetEntry *rt = makeNode(TargetEntry); rt->resdom = resdom; rt->expr = expr; return rt; } -Var * +Var * get_expr(TargetEntry * tle) { Assert(tle != NULL); @@ -576,17 +576,17 @@ get_expr(TargetEntry * tle) void AddGroupAttrToTlist(List * tlist, List * grpCl) { - List *gl; - int last_resdomno = length(tlist) + 1; + List *gl; + int last_resdomno = length(tlist) + 1; foreach(gl, grpCl) { - GroupClause *gc = (GroupClause *) lfirst(gl); - Var *var = gc->grpAttr; + GroupClause *gc = (GroupClause *) lfirst(gl); + Var *var = gc->grpAttr; if (!(tlist_member(var, tlist))) { - Resdom *r; + Resdom *r; r = makeResdom(last_resdomno, var->vartype, @@ -608,9 +608,9 @@ AddGroupAttrToTlist(List * tlist, List * grpCl) int exec_tlist_length(List * targetlist) { - int len; - List *tl; - TargetEntry *curTle; + int len; + List *tl; + TargetEntry *curTle; len = 0; foreach(tl, targetlist) diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index 40abf5f80cb..e01720aa2e8 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.4 1997/09/07 04:44:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.5 1997/09/08 02:25:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,35 +34,35 @@ * XXX assumes varno's are always integers, which shouldn't be true... * (though it currently is, see primnodes.h) */ -List * +List * pull_varnos(Node * me) { - List *i, - *result = NIL; + List *i, + *result = NIL; if (me == NULL) return (NIL); switch (nodeTag(me)) { - case T_List: - foreach(i, (List *) me) - { - result = nconc(result, pull_varnos(lfirst(i))); - } - break; - case T_ArrayRef: - foreach(i, ((ArrayRef *) me)->refupperindexpr) - result = nconc(result, pull_varnos(lfirst(i))); - foreach(i, ((ArrayRef *) me)->reflowerindexpr) - result = nconc(result, pull_varnos(lfirst(i))); - result = nconc(result, pull_varnos(((ArrayRef *) me)->refassgnexpr)); - break; - case T_Var: - result = lconsi(((Var *) me)->varno, NIL); - break; - default: - break; + case T_List: + foreach(i, (List *) me) + { + result = nconc(result, pull_varnos(lfirst(i))); + } + break; + case T_ArrayRef: + foreach(i, ((ArrayRef *) me)->refupperindexpr) + result = nconc(result, pull_varnos(lfirst(i))); + foreach(i, ((ArrayRef *) me)->reflowerindexpr) + result = nconc(result, pull_varnos(lfirst(i))); + result = nconc(result, pull_varnos(((ArrayRef *) me)->refassgnexpr)); + break; + case T_Var: + result = lconsi(((Var *) me)->varno, NIL); + break; + default: + break; } return (result); } @@ -87,7 +87,7 @@ contain_var_clause(Node * clause) return FALSE; else if (or_clause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) { @@ -98,7 +98,7 @@ contain_var_clause(Node * clause) } else if (is_funcclause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) { @@ -109,7 +109,7 @@ contain_var_clause(Node * clause) } else if (IsA(clause, ArrayRef)) { - List *temp; + List *temp; foreach(temp, ((ArrayRef *) clause)->refupperindexpr) { @@ -143,10 +143,10 @@ contain_var_clause(Node * clause) * * Returns list of varnodes found. */ -List * +List * pull_var_clause(Node * clause) { - List *retval = NIL; + List *retval = NIL; if (clause == NULL) return (NIL); @@ -158,14 +158,14 @@ pull_var_clause(Node * clause) retval = NIL; else if (or_clause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) retval = nconc(retval, pull_var_clause(lfirst(temp))); } else if (is_funcclause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) retval = nconc(retval, pull_var_clause(lfirst(temp))); @@ -176,7 +176,7 @@ pull_var_clause(Node * clause) } else if (IsA(clause, ArrayRef)) { - List *temp; + List *temp; foreach(temp, ((ArrayRef *) clause)->refupperindexpr) retval = nconc(retval, pull_var_clause(lfirst(temp))); diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 8f63522812e..c796c74b1ad 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.39 1997/09/07 04:44:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.40 1997/09/08 02:25:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,54 +44,54 @@ #include "port-protos.h" /* strdup() */ /* convert the parse tree into a query tree */ -static Query *transformStmt(ParseState * pstate, Node * stmt); - -static Query *transformDeleteStmt(ParseState * pstate, DeleteStmt * stmt); -static Query *transformInsertStmt(ParseState * pstate, AppendStmt * stmt); -static Query *transformIndexStmt(ParseState * pstate, IndexStmt * stmt); -static Query *transformExtendStmt(ParseState * pstate, ExtendStmt * stmt); -static Query *transformRuleStmt(ParseState * query, RuleStmt * stmt); -static Query *transformSelectStmt(ParseState * pstate, RetrieveStmt * stmt); -static Query *transformUpdateStmt(ParseState * pstate, ReplaceStmt * stmt); -static Query *transformCursorStmt(ParseState * pstate, CursorStmt * stmt); -static Node *handleNestedDots(ParseState * pstate, Attr * attr, int *curr_resno); +static Query *transformStmt(ParseState * pstate, Node * stmt); + +static Query *transformDeleteStmt(ParseState * pstate, DeleteStmt * stmt); +static Query *transformInsertStmt(ParseState * pstate, AppendStmt * stmt); +static Query *transformIndexStmt(ParseState * pstate, IndexStmt * stmt); +static Query *transformExtendStmt(ParseState * pstate, ExtendStmt * stmt); +static Query *transformRuleStmt(ParseState * query, RuleStmt * stmt); +static Query *transformSelectStmt(ParseState * pstate, RetrieveStmt * stmt); +static Query *transformUpdateStmt(ParseState * pstate, ReplaceStmt * stmt); +static Query *transformCursorStmt(ParseState * pstate, CursorStmt * stmt); +static Node *handleNestedDots(ParseState * pstate, Attr * attr, int *curr_resno); #define EXPR_COLUMN_FIRST 1 #define EXPR_RELATION_FIRST 2 -static Node *transformExpr(ParseState * pstate, Node * expr, int precedence); -static Node *transformIdent(ParseState * pstate, Node * expr, int precedence); - -static void makeRangeTable(ParseState * pstate, char *relname, List * frmList); -static List *expandAllTables(ParseState * pstate); -static char *figureColname(Node * expr, Node * resval); -static List *makeTargetNames(ParseState * pstate, List * cols); -static List *transformTargetList(ParseState * pstate, List * targetlist); +static Node *transformExpr(ParseState * pstate, Node * expr, int precedence); +static Node *transformIdent(ParseState * pstate, Node * expr, int precedence); + +static void makeRangeTable(ParseState * pstate, char *relname, List * frmList); +static List *expandAllTables(ParseState * pstate); +static char *figureColname(Node * expr, Node * resval); +static List *makeTargetNames(ParseState * pstate, List * cols); +static List *transformTargetList(ParseState * pstate, List * targetlist); static TargetEntry * make_targetlist_expr(ParseState * pstate, char *colname, Node * expr, List * arrayRef); -static bool inWhereClause = false; -static Node *transformWhereClause(ParseState * pstate, Node * a_expr); -static List * +static bool inWhereClause = false; +static Node *transformWhereClause(ParseState * pstate, Node * a_expr); +static List * transformGroupClause(ParseState * pstate, List * grouplist, List * targetlist); -static List * +static List * transformSortClause(ParseState * pstate, List * orderlist, List * targetlist, char *uniqueFlag); -static void parseFromClause(ParseState * pstate, List * frmList); -static Node * +static void parseFromClause(ParseState * pstate, List * frmList); +static Node * ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno); -static List *setup_tlist(char *attname, Oid relid); -static List *setup_base_tlist(Oid typeid); +static List *setup_tlist(char *attname, Oid relid); +static List *setup_base_tlist(Oid typeid); static void make_arguments(int nargs, List * fargs, Oid * input_typeids, Oid * function_typeids); -static void AddAggToParseState(ParseState * pstate, Aggreg * aggreg); -static void finalizeAggregates(ParseState * pstate, Query * qry); -static void parseCheckAggregates(ParseState * pstate, Query * qry); +static void AddAggToParseState(ParseState * pstate, Aggreg * aggreg); +static void finalizeAggregates(ParseState * pstate, Query * qry); +static void parseCheckAggregates(ParseState * pstate, Query * qry); static ParseState *makeParseState(void); /***************************************************************************** @@ -108,7 +108,7 @@ static ParseState *makeParseState(void); static ParseState * makeParseState(void) { - ParseState *pstate; + ParseState *pstate; pstate = malloc(sizeof(ParseState)); pstate->p_last_resno = 1; @@ -134,12 +134,12 @@ makeParseState(void) * * CALLER is responsible for freeing the QueryTreeList* returned */ -QueryTreeList * +QueryTreeList * parse_analyze(List * pl) { - QueryTreeList *result; - ParseState *pstate; - int i = 0; + QueryTreeList *result; + ParseState *pstate; + int i = 0; result = malloc(sizeof(QueryTreeList)); result->len = length(pl); @@ -165,102 +165,103 @@ parse_analyze(List * pl) * transform a Parse tree. If it is an optimizable statement, turn it * into a Query tree. */ -static Query * +static Query * transformStmt(ParseState * pstate, Node * parseTree) { - Query *result = NULL; + Query *result = NULL; switch (nodeTag(parseTree)) { - /*------------------------ - * Non-optimizable statements - *------------------------ - */ - case T_IndexStmt: - result = transformIndexStmt(pstate, (IndexStmt *) parseTree); - break; + /*------------------------ + * Non-optimizable statements + *------------------------ + */ + case T_IndexStmt: + result = transformIndexStmt(pstate, (IndexStmt *) parseTree); + break; - case T_ExtendStmt: - result = transformExtendStmt(pstate, (ExtendStmt *) parseTree); - break; + case T_ExtendStmt: + result = transformExtendStmt(pstate, (ExtendStmt *) parseTree); + break; - case T_RuleStmt: - result = transformRuleStmt(pstate, (RuleStmt *) parseTree); - break; + case T_RuleStmt: + result = transformRuleStmt(pstate, (RuleStmt *) parseTree); + break; - case T_ViewStmt: - { - ViewStmt *n = (ViewStmt *) parseTree; + case T_ViewStmt: + { + ViewStmt *n = (ViewStmt *) parseTree; - n->query = (Query *) transformStmt(pstate, (Node *) n->query); - result = makeNode(Query); - result->commandType = CMD_UTILITY; - result->utilityStmt = (Node *) n; - } - break; + n->query = (Query *) transformStmt(pstate, (Node *) n->query); + result = makeNode(Query); + result->commandType = CMD_UTILITY; + result->utilityStmt = (Node *) n; + } + break; - case T_VacuumStmt: - { - MemoryContext oldcontext; + case T_VacuumStmt: + { + MemoryContext oldcontext; - /* - * make sure that this Query is allocated in TopMemory context - * because vacuum spans transactions and we don't want to lose - * the vacuum Query due to end-of-transaction free'ing - */ - oldcontext = MemoryContextSwitchTo(TopMemoryContext); - result = makeNode(Query); - result->commandType = CMD_UTILITY; - result->utilityStmt = (Node *) parseTree; - MemoryContextSwitchTo(oldcontext); - break; + /* + * make sure that this Query is allocated in TopMemory + * context because vacuum spans transactions and we don't + * want to lose the vacuum Query due to end-of-transaction + * free'ing + */ + oldcontext = MemoryContextSwitchTo(TopMemoryContext); + result = makeNode(Query); + result->commandType = CMD_UTILITY; + result->utilityStmt = (Node *) parseTree; + MemoryContextSwitchTo(oldcontext); + break; - } - case T_ExplainStmt: - { - ExplainStmt *n = (ExplainStmt *) parseTree; + } + case T_ExplainStmt: + { + ExplainStmt *n = (ExplainStmt *) parseTree; - result = makeNode(Query); - result->commandType = CMD_UTILITY; - n->query = transformStmt(pstate, (Node *) n->query); - result->utilityStmt = (Node *) parseTree; - } - break; + result = makeNode(Query); + result->commandType = CMD_UTILITY; + n->query = transformStmt(pstate, (Node *) n->query); + result->utilityStmt = (Node *) parseTree; + } + break; - /*------------------------ - * Optimizable statements - *------------------------ - */ - case T_AppendStmt: - result = transformInsertStmt(pstate, (AppendStmt *) parseTree); - break; + /*------------------------ + * Optimizable statements + *------------------------ + */ + case T_AppendStmt: + result = transformInsertStmt(pstate, (AppendStmt *) parseTree); + break; - case T_DeleteStmt: - result = transformDeleteStmt(pstate, (DeleteStmt *) parseTree); - break; + case T_DeleteStmt: + result = transformDeleteStmt(pstate, (DeleteStmt *) parseTree); + break; - case T_ReplaceStmt: - result = transformUpdateStmt(pstate, (ReplaceStmt *) parseTree); - break; + case T_ReplaceStmt: + result = transformUpdateStmt(pstate, (ReplaceStmt *) parseTree); + break; - case T_CursorStmt: - result = transformCursorStmt(pstate, (CursorStmt *) parseTree); - break; + case T_CursorStmt: + result = transformCursorStmt(pstate, (CursorStmt *) parseTree); + break; - case T_RetrieveStmt: - result = transformSelectStmt(pstate, (RetrieveStmt *) parseTree); - break; + case T_RetrieveStmt: + result = transformSelectStmt(pstate, (RetrieveStmt *) parseTree); + break; - default: + default: - /* - * other statments don't require any transformation-- just return - * the original parsetree - */ - result = makeNode(Query); - result->commandType = CMD_UTILITY; - result->utilityStmt = (Node *) parseTree; - break; + /* + * other statments don't require any transformation-- just + * return the original parsetree + */ + result = makeNode(Query); + result->commandType = CMD_UTILITY; + result->utilityStmt = (Node *) parseTree; + break; } return result; } @@ -269,10 +270,10 @@ transformStmt(ParseState * pstate, Node * parseTree) * transformDeleteStmt - * transforms a Delete Statement */ -static Query * +static Query * transformDeleteStmt(ParseState * pstate, DeleteStmt * stmt) { - Query *qry = makeNode(Query); + Query *qry = makeNode(Query); qry->commandType = CMD_DELETE; @@ -298,10 +299,10 @@ transformDeleteStmt(ParseState * pstate, DeleteStmt * stmt) * transformInsertStmt - * transform an Insert Statement */ -static Query * +static Query * transformInsertStmt(ParseState * pstate, AppendStmt * stmt) { - Query *qry = makeNode(Query); /* make a new query tree */ + Query *qry = makeNode(Query); /* make a new query tree */ qry->commandType = CMD_INSERT; pstate->p_is_insert = true; @@ -333,10 +334,10 @@ transformInsertStmt(ParseState * pstate, AppendStmt * stmt) * transformIndexStmt - * transforms the qualification of the index statement */ -static Query * +static Query * transformIndexStmt(ParseState * pstate, IndexStmt * stmt) { - Query *q; + Query *q; q = makeNode(Query); q->commandType = CMD_UTILITY; @@ -355,10 +356,10 @@ transformIndexStmt(ParseState * pstate, IndexStmt * stmt) * transform the qualifications of the Extend Index Statement * */ -static Query * +static Query * transformExtendStmt(ParseState * pstate, ExtendStmt * stmt) { - Query *q; + Query *q; q = makeNode(Query); q->commandType = CMD_UTILITY; @@ -376,11 +377,11 @@ transformExtendStmt(ParseState * pstate, ExtendStmt * stmt) * transform a Create Rule Statement. The actions is a list of parse * trees which is transformed into a list of query trees. */ -static Query * +static Query * transformRuleStmt(ParseState * pstate, RuleStmt * stmt) { - Query *q; - List *actions; + Query *q; + List *actions; q = makeNode(Query); q->commandType = CMD_UTILITY; @@ -424,10 +425,10 @@ transformRuleStmt(ParseState * pstate, RuleStmt * stmt) * transforms a Select Statement * */ -static Query * +static Query * transformSelectStmt(ParseState * pstate, RetrieveStmt * stmt) { - Query *qry = makeNode(Query); + Query *qry = makeNode(Query); qry->commandType = CMD_SELECT; @@ -476,10 +477,10 @@ transformSelectStmt(ParseState * pstate, RetrieveStmt * stmt) * transforms an update statement * */ -static Query * +static Query * transformUpdateStmt(ParseState * pstate, ReplaceStmt * stmt) { - Query *qry = makeNode(Query); + Query *qry = makeNode(Query); qry->commandType = CMD_UPDATE; pstate->p_is_update = true; @@ -511,10 +512,10 @@ transformUpdateStmt(ParseState * pstate, ReplaceStmt * stmt) * transform a Create Cursor Statement * */ -static Query * +static Query * transformCursorStmt(ParseState * pstate, CursorStmt * stmt) { - Query *qry = makeNode(Query); + Query *qry = makeNode(Query); /* * in the old days, a cursor statement is a 'retrieve into portal'; If @@ -569,239 +570,240 @@ transformCursorStmt(ParseState * pstate, CursorStmt * stmt) * (raw) expressions collected by the parse tree. Hence the transformation * here. */ -static Node * +static Node * transformExpr(ParseState * pstate, Node * expr, int precedence) { - Node *result = NULL; + Node *result = NULL; if (expr == NULL) return NULL; switch (nodeTag(expr)) { - case T_Attr: - { - Attr *att = (Attr *) expr; - Node *temp; - - /* what if att.attrs == "*"?? */ - temp = handleNestedDots(pstate, att, &pstate->p_last_resno); - if (att->indirection != NIL) + case T_Attr: { - List *idx = att->indirection; + Attr *att = (Attr *) expr; + Node *temp; - while (idx != NIL) + /* what if att.attrs == "*"?? */ + temp = handleNestedDots(pstate, att, &pstate->p_last_resno); + if (att->indirection != NIL) { - A_Indices *ai = (A_Indices *) lfirst(idx); - Node *lexpr = NULL, - *uexpr; + List *idx = att->indirection; - uexpr = transformExpr(pstate, ai->uidx, precedence); /* must exists */ - if (exprType(uexpr) != INT4OID) - elog(WARN, "array index expressions must be int4's"); - if (ai->lidx != NULL) + while (idx != NIL) { - lexpr = transformExpr(pstate, ai->lidx, precedence); - if (exprType(lexpr) != INT4OID) + A_Indices *ai = (A_Indices *) lfirst(idx); + Node *lexpr = NULL, + *uexpr; + + uexpr = transformExpr(pstate, ai->uidx, precedence); /* must exists */ + if (exprType(uexpr) != INT4OID) elog(WARN, "array index expressions must be int4's"); - } + if (ai->lidx != NULL) + { + lexpr = transformExpr(pstate, ai->lidx, precedence); + if (exprType(lexpr) != INT4OID) + elog(WARN, "array index expressions must be int4's"); + } #if 0 - pfree(ai->uidx); - if (ai->lidx != NULL) - pfree(ai->lidx); + pfree(ai->uidx); + if (ai->lidx != NULL) + pfree(ai->lidx); #endif - ai->lidx = lexpr; - ai->uidx = uexpr; + ai->lidx = lexpr; + ai->uidx = uexpr; - /* - * note we reuse the list of indices, make sure we - * don't free them! Otherwise, make a new list here - */ - idx = lnext(idx); + /* + * note we reuse the list of indices, make sure we + * don't free them! Otherwise, make a new list + * here + */ + idx = lnext(idx); + } + result = (Node *) make_array_ref(temp, att->indirection); + } + else + { + result = temp; } - result = (Node *) make_array_ref(temp, att->indirection); + break; } - else + case T_A_Const: { - result = temp; - } - break; - } - case T_A_Const: - { - A_Const *con = (A_Const *) expr; - Value *val = &con->val; + A_Const *con = (A_Const *) expr; + Value *val = &con->val; - if (con->typename != NULL) - { - result = parser_typecast(val, con->typename, -1); + if (con->typename != NULL) + { + result = parser_typecast(val, con->typename, -1); + } + else + { + result = (Node *) make_const(val); + } + break; } - else + case T_ParamNo: { - result = (Node *) make_const(val); + ParamNo *pno = (ParamNo *) expr; + Oid toid; + int paramno; + Param *param; + + paramno = pno->number; + toid = param_type(paramno); + if (!OidIsValid(toid)) + { + elog(WARN, "Parameter '$%d' is out of range", + paramno); + } + param = makeNode(Param); + param->paramkind = PARAM_NUM; + param->paramid = (AttrNumber) paramno; + param->paramname = "<unnamed>"; + param->paramtype = (Oid) toid; + param->param_tlist = (List *) NULL; + + result = (Node *) param; + break; } - break; - } - case T_ParamNo: - { - ParamNo *pno = (ParamNo *) expr; - Oid toid; - int paramno; - Param *param; - - paramno = pno->number; - toid = param_type(paramno); - if (!OidIsValid(toid)) + case T_A_Expr: { - elog(WARN, "Parameter '$%d' is out of range", - paramno); - } - param = makeNode(Param); - param->paramkind = PARAM_NUM; - param->paramid = (AttrNumber) paramno; - param->paramname = "<unnamed>"; - param->paramtype = (Oid) toid; - param->param_tlist = (List *) NULL; - - result = (Node *) param; - break; - } - case T_A_Expr: - { - A_Expr *a = (A_Expr *) expr; + A_Expr *a = (A_Expr *) expr; - switch (a->oper) - { - case OP: + switch (a->oper) { - Node *lexpr = transformExpr(pstate, a->lexpr, precedence); - Node *rexpr = transformExpr(pstate, a->rexpr, precedence); + case OP: + { + Node *lexpr = transformExpr(pstate, a->lexpr, precedence); + Node *rexpr = transformExpr(pstate, a->rexpr, precedence); - result = (Node *) make_op(a->opname, lexpr, rexpr); - } - break; - case ISNULL: - { - Node *lexpr = transformExpr(pstate, a->lexpr, precedence); + result = (Node *) make_op(a->opname, lexpr, rexpr); + } + break; + case ISNULL: + { + Node *lexpr = transformExpr(pstate, a->lexpr, precedence); - result = ParseFunc(pstate, - "nullvalue", lcons(lexpr, NIL), - &pstate->p_last_resno); - } - break; - case NOTNULL: - { - Node *lexpr = transformExpr(pstate, a->lexpr, precedence); + result = ParseFunc(pstate, + "nullvalue", lcons(lexpr, NIL), + &pstate->p_last_resno); + } + break; + case NOTNULL: + { + Node *lexpr = transformExpr(pstate, a->lexpr, precedence); - result = ParseFunc(pstate, + result = ParseFunc(pstate, "nonnullvalue", lcons(lexpr, NIL), - &pstate->p_last_resno); - } - break; - case AND: - { - Expr *expr = makeNode(Expr); - Node *lexpr = transformExpr(pstate, a->lexpr, precedence); - Node *rexpr = transformExpr(pstate, a->rexpr, precedence); + &pstate->p_last_resno); + } + break; + case AND: + { + Expr *expr = makeNode(Expr); + Node *lexpr = transformExpr(pstate, a->lexpr, precedence); + Node *rexpr = transformExpr(pstate, a->rexpr, precedence); - if (exprType(lexpr) != BOOLOID) - elog(WARN, - "left-hand side of AND is type '%s', not bool", - tname(get_id_type(exprType(lexpr)))); - if (exprType(rexpr) != BOOLOID) - elog(WARN, - "right-hand side of AND is type '%s', not bool", - tname(get_id_type(exprType(rexpr)))); - expr->typeOid = BOOLOID; - expr->opType = AND_EXPR; - expr->args = makeList(lexpr, rexpr, -1); - result = (Node *) expr; - } - break; - case OR: - { - Expr *expr = makeNode(Expr); - Node *lexpr = transformExpr(pstate, a->lexpr, precedence); - Node *rexpr = transformExpr(pstate, a->rexpr, precedence); + if (exprType(lexpr) != BOOLOID) + elog(WARN, + "left-hand side of AND is type '%s', not bool", + tname(get_id_type(exprType(lexpr)))); + if (exprType(rexpr) != BOOLOID) + elog(WARN, + "right-hand side of AND is type '%s', not bool", + tname(get_id_type(exprType(rexpr)))); + expr->typeOid = BOOLOID; + expr->opType = AND_EXPR; + expr->args = makeList(lexpr, rexpr, -1); + result = (Node *) expr; + } + break; + case OR: + { + Expr *expr = makeNode(Expr); + Node *lexpr = transformExpr(pstate, a->lexpr, precedence); + Node *rexpr = transformExpr(pstate, a->rexpr, precedence); - if (exprType(lexpr) != BOOLOID) - elog(WARN, - "left-hand side of OR is type '%s', not bool", - tname(get_id_type(exprType(lexpr)))); - if (exprType(rexpr) != BOOLOID) - elog(WARN, - "right-hand side of OR is type '%s', not bool", - tname(get_id_type(exprType(rexpr)))); - expr->typeOid = BOOLOID; - expr->opType = OR_EXPR; - expr->args = makeList(lexpr, rexpr, -1); - result = (Node *) expr; - } - break; - case NOT: - { - Expr *expr = makeNode(Expr); - Node *rexpr = transformExpr(pstate, a->rexpr, precedence); + if (exprType(lexpr) != BOOLOID) + elog(WARN, + "left-hand side of OR is type '%s', not bool", + tname(get_id_type(exprType(lexpr)))); + if (exprType(rexpr) != BOOLOID) + elog(WARN, + "right-hand side of OR is type '%s', not bool", + tname(get_id_type(exprType(rexpr)))); + expr->typeOid = BOOLOID; + expr->opType = OR_EXPR; + expr->args = makeList(lexpr, rexpr, -1); + result = (Node *) expr; + } + break; + case NOT: + { + Expr *expr = makeNode(Expr); + Node *rexpr = transformExpr(pstate, a->rexpr, precedence); - if (exprType(rexpr) != BOOLOID) - elog(WARN, - "argument to NOT is type '%s', not bool", - tname(get_id_type(exprType(rexpr)))); - expr->typeOid = BOOLOID; - expr->opType = NOT_EXPR; - expr->args = makeList(rexpr, -1); - result = (Node *) expr; + if (exprType(rexpr) != BOOLOID) + elog(WARN, + "argument to NOT is type '%s', not bool", + tname(get_id_type(exprType(rexpr)))); + expr->typeOid = BOOLOID; + expr->opType = NOT_EXPR; + expr->args = makeList(rexpr, -1); + result = (Node *) expr; + } + break; } break; } - break; - } - case T_Ident: - { + case T_Ident: + { - /* - * look for a column name or a relation name (the default - * behavior) - */ - result = transformIdent(pstate, expr, precedence); - break; - } - case T_FuncCall: - { - FuncCall *fn = (FuncCall *) expr; - List *args; + /* + * look for a column name or a relation name (the default + * behavior) + */ + result = transformIdent(pstate, expr, precedence); + break; + } + case T_FuncCall: + { + FuncCall *fn = (FuncCall *) expr; + List *args; - /* transform the list of arguments */ - foreach(args, fn->args) - lfirst(args) = transformExpr(pstate, (Node *) lfirst(args), precedence); - result = ParseFunc(pstate, + /* transform the list of arguments */ + foreach(args, fn->args) + lfirst(args) = transformExpr(pstate, (Node *) lfirst(args), precedence); + result = ParseFunc(pstate, fn->funcname, fn->args, &pstate->p_last_resno); + break; + } + default: + /* should not reach here */ + elog(WARN, "transformExpr: does not know how to transform %d\n", + nodeTag(expr)); break; - } - default: - /* should not reach here */ - elog(WARN, "transformExpr: does not know how to transform %d\n", - nodeTag(expr)); - break; } return result; } -static Node * +static Node * transformIdent(ParseState * pstate, Node * expr, int precedence) { - Ident *ident = (Ident *) expr; - RangeTblEntry *rte; - Node *column_result, - *relation_result, - *result; + Ident *ident = (Ident *) expr; + RangeTblEntry *rte; + Node *column_result, + *relation_result, + *result; column_result = relation_result = result = 0; /* try to find the ident as a column */ if ((rte = colnameRangeTableEntry(pstate, ident->name)) != NULL) { - Attr *att = makeNode(Attr); + Attr *att = makeNode(Attr); att->relname = rte->refname; att->attrs = lcons(makeString(ident->name), NIL); @@ -856,15 +858,15 @@ transformIdent(ParseState * pstate, Node * expr, int precedence) static void parseFromClause(ParseState * pstate, List * frmList) { - List *fl; + List *fl; foreach(fl, frmList) { - RangeVar *r = lfirst(fl); - RelExpr *baserel = r->relExpr; - char *relname = baserel->relname; - char *refname = r->name; - RangeTblEntry *rte; + RangeVar *r = lfirst(fl); + RelExpr *baserel = r->relExpr; + char *relname = baserel->relname; + char *refname = r->name; + RangeTblEntry *rte; if (refname == NULL) refname = relname; @@ -893,7 +895,7 @@ parseFromClause(ParseState * pstate, List * frmList) static void makeRangeTable(ParseState * pstate, char *relname, List * frmList) { - RangeTblEntry *rte; + RangeTblEntry *rte; parseFromClause(pstate, frmList); @@ -919,42 +921,42 @@ makeRangeTable(ParseState * pstate, char *relname, List * frmList) Oid exprType(Node * expr) { - Oid type = (Oid) 0; + Oid type = (Oid) 0; switch (nodeTag(expr)) { - case T_Func: - type = ((Func *) expr)->functype; - break; - case T_Iter: - type = ((Iter *) expr)->itertype; - break; - case T_Var: - type = ((Var *) expr)->vartype; - break; - case T_Expr: - type = ((Expr *) expr)->typeOid; - break; - case T_Const: - type = ((Const *) expr)->consttype; - break; - case T_ArrayRef: - type = ((ArrayRef *) expr)->refelemtype; - break; - case T_Aggreg: - type = ((Aggreg *) expr)->aggtype; - break; - case T_Param: - type = ((Param *) expr)->paramtype; - break; - case T_Ident: - /* is this right? */ - type = UNKNOWNOID; - break; - default: - elog(WARN, "exprType: don't know how to get type for %d node", - nodeTag(expr)); - break; + case T_Func: + type = ((Func *) expr)->functype; + break; + case T_Iter: + type = ((Iter *) expr)->itertype; + break; + case T_Var: + type = ((Var *) expr)->vartype; + break; + case T_Expr: + type = ((Expr *) expr)->typeOid; + break; + case T_Const: + type = ((Const *) expr)->consttype; + break; + case T_ArrayRef: + type = ((ArrayRef *) expr)->refelemtype; + break; + case T_Aggreg: + type = ((Aggreg *) expr)->aggtype; + break; + case T_Param: + type = ((Param *) expr)->paramtype; + break; + case T_Ident: + /* is this right? */ + type = UNKNOWNOID; + break; + default: + elog(WARN, "exprType: don't know how to get type for %d node", + nodeTag(expr)); + break; } return type; } @@ -964,13 +966,13 @@ exprType(Node * expr) * turns '*' (in the target list) into a list of attributes (of all * relations in the range table) */ -static List * +static List * expandAllTables(ParseState * pstate) { - List *target = NIL; - List *legit_rtable = NIL; - List *rt, - *rtable; + List *target = NIL; + List *legit_rtable = NIL; + List *rt, + *rtable; rtable = pstate->p_rtable; if (pstate->p_is_rule) @@ -992,7 +994,7 @@ expandAllTables(ParseState * pstate) */ foreach(rt, rtable) { - RangeTblEntry *rte = lfirst(rt); + RangeTblEntry *rte = lfirst(rt); /* * we only expand those specify in the from clause. (This will @@ -1006,8 +1008,8 @@ expandAllTables(ParseState * pstate) foreach(rt, legit_rtable) { - RangeTblEntry *rte = lfirst(rt); - List *temp = target; + RangeTblEntry *rte = lfirst(rt); + List *temp = target; if (temp == NIL) target = expandAll(pstate, rte->relname, rte->refname, @@ -1030,23 +1032,23 @@ expandAllTables(ParseState * pstate) * list, we have to guess. * */ -static char * +static char * figureColname(Node * expr, Node * resval) { switch (nodeTag(expr)) { - case T_Aggreg: - return (char *) /* XXX */ - ((Aggreg *) expr)->aggname; - case T_Expr: - if (((Expr *) expr)->opType == FUNC_EXPR) - { - if (nodeTag(resval) == T_FuncCall) - return ((FuncCall *) resval)->funcname; - } - break; - default: - break; + case T_Aggreg: + return (char *) /* XXX */ + ((Aggreg *) expr)->aggname; + case T_Expr: + if (((Expr *) expr)->opType == FUNC_EXPR) + { + if (nodeTag(resval) == T_FuncCall) + return ((FuncCall *) resval)->funcname; + } + break; + default: + break; } return "?column?"; @@ -1064,23 +1066,23 @@ figureColname(Node * expr, Node * resval) * test supplied column names to make sure they are in target table * (used exclusively for inserts) */ -static List * +static List * makeTargetNames(ParseState * pstate, List * cols) { - List *tl = NULL; + List *tl = NULL; /* Generate ResTarget if not supplied */ if (cols == NIL) { - int numcol; - int i; + int numcol; + int i; AttributeTupleForm *attr = pstate->p_target_relation->rd_att->attrs; numcol = pstate->p_target_relation->rd_rel->relnatts; for (i = 0; i < numcol; i++) { - Ident *id = makeNode(Ident); + Ident *id = makeNode(Ident); id->name = palloc(NAMEDATALEN); strNcpy(id->name, attr[i]->attname.data, NAMEDATALEN - 1); @@ -1107,264 +1109,269 @@ makeTargetNames(ParseState * pstate, List * cols) * transformTargetList - * turns a list of ResTarget's into a list of TargetEntry's */ -static List * +static List * transformTargetList(ParseState * pstate, List * targetlist) { - List *p_target = NIL; - List *tail_p_target = NIL; + List *p_target = NIL; + List *tail_p_target = NIL; while (targetlist != NIL) { - ResTarget *res = (ResTarget *) lfirst(targetlist); - TargetEntry *tent = makeNode(TargetEntry); + ResTarget *res = (ResTarget *) lfirst(targetlist); + TargetEntry *tent = makeNode(TargetEntry); switch (nodeTag(res->val)) { - case T_Ident: - { - Node *expr; - Oid type_id; - int type_len; - char *identname; - char *resname; + case T_Ident: + { + Node *expr; + Oid type_id; + int type_len; + char *identname; + char *resname; - identname = ((Ident *) res->val)->name; - handleTargetColname(pstate, &res->name, NULL, identname); + identname = ((Ident *) res->val)->name; + handleTargetColname(pstate, &res->name, NULL, identname); - /* - * here we want to look for column names only, not - * relation - */ - /* names (even though they can be stored in Ident nodes, */ - /* too) */ - expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); - type_id = exprType(expr); - type_len = tlen(get_id_type(type_id)); - resname = (res->name) ? res->name : identname; - tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++, - (Oid) type_id, - (Size) type_len, - resname, - (Index) 0, - (Oid) 0, - 0); - - tent->expr = expr; - break; - } - case T_ParamNo: - case T_FuncCall: - case T_A_Const: - case T_A_Expr: - { - Node *expr = transformExpr(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); + /* + * here we want to look for column names only, not + * relation + */ - handleTargetColname(pstate, &res->name, NULL, NULL); - /* note indirection has not been transformed */ - if (pstate->p_is_insert && res->indirection != NIL) + /* + * names (even though they can be stored in Ident + * nodes, + */ + /* too) */ + expr = transformIdent(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); + type_id = exprType(expr); + type_len = tlen(get_id_type(type_id)); + resname = (res->name) ? res->name : identname; + tent->resdom = makeResdom((AttrNumber) pstate->p_last_resno++, + (Oid) type_id, + (Size) type_len, + resname, + (Index) 0, + (Oid) 0, + 0); + + tent->expr = expr; + break; + } + case T_ParamNo: + case T_FuncCall: + case T_A_Const: + case T_A_Expr: { - /* this is an array assignment */ - char *val; - char *str, + Node *expr = transformExpr(pstate, (Node *) res->val, EXPR_COLUMN_FIRST); + + handleTargetColname(pstate, &res->name, NULL, NULL); + /* note indirection has not been transformed */ + if (pstate->p_is_insert && res->indirection != NIL) + { + /* this is an array assignment */ + char *val; + char *str, *save_str; - List *elt; - int i = 0, + List *elt; + int i = 0, ndims; - int lindx[MAXDIM], + int lindx[MAXDIM], uindx[MAXDIM]; - int resdomno; - Relation rd; - Value *constval; + int resdomno; + Relation rd; + Value *constval; - if (exprType(expr) != UNKNOWNOID || - !IsA(expr, Const)) - elog(WARN, "yyparse: string constant expected"); + if (exprType(expr) != UNKNOWNOID || + !IsA(expr, Const)) + elog(WARN, "yyparse: string constant expected"); - val = (char *) textout((struct varlena *) + val = (char *) textout((struct varlena *) ((Const *) expr)->constvalue); - str = save_str = (char *) palloc(strlen(val) + MAXDIM * 25 + 2); - foreach(elt, res->indirection) - { - A_Indices *aind = (A_Indices *) lfirst(elt); - - aind->uidx = transformExpr(pstate, aind->uidx, EXPR_COLUMN_FIRST); - if (!IsA(aind->uidx, Const)) - elog(WARN, - "Array Index for Append should be a constant"); - uindx[i] = ((Const *) aind->uidx)->constvalue; - if (aind->lidx != NULL) + str = save_str = (char *) palloc(strlen(val) + MAXDIM * 25 + 2); + foreach(elt, res->indirection) { - aind->lidx = transformExpr(pstate, aind->lidx, EXPR_COLUMN_FIRST); - if (!IsA(aind->lidx, Const)) + A_Indices *aind = (A_Indices *) lfirst(elt); + + aind->uidx = transformExpr(pstate, aind->uidx, EXPR_COLUMN_FIRST); + if (!IsA(aind->uidx, Const)) elog(WARN, "Array Index for Append should be a constant"); - lindx[i] = ((Const *) aind->lidx)->constvalue; + uindx[i] = ((Const *) aind->uidx)->constvalue; + if (aind->lidx != NULL) + { + aind->lidx = transformExpr(pstate, aind->lidx, EXPR_COLUMN_FIRST); + if (!IsA(aind->lidx, Const)) + elog(WARN, + "Array Index for Append should be a constant"); + lindx[i] = ((Const *) aind->lidx)->constvalue; + } + else + { + lindx[i] = 1; + } + if (lindx[i] > uindx[i]) + elog(WARN, "yyparse: lower index cannot be greater than upper index"); + sprintf(str, "[%d:%d]", lindx[i], uindx[i]); + str += strlen(str); + i++; } - else - { - lindx[i] = 1; - } - if (lindx[i] > uindx[i]) - elog(WARN, "yyparse: lower index cannot be greater than upper index"); - sprintf(str, "[%d:%d]", lindx[i], uindx[i]); - str += strlen(str); - i++; - } - sprintf(str, "=%s", val); - rd = pstate->p_target_relation; - Assert(rd != NULL); - resdomno = varattno(rd, res->name); - ndims = att_attnelems(rd, resdomno); - if (i != ndims) - elog(WARN, "yyparse: array dimensions do not match"); - constval = makeNode(Value); - constval->type = T_String; - constval->val.str = save_str; - tent = make_targetlist_expr(pstate, res->name, + sprintf(str, "=%s", val); + rd = pstate->p_target_relation; + Assert(rd != NULL); + resdomno = varattno(rd, res->name); + ndims = att_attnelems(rd, resdomno); + if (i != ndims) + elog(WARN, "yyparse: array dimensions do not match"); + constval = makeNode(Value); + constval->type = T_String; + constval->val.str = save_str; + tent = make_targetlist_expr(pstate, res->name, (Node *) make_const(constval), - NULL); - pfree(save_str); - } - else - { - char *colname = res->name; - - /* this is not an array assignment */ - if (colname == NULL) - { - - /* - * if you're wondering why this is here, look at - * the yacc grammar for why a name can be missing. - * -ay - */ - colname = figureColname(expr, res->val); + NULL); + pfree(save_str); } - if (res->indirection) + else { - List *ilist = res->indirection; + char *colname = res->name; - while (ilist != NIL) + /* this is not an array assignment */ + if (colname == NULL) { - A_Indices *ind = lfirst(ilist); - ind->lidx = transformExpr(pstate, ind->lidx, EXPR_COLUMN_FIRST); - ind->uidx = transformExpr(pstate, ind->uidx, EXPR_COLUMN_FIRST); - ilist = lnext(ilist); + /* + * if you're wondering why this is here, look + * at the yacc grammar for why a name can be + * missing. -ay + */ + colname = figureColname(expr, res->val); } + if (res->indirection) + { + List *ilist = res->indirection; + + while (ilist != NIL) + { + A_Indices *ind = lfirst(ilist); + + ind->lidx = transformExpr(pstate, ind->lidx, EXPR_COLUMN_FIRST); + ind->uidx = transformExpr(pstate, ind->uidx, EXPR_COLUMN_FIRST); + ilist = lnext(ilist); + } + } + res->name = colname; + tent = make_targetlist_expr(pstate, res->name, expr, + res->indirection); } - res->name = colname; - tent = make_targetlist_expr(pstate, res->name, expr, - res->indirection); + break; } - break; - } - case T_Attr: - { - Oid type_id; - int type_len; - Attr *att = (Attr *) res->val; - Node *result; - char *attrname; - char *resname; - Resdom *resnode; - List *attrs = att->attrs; - - /* - * Target item is a single '*', expand all tables (eg. - * SELECT * FROM emp) - */ - if (att->relname != NULL && !strcmp(att->relname, "*")) + case T_Attr: { - if (tail_p_target == NIL) - p_target = tail_p_target = expandAllTables(pstate); - else - lnext(tail_p_target) = expandAllTables(pstate); - - while (lnext(tail_p_target) != NIL) - /* make sure we point to the last target entry */ - tail_p_target = lnext(tail_p_target); + Oid type_id; + int type_len; + Attr *att = (Attr *) res->val; + Node *result; + char *attrname; + char *resname; + Resdom *resnode; + List *attrs = att->attrs; /* - * skip rest of while loop + * Target item is a single '*', expand all tables (eg. + * SELECT * FROM emp) */ - targetlist = lnext(targetlist); - continue; - } + if (att->relname != NULL && !strcmp(att->relname, "*")) + { + if (tail_p_target == NIL) + p_target = tail_p_target = expandAllTables(pstate); + else + lnext(tail_p_target) = expandAllTables(pstate); - /* - * Target item is relation.*, expand the table (eg. SELECT - * emp.*, dname FROM emp, dept) - */ - attrname = strVal(lfirst(att->attrs)); - if (att->attrs != NIL && !strcmp(attrname, "*")) - { + while (lnext(tail_p_target) != NIL) + /* make sure we point to the last target entry */ + tail_p_target = lnext(tail_p_target); - /* - * tail_p_target is the target list we're building in - * the while loop. Make sure we fix it after appending - * more nodes. - */ - if (tail_p_target == NIL) - p_target = tail_p_target = expandAll(pstate, att->relname, - att->relname, &pstate->p_last_resno); - else - lnext(tail_p_target) = - expandAll(pstate, att->relname, att->relname, - &pstate->p_last_resno); - while (lnext(tail_p_target) != NIL) - /* make sure we point to the last target entry */ - tail_p_target = lnext(tail_p_target); + /* + * skip rest of while loop + */ + targetlist = lnext(targetlist); + continue; + } /* - * skip the rest of the while loop + * Target item is relation.*, expand the table (eg. + * SELECT emp.*, dname FROM emp, dept) */ - targetlist = lnext(targetlist); - continue; - } + attrname = strVal(lfirst(att->attrs)); + if (att->attrs != NIL && !strcmp(attrname, "*")) + { + /* + * tail_p_target is the target list we're building + * in the while loop. Make sure we fix it after + * appending more nodes. + */ + if (tail_p_target == NIL) + p_target = tail_p_target = expandAll(pstate, att->relname, + att->relname, &pstate->p_last_resno); + else + lnext(tail_p_target) = + expandAll(pstate, att->relname, att->relname, + &pstate->p_last_resno); + while (lnext(tail_p_target) != NIL) + /* make sure we point to the last target entry */ + tail_p_target = lnext(tail_p_target); + + /* + * skip the rest of the while loop + */ + targetlist = lnext(targetlist); + continue; + } - /* - * Target item is fully specified: ie. relation.attribute - */ - result = handleNestedDots(pstate, att, &pstate->p_last_resno); - handleTargetColname(pstate, &res->name, att->relname, attrname); - if (att->indirection != NIL) - { - List *ilist = att->indirection; - while (ilist != NIL) + /* + * Target item is fully specified: ie. + * relation.attribute + */ + result = handleNestedDots(pstate, att, &pstate->p_last_resno); + handleTargetColname(pstate, &res->name, att->relname, attrname); + if (att->indirection != NIL) { - A_Indices *ind = lfirst(ilist); + List *ilist = att->indirection; - ind->lidx = transformExpr(pstate, ind->lidx, EXPR_COLUMN_FIRST); - ind->uidx = transformExpr(pstate, ind->uidx, EXPR_COLUMN_FIRST); - ilist = lnext(ilist); + while (ilist != NIL) + { + A_Indices *ind = lfirst(ilist); + + ind->lidx = transformExpr(pstate, ind->lidx, EXPR_COLUMN_FIRST); + ind->uidx = transformExpr(pstate, ind->uidx, EXPR_COLUMN_FIRST); + ilist = lnext(ilist); + } + result = (Node *) make_array_ref(result, att->indirection); } - result = (Node *) make_array_ref(result, att->indirection); + type_id = exprType(result); + type_len = tlen(get_id_type(type_id)); + /* move to last entry */ + while (lnext(attrs) != NIL) + attrs = lnext(attrs); + resname = (res->name) ? res->name : strVal(lfirst(attrs)); + resnode = makeResdom((AttrNumber) pstate->p_last_resno++, + (Oid) type_id, + (Size) type_len, + resname, + (Index) 0, + (Oid) 0, + 0); + tent->resdom = resnode; + tent->expr = result; + break; } - type_id = exprType(result); - type_len = tlen(get_id_type(type_id)); - /* move to last entry */ - while (lnext(attrs) != NIL) - attrs = lnext(attrs); - resname = (res->name) ? res->name : strVal(lfirst(attrs)); - resnode = makeResdom((AttrNumber) pstate->p_last_resno++, - (Oid) type_id, - (Size) type_len, - resname, - (Index) 0, - (Oid) 0, - 0); - tent->resdom = resnode; - tent->expr = result; + default: + /* internal error */ + elog(WARN, + "internal error: do not know how to transform targetlist"); break; - } - default: - /* internal error */ - elog(WARN, - "internal error: do not know how to transform targetlist"); - break; } if (p_target == NIL) @@ -1395,15 +1402,15 @@ make_targetlist_expr(ParseState * pstate, Node * expr, List * arrayRef) { - Oid type_id, - attrtype; - int type_len, - attrlen; - int resdomno; - Relation rd; - bool attrisset; - TargetEntry *tent; - Resdom *resnode; + Oid type_id, + attrtype; + int type_len, + attrlen; + int resdomno; + Relation rd; + bool attrisset; + TargetEntry *tent; + Resdom *resnode; if (expr == NULL) elog(WARN, "make_targetlist_expr: invalid use of NULL expression"); @@ -1443,7 +1450,7 @@ make_targetlist_expr(ParseState * pstate, #if 0 if (Input_is_string && Typecast_ok) { - Datum val; + Datum val; if (type_id == typeid(type("unknown"))) { @@ -1505,7 +1512,7 @@ make_targetlist_expr(ParseState * pstate, if (arrayRef && !(((A_Indices *) lfirst(arrayRef))->lidx)) { /* updating a single item */ - Oid typelem = get_typelem(attrtype); + Oid typelem = get_typelem(attrtype); expr = (Node *) parser_typecast2(expr, type_id, @@ -1530,11 +1537,11 @@ make_targetlist_expr(ParseState * pstate, if (arrayRef != NIL) { - Expr *target_expr; - Attr *att = makeNode(Attr); - List *ar = arrayRef; - List *upperIndexpr = NIL; - List *lowerIndexpr = NIL; + Expr *target_expr; + Attr *att = makeNode(Attr); + List *ar = arrayRef; + List *upperIndexpr = NIL; + List *lowerIndexpr = NIL; att->relname = pstrdup(RelationGetRelationName(rd)->data); att->attrs = lcons(makeString(colname), NIL); @@ -1542,7 +1549,7 @@ make_targetlist_expr(ParseState * pstate, &pstate->p_last_resno); while (ar != NIL) { - A_Indices *ind = lfirst(ar); + A_Indices *ind = lfirst(ar); if (lowerIndexpr || (!upperIndexpr && ind->lidx)) { @@ -1599,10 +1606,10 @@ make_targetlist_expr(ParseState * pstate, * transforms the qualification and make sure it is of type Boolean * */ -static Node * +static Node * transformWhereClause(ParseState * pstate, Node * a_expr) { - Node *qual; + Node *qual; if (a_expr == NULL) return (Node *) NULL; /* no qualifiers */ @@ -1634,10 +1641,10 @@ transformWhereClause(ParseState * pstate, Node * a_expr) static TargetEntry * find_targetlist_entry(ParseState * pstate, SortGroupBy * sortgroupby, List * tlist) { - List *i; - int real_rtable_pos = 0, - target_pos = 0; - TargetEntry *target_result = NULL; + List *i; + int real_rtable_pos = 0, + target_pos = 0; + TargetEntry *target_result = NULL; if (sortgroupby->range) real_rtable_pos = refnameRangeTablePosn(pstate->p_rtable, @@ -1645,11 +1652,11 @@ find_targetlist_entry(ParseState * pstate, SortGroupBy * sortgroupby, List * tli foreach(i, tlist) { - TargetEntry *target = (TargetEntry *) lfirst(i); - Resdom *resnode = target->resdom; - Var *var = (Var *) target->expr; - char *resname = resnode->resname; - int test_rtable_pos = var->varno; + TargetEntry *target = (TargetEntry *) lfirst(i); + Resdom *resnode = target->resdom; + Var *var = (Var *) target->expr; + char *resname = resnode->resname; + int test_rtable_pos = var->varno; #ifdef PARSEDEBUG printf("find_targetlist_entry- target name is %s, position %d, resno %d\n", @@ -1691,11 +1698,11 @@ find_targetlist_entry(ParseState * pstate, SortGroupBy * sortgroupby, List * tli return target_result; } -static Oid +static Oid any_ordering_op(int restype) { - Operator order_op; - Oid order_opid; + Operator order_op; + Oid order_opid; order_op = oper("<", restype, restype, false); order_opid = oprid(order_op); @@ -1708,17 +1715,17 @@ any_ordering_op(int restype) * transform a Group By clause * */ -static List * +static List * transformGroupClause(ParseState * pstate, List * grouplist, List * targetlist) { - List *glist = NIL, - *gl = NIL; + List *glist = NIL, + *gl = NIL; while (grouplist != NIL) { - GroupClause *grpcl = makeNode(GroupClause); - TargetEntry *restarget; - Resdom *resdom; + GroupClause *grpcl = makeNode(GroupClause); + TargetEntry *restarget; + Resdom *resdom; restarget = find_targetlist_entry(pstate, lfirst(grouplist), targetlist); @@ -1748,21 +1755,21 @@ transformGroupClause(ParseState * pstate, List * grouplist, List * targetlist) * transform an Order By clause * */ -static List * +static List * transformSortClause(ParseState * pstate, List * orderlist, List * targetlist, char *uniqueFlag) { - List *sortlist = NIL; - List *s = NIL, - *i; + List *sortlist = NIL; + List *s = NIL, + *i; while (orderlist != NIL) { - SortGroupBy *sortby = lfirst(orderlist); - SortClause *sortcl = makeNode(SortClause); - TargetEntry *restarget; - Resdom *resdom; + SortGroupBy *sortby = lfirst(orderlist); + SortClause *sortcl = makeNode(SortClause); + TargetEntry *restarget; + Resdom *resdom; restarget = find_targetlist_entry(pstate, sortby, targetlist); if (restarget == NULL) @@ -1795,12 +1802,12 @@ transformSortClause(ParseState * pstate, */ foreach(i, targetlist) { - TargetEntry *tlelt = (TargetEntry *) lfirst(i); + TargetEntry *tlelt = (TargetEntry *) lfirst(i); s = sortlist; while (s != NIL) { - SortClause *sortcl = lfirst(s); + SortClause *sortcl = lfirst(s); if (sortcl->resdom == tlelt->resdom) break; @@ -1809,7 +1816,7 @@ transformSortClause(ParseState * pstate, if (s == NIL) { /* not a member of the sortclauses yet */ - SortClause *sortcl = makeNode(SortClause); + SortClause *sortcl = makeNode(SortClause); sortcl->resdom = tlelt->resdom; sortcl->opoid = any_ordering_op(tlelt->resdom->restype); @@ -1820,8 +1827,8 @@ transformSortClause(ParseState * pstate, } else { - TargetEntry *tlelt = NULL; - char *uniqueAttrName = uniqueFlag; + TargetEntry *tlelt = NULL; + char *uniqueAttrName = uniqueFlag; /* only create sort clause with the specified unique attribute */ foreach(i, targetlist) @@ -1837,7 +1844,7 @@ transformSortClause(ParseState * pstate, s = sortlist; foreach(s, sortlist) { - SortClause *sortcl = lfirst(s); + SortClause *sortcl = lfirst(s); if (sortcl->resdom == tlelt->resdom) break; @@ -1845,7 +1852,7 @@ transformSortClause(ParseState * pstate, if (s == NIL) { /* not a member of the sortclauses yet */ - SortClause *sortcl = makeNode(SortClause); + SortClause *sortcl = makeNode(SortClause); sortcl->resdom = tlelt->resdom; sortcl->opoid = any_ordering_op(tlelt->resdom->restype); @@ -1864,15 +1871,15 @@ transformSortClause(ParseState * pstate, ** Given a nested dot expression (i.e. (relation func ... attr), build up ** a tree with of Iter and Func nodes. */ -static Node * +static Node * handleNestedDots(ParseState * pstate, Attr * attr, int *curr_resno) { - List *mutator_iter; - Node *retval = NULL; + List *mutator_iter; + Node *retval = NULL; if (attr->paramNo != NULL) { - Param *param = (Param *) transformExpr(pstate, (Node *) attr->paramNo, EXPR_RELATION_FIRST); + Param *param = (Param *) transformExpr(pstate, (Node *) attr->paramNo, EXPR_RELATION_FIRST); retval = ParseFunc(pstate, strVal(lfirst(attr->attrs)), @@ -1881,7 +1888,7 @@ handleNestedDots(ParseState * pstate, Attr * attr, int *curr_resno) } else { - Ident *ident = makeNode(Ident); + Ident *ident = makeNode(Ident); ident->name = attr->relname; ident->isRel = TRUE; @@ -1921,8 +1928,8 @@ make_arguments(int nargs, * is all we check for. */ - List *current_fargs; - int i; + List *current_fargs; + int i; for (i = 0, current_fargs = fargs; i < nargs; @@ -1947,14 +1954,14 @@ make_arguments(int nargs, ** on a tuple parameter or return value. Due to a bug in 4.0, ** it's not possible to refer to system attributes in this case. */ -static List * +static List * setup_tlist(char *attname, Oid relid) { - TargetEntry *tle; - Resdom *resnode; - Var *varnode; - Oid typeid; - int attno; + TargetEntry *tle; + Resdom *resnode; + Var *varnode; + Oid typeid; + int attno; attno = get_attnum(relid, attname); if (attno < 0) @@ -1981,12 +1988,12 @@ setup_tlist(char *attname, Oid relid) ** Build a tlist that extracts a base type from the tuple ** returned by the executor. */ -static List * +static List * setup_base_tlist(Oid typeid) { - TargetEntry *tle; - Resdom *resnode; - Var *varnode; + TargetEntry *tle; + Resdom *resnode; + Var *varnode; resnode = makeResdom(1, typeid, @@ -2008,185 +2015,186 @@ setup_base_tlist(Oid typeid) * handles function calls with a single argument that is of complex type. * This routine returns NULL if it can't handle the projection (eg. sets). */ -static Node * +static Node * ParseComplexProjection(ParseState * pstate, char *funcname, Node * first_arg, bool * attisset) { - Oid argtype; - Oid argrelid; - Name relname; - Relation rd; - Oid relid; - int attnum; + Oid argtype; + Oid argrelid; + Name relname; + Relation rd; + Oid relid; + int attnum; switch (nodeTag(first_arg)) { - case T_Iter: - { - Func *func; - Iter *iter; - - iter = (Iter *) first_arg; - func = (Func *) ((Expr *) iter->iterexpr)->oper; - argtype = funcid_get_rettype(func->funcid); - argrelid = typeid_get_relid(argtype); - if (argrelid && - ((attnum = get_attnum(argrelid, funcname)) - != InvalidAttrNumber)) + case T_Iter: { + Func *func; + Iter *iter; + + iter = (Iter *) first_arg; + func = (Func *) ((Expr *) iter->iterexpr)->oper; + argtype = funcid_get_rettype(func->funcid); + argrelid = typeid_get_relid(argtype); + if (argrelid && + ((attnum = get_attnum(argrelid, funcname)) + != InvalidAttrNumber)) + { - /* - * the argument is a function returning a tuple, so - * funcname may be a projection - */ + /* + * the argument is a function returning a tuple, so + * funcname may be a projection + */ - /* add a tlist to the func node and return the Iter */ - rd = heap_openr(tname(get_id_type(argtype))); - if (RelationIsValid(rd)) - { - relid = RelationGetRelationId(rd); - relname = RelationGetRelationName(rd); - heap_close(rd); - } - if (RelationIsValid(rd)) - { - func->func_tlist = - setup_tlist(funcname, argrelid); - iter->itertype = att_typeid(rd, attnum); - return ((Node *) iter); + /* add a tlist to the func node and return the Iter */ + rd = heap_openr(tname(get_id_type(argtype))); + if (RelationIsValid(rd)) + { + relid = RelationGetRelationId(rd); + relname = RelationGetRelationName(rd); + heap_close(rd); + } + if (RelationIsValid(rd)) + { + func->func_tlist = + setup_tlist(funcname, argrelid); + iter->itertype = att_typeid(rd, attnum); + return ((Node *) iter); + } + else + { + elog(WARN, + "Function %s has bad returntype %d", + funcname, argtype); + } } else { - elog(WARN, - "Function %s has bad returntype %d", - funcname, argtype); + /* drop through */ + ; } + break; } - else + case T_Var: { - /* drop through */ - ; + + /* + * The argument is a set, so this is either a projection + * or a function call on this set. + */ + *attisset = true; + break; } - break; - } - case T_Var: - { + case T_Expr: + { + Expr *expr = (Expr *) first_arg; + Func *funcnode; - /* - * The argument is a set, so this is either a projection or a - * function call on this set. - */ - *attisset = true; - break; - } - case T_Expr: - { - Expr *expr = (Expr *) first_arg; - Func *funcnode; + if (expr->opType != FUNC_EXPR) + break; - if (expr->opType != FUNC_EXPR) - break; + funcnode = (Func *) expr->oper; + argtype = funcid_get_rettype(funcnode->funcid); + argrelid = typeid_get_relid(argtype); - funcnode = (Func *) expr->oper; - argtype = funcid_get_rettype(funcnode->funcid); - argrelid = typeid_get_relid(argtype); + /* + * the argument is a function returning a tuple, so + * funcname may be a projection + */ + if (argrelid && + (attnum = get_attnum(argrelid, funcname)) + != InvalidAttrNumber) + { - /* - * the argument is a function returning a tuple, so funcname - * may be a projection - */ - if (argrelid && - (attnum = get_attnum(argrelid, funcname)) - != InvalidAttrNumber) + /* add a tlist to the func node */ + rd = heap_openr(tname(get_id_type(argtype))); + if (RelationIsValid(rd)) + { + relid = RelationGetRelationId(rd); + relname = RelationGetRelationName(rd); + heap_close(rd); + } + if (RelationIsValid(rd)) + { + Expr *newexpr; + + funcnode->func_tlist = + setup_tlist(funcname, argrelid); + funcnode->functype = att_typeid(rd, attnum); + + newexpr = makeNode(Expr); + newexpr->typeOid = funcnode->functype; + newexpr->opType = FUNC_EXPR; + newexpr->oper = (Node *) funcnode; + newexpr->args = lcons(first_arg, NIL); + + return ((Node *) newexpr); + } + + } + + elog(WARN, "Function %s has bad returntype %d", + funcname, argtype); + break; + } + case T_Param: { + Param *param = (Param *) first_arg; - /* add a tlist to the func node */ - rd = heap_openr(tname(get_id_type(argtype))); + /* + * If the Param is a complex type, this could be a + * projection + */ + rd = heap_openr(tname(get_id_type(param->paramtype))); if (RelationIsValid(rd)) { relid = RelationGetRelationId(rd); relname = RelationGetRelationName(rd); heap_close(rd); } - if (RelationIsValid(rd)) + if (RelationIsValid(rd) && + (attnum = get_attnum(relid, funcname)) + != InvalidAttrNumber) { - Expr *newexpr; - - funcnode->func_tlist = - setup_tlist(funcname, argrelid); - funcnode->functype = att_typeid(rd, attnum); - - newexpr = makeNode(Expr); - newexpr->typeOid = funcnode->functype; - newexpr->opType = FUNC_EXPR; - newexpr->oper = (Node *) funcnode; - newexpr->args = lcons(first_arg, NIL); - return ((Node *) newexpr); + param->paramtype = att_typeid(rd, attnum); + param->param_tlist = setup_tlist(funcname, relid); + return ((Node *) param); } - - } - - elog(WARN, "Function %s has bad returntype %d", - funcname, argtype); - break; - } - case T_Param: - { - Param *param = (Param *) first_arg; - - /* - * If the Param is a complex type, this could be a projection - */ - rd = heap_openr(tname(get_id_type(param->paramtype))); - if (RelationIsValid(rd)) - { - relid = RelationGetRelationId(rd); - relname = RelationGetRelationName(rd); - heap_close(rd); - } - if (RelationIsValid(rd) && - (attnum = get_attnum(relid, funcname)) - != InvalidAttrNumber) - { - - param->paramtype = att_typeid(rd, attnum); - param->param_tlist = setup_tlist(funcname, relid); - return ((Node *) param); + break; } + default: break; - } - default: - break; } return NULL; } -static Node * +static Node * ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) { - Oid rettype = (Oid) 0; - Oid argrelid = (Oid) 0; - Oid funcid = (Oid) 0; - List *i = NIL; - Node *first_arg = NULL; - char *relname = NULL; - char *refname = NULL; - Relation rd; - Oid relid; - int nargs; - Func *funcnode; - Oid oid_array[8]; - Oid *true_oid_array; - Node *retval; - bool retset; - bool exists; - bool attisset = false; - Oid toid = (Oid) 0; - Expr *expr; + Oid rettype = (Oid) 0; + Oid argrelid = (Oid) 0; + Oid funcid = (Oid) 0; + List *i = NIL; + Node *first_arg = NULL; + char *relname = NULL; + char *refname = NULL; + Relation rd; + Oid relid; + int nargs; + Func *funcnode; + Oid oid_array[8]; + Oid *true_oid_array; + Node *retval; + bool retset; + bool exists; + bool attisset = false; + Oid toid = (Oid) 0; + Expr *expr; if (fargs) { @@ -2205,8 +2213,8 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) if (nodeTag(first_arg) == T_Ident && ((Ident *) first_arg)->isRel) { - RangeTblEntry *rte; - Ident *ident = (Ident *) first_arg; + RangeTblEntry *rte; + Ident *ident = (Ident *) first_arg; /* * first arg is a relation. This could be a projection. @@ -2226,7 +2234,7 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) */ if (get_attnum(relid, funcname) != InvalidAttrNumber) { - Oid dummyTypeId; + Oid dummyTypeId; return ((Node *) make_var(pstate, @@ -2287,7 +2295,7 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) /* * Parsing aggregates. */ - Oid basetype; + Oid basetype; /* * the aggregate count is a special case, ignore its base @@ -2302,7 +2310,7 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) ObjectIdGetDatum(basetype), 0, 0)) { - Aggreg *aggreg = ParseAgg(funcname, basetype, lfirst(fargs)); + Aggreg *aggreg = ParseAgg(funcname, basetype, lfirst(fargs)); AddAggToParseState(pstate, aggreg); return (Node *) aggreg; @@ -2322,9 +2330,9 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) nargs = 0; foreach(i, fargs) { - int vnum; - RangeTblEntry *rte; - Node *pair = lfirst(i); + int vnum; + RangeTblEntry *rte; + Node *pair = lfirst(i); if (nodeTag(pair) == T_Ident && ((Ident *) pair)->isRel) { @@ -2457,9 +2465,9 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) if (funcid == SeqNextValueRegProcedure || funcid == SeqCurrValueRegProcedure) { - Const *seq; - char *seqrel; - int32 aclcheck_result = -1; + Const *seq; + char *seqrel; + int32 aclcheck_result = -1; Assert(length(fargs) == 1); seq = (Const *) lfirst(fargs); @@ -2495,7 +2503,7 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) if (retset) { - Iter *iter = makeNode(Iter); + Iter *iter = makeNode(Iter); iter->itertype = rettype; iter->iterexpr = retval; @@ -2518,8 +2526,8 @@ ParseFunc(ParseState * pstate, char *funcname, List * fargs, int *curr_resno) static void AddAggToParseState(ParseState * pstate, Aggreg * aggreg) { - List *ag; - int i; + List *ag; + int i; /* * see if we have the aggregate already (we only need to record the @@ -2528,7 +2536,7 @@ AddAggToParseState(ParseState * pstate, Aggreg * aggreg) i = 0; foreach(ag, pstate->p_aggs) { - Aggreg *a = lfirst(ag); + Aggreg *a = lfirst(ag); if (!strcmp(a->aggname, aggreg->aggname) && equal(a->target, aggreg->target)) @@ -2556,8 +2564,8 @@ AddAggToParseState(ParseState * pstate, Aggreg * aggreg) static void finalizeAggregates(ParseState * pstate, Query * qry) { - List *l; - int i; + List *l; + int i; parseCheckAggregates(pstate, qry); @@ -2575,7 +2583,7 @@ finalizeAggregates(ParseState * pstate, Query * qry) * * Returns true if any aggregate found. */ -static bool +static bool contain_agg_clause(Node * clause) { if (clause == NULL) @@ -2588,7 +2596,7 @@ contain_agg_clause(Node * clause) return FALSE; else if (or_clause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) if (contain_agg_clause(lfirst(temp))) @@ -2597,7 +2605,7 @@ contain_agg_clause(Node * clause) } else if (is_funcclause(clause)) { - List *temp; + List *temp; foreach(temp, ((Expr *) clause)->args) if (contain_agg_clause(lfirst(temp))) @@ -2606,7 +2614,7 @@ contain_agg_clause(Node * clause) } else if (IsA(clause, ArrayRef)) { - List *temp; + List *temp; foreach(temp, ((ArrayRef *) clause)->refupperindexpr) if (contain_agg_clause(lfirst(temp))) @@ -2633,10 +2641,10 @@ contain_agg_clause(Node * clause) * exprIsAggOrGroupCol - * returns true if the expression does not contain non-group columns. */ -static bool +static bool exprIsAggOrGroupCol(Node * expr, List * groupClause) { - List *gl; + List *gl; if (expr == NULL || IsA(expr, Const) || IsA(expr, Param) || IsA(expr, Aggreg)) @@ -2644,7 +2652,7 @@ exprIsAggOrGroupCol(Node * expr, List * groupClause) foreach(gl, groupClause) { - GroupClause *grpcl = lfirst(gl); + GroupClause *grpcl = lfirst(gl); if (equal(expr, grpcl->entry->expr)) return TRUE; @@ -2652,7 +2660,7 @@ exprIsAggOrGroupCol(Node * expr, List * groupClause) if (IsA(expr, Expr)) { - List *temp; + List *temp; foreach(temp, ((Expr *) expr)->args) if (!exprIsAggOrGroupCol(lfirst(temp), groupClause)) @@ -2667,18 +2675,18 @@ exprIsAggOrGroupCol(Node * expr, List * groupClause) * tleIsAggOrGroupCol - * returns true if the TargetEntry is Agg or GroupCol. */ -static bool +static bool tleIsAggOrGroupCol(TargetEntry * tle, List * groupClause) { - Node *expr = tle->expr; - List *gl; + Node *expr = tle->expr; + List *gl; if (expr == NULL || IsA(expr, Const) || IsA(expr, Param)) return TRUE; foreach(gl, groupClause) { - GroupClause *grpcl = lfirst(gl); + GroupClause *grpcl = lfirst(gl); if (tle->resdom->resno == grpcl->entry->resdom->resno) { @@ -2693,7 +2701,7 @@ tleIsAggOrGroupCol(TargetEntry * tle, List * groupClause) if (IsA(expr, Expr)) { - List *temp; + List *temp; foreach(temp, ((Expr *) expr)->args) if (!exprIsAggOrGroupCol(lfirst(temp), groupClause)) @@ -2713,7 +2721,7 @@ tleIsAggOrGroupCol(TargetEntry * tle, List * groupClause) static void parseCheckAggregates(ParseState * pstate, Query * qry) { - List *tl; + List *tl; Assert(pstate->p_numAgg > 0); @@ -2731,7 +2739,7 @@ parseCheckAggregates(ParseState * pstate, Query * qry) */ foreach(tl, qry->targetList) { - TargetEntry *tle = lfirst(tl); + TargetEntry *tle = lfirst(tl); if (!tleIsAggOrGroupCol(tle, qry->groupClause)) elog(WARN, diff --git a/src/backend/parser/catalog_utils.c b/src/backend/parser/catalog_utils.c index 41e6fffac9b..967bf08101a 100644 --- a/src/backend/parser/catalog_utils.c +++ b/src/backend/parser/catalog_utils.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.23 1997/09/07 04:44:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/catalog_utils.c,v 1.24 1997/09/08 02:25:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,9 +52,9 @@ struct { - char *field; - int code; -} special_attr[] = + char *field; + int code; +} special_attr[] = { { @@ -94,7 +94,7 @@ struct #define SPECIALS (sizeof(special_attr)/sizeof(*special_attr)) -static char *attnum_type[SPECIALS] = { +static char *attnum_type[SPECIALS] = { "tid", "oid", "xid", @@ -118,10 +118,10 @@ static char *attnum_type[SPECIALS] = { typedef struct _InhPaths { - int nsupers; /* number of superclasses */ - Oid self; /* this class */ - Oid *supervec; /* vector of superclasses */ -} InhPaths; + int nsupers; /* number of superclasses */ + Oid self; /* this class */ + Oid *supervec; /* vector of superclasses */ +} InhPaths; /* * This structure holds a list of possible functions or operators that @@ -129,16 +129,16 @@ typedef struct _InhPaths */ typedef struct _CandidateList { - Oid *args; + Oid *args; struct _CandidateList *next; -} *CandidateList; +} *CandidateList; -static Oid **argtype_inherit(int nargs, Oid * oid_array); -static Oid **genxprod(InhPaths * arginh, int nargs); -static int findsupers(Oid relid, Oid ** supervec); -static bool check_typeid(Oid id); -static char *instr1(TypeTupleForm tp, char *string, int typlen); -static void op_error(char *op, Oid arg1, Oid arg2); +static Oid **argtype_inherit(int nargs, Oid * oid_array); +static Oid **genxprod(InhPaths * arginh, int nargs); +static int findsupers(Oid relid, Oid ** supervec); +static bool check_typeid(Oid id); +static char *instr1(TypeTupleForm tp, char *string, int typlen); +static void op_error(char *op, Oid arg1, Oid arg2); /* check to see if a type id is valid, * returns true if it is. By using this call before calling @@ -146,7 +146,7 @@ static void op_error(char *op, Oid arg1, Oid arg2); * can be produced because the caller typically has more context of * what's going on - jolly */ -static bool +static bool check_typeid(Oid id) { return (SearchSysCacheTuple(TYPOID, @@ -159,7 +159,7 @@ check_typeid(Oid id) Type get_id_type(Oid id) { - HeapTuple tup; + HeapTuple tup; if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id), 0, 0, 0))) @@ -171,11 +171,11 @@ get_id_type(Oid id) } /* return a type name, given a typeid */ -char * +char * get_id_typname(Oid id) { - HeapTuple tup; - TypeTupleForm typetuple; + HeapTuple tup; + TypeTupleForm typetuple; if (!(tup = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(id), 0, 0, 0))) @@ -191,7 +191,7 @@ get_id_typname(Oid id) Type type(char *s) { - HeapTuple tup; + HeapTuple tup; if (s == NULL) { @@ -245,7 +245,7 @@ typeid(Type tp) int16 tlen(Type t) { - TypeTupleForm typ; + TypeTupleForm typ; typ = (TypeTupleForm) GETSTRUCT(t); return (typ->typlen); @@ -255,17 +255,17 @@ tlen(Type t) bool tbyval(Type t) { - TypeTupleForm typ; + TypeTupleForm typ; typ = (TypeTupleForm) GETSTRUCT(t); return (typ->typbyval); } /* given type (as type struct), return the name of type */ -char * +char * tname(Type t) { - TypeTupleForm typ; + TypeTupleForm typ; typ = (TypeTupleForm) GETSTRUCT(t); return (typ->typname).data; @@ -275,7 +275,7 @@ tname(Type t) int tbyvalue(Type t) { - TypeTupleForm typ; + TypeTupleForm typ; typ = (TypeTupleForm) GETSTRUCT(t); return (typ->typbyval); @@ -285,7 +285,7 @@ tbyvalue(Type t) static char typetypetype(Type t) { - TypeTupleForm typ; + TypeTupleForm typ; typ = (TypeTupleForm) GETSTRUCT(t); return (typ->typtype); @@ -310,15 +310,15 @@ binary_oper_get_candidates(char *opname, Oid rightTypeId, CandidateList * candidates) { - CandidateList current_candidate; - Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; + CandidateList current_candidate; + Relation pg_operator_desc; + HeapScanDesc pg_operator_scan; + HeapTuple tup; OperatorTupleForm oper; - Buffer buffer; - int nkeys; - int ncandidates = 0; - ScanKeyData opKey[3]; + Buffer buffer; + int nkeys; + int ncandidates = 0; + ScanKeyData opKey[3]; *candidates = NULL; @@ -404,43 +404,43 @@ binary_oper_get_candidates(char *opname, * the all the candidates operate on the same data types after * promotion (int2, int4, float4 -> float8). */ -static bool +static bool equivalentOpersAfterPromotion(CandidateList candidates) { - CandidateList result; - CandidateList promotedCandidates = NULL; - Oid leftarg, - rightarg; + CandidateList result; + CandidateList promotedCandidates = NULL; + Oid leftarg, + rightarg; for (result = candidates; result != NULL; result = result->next) { - CandidateList c; + CandidateList c; c = (CandidateList) palloc(sizeof(*c)); c->args = (Oid *) palloc(2 * sizeof(Oid)); switch (result->args[0]) { - case FLOAT4OID: - case INT4OID: - case INT2OID: - case CASHOID: - c->args[0] = FLOAT8OID; - break; - default: - c->args[0] = result->args[0]; - break; + case FLOAT4OID: + case INT4OID: + case INT2OID: + case CASHOID: + c->args[0] = FLOAT8OID; + break; + default: + c->args[0] = result->args[0]; + break; } switch (result->args[1]) { - case FLOAT4OID: - case INT4OID: - case INT2OID: - case CASHOID: - c->args[1] = FLOAT8OID; - break; - default: - c->args[1] = result->args[1]; - break; + case FLOAT4OID: + case INT4OID: + case INT2OID: + case CASHOID: + c->args[1] = FLOAT8OID; + break; + default: + c->args[1] = result->args[1]; + break; } c->next = promotedCandidates; promotedCandidates = c; @@ -478,12 +478,12 @@ equivalentOpersAfterPromotion(CandidateList candidates) * given a choice of argument type pairs for a binary operator, * try to choose a default pair */ -static CandidateList +static CandidateList binary_oper_select_candidate(Oid arg1, Oid arg2, CandidateList candidates) { - CandidateList result; + CandidateList result; /* * if both are "unknown", there is no way to select a candidate @@ -538,9 +538,9 @@ binary_oper_select_candidate(Oid arg1, Operator oper(char *op, Oid arg1, Oid arg2, bool noWarnings) { - HeapTuple tup; - CandidateList candidates; - int ncandidates; + HeapTuple tup; + CandidateList candidates; + int ncandidates; if (!arg2) arg2 = arg1; @@ -596,8 +596,8 @@ oper(char *op, Oid arg1, Oid arg2, bool noWarnings) } else { - Type tp1, - tp2; + Type tp1, + tp2; /* we chose none of them */ tp1 = get_id_type(arg1); @@ -627,13 +627,13 @@ unary_oper_get_candidates(char *op, CandidateList * candidates, char rightleft) { - CandidateList current_candidate; - Relation pg_operator_desc; - HeapScanDesc pg_operator_scan; - HeapTuple tup; + CandidateList current_candidate; + Relation pg_operator_desc; + HeapScanDesc pg_operator_scan; + HeapTuple tup; OperatorTupleForm oper; - Buffer buffer; - int ncandidates = 0; + Buffer buffer; + int ncandidates = 0; static ScanKeyData opKey[2] = { {0, Anum_pg_operator_oprname, NameEqualRegProcedure}, @@ -697,9 +697,9 @@ unary_oper_get_candidates(char *op, Operator right_oper(char *op, Oid arg) { - HeapTuple tup; - CandidateList candidates; - int ncandidates; + HeapTuple tup; + CandidateList candidates; + int ncandidates; /* * if (!OpCache) { init_op_cache(); } @@ -742,9 +742,9 @@ right_oper(char *op, Oid arg) Operator left_oper(char *op, Oid arg) { - HeapTuple tup; - CandidateList candidates; - int ncandidates; + HeapTuple tup; + CandidateList candidates; + int ncandidates; /* * if (!OpCache) { init_op_cache(); } @@ -787,7 +787,7 @@ left_oper(char *op, Oid arg) int varattno(Relation rd, char *a) { - int i; + int i; for (i = 0; i < rd->rd_rel->relnatts; i++) { @@ -817,7 +817,7 @@ varattno(Relation rd, char *a) bool varisset(Relation rd, char *name) { - int i; + int i; /* First check if this is a system attribute */ for (i = 0; i < SPECIALS; i++) @@ -834,7 +834,7 @@ varisset(Relation rd, char *name) int nf_varattno(Relation rd, char *a) { - int i; + int i; for (i = 0; i < rd->rd_rel->relnatts; i++) { @@ -856,11 +856,11 @@ nf_varattno(Relation rd, char *a) /*------------- * given an attribute number and a relation, return its relation name */ -char * +char * getAttrName(Relation rd, int attrno) { - char *name; - int i; + char *name; + int i; if (attrno < 0) { @@ -896,12 +896,12 @@ getAttrName(Relation rd, int attrno) /* Given a typename and value, returns the ascii form of the value */ #ifdef NOT_USED -char * +char * outstr(char *typename, /* Name of type of value */ char *value) /* Could be of any type */ { - TypeTupleForm tp; - Oid op; + TypeTupleForm tp; + Oid op; tp = (TypeTupleForm) GETSTRUCT(type(typename)); op = tp->typoutput; @@ -911,7 +911,7 @@ outstr(char *typename, /* Name of type of value */ #endif /* Given a Type and a string, return the internal form of that string */ -char * +char * instr2(Type tp, char *string, int typlen) { return (instr1((TypeTupleForm) GETSTRUCT(tp), string, typlen)); @@ -919,11 +919,11 @@ instr2(Type tp, char *string, int typlen) /* Given a type structure and a string, returns the internal form of that string */ -static char * +static char * instr1(TypeTupleForm tp, char *string, int typlen) { - Oid op; - Oid typelem; + Oid op; + Oid typelem; op = tp->typinput; typelem = tp->typelem; /* XXX - used for array_in */ @@ -937,8 +937,8 @@ instr1(TypeTupleForm tp, char *string, int typlen) Oid GetArrayElementType(Oid typearray) { - HeapTuple type_tuple; - TypeTupleForm type_struct_array; + HeapTuple type_tuple; + TypeTupleForm type_struct_array; type_tuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typearray), @@ -963,8 +963,8 @@ GetArrayElementType(Oid typearray) Oid funcid_get_rettype(Oid funcid) { - HeapTuple func_tuple = NULL; - Oid funcrettype = (Oid) 0; + HeapTuple func_tuple = NULL; + Oid funcrettype = (Oid) 0; func_tuple = SearchSysCacheTuple(PROOID, ObjectIdGetDatum(funcid), 0, 0, 0); @@ -982,21 +982,21 @@ funcid_get_rettype(Oid funcid) * get a list of all argument type vectors for which a function named * funcname taking nargs arguments exists */ -static CandidateList +static CandidateList func_get_candidates(char *funcname, int nargs) { - Relation heapRelation; - Relation idesc; - ScanKeyData skey; - HeapTuple tuple; - IndexScanDesc sd; + Relation heapRelation; + Relation idesc; + ScanKeyData skey; + HeapTuple tuple; + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - Form_pg_proc pgProcP; - bool bufferUsed = FALSE; - CandidateList candidates = NULL; - CandidateList current_candidate; - int i; + Buffer buffer; + Form_pg_proc pgProcP; + bool bufferUsed = FALSE; + CandidateList candidates = NULL; + CandidateList current_candidate; + int i; heapRelation = heap_openr(ProcedureRelationName); ScanKeyEntryInitialize(&skey, @@ -1021,7 +1021,7 @@ func_get_candidates(char *funcname, int nargs) indexRes = index_getnext(sd, ForwardScanDirection); if (indexRes) { - ItemPointer iptr; + ItemPointer iptr; iptr = &indexRes->heap_iptr; tuple = heap_fetch(heapRelation, NowTimeQual, iptr, &buffer); @@ -1060,11 +1060,11 @@ func_get_candidates(char *funcname, int nargs) /* * can input_typeids be coerced to func_typeids? */ -static bool +static bool can_coerce(int nargs, Oid * input_typeids, Oid * func_typeids) { - int i; - Type tp; + int i; + Type tp; /* * right now, we only coerce "unknown", and we cannot coerce it to a @@ -1105,10 +1105,10 @@ match_argtypes(int nargs, CandidateList function_typeids, CandidateList * candidates) /* return value */ { - CandidateList current_candidate; - CandidateList matching_candidate; - Oid *current_typeids; - int ncandidates = 0; + CandidateList current_candidate; + CandidateList matching_candidate; + Oid *current_typeids; + int ncandidates = 0; *candidates = NULL; @@ -1137,7 +1137,7 @@ match_argtypes(int nargs, * returns the selected argtype array if the conflict can be resolved, * otherwise returns NULL */ -static Oid * +static Oid * func_select_candidate(int nargs, Oid * input_typeids, CandidateList candidates) @@ -1155,12 +1155,12 @@ func_get_detail(char *funcname, bool * retset, /* return value */ Oid ** true_typeids) /* return value */ { - Oid **input_typeid_vector; - Oid *current_input_typeids; - CandidateList function_typeids; - CandidateList current_function_typeids; - HeapTuple ftup; - Form_pg_proc pform; + Oid **input_typeid_vector; + Oid *current_input_typeids; + CandidateList function_typeids; + CandidateList current_function_typeids; + HeapTuple ftup; + Form_pg_proc pform; /* * attempt to find named function in the system catalogs with @@ -1191,7 +1191,7 @@ func_get_detail(char *funcname, if (function_typeids != NULL) { - int ncandidates = 0; + int ncandidates = 0; input_typeid_vector = argtype_inherit(nargs, oid_array); current_input_typeids = oid_array; @@ -1244,7 +1244,7 @@ func_get_detail(char *funcname, if (!HeapTupleIsValid(ftup)) { - Type tp; + Type tp; if (nargs == 1) { @@ -1291,12 +1291,12 @@ func_get_detail(char *funcname, * not defined. There are lots of these (mostly builtins) in the * catalogs. */ -static Oid ** +static Oid ** argtype_inherit(int nargs, Oid * oid_array) { - Oid relid; - int i; - InhPaths arginh[MAXFARGS]; + Oid relid; + int i; + InhPaths arginh[MAXFARGS]; for (i = 0; i < MAXFARGS; i++) { @@ -1327,31 +1327,31 @@ argtype_inherit(int nargs, Oid * oid_array) typedef struct _SuperQE { - Oid sqe_relid; -} SuperQE; + Oid sqe_relid; +} SuperQE; static int findsupers(Oid relid, Oid ** supervec) { - Oid *relidvec; - Relation inhrel; - HeapScanDesc inhscan; - ScanKeyData skey; - HeapTuple inhtup; - TupleDesc inhtupdesc; - int nvisited; - SuperQE *qentry, - *vnode; - Dllist *visited, - *queue; - Dlelem *qe, - *elt; - - Relation rd; - Buffer buf; - Datum d; - bool newrelid; - char isNull; + Oid *relidvec; + Relation inhrel; + HeapScanDesc inhscan; + ScanKeyData skey; + HeapTuple inhtup; + TupleDesc inhtupdesc; + int nvisited; + SuperQE *qentry, + *vnode; + Dllist *visited, + *queue; + Dlelem *qe, + *elt; + + Relation rd; + Buffer buf; + Datum d; + bool newrelid; + char isNull; nvisited = 0; queue = DLNewList(); @@ -1451,16 +1451,16 @@ findsupers(Oid relid, Oid ** supervec) return (nvisited); } -static Oid ** +static Oid ** genxprod(InhPaths * arginh, int nargs) { - int nanswers; - Oid **result, - **iter; - Oid *oneres; - int i, - j; - int cur[MAXFARGS]; + int nanswers; + Oid **result, + **iter; + Oid *oneres; + int i, + j; + int cur[MAXFARGS]; nanswers = 1; for (i = 0; i < nargs; i++) @@ -1510,9 +1510,9 @@ genxprod(InhPaths * arginh, int nargs) Oid typeid_get_retinfunc(Oid type_id) { - HeapTuple typeTuple; - TypeTupleForm type; - Oid infunc; + HeapTuple typeTuple; + TypeTupleForm type; + Oid infunc; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type_id), @@ -1531,9 +1531,9 @@ typeid_get_retinfunc(Oid type_id) Oid typeid_get_retoutfunc(Oid type_id) { - HeapTuple typeTuple; - TypeTupleForm type; - Oid outfunc; + HeapTuple typeTuple; + TypeTupleForm type; + Oid outfunc; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type_id), @@ -1551,9 +1551,9 @@ typeid_get_retoutfunc(Oid type_id) Oid typeid_get_relid(Oid type_id) { - HeapTuple typeTuple; - TypeTupleForm type; - Oid infunc; + HeapTuple typeTuple; + TypeTupleForm type; + Oid infunc; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type_id), @@ -1569,7 +1569,7 @@ typeid_get_relid(Oid type_id) Oid get_typrelid(Type typ) { - TypeTupleForm typtup; + TypeTupleForm typtup; typtup = (TypeTupleForm) GETSTRUCT(typ); @@ -1579,8 +1579,8 @@ get_typrelid(Type typ) Oid get_typelem(Oid type_id) { - HeapTuple typeTuple; - TypeTupleForm type; + HeapTuple typeTuple; + TypeTupleForm type; if (!(typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(type_id), @@ -1597,9 +1597,9 @@ get_typelem(Oid type_id) char FindDelimiter(char *typename) { - char delim; - HeapTuple typeTuple; - TypeTupleForm type; + char delim; + HeapTuple typeTuple; + TypeTupleForm type; if (!(typeTuple = SearchSysCacheTuple(TYPNAME, @@ -1623,8 +1623,8 @@ FindDelimiter(char *typename) static void op_error(char *op, Oid arg1, Oid arg2) { - Type tp1 = NULL, - tp2 = NULL; + Type tp1 = NULL, + tp2 = NULL; if (check_typeid(arg1)) { @@ -1659,9 +1659,9 @@ op_error(char *op, Oid arg1, Oid arg2) void func_error(char *caller, char *funcname, int nargs, Oid * argtypes) { - char p[(NAMEDATALEN + 2) * MAXFMGRARGS], - *ptr; - int i; + char p[(NAMEDATALEN + 2) * MAXFMGRARGS], + *ptr; + int i; ptr = p; *ptr = '\0'; diff --git a/src/backend/parser/dbcommands.c b/src/backend/parser/dbcommands.c index 158e033b6e7..e0add781242 100644 --- a/src/backend/parser/dbcommands.c +++ b/src/backend/parser/dbcommands.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.7 1997/09/07 04:44:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/dbcommands.c,v 1.8 1997/09/08 02:25:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,14 +39,14 @@ static void check_permissions(char *command, char *dbname, Oid * dbIdP, Oid * userIdP); static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel); -static void stop_vacuum(char *dbname); +static void stop_vacuum(char *dbname); void createdb(char *dbname) { - Oid db_id, - user_id; - char buf[512]; + Oid db_id, + user_id; + char buf[512]; /* * If this call returns, the database does not exist and we're allowed @@ -78,9 +78,9 @@ createdb(char *dbname) void destroydb(char *dbname) { - Oid user_id, - db_id; - char buf[512]; + Oid user_id, + db_id; + char buf[512]; /* * If this call returns, the database exists and we're allowed to @@ -115,14 +115,14 @@ destroydb(char *dbname) DropBuffers(db_id); } -static HeapTuple +static HeapTuple get_pg_dbtup(char *command, char *dbname, Relation dbrel) { - HeapTuple dbtup; - HeapTuple tup; - Buffer buf; - HeapScanDesc scan; - ScanKeyData scanKey; + HeapTuple dbtup; + HeapTuple tup; + Buffer buf; + HeapScanDesc scan; + ScanKeyData scanKey; ScanKeyEntryInitialize(&scanKey, 0, Anum_pg_database_datname, NameEqualRegProcedure, NameGetDatum(dbname)); @@ -164,14 +164,14 @@ check_permissions(char *command, Oid * dbIdP, Oid * userIdP) { - Relation dbrel; - HeapTuple dbtup, - utup; - Oid dbowner = (Oid) 0; - char use_createdb; - bool dbfound; - bool use_super; - char *userName; + Relation dbrel; + HeapTuple dbtup, + utup; + Oid dbowner = (Oid) 0; + char use_createdb; + bool dbfound; + bool use_super; + char *userName; userName = GetPgUserName(); utup = SearchSysCacheTuple(USENAME, PointerGetDatum(userName), @@ -268,9 +268,9 @@ check_permissions(char *command, static void stop_vacuum(char *dbname) { - char filename[256]; - FILE *fp; - int pid; + char filename[256]; + FILE *fp; + int pid; sprintf(filename, "%s%cbase%c%s%c%s.vacuum", DataDir, SEP_CHAR, SEP_CHAR, dbname, SEP_CHAR, dbname); diff --git a/src/backend/parser/keywords.c b/src/backend/parser/keywords.c index b9f1a273398..8bebcfb0af3 100644 --- a/src/backend/parser/keywords.c +++ b/src/backend/parser/keywords.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.15 1997/09/07 04:44:47 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/keywords.c,v 1.16 1997/09/08 02:25:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -180,13 +180,13 @@ static ScanKeyword ScanKeywords[] = { {"zone", ZONE}, }; -ScanKeyword * +ScanKeyword * ScanKeywordLookup(char *text) { - ScanKeyword *low = &ScanKeywords[0]; - ScanKeyword *high = endof(ScanKeywords) - 1; - ScanKeyword *middle; - int difference; + ScanKeyword *low = &ScanKeywords[0]; + ScanKeyword *high = endof(ScanKeywords) - 1; + ScanKeyword *middle; + int difference; while (low <= high) { @@ -204,13 +204,13 @@ ScanKeywordLookup(char *text) } #ifdef NOT_USED -char * +char * AtomValueGetString(int atomval) { - ScanKeyword *low = &ScanKeywords[0]; - ScanKeyword *high = endof(ScanKeywords) - 1; - int keyword_list_length = (high - low); - int i; + ScanKeyword *low = &ScanKeywords[0]; + ScanKeyword *high = endof(ScanKeywords) - 1; + int keyword_list_length = (high - low); + int i; for (i = 0; i < keyword_list_length; i++) if (ScanKeywords[i].value == atomval) diff --git a/src/backend/parser/parse_query.c b/src/backend/parser/parse_query.c index 5d144660a48..f9670431f33 100644 --- a/src/backend/parser/parse_query.c +++ b/src/backend/parser/parse_query.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.19 1997/09/07 04:44:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/Attic/parse_query.c,v 1.20 1997/09/08 02:25:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,18 +42,18 @@ static void checkTargetTypes(ParseState * pstate, char *target_colname, char *refname, char *colname); -Oid *param_type_info; -int pfunc_num_args; +Oid *param_type_info; +int pfunc_num_args; /* given refname, return a pointer to the range table entry */ -RangeTblEntry * +RangeTblEntry * refnameRangeTableEntry(List * rtable, char *refname) { - List *temp; + List *temp; foreach(temp, rtable) { - RangeTblEntry *rte = lfirst(temp); + RangeTblEntry *rte = lfirst(temp); if (!strcmp(rte->refname, refname)) return rte; @@ -65,13 +65,13 @@ refnameRangeTableEntry(List * rtable, char *refname) int refnameRangeTablePosn(List * rtable, char *refname) { - int index; - List *temp; + int index; + List *temp; index = 1; foreach(temp, rtable) { - RangeTblEntry *rte = lfirst(temp); + RangeTblEntry *rte = lfirst(temp); if (!strcmp(rte->refname, refname)) return index; @@ -83,12 +83,12 @@ refnameRangeTablePosn(List * rtable, char *refname) /* * returns range entry if found, else NULL */ -RangeTblEntry * +RangeTblEntry * colnameRangeTableEntry(ParseState * pstate, char *colname) { - List *et; - List *rtable; - RangeTblEntry *rte_result; + List *et; + List *rtable; + RangeTblEntry *rte_result; if (pstate->p_is_rule) rtable = lnext(lnext(pstate->p_rtable)); @@ -98,7 +98,7 @@ colnameRangeTableEntry(ParseState * pstate, char *colname) rte_result = NULL; foreach(et, rtable) { - RangeTblEntry *rte = lfirst(et); + RangeTblEntry *rte = lfirst(et); /* only entries on outer(non-function?) scope */ if (!rte->inFromCl && rte != pstate->p_target_rangetblentry) @@ -123,15 +123,15 @@ colnameRangeTableEntry(ParseState * pstate, char *colname) * put new entry in pstate p_rtable structure, or return pointer * if pstate null */ -RangeTblEntry * +RangeTblEntry * addRangeTableEntry(ParseState * pstate, char *relname, char *refname, bool inh, bool inFromCl, TimeRange * timeRange) { - Relation relation; - RangeTblEntry *rte = makeNode(RangeTblEntry); + Relation relation; + RangeTblEntry *rte = makeNode(RangeTblEntry); if (pstate != NULL && refnameRangeTableEntry(pstate->p_rtable, refname) != NULL) @@ -179,18 +179,18 @@ addRangeTableEntry(ParseState * pstate, * makes a list of attributes * assumes reldesc caching works */ -List * +List * expandAll(ParseState * pstate, char *relname, char *refname, int *this_resno) { - Relation rdesc; - List *te_tail = NIL, - *te_head = NIL; - Var *varnode; - int varattno, - maxattrs; - Oid type_id; - int type_len; - RangeTblEntry *rte; + Relation rdesc; + List *te_tail = NIL, + *te_head = NIL; + Var *varnode; + int varattno, + maxattrs; + Oid type_id; + int type_len; + RangeTblEntry *rte; rte = refnameRangeTableEntry(pstate->p_rtable, refname); if (rte == NULL) @@ -208,9 +208,9 @@ expandAll(ParseState * pstate, char *relname, char *refname, int *this_resno) for (varattno = 0; varattno <= maxattrs - 1; varattno++) { - char *attrname; - char *resname = NULL; - TargetEntry *te = makeNode(TargetEntry); + char *attrname; + char *resname = NULL; + TargetEntry *te = makeNode(TargetEntry); attrname = pstrdup((rdesc->rd_att->attrs[varattno]->attname).data); varnode = (Var *) make_var(pstate, refname, attrname, &type_id); @@ -248,58 +248,58 @@ makeTimeRange(char *datestring1, char *datestring2, int timecode) /* 0 = snapshot , 1 = timerange */ { - TimeQual qual = NULL; - AbsoluteTime t1, - t2; + TimeQual qual = NULL; + AbsoluteTime t1, + t2; switch (timecode) { - case 0: - if (datestring1 == NULL) - { - elog(WARN, "MakeTimeRange: bad snapshot arg"); - } - t1 = nabstimein(datestring1); - if (!AbsoluteTimeIsValid(t1)) - { - elog(WARN, "bad snapshot time: \"%s\"", - datestring1); - } - qual = TimeFormSnapshotTimeQual(t1); - break; - case 1: - if (datestring1 == NULL) - { - t1 = NOSTART_ABSTIME; - } - else - { + case 0: + if (datestring1 == NULL) + { + elog(WARN, "MakeTimeRange: bad snapshot arg"); + } t1 = nabstimein(datestring1); if (!AbsoluteTimeIsValid(t1)) { - elog(WARN, - "bad range start time: \"%s\"", + elog(WARN, "bad snapshot time: \"%s\"", datestring1); } - } - if (datestring2 == NULL) - { - t2 = NOEND_ABSTIME; - } - else - { - t2 = nabstimein(datestring2); - if (!AbsoluteTimeIsValid(t2)) + qual = TimeFormSnapshotTimeQual(t1); + break; + case 1: + if (datestring1 == NULL) { - elog(WARN, - "bad range end time: \"%s\"", - datestring2); + t1 = NOSTART_ABSTIME; } - } - qual = TimeFormRangedTimeQual(t1, t2); - break; - default: - elog(WARN, "MakeTimeRange: internal parser error"); + else + { + t1 = nabstimein(datestring1); + if (!AbsoluteTimeIsValid(t1)) + { + elog(WARN, + "bad range start time: \"%s\"", + datestring1); + } + } + if (datestring2 == NULL) + { + t2 = NOEND_ABSTIME; + } + else + { + t2 = nabstimein(datestring2); + if (!AbsoluteTimeIsValid(t2)) + { + elog(WARN, + "bad range end time: \"%s\"", + datestring2); + } + } + qual = TimeFormRangedTimeQual(t1, t2); + break; + default: + elog(WARN, "MakeTimeRange: internal parser error"); } return qual; } @@ -319,16 +319,16 @@ disallow_setop(char *op, Type optype, Node * operand) } } -static Node * +static Node * make_operand(char *opname, Node * tree, Oid orig_typeId, Oid true_typeId) { - Node *result; - Type true_type; - Datum val; - Oid infunc; + Node *result; + Type true_type; + Datum val; + Oid infunc; if (tree != NULL) { @@ -337,7 +337,7 @@ make_operand(char *opname, disallow_setop(opname, true_type, result); if (true_typeId != orig_typeId) { /* must coerce */ - Const *con = (Const *) result; + Const *con = (Const *) result; Assert(nodeTag(result) == T_Const); val = (Datum) textout((struct varlena *) @@ -358,7 +358,7 @@ make_operand(char *opname, } else { - Const *con = makeNode(Const); + Const *con = makeNode(Const); con->consttype = true_typeId; con->constlen = 0; @@ -373,17 +373,17 @@ make_operand(char *opname, } -Expr * +Expr * make_op(char *opname, Node * ltree, Node * rtree) { - Oid ltypeId, - rtypeId; - Operator temp; + Oid ltypeId, + rtypeId; + Operator temp; OperatorTupleForm opform; - Oper *newop; - Node *left, - *right; - Expr *result; + Oper *newop; + Node *left, + *right; + Expr *result; if (rtree == NULL) { @@ -409,10 +409,10 @@ make_op(char *opname, Node * ltree, Node * rtree) } else { - char *outstr; - Oid infunc, - outfunc; - Type newtype; + char *outstr; + Oid infunc, + outfunc; + Type newtype; #define CONVERTABLE_TYPE(t) ( (t) == INT2OID || \ (t) == INT4OID || \ @@ -495,9 +495,9 @@ make_op(char *opname, Node * ltree, Node * rtree) Oid find_atttype(Oid relid, char *attrname) { - int attid; - Oid vartype; - Relation rd; + int attid; + Oid vartype; + Relation rd; rd = heap_open(relid); if (!RelationIsValid(rd)) @@ -524,15 +524,15 @@ find_atttype(Oid relid, char *attrname) } -Var * +Var * make_var(ParseState * pstate, char *refname, char *attrname, Oid * type_id) { - Var *varnode; - int vnum, - attid; - Oid vartypeid; - Relation rd; - RangeTblEntry *rte; + Var *varnode; + int vnum, + attid; + Oid vartypeid; + Relation rd; + RangeTblEntry *rte; rte = refnameRangeTableEntry(pstate->p_rtable, refname); if (rte == NULL) @@ -567,18 +567,18 @@ make_var(ParseState * pstate, char *refname, char *attrname, Oid * type_id) * * indirection is a list of A_Indices */ -ArrayRef * +ArrayRef * make_array_ref(Node * expr, List * indirection) { - Oid typearray; - HeapTuple type_tuple; - TypeTupleForm type_struct_array, - type_struct_element; - ArrayRef *aref; - Oid reftype; - List *upperIndexpr = NIL; - List *lowerIndexpr = NIL; + Oid typearray; + HeapTuple type_tuple; + TypeTupleForm type_struct_array, + type_struct_element; + ArrayRef *aref; + Oid reftype; + List *upperIndexpr = NIL; + List *lowerIndexpr = NIL; typearray = exprType(expr); @@ -611,7 +611,7 @@ make_array_ref(Node * expr, while (indirection != NIL) { - A_Indices *ind = lfirst(indirection); + A_Indices *ind = lfirst(indirection); if (ind->lidx) { @@ -649,18 +649,18 @@ make_array_ref(Node * expr, return aref; } -ArrayRef * +ArrayRef * make_array_set(Expr * target_expr, List * upperIndexpr, List * lowerIndexpr, Expr * expr) { - Oid typearray; - HeapTuple type_tuple; - TypeTupleForm type_struct_array; - TypeTupleForm type_struct_element; - ArrayRef *aref; - Oid reftype; + Oid typearray; + HeapTuple type_tuple; + TypeTupleForm type_struct_array; + TypeTupleForm type_struct_element; + ArrayRef *aref; + Oid reftype; typearray = exprType((Node *) target_expr); @@ -723,48 +723,49 @@ make_array_set(Expr * target_expr, * * eventually, produces a "const" lisp-struct as per nodedefs.cl */ -Const * +Const * make_const(Value * value) { - Type tp; - Datum val; - Const *con; + Type tp; + Datum val; + Const *con; switch (nodeTag(value)) { - case T_Integer: - tp = type("int4"); - val = Int32GetDatum(intVal(value)); - break; + case T_Integer: + tp = type("int4"); + val = Int32GetDatum(intVal(value)); + break; - case T_Float: - { - float64 dummy; + case T_Float: + { + float64 dummy; - tp = type("float8"); + tp = type("float8"); - dummy = (float64) palloc(sizeof(float64data)); - *dummy = floatVal(value); + dummy = (float64) palloc(sizeof(float64data)); + *dummy = floatVal(value); - val = Float64GetDatum(dummy); - } - break; + val = Float64GetDatum(dummy); + } + break; - case T_String: - tp = type("unknown"); /* unknown for now, will be type coerced */ - val = PointerGetDatum(textin(strVal(value))); - break; + case T_String: + tp = type("unknown"); /* unknown for now, will be type + * coerced */ + val = PointerGetDatum(textin(strVal(value))); + break; - case T_Null: - default: - { - if (nodeTag(value) != T_Null) - elog(NOTICE, "unknown type : %d\n", nodeTag(value)); + case T_Null: + default: + { + if (nodeTag(value) != T_Null) + elog(NOTICE, "unknown type : %d\n", nodeTag(value)); - /* null const */ - con = makeConst(0, 0, (Datum) NULL, true, false, false, false); - return con; - } + /* null const */ + con = makeConst(0, 0, (Datum) NULL, true, false, false, false); + return con; + } } con = makeConst(typeid(tp), @@ -811,7 +812,7 @@ handleTargetColname(ParseState * pstate, char **resname, { if (pstate->p_insert_columns != NIL) { - Ident *id = lfirst(pstate->p_insert_columns); + Ident *id = lfirst(pstate->p_insert_columns); *resname = id->name; pstate->p_insert_columns = lnext(pstate->p_insert_columns); @@ -831,12 +832,12 @@ static void checkTargetTypes(ParseState * pstate, char *target_colname, char *refname, char *colname) { - Oid attrtype_id, - attrtype_target; - int resdomno_id, - resdomno_target; - Relation rd; - RangeTblEntry *rte; + Oid attrtype_id, + attrtype_target; + int resdomno_id, + resdomno_target; + Relation rd; + RangeTblEntry *rte; if (target_colname == NULL || colname == NULL) return; diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index 99c6ce2bfdb..3ca419dd6b4 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.23 1997/09/07 04:44:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.24 1997/09/08 02:25:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,20 +36,20 @@ #include "access/heapam.h" #include "optimizer/clauses.h" -void init_io(); /* from scan.l */ -void parser_init(Oid * typev, int nargs); /* from gram.y */ -int yyparse(); /* from gram.c */ +void init_io(); /* from scan.l */ +void parser_init(Oid * typev, int nargs); /* from gram.y */ +int yyparse(); /* from gram.c */ -char *parseString; /* the char* which holds the string to be +char *parseString; /* the char* which holds the string to be * parsed */ -char *parseCh; /* a pointer used during parsing to walk +char *parseCh; /* a pointer used during parsing to walk * down ParseString */ -List *parsetree = NIL; +List *parsetree = NIL; #ifdef SETS_FIXED -static void fixupsets(); -static void define_sets(); +static void fixupsets(); +static void define_sets(); #endif /* @@ -57,14 +57,14 @@ static void define_sets(); * * CALLER is responsible for free'ing the list returned */ -QueryTreeList * +QueryTreeList * parser(char *str, Oid * typev, int nargs) { - QueryTreeList *queryList; - int yyresult; + QueryTreeList *queryList; + int yyresult; #if defined(FLEX_SCANNER) - extern void DeleteBuffer(void); + extern void DeleteBuffer(void); #endif /* FLEX_SCANNER */ @@ -131,11 +131,11 @@ fixupsets(Query * parse) static void define_sets(Node * clause) { - Oid setoid; - Type t = type("oid"); - Oid typeoid = typeid(t); - Size oidsize = tlen(t); - bool oidbyval = tbyval(t); + Oid setoid; + Type t = type("oid"); + Oid typeoid = typeid(t); + Size oidsize = tlen(t); + bool oidbyval = tbyval(t); if (clause == NULL) { @@ -170,7 +170,7 @@ define_sets(Node * clause) } else if (or_clause(clause)) { - List *temp; + List *temp; /* mapcan */ foreach(temp, ((Expr *) clause)->args) @@ -180,7 +180,7 @@ define_sets(Node * clause) } else if (is_funcclause(clause)) { - List *temp; + List *temp; /* mapcan */ foreach(temp, ((Expr *) clause)->args) @@ -209,33 +209,33 @@ define_sets(Node * clause) #define PSIZE(PTR) (*((int32 *)(PTR) - 1)) */ -Node * +Node * parser_typecast(Value * expr, TypeName * typename, int typlen) { /* check for passing non-ints */ - Const *adt; - Datum lcp; - Type tp; - char type_string[16]; - int32 len; - char *cp = NULL; - char *const_string = NULL; - bool string_palloced = false; + Const *adt; + Datum lcp; + Type tp; + char type_string[16]; + int32 len; + char *cp = NULL; + char *const_string = NULL; + bool string_palloced = false; switch (nodeTag(expr)) { - case T_String: - const_string = DatumGetPointer(expr->val.str); - break; - case T_Integer: - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%d", expr->val.ival); - break; - default: - elog(WARN, - "parser_typecast: cannot cast this expression to type \"%s\"", - typename->name); + case T_String: + const_string = DatumGetPointer(expr->val.str); + break; + case T_Integer: + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%d", expr->val.ival); + break; + default: + elog(WARN, + "parser_typecast: cannot cast this expression to type \"%s\"", + typename->name); } if (typename->arrayBounds != NIL) @@ -253,49 +253,49 @@ parser_typecast(Value * expr, TypeName * typename, int typlen) #if 0 /* fix me */ switch (CInteger(lfirst(expr))) { - case INT4OID: /* int4 */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%d", ((Const *) lnext(expr))->constvalue); - break; - - case NAMEOID: /* char16 */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%s", ((Const *) lnext(expr))->constvalue); - break; - - case CHAROID: /* char */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%c", ((Const) lnext(expr))->constvalue); - break; - - case FLOAT8OID: /* float8 */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%f", ((Const) lnext(expr))->constvalue); - break; - - case CASHOID: /* money */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%d", - (int) ((Const *) expr)->constvalue); - break; - - case TEXTOID: /* text */ - const_string = DatumGetPointer(((Const) lnext(expr))->constvalue); - const_string = (char *) textout((struct varlena *) const_string); - break; - - case UNKNOWNOID: /* unknown */ - const_string = DatumGetPointer(((Const) lnext(expr))->constvalue); - const_string = (char *) textout((struct varlena *) const_string); - break; - - default: - elog(WARN, "unknown type %d", CInteger(lfirst(expr))); + case INT4OID: /* int4 */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%d", ((Const *) lnext(expr))->constvalue); + break; + + case NAMEOID: /* char16 */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%s", ((Const *) lnext(expr))->constvalue); + break; + + case CHAROID: /* char */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%c", ((Const) lnext(expr))->constvalue); + break; + + case FLOAT8OID: /* float8 */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%f", ((Const) lnext(expr))->constvalue); + break; + + case CASHOID: /* money */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%d", + (int) ((Const *) expr)->constvalue); + break; + + case TEXTOID: /* text */ + const_string = DatumGetPointer(((Const) lnext(expr))->constvalue); + const_string = (char *) textout((struct varlena *) const_string); + break; + + case UNKNOWNOID: /* unknown */ + const_string = DatumGetPointer(((Const) lnext(expr))->constvalue); + const_string = (char *) textout((struct varlena *) const_string); + break; + + default: + elog(WARN, "unknown type %d", CInteger(lfirst(expr))); } #endif @@ -317,18 +317,18 @@ parser_typecast(Value * expr, TypeName * typename, int typlen) { switch (len) { - case 1: - lcp = Int8GetDatum(cp); - break; - case 2: - lcp = Int16GetDatum(cp); - break; - case 4: - lcp = Int32GetDatum(cp); - break; - default: - lcp = PointerGetDatum(cp); - break; + case 1: + lcp = Int8GetDatum(cp); + break; + case 2: + lcp = Int16GetDatum(cp); + break; + case 4: + lcp = Int32GetDatum(cp); + break; + default: + lcp = PointerGetDatum(cp); + break; } } @@ -346,80 +346,80 @@ parser_typecast(Value * expr, TypeName * typename, int typlen) return (Node *) adt; } -Node * +Node * parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen) { /* check for passing non-ints */ - Const *adt; - Datum lcp; - int32 len = tlen(tp); - char *cp = NULL; + Const *adt; + Datum lcp; + int32 len = tlen(tp); + char *cp = NULL; - char *const_string = NULL; - bool string_palloced = false; + char *const_string = NULL; + bool string_palloced = false; Assert(IsA(expr, Const)); switch (exprType) { - case 0: /* NULL */ - break; - case INT4OID: /* int4 */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%d", - (int) ((Const *) expr)->constvalue); - break; - case NAMEOID: /* char16 */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%s", - (char *) ((Const *) expr)->constvalue); - break; - case CHAROID: /* char */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%c", - (char) ((Const *) expr)->constvalue); - break; - case FLOAT4OID: /* float4 */ - { - float32 floatVal = - DatumGetFloat32(((Const *) expr)->constvalue); - + case 0: /* NULL */ + break; + case INT4OID: /* int4 */ const_string = (char *) palloc(256); string_palloced = true; - sprintf(const_string, "%f", *floatVal); + sprintf(const_string, "%d", + (int) ((Const *) expr)->constvalue); break; - } - case FLOAT8OID: /* float8 */ - { - float64 floatVal = - DatumGetFloat64(((Const *) expr)->constvalue); - + case NAMEOID: /* char16 */ const_string = (char *) palloc(256); string_palloced = true; - sprintf(const_string, "%f", *floatVal); + sprintf(const_string, "%s", + (char *) ((Const *) expr)->constvalue); break; - } - case CASHOID: /* money */ - const_string = (char *) palloc(256); - string_palloced = true; - sprintf(const_string, "%d", - (long) ((Const *) expr)->constvalue); - break; - case TEXTOID: /* text */ - const_string = - DatumGetPointer(((Const *) expr)->constvalue); - const_string = (char *) textout((struct varlena *) const_string); - break; - case UNKNOWNOID: /* unknown */ - const_string = - DatumGetPointer(((Const *) expr)->constvalue); - const_string = (char *) textout((struct varlena *) const_string); - break; - default: - elog(WARN, "unknown type %u ", exprType); + case CHAROID: /* char */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%c", + (char) ((Const *) expr)->constvalue); + break; + case FLOAT4OID: /* float4 */ + { + float32 floatVal = + DatumGetFloat32(((Const *) expr)->constvalue); + + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%f", *floatVal); + break; + } + case FLOAT8OID: /* float8 */ + { + float64 floatVal = + DatumGetFloat64(((Const *) expr)->constvalue); + + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%f", *floatVal); + break; + } + case CASHOID: /* money */ + const_string = (char *) palloc(256); + string_palloced = true; + sprintf(const_string, "%d", + (long) ((Const *) expr)->constvalue); + break; + case TEXTOID: /* text */ + const_string = + DatumGetPointer(((Const *) expr)->constvalue); + const_string = (char *) textout((struct varlena *) const_string); + break; + case UNKNOWNOID: /* unknown */ + const_string = + DatumGetPointer(((Const *) expr)->constvalue); + const_string = (char *) textout((struct varlena *) const_string); + break; + default: + elog(WARN, "unknown type %u ", exprType); } if (!exprType) @@ -453,18 +453,18 @@ parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen) { switch (len) { - case 1: - lcp = Int8GetDatum(cp); - break; - case 2: - lcp = Int16GetDatum(cp); - break; - case 4: - lcp = Int32GetDatum(cp); - break; - default: - lcp = PointerGetDatum(cp); - break; + case 1: + lcp = Int8GetDatum(cp); + break; + case 2: + lcp = Int16GetDatum(cp); + break; + case 4: + lcp = Int32GetDatum(cp); + break; + default: + lcp = PointerGetDatum(cp); + break; } } @@ -485,15 +485,15 @@ parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen) return ((Node *) adt); } -Aggreg * +Aggreg * ParseAgg(char *aggname, Oid basetype, Node * target) { - Oid fintype; - Oid vartype; - Oid xfn1; + Oid fintype; + Oid vartype; + Oid xfn1; Form_pg_aggregate aggform; - Aggreg *aggreg; - HeapTuple theAggTuple; + Aggreg *aggreg; + HeapTuple theAggTuple; theAggTuple = SearchSysCacheTuple(AGGNAME, PointerGetDatum(aggname), ObjectIdGetDatum(basetype), @@ -521,8 +521,8 @@ ParseAgg(char *aggname, Oid basetype, Node * target) if (basetype != vartype) { - Type tp1, - tp2; + Type tp1, + tp2; tp1 = get_id_type(basetype); tp2 = get_id_type(vartype); diff --git a/src/backend/parser/scansup.c b/src/backend/parser/scansup.c index 0b944528980..dcc66145a50 100644 --- a/src/backend/parser/scansup.c +++ b/src/backend/parser/scansup.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.6 1997/09/07 04:44:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/scansup.c,v 1.7 1997/09/08 02:25:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,13 +38,13 @@ * ---------------- */ -char * +char * scanstr(char *s) { - static char newStr[MAX_PARSE_BUFFER]; - int len, - i, - j; + static char newStr[MAX_PARSE_BUFFER]; + int len, + i, + j; if (s == NULL || s[0] == '\0') return s; @@ -66,60 +66,60 @@ scanstr(char *s) i = i + 1; switch (s[i]) { - case '\\': - newStr[j] = '\\'; - break; - case 'b': - newStr[j] = '\b'; - break; - case 'f': - newStr[j] = '\f'; - break; - case 'n': - newStr[j] = '\n'; - break; - case 'r': - newStr[j] = '\r'; - break; - case 't': - newStr[j] = '\t'; - break; - case '"': - newStr[j] = '"'; - break; - case '\'': - newStr[j] = '\''; - break; - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - { - char octal[4]; - int k; - long octVal; + case '\\': + newStr[j] = '\\'; + break; + case 'b': + newStr[j] = '\b'; + break; + case 'f': + newStr[j] = '\f'; + break; + case 'n': + newStr[j] = '\n'; + break; + case 'r': + newStr[j] = '\r'; + break; + case 't': + newStr[j] = '\t'; + break; + case '"': + newStr[j] = '"'; + break; + case '\'': + newStr[j] = '\''; + break; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + { + char octal[4]; + int k; + long octVal; - for (k = 0; + for (k = 0; s[i + k] >= '0' && s[i + k] <= '7' && k < 3; - k++) - octal[k] = s[i + k]; - i += k - 1; - octal[3] = '\0'; + k++) + octal[k] = s[i + k]; + i += k - 1; + octal[3] = '\0'; - octVal = strtol(octal, 0, 8); + octVal = strtol(octal, 0, 8); /* elog (NOTICE, "octal = %s octVal = %d, %od", octal, octVal, octVal);*/ - if (octVal <= 0377) - { - newStr[j] = ((char) octVal); - break; + if (octVal <= 0377) + { + newStr[j] = ((char) octVal); + break; + } } - } - default: - newStr[j] = s[i]; + default: + newStr[j] = s[i]; } /* switch */ } /* s[i] == '\\' */ else diff --git a/src/backend/parser/sysfunc.c b/src/backend/parser/sysfunc.c index 02d6d6b21a7..f65f9b863ed 100644 --- a/src/backend/parser/sysfunc.c +++ b/src/backend/parser/sysfunc.c @@ -27,12 +27,12 @@ * Can't get much more obvious than this. Might need to replace localtime() * on older systems... */ -static char * +static char * Sysfunc_system_date(void) { - time_t cur_time_secs; - struct tm *cur_time_expanded; - static char buf[12]; /* Just for safety, y'understand... */ + time_t cur_time_secs; + struct tm *cur_time_expanded; + static char buf[12]; /* Just for safety, y'understand... */ time(&cur_time_secs); cur_time_expanded = localtime(&cur_time_secs); @@ -46,12 +46,12 @@ Sysfunc_system_date(void) return &buf[0]; } -static char * +static char * Sysfunc_system_time(void) { - time_t cur_time_secs; - struct tm *cur_time_expanded; - static char buf[10]; /* Just for safety, y'understand... */ + time_t cur_time_secs; + struct tm *cur_time_expanded; + static char buf[10]; /* Just for safety, y'understand... */ time(&cur_time_secs); cur_time_expanded = localtime(&cur_time_secs); @@ -61,7 +61,7 @@ Sysfunc_system_time(void) return &buf[0]; } -char * +char * SystemFunctionHandler(char *funct) { if (!strcmp(funct, "SYS_DATE")) diff --git a/src/backend/port/BSD44_derived/dl.c b/src/backend/port/BSD44_derived/dl.c index 091507204b4..42d15d840f3 100644 --- a/src/backend/port/BSD44_derived/dl.c +++ b/src/backend/port/BSD44_derived/dl.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; +static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ @@ -46,26 +46,26 @@ static char sccsid[] = "@(#)dl.c 5.4 (Berkeley) 2/23/91"; #include "port-protos.h" -static char error_message[BUFSIZ]; +static char error_message[BUFSIZ]; -char * +char * BSD44_derived_dlerror(void) { - static char ret[BUFSIZ]; + static char ret[BUFSIZ]; strcpy(ret, error_message); error_message[0] = 0; return ((ret[0] == 0) ? (char *) NULL : ret); } -void * +void * BSD44_derived_dlopen(const char *file, int num) { #ifdef __mips__ sprintf(error_message, "dlopen (%s) not supported", file); return NULL; #else - void *vp; + void *vp; if ((vp = dlopen((char *) file, num)) == (void *) NULL) { @@ -75,15 +75,15 @@ BSD44_derived_dlopen(const char *file, int num) #endif } -void * +void * BSD44_derived_dlsym(void *handle, const char *name) { #ifdef __mips__ sprintf(error_message, "dlsym (%s) failed", name); return NULL; #else - void *vp; - char buf[BUFSIZ]; + void *vp; + char buf[BUFSIZ]; if (*name != '_') { diff --git a/src/backend/port/BSD44_derived/port-protos.h b/src/backend/port/BSD44_derived/port-protos.h index 2452355d29d..224058dfeaa 100644 --- a/src/backend/port/BSD44_derived/port-protos.h +++ b/src/backend/port/BSD44_derived/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.7 1997/09/07 04:45:03 momjian Exp $ + * $Id: port-protos.h,v 1.8 1997/09/08 02:25:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,9 +40,9 @@ #define pg_dlclose BSD44_derived_dlclose #define pg_dlerror BSD44_derived_dlerror -char *BSD44_derived_dlerror(void); -void *BSD44_derived_dlopen(const char *filename, int num); -void *BSD44_derived_dlsym(void *handle, const char *name); -void BSD44_derived_dlclose(void *handle); +char *BSD44_derived_dlerror(void); +void *BSD44_derived_dlopen(const char *filename, int num); +void *BSD44_derived_dlsym(void *handle, const char *name); +void BSD44_derived_dlclose(void *handle); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/aix/dlfcn.c b/src/backend/port/aix/dlfcn.c index 58a3dea3c12..e42b00f247c 100644 --- a/src/backend/port/aix/dlfcn.c +++ b/src/backend/port/aix/dlfcn.c @@ -24,9 +24,9 @@ typedef struct { - char *name; /* the symbols's name */ - void *addr; /* its relocated virtual address */ -} Export, *ExportPtr; + char *name; /* the symbols's name */ + void *addr; /* its relocated virtual address */ +} Export, *ExportPtr; /* * xlC uses the following structure to list its constructors and @@ -34,24 +34,24 @@ typedef struct */ typedef struct { - void (*init) (void); /* call static constructors */ - void (*term) (void); /* call static destructors */ -} Cdtor, *CdtorPtr; + void (*init) (void); /* call static constructors */ + void (*term) (void); /* call static destructors */ +} Cdtor, *CdtorPtr; /* * The void * handle returned from dlopen is actually a ModulePtr. */ typedef struct Module { - struct Module *next; - char *name; /* module name for refcounting */ - int refCnt; /* the number of references */ - void *entry; /* entry point from load */ + struct Module *next; + char *name; /* module name for refcounting */ + int refCnt; /* the number of references */ + void *entry; /* entry point from load */ struct dl_info *info; /* optional init/terminate functions */ - CdtorPtr cdtors; /* optional C++ constructors */ - int nExports; /* the number of exports found */ - ExportPtr exports; /* the array of exports */ -} Module, *ModulePtr; + CdtorPtr cdtors; /* optional C++ constructors */ + int nExports; /* the number of exports found */ + ExportPtr exports; /* the array of exports */ +} Module, *ModulePtr; /* * We keep a list of all loaded modules to be able to call the fini @@ -63,20 +63,20 @@ static ModulePtr modList; * The last error from one of the dl* routines is kept in static * variables here. Each error is returned only once to the caller. */ -static char errbuf[BUFSIZ]; -static int errvalid; +static char errbuf[BUFSIZ]; +static int errvalid; -extern char *strdup(const char *); -static void caterr(char *); -static int readExports(ModulePtr); -static void terminate(void); -static void *findMain(void); +extern char *strdup(const char *); +static void caterr(char *); +static int readExports(ModulePtr); +static void terminate(void); +static void *findMain(void); -void * +void * dlopen(const char *path, int mode) { register ModulePtr mp; - static void *mainModule; + static void *mainModule; /* * Upon the first call register a terminate handler that will close @@ -134,13 +134,13 @@ dlopen(const char *path, int mode) */ if (errno == ENOEXEC) { - char *tmp[BUFSIZ / sizeof(char *)]; + char *tmp[BUFSIZ / sizeof(char *)]; if (loadquery(L_GETMESSAGES, tmp, sizeof(tmp)) == -1) strcpy(errbuf, strerror(errno)); else { - char **p; + char **p; for (p = tmp; *p; p++) caterr(*p); @@ -221,46 +221,46 @@ dlopen(const char *path, int mode) static void caterr(char *s) { - register char *p = s; + register char *p = s; while (*p >= '0' && *p <= '9') p++; switch (atoi(s)) { - case L_ERROR_TOOMANY: - strcat(errbuf, "to many errors"); - break; - case L_ERROR_NOLIB: - strcat(errbuf, "can't load library"); - strcat(errbuf, p); - break; - case L_ERROR_UNDEF: - strcat(errbuf, "can't find symbol"); - strcat(errbuf, p); - break; - case L_ERROR_RLDBAD: - strcat(errbuf, "bad RLD"); - strcat(errbuf, p); - break; - case L_ERROR_FORMAT: - strcat(errbuf, "bad exec format in"); - strcat(errbuf, p); - break; - case L_ERROR_ERRNO: - strcat(errbuf, strerror(atoi(++p))); - break; - default: - strcat(errbuf, s); - break; + case L_ERROR_TOOMANY: + strcat(errbuf, "to many errors"); + break; + case L_ERROR_NOLIB: + strcat(errbuf, "can't load library"); + strcat(errbuf, p); + break; + case L_ERROR_UNDEF: + strcat(errbuf, "can't find symbol"); + strcat(errbuf, p); + break; + case L_ERROR_RLDBAD: + strcat(errbuf, "bad RLD"); + strcat(errbuf, p); + break; + case L_ERROR_FORMAT: + strcat(errbuf, "bad exec format in"); + strcat(errbuf, p); + break; + case L_ERROR_ERRNO: + strcat(errbuf, strerror(atoi(++p))); + break; + default: + strcat(errbuf, s); + break; } } -void * +void * dlsym(void *handle, const char *symbol) { register ModulePtr mp = (ModulePtr) handle; register ExportPtr ep; - register int i; + register int i; /* * Could speed up the search, but I assume that one assigns the result @@ -275,7 +275,7 @@ dlsym(void *handle, const char *symbol) return NULL; } -char * +char * dlerror(void) { if (errvalid) @@ -290,7 +290,7 @@ int dlclose(void *handle) { register ModulePtr mp = (ModulePtr) handle; - int result; + int result; register ModulePtr mp1; if (--mp->refCnt > 0) @@ -312,7 +312,7 @@ dlclose(void *handle) if (mp->exports) { register ExportPtr ep; - register int i; + register int i; for (ep = mp->exports, i = mp->nExports; i; i--, ep++) if (ep->name) @@ -348,20 +348,20 @@ terminate(void) static int readExports(ModulePtr mp) { - LDFILE *ldp = NULL; - SCNHDR sh, - shdata; - LDHDR *lhp; - char *ldbuf; - LDSYM *ls; - int i; - ExportPtr ep; + LDFILE *ldp = NULL; + SCNHDR sh, + shdata; + LDHDR *lhp; + char *ldbuf; + LDSYM *ls; + int i; + ExportPtr ep; if ((ldp = ldopen(mp->name, ldp)) == NULL) { struct ld_info *lp; - char *buf; - int size = 4 * 1024; + char *buf; + int size = 4 * 1024; if (errno != ENOENT) { @@ -522,8 +522,8 @@ readExports(ModulePtr mp) ls = (LDSYM *) (ldbuf + LDHDRSZ); for (i = lhp->l_nsyms; i; i--, ls++) { - char *symname; - char tmpsym[SYMNMLEN + 1]; + char *symname; + char tmpsym[SYMNMLEN + 1]; if (!LDR_EXPORT(*ls)) continue; @@ -555,14 +555,14 @@ readExports(ModulePtr mp) * Find the main modules entry point. This is used as export pointer * for loadbind() to be able to resolve references to the main part. */ -static void * +static void * findMain(void) { struct ld_info *lp; - char *buf; - int size = 4 * 1024; - int i; - void *ret; + char *buf; + int size = 4 * 1024; + int i; + void *ret; if ((buf = malloc(size)) == NULL) { diff --git a/src/backend/port/aix/dlfcn.h b/src/backend/port/aix/dlfcn.h index 1e874d96559..0a4f322e9dc 100644 --- a/src/backend/port/aix/dlfcn.h +++ b/src/backend/port/aix/dlfcn.h @@ -8,7 +8,7 @@ #define __dlfcn_h__ #ifdef __cplusplus -extern "C" +extern "C" { #endif @@ -25,20 +25,20 @@ extern "C" */ struct dl_info { - void (*init) (void); - void (*fini) (void); + void (*init) (void); + void (*fini) (void); }; #if __STDC__ || defined(_IBMR2) - void *dlopen(const char *path, int mode); - void *dlsym(void *handle, const char *symbol); - char *dlerror(void); - int dlclose(void *handle); + void *dlopen(const char *path, int mode); + void *dlsym(void *handle, const char *symbol); + char *dlerror(void); + int dlclose(void *handle); #else - void *dlopen(); - void *dlsym(); - char *dlerror(); - int dlclose(); + void *dlopen(); + void *dlsym(); + char *dlerror(); + int dlclose(); #endif #ifdef __cplusplus diff --git a/src/backend/port/alpha/port-protos.h b/src/backend/port/alpha/port-protos.h index 3b5cb47adea..89c7d420435 100644 --- a/src/backend/port/alpha/port-protos.h +++ b/src/backend/port/alpha/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.2 1997/09/07 04:45:20 momjian Exp $ + * $Id: port-protos.h,v 1.3 1997/09/08 02:25:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,6 +34,6 @@ /* port.c */ -extern void init_address_fixup(void); +extern void init_address_fixup(void); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/alpha/port.c b/src/backend/port/alpha/port.c index 80b03088a43..e01ca93dc82 100644 --- a/src/backend/port/alpha/port.c +++ b/src/backend/port/alpha/port.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/port.c,v 1.2 1997/09/07 04:45:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/alpha/Attic/port.c,v 1.3 1997/09/08 02:25:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,11 +21,11 @@ void init_address_fixup() { #ifdef NOFIXADE - int buffer[] = {SSIN_UACPROC, UAC_SIGBUS}; + int buffer[] = {SSIN_UACPROC, UAC_SIGBUS}; #endif /* NOFIXADE */ #ifdef NOPRINTADE - int buffer[] = {SSIN_UACPROC, UAC_NOPRINT}; + int buffer[] = {SSIN_UACPROC, UAC_NOPRINT}; #endif /* NOPRINTADE */ diff --git a/src/backend/port/bsdi/dynloader.c b/src/backend/port/bsdi/dynloader.c index cfaeec0c200..9754236a20b 100644 --- a/src/backend/port/bsdi/dynloader.c +++ b/src/backend/port/bsdi/dynloader.c @@ -22,12 +22,12 @@ #include "utils/elog.h" #include "fmgr.h" -extern char pg_pathname[]; +extern char pg_pathname[]; -void * +void * pg_dlopen(char *filename) { - static int dl_initialized = 0; + static int dl_initialized = 0; /* * initializes the dynamic loader with the executable's pathname. @@ -76,8 +76,8 @@ pg_dlopen(char *filename) } if (dld_undefined_sym_count > 0) { - int count = dld_undefined_sym_count; - char **list = dld_list_undefined_sym(); + int count = dld_undefined_sym_count; + char **list = dld_list_undefined_sym(); /* list the undefined symbols, if any */ elog(NOTICE, "dld: Undefined:"); @@ -97,7 +97,7 @@ pg_dlopen(char *filename) return (void *) strdup(filename); } -char * +char * pg_dlerror() { return dld_strerror(dld_errno); diff --git a/src/backend/port/bsdi/port-protos.h b/src/backend/port/bsdi/port-protos.h index acd0e85a49b..579706d0bb8 100644 --- a/src/backend/port/bsdi/port-protos.h +++ b/src/backend/port/bsdi/port-protos.h @@ -17,8 +17,8 @@ * Externals in libc that need prototypes (or at least declarations) */ -extern char *ecvt(double, int, int *, int *); -extern char *fcvt(double, int, int *, int *); +extern char *ecvt(double, int, int *, int *); +extern char *fcvt(double, int, int *, int *); #include "fmgr.h" /* for func_ptr */ diff --git a/src/backend/port/dgux/dynloader.c b/src/backend/port/dgux/dynloader.c index 0f7d38bc092..47834c74863 100644 --- a/src/backend/port/dgux/dynloader.c +++ b/src/backend/port/dgux/dynloader.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.2 1997/09/07 04:45:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/dgux/Attic/dynloader.c,v 1.3 1997/09/08 02:26:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,12 +19,12 @@ #include "utils/elog.h" #include "fmgr.h" -extern char pg_pathname[]; +extern char pg_pathname[]; -void * +void * pg_dlopen(char *filename) { - static int dl_initialized = 0; + static int dl_initialized = 0; /* * initializes the dynamic loader with the executable's pathname. @@ -73,8 +73,8 @@ pg_dlopen(char *filename) } if (dld_undefined_sym_count > 0) { - int count = dld_undefined_sym_count; - char **list = dld_list_undefined_sym(); + int count = dld_undefined_sym_count; + char **list = dld_list_undefined_sym(); /* list the undefined symbols, if any */ elog(NOTICE, "dld: Undefined:"); @@ -94,7 +94,7 @@ pg_dlopen(char *filename) return (void *) strdup(filename); } -char * +char * pg_dlerror() { return dld_strerror(dld_errno); diff --git a/src/backend/port/hpux/dynloader.c b/src/backend/port/hpux/dynloader.c index 3c7a8acaa7a..972654adb50 100644 --- a/src/backend/port/hpux/dynloader.c +++ b/src/backend/port/hpux/dynloader.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.2 1997/09/07 04:45:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/hpux/Attic/dynloader.c,v 1.3 1997/09/08 02:26:15 momjian Exp $ * * NOTES * all functions are defined here -- it's impossible to trace the @@ -24,10 +24,10 @@ #include "utils/dynamic_loader.h" #include "port-protos.h" -void * +void * pg_dlopen(char *filename) { - shl_t handle = shl_load(filename, BIND_DEFERRED, 0); + shl_t handle = shl_load(filename, BIND_DEFERRED, 0); return ((void *) handle); } @@ -35,7 +35,7 @@ pg_dlopen(char *filename) func_ptr pg_dlsym(void *handle, char *funcname) { - func_ptr f; + func_ptr f; if (shl_findsym((shl_t *) & handle, funcname, TYPE_PROCEDURE, &f) == -1) { @@ -50,10 +50,10 @@ pg_dlclose(void *handle) shl_unload((shl_t) handle); } -char * +char * pg_dlerror() { - static char errmsg[] = "shl_load failed"; + static char errmsg[] = "shl_load failed"; return errmsg; } diff --git a/src/backend/port/hpux/fixade.h b/src/backend/port/hpux/fixade.h index 094cd13ca83..8ed40481aba 100644 --- a/src/backend/port/hpux/fixade.h +++ b/src/backend/port/hpux/fixade.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fixade.h,v 1.2 1997/09/07 04:45:48 momjian Exp $ + * $Id: fixade.h,v 1.3 1997/09/08 02:26:22 momjian Exp $ * * NOTES * This must be included in EVERY source file. @@ -47,11 +47,11 @@ */ struct HP_WAY_BOGUS { - char hpwb_bogus[8192]; + char hpwb_bogus[8192]; }; struct HP_TOO_BOGUS { - int hptb_bogus[8192]; + int hptb_bogus[8192]; }; #endif /* BROKEN_STRUCT_INIT */ diff --git a/src/backend/port/hpux/port-protos.h b/src/backend/port/hpux/port-protos.h index 76b336aae22..7b4fad99fa7 100644 --- a/src/backend/port/hpux/port-protos.h +++ b/src/backend/port/hpux/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.3 1997/09/07 04:45:51 momjian Exp $ + * $Id: port-protos.h,v 1.4 1997/09/08 02:26:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,11 +24,11 @@ /* port.c */ -extern int init_address_fixup(void); -extern double rint(double x); -extern double cbrt(double x); -extern long random(void); -extern void srandom(unsigned seed); -extern int getrusage(int who, struct rusage * ru); +extern int init_address_fixup(void); +extern double rint(double x); +extern double cbrt(double x); +extern long random(void); +extern void srandom(unsigned seed); +extern int getrusage(int who, struct rusage * ru); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/hpux/rusagestub.h b/src/backend/port/hpux/rusagestub.h index 5eda998802e..9f32a10cc10 100644 --- a/src/backend/port/hpux/rusagestub.h +++ b/src/backend/port/hpux/rusagestub.h @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/i386_solaris/port-protos.h b/src/backend/port/i386_solaris/port-protos.h index 6118a650460..dd5d73418a2 100644 --- a/src/backend/port/i386_solaris/port-protos.h +++ b/src/backend/port/i386_solaris/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.2 1997/09/07 04:45:56 momjian Exp $ + * $Id: port-protos.h,v 1.3 1997/09/08 02:26:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ #define pg_dlerror dlerror /* port.c */ -extern long random(void); -extern void srandom(int seed); +extern long random(void); +extern void srandom(int seed); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/i386_solaris/port.c b/src/backend/port/i386_solaris/port.c index 119163a1869..71e8d9b95d3 100644 --- a/src/backend/port/i386_solaris/port.c +++ b/src/backend/port/i386_solaris/port.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/port.c,v 1.2 1997/09/07 04:45:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/i386_solaris/Attic/port.c,v 1.3 1997/09/08 02:26:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,10 +31,10 @@ srandom(int seed) int getrusage(int who, struct rusage * rusage) { - struct tms tms; - register int tick_rate = CLK_TCK; /* ticks per second */ - clock_t u, - s; + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, + s; if (rusage == (struct rusage *) NULL) { @@ -48,17 +48,17 @@ getrusage(int who, struct rusage * rusage) } switch (who) { - case RUSAGE_SELF: - u = tms.tms_utime; - s = tms.tms_stime; - break; - case RUSAGE_CHILDREN: - u = tms.tms_cutime; - s = tms.tms_cstime; - break; - default: - errno = EINVAL; - return (-1); + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return (-1); } #define TICK_TO_SEC(T, RATE) ((T)/(RATE)) #define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) diff --git a/src/backend/port/i386_solaris/rusagestub.h b/src/backend/port/i386_solaris/rusagestub.h index c6e2ceae453..1370e509c5c 100644 --- a/src/backend/port/i386_solaris/rusagestub.h +++ b/src/backend/port/i386_solaris/rusagestub.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rusagestub.h,v 1.2 1997/09/07 04:46:04 momjian Exp $ + * $Id: rusagestub.h,v 1.3 1997/09/08 02:26:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/inet_aton.c b/src/backend/port/inet_aton.c index 122875eda3b..f1283e6e6b6 100644 --- a/src/backend/port/inet_aton.c +++ b/src/backend/port/inet_aton.c @@ -58,10 +58,10 @@ int inet_aton(const char *cp, struct in_addr * addr) { register u_long val; - register int base, - n; - register char c; - u_int parts[4]; + register int base, + n; + register char c; + u_int parts[4]; register u_int *pp = parts; for (;;) @@ -125,26 +125,26 @@ inet_aton(const char *cp, struct in_addr * addr) switch (n) { - case 1: /* a -- 32 bits */ - break; + case 1: /* a -- 32 bits */ + break; - case 2: /* a.b -- 8.24 bits */ - if (val > 0xffffff) - return (0); - val |= parts[0] << 24; - break; + case 2: /* a.b -- 8.24 bits */ + if (val > 0xffffff) + return (0); + val |= parts[0] << 24; + break; - case 3: /* a.b.c -- 8.8.16 bits */ - if (val > 0xffff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16); - break; + case 3: /* a.b.c -- 8.8.16 bits */ + if (val > 0xffff) + return (0); + val |= (parts[0] << 24) | (parts[1] << 16); + break; - case 4: /* a.b.c.d -- 8.8.8.8 bits */ - if (val > 0xff) - return (0); - val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); - break; + case 4: /* a.b.c.d -- 8.8.8.8 bits */ + if (val > 0xff) + return (0); + val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8); + break; } if (addr) addr->s_addr = htonl(val); diff --git a/src/backend/port/inet_aton.h b/src/backend/port/inet_aton.h index b1df9a8ff3d..8d04f544bcd 100644 --- a/src/backend/port/inet_aton.h +++ b/src/backend/port/inet_aton.h @@ -1,2 +1,2 @@ int - inet_aton(const char *cp, struct in_addr * addr); + inet_aton(const char *cp, struct in_addr * addr); diff --git a/src/backend/port/irix5/port-protos.h b/src/backend/port/irix5/port-protos.h index be894ed5b12..2babb773e0f 100644 --- a/src/backend/port/irix5/port-protos.h +++ b/src/backend/port/irix5/port-protos.h @@ -32,6 +32,6 @@ #define pg_dlerror dlerror /* port.c */ -extern long random(void); +extern long random(void); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/linux/dynloader.c b/src/backend/port/linux/dynloader.c index adb13b40194..ee4f17cb9d2 100644 --- a/src/backend/port/linux/dynloader.c +++ b/src/backend/port/linux/dynloader.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/dynloader.c,v 1.3 1997/09/07 04:46:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/linux/Attic/dynloader.c,v 1.4 1997/09/08 02:26:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,16 +23,16 @@ #include "utils/elog.h" #include "fmgr.h" -extern char pg_pathname[]; +extern char pg_pathname[]; -void * +void * pg_dlopen(char *filename) { #ifndef HAVE_DLD_H elog(WARN, "dynamic load not supported"); return (NULL); #else - static int dl_initialized = 0; + static int dl_initialized = 0; /* * initializes the dynamic loader with the executable's pathname. @@ -81,8 +81,8 @@ pg_dlopen(char *filename) } if (dld_undefined_sym_count > 0) { - int count = dld_undefined_sym_count; - char **list = dld_list_undefined_sym(); + int count = dld_undefined_sym_count; + char **list = dld_list_undefined_sym(); /* list the undefined symbols, if any */ elog(NOTICE, "dld: Undefined:"); @@ -103,7 +103,7 @@ pg_dlopen(char *filename) #endif } -char * +char * pg_dlerror() { #ifndef HAVE_DLD_H diff --git a/src/backend/port/nextstep/dynloader.c b/src/backend/port/nextstep/dynloader.c index c37508f7f19..649454d48af 100644 --- a/src/backend/port/nextstep/dynloader.c +++ b/src/backend/port/nextstep/dynloader.c @@ -2,7 +2,7 @@ #include <streams/streams.h> #include <stdlib.h> -static char *lastError = NULL; +static char *lastError = NULL; static NXStream * OpenError() @@ -20,9 +20,9 @@ CloseError(NXStream * s) static void TransferError(NXStream * s) { - char *buffer; - int len, - maxlen; + char *buffer; + int len, + maxlen; if (lastError) free(lastError); @@ -31,13 +31,13 @@ TransferError(NXStream * s) strcpy(lastError, buffer); } -void * +void * next_dlopen(char *name) { - int rld_success; - NXStream *errorStream; - char *result = NULL; - char **p; + int rld_success; + NXStream *errorStream; + char *result = NULL; + char **p; errorStream = OpenError(); p = calloc(2, sizeof(void *)); @@ -60,12 +60,12 @@ next_dlclose(void *handle) return 0; } -void * +void * next_dlsym(void *handle, char *symbol) { - NXStream *errorStream = OpenError(); - char symbuf[1024]; - unsigned long symref = 0; + NXStream *errorStream = OpenError(); + char symbuf[1024]; + unsigned long symref = 0; sprintf(symbuf, "_%s", symbol); if (!rld_lookup(errorStream, symbuf, &symref)) @@ -74,7 +74,7 @@ next_dlsym(void *handle, char *symbol) return (void *) symref; } -char * +char * next_dlerror(void) { return lastError; diff --git a/src/backend/port/nextstep/port-protos.h b/src/backend/port/nextstep/port-protos.h index ce17beb69a6..9dfb20a99e4 100644 --- a/src/backend/port/nextstep/port-protos.h +++ b/src/backend/port/nextstep/port-protos.h @@ -12,10 +12,10 @@ #include "fmgr.h" /* for func_ptr */ #include "utils/dynamic_loader.h" -void *next_dlopen(char *name); -int next_dlclose(void *handle); -void *next_dlsym(void *handle, char *symbol); -char *next_dlerror(void); +void *next_dlopen(char *name); +int next_dlclose(void *handle); +void *next_dlsym(void *handle, char *symbol); +char *next_dlerror(void); #define pg_dlopen(f) next_dlopen #define pg_dlsym next_dlsym diff --git a/src/backend/port/nextstep/port.c b/src/backend/port/nextstep/port.c index baf026d5d1d..c71befe0151 100644 --- a/src/backend/port/nextstep/port.c +++ b/src/backend/port/nextstep/port.c @@ -12,9 +12,9 @@ void putenv(char *name) { - extern char **environ; - static int was_mallocated = 0; - int size; + extern char **environ; + static int was_mallocated = 0; + int size; /* Compute the size of environ array including the final NULL */ for (size = 1; environ[size++];) @@ -22,8 +22,8 @@ putenv(char *name) if (!was_mallocated) { - char **tmp = environ; - int i; + char **tmp = environ; + int i; was_mallocated = 1; environ = malloc(size * sizeof(char *)); @@ -36,7 +36,7 @@ putenv(char *name) environ[size] = NULL; } -char * +char * strdup(const char *string) { return strcpy(malloc(strlen(string) + 1), string); @@ -56,7 +56,7 @@ sigemptyset(int *set) return (*set = 0); } -char * +char * getcwd(char *buf, size_t size) { return getwd(buf); diff --git a/src/backend/port/sco/port.c b/src/backend/port/sco/port.c index d1c868e8426..d7acc97a755 100644 --- a/src/backend/port/sco/port.c +++ b/src/backend/port/sco/port.c @@ -21,10 +21,10 @@ int getrusage(int who, struct rusage * rusage) { - struct tms tms; - register int tick_rate = CLK_TCK; /* ticks per second */ - clock_t u, - s; + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, + s; if (rusage == (struct rusage *) NULL) { @@ -38,17 +38,17 @@ getrusage(int who, struct rusage * rusage) } switch (who) { - case RUSAGE_SELF: - u = tms.tms_utime; - s = tms.tms_stime; - break; - case RUSAGE_CHILDREN: - u = tms.tms_cutime; - s = tms.tms_cstime; - break; - default: - errno = EINVAL; - return (-1); + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return (-1); } #define TICK_TO_SEC(T, RATE) ((T)/(RATE)) #define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) diff --git a/src/backend/port/sco/rusagestub.h b/src/backend/port/sco/rusagestub.h index 5eda998802e..9f32a10cc10 100644 --- a/src/backend/port/sco/rusagestub.h +++ b/src/backend/port/sco/rusagestub.h @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/sparc_solaris/port-protos.h b/src/backend/port/sparc_solaris/port-protos.h index 95239173462..36a423df67c 100644 --- a/src/backend/port/sparc_solaris/port-protos.h +++ b/src/backend/port/sparc_solaris/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.5 1997/09/07 04:46:50 momjian Exp $ + * $Id: port-protos.h,v 1.6 1997/09/08 02:27:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,17 +36,17 @@ #define pg_dlerror dlerror /* port.c */ -extern long random(void); -extern void srandom(int seed); +extern long random(void); +extern void srandom(int seed); /* inet_aton.c in backend/port directory */ -extern int inet_aton(const char *cp, struct in_addr * addr); +extern int inet_aton(const char *cp, struct in_addr * addr); /* In system library, but can't find prototype in system library .h files */ -extern int gethostname(char *name, int namelen); +extern int gethostname(char *name, int namelen); /* In system library, but can't find prototype in system library .h files */ #include <sys/resource.h> -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/sparc_solaris/port.c b/src/backend/port/sparc_solaris/port.c index 7f19a1ae237..69980d6ea8a 100644 --- a/src/backend/port/sparc_solaris/port.c +++ b/src/backend/port/sparc_solaris/port.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/port.c,v 1.5 1997/09/07 04:46:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/sparc_solaris/Attic/port.c,v 1.6 1997/09/08 02:27:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,10 +38,10 @@ srandom(int seed) int getrusage(int who, struct rusage * rusage) { - struct tms tms; - register int tick_rate = CLK_TCK; /* ticks per second */ - clock_t u, - s; + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, + s; if (rusage == (struct rusage *) NULL) { @@ -55,17 +55,17 @@ getrusage(int who, struct rusage * rusage) } switch (who) { - case RUSAGE_SELF: - u = tms.tms_utime; - s = tms.tms_stime; - break; - case RUSAGE_CHILDREN: - u = tms.tms_cutime; - s = tms.tms_cstime; - break; - default: - errno = EINVAL; - return (-1); + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return (-1); } #define TICK_TO_SEC(T, RATE) ((T)/(RATE)) #define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) diff --git a/src/backend/port/sparc_solaris/rusagestub.h b/src/backend/port/sparc_solaris/rusagestub.h index 87957a45eac..708cfc9ff1e 100644 --- a/src/backend/port/sparc_solaris/rusagestub.h +++ b/src/backend/port/sparc_solaris/rusagestub.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rusagestub.h,v 1.2 1997/09/07 04:46:56 momjian Exp $ + * $Id: rusagestub.h,v 1.3 1997/09/08 02:27:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/strerror.c b/src/backend/port/strerror.c index 5bcd3cb4527..2e0511d04d3 100644 --- a/src/backend/port/strerror.c +++ b/src/backend/port/strerror.c @@ -12,12 +12,12 @@ #include <errno.h> extern const char *const sys_errlist[]; -extern int sys_nerr; +extern int sys_nerr; -const char * +const char * strerror(int errnum) { - static char buf[24]; + static char buf[24]; if (errnum < 0 || errnum > sys_nerr) { diff --git a/src/backend/port/sunos4/strtol.c b/src/backend/port/sunos4/strtol.c index c788d94bd50..dcf3e89860d 100644 --- a/src/backend/port/sunos4/strtol.c +++ b/src/backend/port/sunos4/strtol.c @@ -32,7 +32,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; +static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; #endif /* LIBC_SCCS and not lint */ @@ -51,17 +51,17 @@ static char sccsid[] = "@(#)strtol.c 5.4 (Berkeley) 2/23/91"; */ long strtol(nptr, endptr, base) -const char *nptr; -char **endptr; -register int base; +const char *nptr; +char **endptr; +register int base; { register const char *s = nptr; register unsigned long acc; - register int c; + register int c; register unsigned long cutoff; - register int neg = 0, - any, - cutlim; + register int neg = 0, + any, + cutlim; /* * Skip white space and pick up leading +/- sign if any. If base is 0, diff --git a/src/backend/port/svr4/port-protos.h b/src/backend/port/svr4/port-protos.h index 1baff088769..3926b253429 100644 --- a/src/backend/port/svr4/port-protos.h +++ b/src/backend/port/svr4/port-protos.h @@ -32,7 +32,7 @@ #define pg_dlerror dlerror /* port.c */ -extern long random(void); -extern void srandom(int seed); +extern long random(void); +extern void srandom(int seed); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/svr4/port.c b/src/backend/port/svr4/port.c index 0b38e2c4acd..92acee71ec9 100644 --- a/src/backend/port/svr4/port.c +++ b/src/backend/port/svr4/port.c @@ -31,10 +31,10 @@ srandom(int seed) int getrusage(int who, struct rusage * rusage) { - struct tms tms; - register int tick_rate = CLK_TCK; /* ticks per second */ - clock_t u, - s; + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, + s; if (rusage == (struct rusage *) NULL) { @@ -48,17 +48,17 @@ getrusage(int who, struct rusage * rusage) } switch (who) { - case RUSAGE_SELF: - u = tms.tms_utime; - s = tms.tms_stime; - break; - case RUSAGE_CHILDREN: - u = tms.tms_cutime; - s = tms.tms_cstime; - break; - default: - errno = EINVAL; - return (-1); + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return (-1); } #define TICK_TO_SEC(T, RATE) ((T)/(RATE)) #define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) @@ -82,7 +82,7 @@ getrusage(int who, struct rusage * rusage) */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; +static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; #endif /* LIBC_SCCS and not lint */ @@ -133,7 +133,7 @@ int strcasecmp(char *s1, char *s2) { register unsigned char u1, - u2; + u2; for (;;) { diff --git a/src/backend/port/svr4/rusagestub.h b/src/backend/port/svr4/rusagestub.h index 5eda998802e..9f32a10cc10 100644 --- a/src/backend/port/svr4/rusagestub.h +++ b/src/backend/port/svr4/rusagestub.h @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/port/ultrix4/dl.h b/src/backend/port/ultrix4/dl.h index 56eab754bf4..9014e151a5c 100644 --- a/src/backend/port/ultrix4/dl.h +++ b/src/backend/port/ultrix4/dl.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dl.h,v 1.4 1997/09/07 04:47:18 momjian Exp $ + * $Id: dl.h,v 1.5 1997/09/08 02:27:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,73 +42,73 @@ #include <scnhdr.h> -typedef long CoreAddr; +typedef long CoreAddr; typedef struct ScnInfo { - CoreAddr addr; /* starting address of the section */ - SCNHDR hdr; /* section header */ - RELOC *relocEntries; /* relocation entries */ -} ScnInfo; + CoreAddr addr; /* starting address of the section */ + SCNHDR hdr; /* section header */ + RELOC *relocEntries; /* relocation entries */ +} ScnInfo; typedef enum { DL_NEEDRELOC, /* still need relocation */ DL_RELOCATED, /* no relocation necessary */ DL_INPROG /* relocation in progress */ -} dlRStatus; +} dlRStatus; typedef struct JmpTbl { - char *block; /* the jump table memory block */ - struct JmpTbl *next; /* next block */ -} JmpTbl; + char *block; /* the jump table memory block */ + struct JmpTbl *next; /* next block */ +} JmpTbl; typedef struct dlFile { - char *filename; /* file name of the object file */ + char *filename; /* file name of the object file */ - int textSize; /* used by mprotect */ - CoreAddr textAddress;/* start addr of text section */ - long textVaddr; /* vaddr of text section in obj file */ - CoreAddr rdataAddress; /* start addr of rdata section */ - long rdataVaddr; /* vaddr of text section in obj file */ - CoreAddr dataAddress;/* start addr of data section */ - long dataVaddr; /* vaddr of text section in obj file */ - CoreAddr bssAddress; /* start addr of bss section */ - long bssVaddr; /* vaddr of text section in obj file */ + int textSize; /* used by mprotect */ + CoreAddr textAddress; /* start addr of text section */ + long textVaddr; /* vaddr of text section in obj file */ + CoreAddr rdataAddress; /* start addr of rdata section */ + long rdataVaddr; /* vaddr of text section in obj file */ + CoreAddr dataAddress; /* start addr of data section */ + long dataVaddr; /* vaddr of text section in obj file */ + CoreAddr bssAddress; /* start addr of bss section */ + long bssVaddr; /* vaddr of text section in obj file */ - int nsect; /* number of sections */ - ScnInfo *sect; /* details of each section (array) */ + int nsect; /* number of sections */ + ScnInfo *sect; /* details of each section (array) */ - int issExtMax; /* size of string space */ - char *extss; /* extern sym string space (in core) */ - int iextMax; /* maximum number of Symbols */ - pEXTR extsyms; /* extern syms */ + int issExtMax; /* size of string space */ + char *extss; /* extern sym string space (in core) */ + int iextMax; /* maximum number of Symbols */ + pEXTR extsyms; /* extern syms */ - dlRStatus relocStatus;/* what relocation needed? */ - int needReloc; + dlRStatus relocStatus; /* what relocation needed? */ + int needReloc; - JmpTbl *jmptable; /* the jump table for R_JMPADDR */ + JmpTbl *jmptable; /* the jump table for R_JMPADDR */ - struct dlFile *next; /* next member of the archive */ -} dlFile; + struct dlFile *next; /* next member of the archive */ +} dlFile; typedef struct dlSymbol { - char *name; /* name of the symbol */ - long addr; /* address of the symbol */ - dlFile *objFile; /* from which file */ -} dlSymbol; + char *name; /* name of the symbol */ + long addr; /* address of the symbol */ + dlFile *objFile; /* from which file */ +} dlSymbol; /* * prototypes for the dl* interface */ -extern void *dl_open( /* char *filename, int mode */ ); -extern void *dl_sym( /* void *handle, char *name */ ); -extern void dl_close( /* void *handle */ ); -extern char *dl_error( /* void */ ); +extern void *dl_open( /* char *filename, int mode */ ); +extern void *dl_sym( /* void *handle, char *name */ ); +extern void dl_close( /* void *handle */ ); +extern char *dl_error( /* void */ ); #define DL_LAZY 0 /* lazy resolution */ #define DL_NOW 1 /* immediate resolution */ @@ -116,8 +116,8 @@ extern char *dl_error( /* void */ ); /* * Miscellaneous utility routines: */ -extern char **dl_undefinedSymbols( /* int *count */ ); -extern void dl_printAllSymbols( /* void *handle */ ); -extern void dl_setLibraries( /* char *libs */ ); +extern char **dl_undefinedSymbols( /* int *count */ ); +extern void dl_printAllSymbols( /* void *handle */ ); +extern void dl_setLibraries( /* char *libs */ ); #endif /* _DL_HEADER_ */ diff --git a/src/backend/port/ultrix4/dynloader.c b/src/backend/port/ultrix4/dynloader.c index d896eebf901..761289233e1 100644 --- a/src/backend/port/ultrix4/dynloader.c +++ b/src/backend/port/ultrix4/dynloader.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.4 1997/09/07 04:47:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/dynloader.c,v 1.5 1997/09/08 02:27:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,13 +22,13 @@ #include "port-protos.h" #include "utils/elog.h" -extern char pg_pathname[]; +extern char pg_pathname[]; -void * +void * pg_dlopen(char *filename) { - static int dl_initialized = 0; - void *handle; + static int dl_initialized = 0; + void *handle; /* * initializes the dynamic loader with the executable's pathname. @@ -56,8 +56,8 @@ pg_dlopen(char *filename) */ if ((handle = dl_open(filename, DL_NOW)) == NULL) { - int count; - char **list = dl_undefinedSymbols(&count); + int count; + char **list = dl_undefinedSymbols(&count); /* list the undefined symbols, if any */ if (count) diff --git a/src/backend/port/ultrix4/port-protos.h b/src/backend/port/ultrix4/port-protos.h index 25f49db393d..091e8528418 100644 --- a/src/backend/port/ultrix4/port-protos.h +++ b/src/backend/port/ultrix4/port-protos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: port-protos.h,v 1.6 1997/09/07 04:47:24 momjian Exp $ + * $Id: port-protos.h,v 1.7 1997/09/08 02:27:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,8 +17,8 @@ * Externals in libc that need prototypes (or at least declarations) */ -extern char *ecvt(double, int, int *, int *); -extern char *fcvt(double, int, int *, int *); +extern char *ecvt(double, int, int *, int *); +extern char *fcvt(double, int, int *, int *); /* dynloader.c */ /* @@ -32,16 +32,16 @@ extern char *fcvt(double, int, int *, int *); #define pg_dlsym(h, f) ((func_ptr)dl_sym(h, f)) #define pg_dlclose(h) dl_close(h) #define pg_dlerror() dl_error() -extern int dl_init(char *); +extern int dl_init(char *); /* port.c */ -extern int syscall(); +extern int syscall(); -extern void init_address_fixup(void); +extern void init_address_fixup(void); /* strdup.c: strdup() is not part of libc on Ultrix */ -extern char *strdup(char const *); +extern char *strdup(char const *); /* inet_aton() is not part of libc on Ultrix. The following is from backend/port/inet_aton.h @@ -49,6 +49,6 @@ extern char *strdup(char const *); struct in_addr; int - inet_aton(const char *cp, struct in_addr * addr); + inet_aton(const char *cp, struct in_addr * addr); #endif /* PORT_PORTOS_H */ diff --git a/src/backend/port/ultrix4/strdup.c b/src/backend/port/ultrix4/strdup.c index a738e1611ef..395e544a68f 100644 --- a/src/backend/port/ultrix4/strdup.c +++ b/src/backend/port/ultrix4/strdup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.3 1997/09/07 04:47:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/ultrix4/Attic/strdup.c,v 1.4 1997/09/08 02:27:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,10 +17,10 @@ #include "port-protos.h" -char * +char * strdup(char const * string) { - char *nstr; + char *nstr; nstr = strcpy((char *) palloc(strlen(string) + 1), string); return nstr; diff --git a/src/backend/port/univel/frontend-port-protos.h b/src/backend/port/univel/frontend-port-protos.h index 9ca0100cb90..215633b6b72 100644 --- a/src/backend/port/univel/frontend-port-protos.h +++ b/src/backend/port/univel/frontend-port-protos.h @@ -14,9 +14,9 @@ #define FPORT_PROTOS_H /* port.c */ -extern long random(void); -extern void srandom(int seed); -extern int strcasecmp(char *s1, char *s2); -extern int gethostname(char *name, int namelen); +extern long random(void); +extern void srandom(int seed); +extern int strcasecmp(char *s1, char *s2); +extern int gethostname(char *name, int namelen); #endif /* FPORT_PROTOS_H */ diff --git a/src/backend/port/univel/port-protos.h b/src/backend/port/univel/port-protos.h index c181edfc9ec..a4af145110a 100644 --- a/src/backend/port/univel/port-protos.h +++ b/src/backend/port/univel/port-protos.h @@ -32,9 +32,9 @@ #define pg_dlerror dlerror /* port.c */ -extern long random(void); -extern void srandom(int seed); -extern int strcasecmp(char *s1, char *s2); -extern int gethostname(char *name, int namelen); +extern long random(void); +extern void srandom(int seed); +extern int strcasecmp(char *s1, char *s2); +extern int gethostname(char *name, int namelen); #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/univel/port.c b/src/backend/port/univel/port.c index d4c7658859e..37cefb22212 100644 --- a/src/backend/port/univel/port.c +++ b/src/backend/port/univel/port.c @@ -32,10 +32,10 @@ srandom(int seed) int getrusage(int who, struct rusage * rusage) { - struct tms tms; - register int tick_rate = CLK_TCK; /* ticks per second */ - clock_t u, - s; + struct tms tms; + register int tick_rate = CLK_TCK; /* ticks per second */ + clock_t u, + s; if (rusage == (struct rusage *) NULL) { @@ -49,17 +49,17 @@ getrusage(int who, struct rusage * rusage) } switch (who) { - case RUSAGE_SELF: - u = tms.tms_utime; - s = tms.tms_stime; - break; - case RUSAGE_CHILDREN: - u = tms.tms_cutime; - s = tms.tms_cstime; - break; - default: - errno = EINVAL; - return (-1); + case RUSAGE_SELF: + u = tms.tms_utime; + s = tms.tms_stime; + break; + case RUSAGE_CHILDREN: + u = tms.tms_cutime; + s = tms.tms_cstime; + break; + default: + errno = EINVAL; + return (-1); } #define TICK_TO_SEC(T, RATE) ((T)/(RATE)) #define TICK_TO_USEC(T,RATE) (((T)%(RATE)*1000000)/RATE) @@ -83,7 +83,7 @@ getrusage(int who, struct rusage * rusage) */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; +static char sccsid[] = "@(#)strcasecmp.c 5.5 (Berkeley) 11/24/87"; #endif /* LIBC_SCCS and not lint */ @@ -134,7 +134,7 @@ int strcasecmp(char *s1, char *s2) { register unsigned char u1, - u2; + u2; for (;;) { @@ -157,7 +157,7 @@ int gethostname(char *name, int namelen) { static struct utsname mname; - static int called = 0; + static int called = 0; if (!called) { diff --git a/src/backend/port/univel/rusagestub.h b/src/backend/port/univel/rusagestub.h index 5eda998802e..9f32a10cc10 100644 --- a/src/backend/port/univel/rusagestub.h +++ b/src/backend/port/univel/rusagestub.h @@ -22,10 +22,10 @@ struct rusage { - struct timeval ru_utime; /* user time used */ - struct timeval ru_stime; /* system time used */ + struct timeval ru_utime; /* user time used */ + struct timeval ru_stime; /* system time used */ }; -extern int getrusage(int who, struct rusage * rusage); +extern int getrusage(int who, struct rusage * rusage); #endif /* RUSAGESTUB_H */ diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index c9979b76969..998a087d254 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.54 1997/09/07 04:47:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.55 1997/09/08 02:27:53 momjian Exp $ * * NOTES * @@ -111,32 +111,32 @@ */ typedef struct bkend { - int pid; /* process id of backend */ -} Backend; + int pid; /* process id of backend */ +} Backend; /* list of active backends. For garbage collection only now. */ -static Dllist *BackendList; +static Dllist *BackendList; /* list of ports associated with still open, but incomplete connections */ -static Dllist *PortList; +static Dllist *PortList; -static short PostPortName = -1; -static short ActiveBackends = FALSE; -static int NextBackendId = MAXINT; /* XXX why? */ -static char *progname = (char *) NULL; +static short PostPortName = -1; +static short ActiveBackends = FALSE; +static int NextBackendId = MAXINT; /* XXX why? */ +static char *progname = (char *) NULL; /* * Default Values */ -static char Execfile[MAXPATHLEN] = ""; +static char Execfile[MAXPATHLEN] = ""; -static int ServerSock = INVALID_SOCK; /* stream socket server */ +static int ServerSock = INVALID_SOCK; /* stream socket server */ /* * Set by the -o option */ -static char ExtraOptions[ARGV_SIZE] = ""; +static char ExtraOptions[ARGV_SIZE] = ""; /* * These globals control the behavior of the postmaster in case some @@ -145,35 +145,35 @@ static char ExtraOptions[ARGV_SIZE] = ""; * the postmaster stop (rather than kill) peers and not reinitialize * shared data structures. */ -static int Reinit = 1; -static int SendStop = 0; +static int Reinit = 1; +static int SendStop = 0; -static int MultiplexedBackends = 0; -static int MultiplexedBackendPort; +static int MultiplexedBackends = 0; +static int MultiplexedBackendPort; /* * postmaster.c - function prototypes */ -static void pmdaemonize(void); +static void pmdaemonize(void); static void ConnStartup(Port * port, int *status, char *errormsg, const int errormsg_len); -static int ConnCreate(int serverFd, int *newFdP); -static void reset_shared(short port); -static void pmdie(SIGNAL_ARGS); -static void reaper(SIGNAL_ARGS); -static void dumpstatus(SIGNAL_ARGS); -static void CleanupProc(int pid, int exitstatus); -static int DoExec(StartupInfo * packet, int portFd); -static void ExitPostmaster(int status); -static void usage(const char *); -static int ServerLoop(void); -static int BackendStartup(StartupInfo * packet, Port * port, int *pidPtr); -static void send_error_reply(Port * port, const char *errormsg); +static int ConnCreate(int serverFd, int *newFdP); +static void reset_shared(short port); +static void pmdie(SIGNAL_ARGS); +static void reaper(SIGNAL_ARGS); +static void dumpstatus(SIGNAL_ARGS); +static void CleanupProc(int pid, int exitstatus); +static int DoExec(StartupInfo * packet, int portFd); +static void ExitPostmaster(int status); +static void usage(const char *); +static int ServerLoop(void); +static int BackendStartup(StartupInfo * packet, Port * port, int *pidPtr); +static void send_error_reply(Port * port, const char *errormsg); -extern char *optarg; -extern int optind, - opterr; +extern char *optarg; +extern int optind, + opterr; @@ -191,8 +191,8 @@ checkDataDir(const char *DataDir, bool * DataDirOK) } else { - char path[MAXPATHLEN]; - FILE *fp; + char path[MAXPATHLEN]; + FILE *fp; sprintf(path, "%s%cbase%ctemplate1%cpg_class", DataDir, SEP_CHAR, SEP_CHAR, SEP_CHAR); @@ -208,7 +208,7 @@ checkDataDir(const char *DataDir, bool * DataDirOK) } else { - char *reason; + char *reason; /* reason ValidatePgVersion failed. NULL if didn't */ @@ -238,14 +238,14 @@ checkDataDir(const char *DataDir, bool * DataDirOK) int PostmasterMain(int argc, char *argv[]) { - extern int NBuffers; /* from buffer/bufmgr.c */ - extern bool IsPostmaster; /* from smgr/mm.c */ - int opt; - char *hostName; - int status; - int silentflag = 0; - char hostbuf[MAXHOSTNAMELEN]; - bool DataDirOK; /* We have a usable PGDATA value */ + extern int NBuffers; /* from buffer/bufmgr.c */ + extern bool IsPostmaster; /* from smgr/mm.c */ + int opt; + char *hostName; + int status; + int silentflag = 0; + char hostbuf[MAXHOSTNAMELEN]; + bool DataDirOK; /* We have a usable PGDATA value */ progname = argv[0]; @@ -271,100 +271,103 @@ PostmasterMain(int argc, char *argv[]) { switch (opt) { - case 'a': - /* Set the authentication system. */ - be_setauthsvc(optarg); - break; - case 'B': + case 'a': + /* Set the authentication system. */ + be_setauthsvc(optarg); + break; + case 'B': - /* - * The number of buffers to create. Setting this option means - * we have to start each backend with a -B # to make sure they - * know how many buffers were allocated. - */ - NBuffers = atol(optarg); - strcat(ExtraOptions, " -B "); - strcat(ExtraOptions, optarg); - break; - case 'b': - /* Set the backend executable file to use. */ - if (!ValidateBackend(optarg)) - strcpy(Execfile, optarg); - else - { - fprintf(stderr, "%s: invalid backend \"%s\"\n", - progname, optarg); - exit(2); - } - break; - case 'D': - /* Set PGDATA from the command line. */ - DataDir = optarg; - break; - case 'd': + /* + * The number of buffers to create. Setting this option + * means we have to start each backend with a -B # to make + * sure they know how many buffers were allocated. + */ + NBuffers = atol(optarg); + strcat(ExtraOptions, " -B "); + strcat(ExtraOptions, optarg); + break; + case 'b': + /* Set the backend executable file to use. */ + if (!ValidateBackend(optarg)) + strcpy(Execfile, optarg); + else + { + fprintf(stderr, "%s: invalid backend \"%s\"\n", + progname, optarg); + exit(2); + } + break; + case 'D': + /* Set PGDATA from the command line. */ + DataDir = optarg; + break; + case 'd': - /* - * Turn on debugging for the postmaster and the backend - * servers descended from it. - */ - if ((optind < argc) && *argv[optind] != '-') - { - DebugLvl = atoi(argv[optind]); - optind++; - } - else - DebugLvl = 1; - break; - case 'm': - MultiplexedBackends = 1; - MultiplexedBackendPort = atoi(optarg); - break; - case 'M': + /* + * Turn on debugging for the postmaster and the backend + * servers descended from it. + */ + if ((optind < argc) && *argv[optind] != '-') + { + DebugLvl = atoi(argv[optind]); + optind++; + } + else + DebugLvl = 1; + break; + case 'm': + MultiplexedBackends = 1; + MultiplexedBackendPort = atoi(optarg); + break; + case 'M': - /* - * ignore this flag. This may be passed in because the - * program was run as 'postgres -M' instead of 'postmaster' - */ - break; - case 'n': - /* Don't reinit shared mem after abnormal exit */ - Reinit = 0; - break; - case 'o': + /* + * ignore this flag. This may be passed in because the + * program was run as 'postgres -M' instead of + * 'postmaster' + */ + break; + case 'n': + /* Don't reinit shared mem after abnormal exit */ + Reinit = 0; + break; + case 'o': - /* - * Other options to pass to the backend on the command line -- - * useful only for debugging. - */ - strcat(ExtraOptions, " "); - strcat(ExtraOptions, optarg); - break; - case 'p': - /* Set PGPORT by hand. */ - PostPortName = (short) atoi(optarg); - break; - case 'S': + /* + * Other options to pass to the backend on the command + * line -- useful only for debugging. + */ + strcat(ExtraOptions, " "); + strcat(ExtraOptions, optarg); + break; + case 'p': + /* Set PGPORT by hand. */ + PostPortName = (short) atoi(optarg); + break; + case 'S': - /* - * Start in 'S'ilent mode (disassociate from controlling tty). - * You may also think of this as 'S'ysV mode since it's most - * badly needed on SysV-derived systems like SVR4 and HP-UX. - */ - silentflag = 1; - break; - case 's': + /* + * Start in 'S'ilent mode (disassociate from controlling + * tty). You may also think of this as 'S'ysV mode since + * it's most badly needed on SysV-derived systems like + * SVR4 and HP-UX. + */ + silentflag = 1; + break; + case 's': - /* - * In the event that some backend dumps core, send SIGSTOP, - * rather than SIGUSR1, to all its peers. This lets the wily - * post_hacker collect core dumps from everyone. - */ - SendStop = 1; - break; - default: - /* usage() never returns */ - usage(progname); - break; + /* + * In the event that some backend dumps core, send + * SIGSTOP, rather than SIGUSR1, to all its peers. This + * lets the wily post_hacker collect core dumps from + * everyone. + */ + SendStop = 1; + break; + default: + /* usage() never returns */ + usage(progname); + break; } } if (PostPortName == -1) @@ -425,7 +428,7 @@ PostmasterMain(int argc, char *argv[]) static void pmdaemonize(void) { - int i; + int i; if (fork()) exit(0); @@ -468,26 +471,26 @@ usage(const char *progname) static int ServerLoop(void) { - int serverFd = ServerSock; - fd_set rmask, - basemask; - int nSockets, - nSelected, - status, - newFd; - Dlelem *next, - *curr; + int serverFd = ServerSock; + fd_set rmask, + basemask; + int nSockets, + nSelected, + status, + newFd; + Dlelem *next, + *curr; /* * GH: For !HAVE_SIGPROCMASK (NEXTSTEP), TRH implemented an * alternative interface. */ #ifdef HAVE_SIGPROCMASK - sigset_t oldsigmask, - newsigmask; + sigset_t oldsigmask, + newsigmask; #else - int orgsigmask = sigblock(0); + int orgsigmask = sigblock(0); #endif @@ -568,7 +571,7 @@ ServerLoop(void) curr = DLGetHead(PortList); while (curr) { - Port *port = DLE_VAL(curr); + Port *port = DLE_VAL(curr); fprintf(stderr, "%s: ServerLoop:\t\tport %d%s pending\n", progname, port->sock, @@ -583,8 +586,8 @@ ServerLoop(void) while (curr) { - Port *port = (Port *) DLE_VAL(curr); - int lastbytes = port->nBytes; + Port *port = (Port *) DLE_VAL(curr); + int lastbytes = port->nBytes; if (FD_ISSET(port->sock, &rmask) && port->sock != newFd) { @@ -601,59 +604,60 @@ ServerLoop(void) status = PacketReceive(port, &port->buf, NON_BLOCKING); switch (status) { - case STATUS_OK: - { - int CSstatus; /* Completion status of + case STATUS_OK: + { + int CSstatus; /* Completion status of * ConnStartup */ - char errormsg[200]; /* error msg from + char errormsg[200]; /* error msg from * ConnStartup */ - ConnStartup(port, &CSstatus, errormsg, sizeof(errormsg)); - - if (CSstatus == STATUS_ERROR) - send_error_reply(port, errormsg); - ActiveBackends = TRUE; - } - /* FALLTHROUGH */ - case STATUS_INVALID: - if (DebugLvl) - fprintf(stderr, "%s: ServerLoop:\t\tdone with %d\n", - progname, port->sock); - break; - case STATUS_BAD_PACKET: - - /* - * This is a bogus client, kill the connection and - * forget the whole thing. - */ - if (DebugLvl) - fprintf(stderr, "%s: ServerLoop:\t\tbad packet format (reported packet size of %d read on port %d\n", progname, port->nBytes, port->sock); - break; - case STATUS_NOT_DONE: - if (DebugLvl) - fprintf(stderr, "%s: ServerLoop:\t\tpartial packet (%d bytes actually read) on %d\n", - progname, port->nBytes, port->sock); - - /* - * If we've received at least a PacketHdr's worth of - * data and we're still receiving data each time we - * read, we're ok. If the client gives us less than a - * PacketHdr at the beginning, just kill the - * connection and forget about the whole thing. - */ - if (lastbytes < port->nBytes) - { + ConnStartup(port, &CSstatus, errormsg, sizeof(errormsg)); + + if (CSstatus == STATUS_ERROR) + send_error_reply(port, errormsg); + ActiveBackends = TRUE; + } + /* FALLTHROUGH */ + case STATUS_INVALID: if (DebugLvl) - fprintf(stderr, "%s: ServerLoop:\t\tpartial packet on %d ok\n", + fprintf(stderr, "%s: ServerLoop:\t\tdone with %d\n", progname, port->sock); - curr = DLGetSucc(curr); - continue; - } - break; - case STATUS_ERROR: /* system call error - die */ - fprintf(stderr, "%s: ServerLoop:\t\terror receiving packet\n", - progname); - return (STATUS_ERROR); + break; + case STATUS_BAD_PACKET: + + /* + * This is a bogus client, kill the connection and + * forget the whole thing. + */ + if (DebugLvl) + fprintf(stderr, "%s: ServerLoop:\t\tbad packet format (reported packet size of %d read on port %d\n", progname, port->nBytes, port->sock); + break; + case STATUS_NOT_DONE: + if (DebugLvl) + fprintf(stderr, "%s: ServerLoop:\t\tpartial packet (%d bytes actually read) on %d\n", + progname, port->nBytes, port->sock); + + /* + * If we've received at least a PacketHdr's worth + * of data and we're still receiving data each + * time we read, we're ok. If the client gives us + * less than a PacketHdr at the beginning, just + * kill the connection and forget about the whole + * thing. + */ + if (lastbytes < port->nBytes) + { + if (DebugLvl) + fprintf(stderr, "%s: ServerLoop:\t\tpartial packet on %d ok\n", + progname, port->sock); + curr = DLGetSucc(curr); + continue; + } + break; + case STATUS_ERROR: /* system call error - die */ + fprintf(stderr, "%s: ServerLoop:\t\terror receiving packet\n", + progname); + return (STATUS_ERROR); } FD_CLR(port->sock, &basemask); StreamClose(port->sock); @@ -685,12 +689,12 @@ static void ConnStartup(Port * port, int *status, char *errormsg, const int errormsg_len) { - MsgType msgType; - char namebuf[NAMEDATALEN]; - int pid; - PacketBuf *p; - StartupInfo sp; - char *tmp; + MsgType msgType; + char namebuf[NAMEDATALEN]; + int pid; + PacketBuf *p; + StartupInfo sp; + char *tmp; p = &port->buf; @@ -725,7 +729,7 @@ ConnStartup(Port * port, int *status, { if (be_recvauth(msgType, port, namebuf, &sp) != STATUS_OK) { - char buffer[200 + sizeof(namebuf)]; + char buffer[200 + sizeof(namebuf)]; sprintf(buffer, "Failed to authenticate client as Postgres user '%s' " @@ -789,8 +793,8 @@ ConnStartup(Port * port, int *status, static void send_error_reply(Port * port, const char *errormsg) { - int rc; /* return code from sendto */ - char *reply; + int rc; /* return code from sendto */ + char *reply; /* * The literal reply string we put into the socket. This is a pointer @@ -837,8 +841,8 @@ send_error_reply(Port * port, const char *errormsg) static int ConnCreate(int serverFd, int *newFdP) { - int status; - Port *port; + int status; + Port *port; if (!(port = (Port *) calloc(1, sizeof(Port)))) @@ -868,7 +872,7 @@ ConnCreate(int serverFd, int *newFdP) static void reset_shared(short port) { - IPCKey key; + IPCKey key; key = SystemPortAddressCreateIPCKey((SystemPortAddress) port); CreateSharedMemoryAndSemaphores(key); @@ -892,13 +896,13 @@ reaper(SIGNAL_ARGS) { /* GH: replace waitpid for !HAVE_WAITPID. Does this work ? */ #ifdef HAVE_WAITPID - int status; /* backend exit status */ + int status; /* backend exit status */ #else - union wait statusp; /* backend exit status */ + union wait statusp; /* backend exit status */ #endif - int pid; /* process id of dead backend */ + int pid; /* process id of dead backend */ if (DebugLvl) fprintf(stderr, "%s: reaping dead processes...\n", @@ -929,10 +933,10 @@ static void CleanupProc(int pid, int exitstatus) /* child's exit status. */ { - Dlelem *prev, - *curr; - Backend *bp; - int sig; + Dlelem *prev, + *curr; + Backend *bp; + int sig; if (DebugLvl) { @@ -1040,10 +1044,10 @@ BackendStartup(StartupInfo * packet, /* client's startup packet */ Port * port, int *pidPtr) { - Backend *bn; /* for backend cleanup */ - int pid, - i; - static char envEntry[4][2 * ARGV_SIZE]; + Backend *bn; /* for backend cleanup */ + int pid, + i; + static char envEntry[4][2 * ARGV_SIZE]; for (i = 0; i < 4; ++i) { @@ -1067,8 +1071,8 @@ BackendStartup(StartupInfo * packet, /* client's startup packet */ } if (DebugLvl > 2) { - char **p; - extern char **environ; + char **p; + extern char **environ; fprintf(stderr, "%s: BackendStartup: environ dump:\n", progname); @@ -1140,7 +1144,7 @@ BackendStartup(StartupInfo * packet, /* client's startup packet */ static void split_opts(char **argv, int *argcp, char *s) { - int i = *argcp; + int i = *argcp; while (s && *s) { @@ -1171,22 +1175,22 @@ split_opts(char **argv, int *argcp, char *s) static int DoExec(StartupInfo * packet, int portFd) { - char execbuf[MAXPATHLEN]; - char portbuf[ARGV_SIZE]; - char mbbuf[ARGV_SIZE]; - char debugbuf[ARGV_SIZE]; - char ttybuf[ARGV_SIZE + 1]; - char argbuf[(2 * ARGV_SIZE) + 1]; + char execbuf[MAXPATHLEN]; + char portbuf[ARGV_SIZE]; + char mbbuf[ARGV_SIZE]; + char debugbuf[ARGV_SIZE]; + char ttybuf[ARGV_SIZE + 1]; + char argbuf[(2 * ARGV_SIZE) + 1]; /* * each argument takes at least three chars, so we can't have more * than ARGV_SIZE arguments in (2 * ARGV_SIZE) chars (i.e., * packet->options plus ExtraOptions)... */ - char *av[ARGV_SIZE]; - char dbbuf[ARGV_SIZE + 1]; - int ac = 0; - int i; + char *av[ARGV_SIZE]; + char dbbuf[ARGV_SIZE + 1]; + int ac = 0; + int i; strncpy(execbuf, Execfile, MAXPATHLEN - 1); av[ac++] = execbuf; @@ -1273,11 +1277,11 @@ ExitPostmaster(int status) static void dumpstatus(SIGNAL_ARGS) { - Dlelem *curr = DLGetHead(PortList); + Dlelem *curr = DLGetHead(PortList); while (curr) { - Port *port = DLE_VAL(curr); + Port *port = DLE_VAL(curr); fprintf(stderr, "%s: dumpstatus:\n", progname); fprintf(stderr, "\tsock %d: nBytes=%d, laddr=0x%lx, raddr=0x%lx\n", diff --git a/src/backend/regex/engine.c b/src/backend/regex/engine.c index 6e0e7012140..1d86dcc7bd9 100644 --- a/src/backend/regex/engine.c +++ b/src/backend/regex/engine.c @@ -71,43 +71,43 @@ struct match { struct re_guts *g; - int eflags; - regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ - char *offp; /* offsets work from here */ - char *beginp; /* start of string -- virtual NUL precedes */ - char *endp; /* end of string -- virtual NUL here */ - char *coldp; /* can be no match starting before here */ - char **lastpos; /* [nplus+1] */ - STATEVARS; - states st; /* current states */ - states fresh; /* states for a fresh start */ - states tmp; /* temporary */ - states empty; /* empty set of states */ + int eflags; + regmatch_t *pmatch; /* [nsub+1] (0 element unused) */ + char *offp; /* offsets work from here */ + char *beginp; /* start of string -- virtual NUL precedes */ + char *endp; /* end of string -- virtual NUL here */ + char *coldp; /* can be no match starting before here */ + char **lastpos; /* [nplus+1] */ + STATEVARS; + states st; /* current states */ + states fresh; /* states for a fresh start */ + states tmp; /* temporary */ + states empty; /* empty set of states */ }; /* ========= begin header generated by ./mkh ========= */ #ifdef __cplusplus -extern "C" +extern "C" { #endif /* === engine.c === */ static int - matcher(struct re_guts * g, char *string, size_t nmatch, - regmatch_t pmatch[], int eflags); - static char * - dissect(struct match * m, char *start, char *stop, - sopno startst, sopno stopst); - static char * - backref(struct match * m, char *start, char *stop, + matcher(struct re_guts * g, char *string, size_t nmatch, + regmatch_t pmatch[], int eflags); + static char * + dissect(struct match * m, char *start, char *stop, + sopno startst, sopno stopst); + static char * + backref(struct match * m, char *start, char *stop, sopno startst, sopno stopst, sopno lev); - static char * - fast(struct match * m, char *start, char *stop, - sopno startst, sopno stopst); - static char * - slow(struct match * m, char *start, char *stop, sopno startst, sopno stopst); - static states - step(struct re_guts * g, sopno start, + static char * + fast(struct match * m, char *start, char *stop, + sopno startst, sopno stopst); + static char * + slow(struct match * m, char *start, char *stop, sopno startst, sopno stopst); + static states + step(struct re_guts * g, sopno start, sopno stop, states bef, int ch, states aft); #define BOL (OUT+1) #define EOL (BOL+1) @@ -120,16 +120,16 @@ extern "C" #define NNONCHAR (CODEMAX-CHAR_MAX) #ifdef REDEBUG static void - print(struct match * m, char *caption, states st, int ch, FILE * d); + print(struct match * m, char *caption, states st, int ch, FILE * d); #endif #ifdef REDEBUG static void - at(struct match * m, char *title, char *start, char *stop, - sopno startst, sopno stopst); + at(struct match * m, char *title, char *start, char *stop, + sopno startst, sopno stopst); #endif #ifdef REDEBUG - static char * - pchar(int ch); + static char * + pchar(int ch); #endif #ifdef __cplusplus @@ -156,20 +156,20 @@ extern "C" static int /* 0 success, REG_NOMATCH failure */ matcher(g, string, nmatch, pmatch, eflags) register struct re_guts *g; -char *string; -size_t nmatch; -regmatch_t pmatch[]; -int eflags; +char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; { - register char *endp; - register int i; - struct match mv; + register char *endp; + register int i; + struct match mv; register struct match *m = &mv; - register char *dp; + register char *dp; register const sopno gf = g->firststate + 1; /* +1 for OEND */ register const sopno gl = g->laststate; - char *start; - char *stop; + char *start; + char *stop; /* simplify the situation where possible */ if (g->cflags & REG_NOSUB) @@ -336,27 +336,27 @@ int eflags; == static char *dissect(register struct match *m, char *start, \ == char *stop, sopno startst, sopno stopst); */ -static char * /* == stop (success) always */ +static char * /* == stop (success) always */ dissect(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; -sopno startst; -sopno stopst; +char *start; +char *stop; +sopno startst; +sopno stopst; { - register int i; - register sopno ss; /* start sop of current subRE */ - register sopno es; /* end sop of current subRE */ - register char *sp; /* start of string matched by it */ - register char *stp; /* string matched by it cannot pass here */ - register char *rest; /* start of rest of string */ - register char *tail; /* string unmatched by rest of RE */ - register sopno ssub; /* start sop of subsubRE */ - register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *sep; /* end of string matched by subsubRE */ - register char *oldssp; /* previous ssp */ - register char *dp; + register int i; + register sopno ss; /* start sop of current subRE */ + register sopno es; /* end sop of current subRE */ + register char *sp; /* start of string matched by it */ + register char *stp; /* string matched by it cannot pass here */ + register char *rest; /* start of rest of string */ + register char *tail; /* string unmatched by rest of RE */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *sep; /* end of string matched by subsubRE */ + register char *oldssp; /* previous ssp */ + register char *dp; AT("diss", start, stop, startst, stopst); sp = start; @@ -366,164 +366,164 @@ sopno stopst; es = ss; switch (OP(m->g->strip[es])) { - case OPLUS_: - case OQUEST_: - es += OPND(m->g->strip[es]); - break; - case OCH_: - while (OP(m->g->strip[es]) != O_CH) + case OPLUS_: + case OQUEST_: es += OPND(m->g->strip[es]); - break; + break; + case OCH_: + while (OP(m->g->strip[es]) != O_CH) + es += OPND(m->g->strip[es]); + break; } es++; /* figure out what it matched */ switch (OP(m->g->strip[ss])) { - case OEND: - assert(nope); - break; - case OCHAR: - sp++; - break; - case OBOL: - case OEOL: - case OBOW: - case OEOW: - break; - case OANY: - case OANYOF: - sp++; - break; - case OBACK_: - case O_BACK: - assert(nope); - break; - /* cases where length of match is hard to find */ - case OQUEST_: - stp = stop; - for (;;) - { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - /* did innards match? */ - if (slow(m, sp, rest, ssub, esub) != NULL) - { - dp = dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - } - else + case OEND: + assert(nope); + break; + case OCHAR: + sp++; + break; + case OBOL: + case OEOL: + case OBOW: + case OEOW: + break; + case OANY: + case OANYOF: + sp++; + break; + case OBACK_: + case O_BACK: + assert(nope); + break; + /* cases where length of match is hard to find */ + case OQUEST_: + stp = stop; + for (;;) + { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + /* did innards match? */ + if (slow(m, sp, rest, ssub, esub) != NULL) + { + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + } + else /* no */ - assert(sp == rest); - sp = rest; - break; - case OPLUS_: - stp = stop; - for (;;) - { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = es - 1; - ssp = sp; - oldssp = ssp; - for (;;) - { /* find last match of innards */ - sep = slow(m, ssp, rest, ssub, esub); - if (sep == NULL || sep == ssp) - break; /* failed or matched null */ - oldssp = ssp; /* on to next try */ - ssp = sep; - } - if (sep == NULL) - { - /* last successful match */ - sep = ssp; - ssp = oldssp; - } - assert(sep == rest);/* must exhaust substring */ - assert(slow(m, ssp, sep, ssub, esub) == rest); - dp = dissect(m, ssp, sep, ssub, esub); - assert(dp == sep); - sp = rest; - break; - case OCH_: - stp = stop; - for (;;) - { - /* how long could this one be? */ - rest = slow(m, sp, stp, ss, es); - assert(rest != NULL); /* it did match */ - /* could the rest match the rest? */ - tail = slow(m, rest, stop, es, stopst); - if (tail == stop) - break; /* yes! */ - /* no -- try a shorter match for this one */ - stp = rest - 1; - assert(stp >= sp); /* it did work */ - } - ssub = ss + 1; - esub = ss + OPND(m->g->strip[ss]) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) - { /* find first matching branch */ - if (slow(m, sp, rest, ssub, esub) == rest) - break; /* it matched all of it */ - /* that one missed, try next one */ + assert(sp == rest); + sp = rest; + break; + case OPLUS_: + stp = stop; + for (;;) + { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = es - 1; + ssp = sp; + oldssp = ssp; + for (;;) + { /* find last match of innards */ + sep = slow(m, ssp, rest, ssub, esub); + if (sep == NULL || sep == ssp) + break; /* failed or matched null */ + oldssp = ssp; /* on to next try */ + ssp = sep; + } + if (sep == NULL) + { + /* last successful match */ + sep = ssp; + ssp = oldssp; + } + assert(sep == rest); /* must exhaust substring */ + assert(slow(m, ssp, sep, ssub, esub) == rest); + dp = dissect(m, ssp, sep, ssub, esub); + assert(dp == sep); + sp = rest; + break; + case OCH_: + stp = stop; + for (;;) + { + /* how long could this one be? */ + rest = slow(m, sp, stp, ss, es); + assert(rest != NULL); /* it did match */ + /* could the rest match the rest? */ + tail = slow(m, rest, stop, es, stopst); + if (tail == stop) + break; /* yes! */ + /* no -- try a shorter match for this one */ + stp = rest - 1; + assert(stp >= sp); /* it did work */ + } + ssub = ss + 1; + esub = ss + OPND(m->g->strip[ss]) - 1; assert(OP(m->g->strip[esub]) == OOR1); - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } - dp = dissect(m, sp, rest, ssub, esub); - assert(dp == rest); - sp = rest; - break; - case O_PLUS: - case O_QUEST: - case OOR1: - case OOR2: - case O_CH: - assert(nope); - break; - case OLPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_so = sp - m->offp; - break; - case ORPAREN: - i = OPND(m->g->strip[ss]); - assert(0 < i && i <= m->g->nsub); - m->pmatch[i].rm_eo = sp - m->offp; - break; - default: /* uh oh */ - assert(nope); - break; + for (;;) + { /* find first matching branch */ + if (slow(m, sp, rest, ssub, esub) == rest) + break; /* it matched all of it */ + /* that one missed, try next one */ + assert(OP(m->g->strip[esub]) == OOR1); + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + dp = dissect(m, sp, rest, ssub, esub); + assert(dp == rest); + sp = rest; + break; + case O_PLUS: + case O_QUEST: + case OOR1: + case OOR2: + case O_CH: + assert(nope); + break; + case OLPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_so = sp - m->offp; + break; + case ORPAREN: + i = OPND(m->g->strip[ss]); + assert(0 < i && i <= m->g->nsub); + m->pmatch[i].rm_eo = sp - m->offp; + break; + default: /* uh oh */ + assert(nope); + break; } } @@ -536,27 +536,27 @@ sopno stopst; == static char *backref(register struct match *m, char *start, \ == char *stop, sopno startst, sopno stopst, sopno lev); */ -static char * /* == stop (success) or NULL (failure) */ +static char * /* == stop (success) or NULL (failure) */ backref(m, start, stop, startst, stopst, lev) register struct match *m; -char *start; -char *stop; -sopno startst; -sopno stopst; -sopno lev; /* PLUS nesting level */ +char *start; +char *stop; +sopno startst; +sopno stopst; +sopno lev; /* PLUS nesting level */ { - register int i; - register sopno ss; /* start sop of current subRE */ - register char *sp; /* start of string matched by it */ - register sopno ssub; /* start sop of subsubRE */ - register sopno esub; /* end sop of subsubRE */ - register char *ssp; /* start of string matched by subsubRE */ - register char *dp; + register int i; + register sopno ss; /* start sop of current subRE */ + register char *sp; /* start of string matched by it */ + register sopno ssub; /* start sop of subsubRE */ + register sopno esub; /* end sop of subsubRE */ + register char *ssp; /* start of string matched by subsubRE */ + register char *dp; register size_t len; - register int hard; - register sop s; + register int hard; + register sop s; register regoff_t offsave; - register cset *cs; + register cset *cs; AT("back", start, stop, startst, stopst); sp = start; @@ -566,76 +566,76 @@ sopno lev; /* PLUS nesting level */ for (ss = startst; !hard && ss < stopst; ss++) switch (OP(s = m->g->strip[ss])) { - case OCHAR: - if (sp == stop || *sp++ != (char) OPND(s)) - return (NULL); - break; - case OANY: - if (sp == stop) - return (NULL); - sp++; - break; - case OANYOF: - cs = &m->g->sets[OPND(s)]; - if (sp == stop || !CHIN(cs, *sp++)) - return (NULL); - break; - case OBOL: - if ((sp == m->beginp && !(m->eflags & REG_NOTBOL)) || - (sp < m->endp && *(sp - 1) == '\n' && - (m->g->cflags & REG_NEWLINE))) - { /* yes */ - } - else - return (NULL); - break; - case OEOL: - if ((sp == m->endp && !(m->eflags & REG_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags & REG_NEWLINE))) - { /* yes */ - } - else - return (NULL); - break; - case OBOW: - if (((sp == m->beginp && !(m->eflags & REG_NOTBOL)) || - (sp < m->endp && *(sp - 1) == '\n' && - (m->g->cflags & REG_NEWLINE)) || - (sp > m->beginp && - !ISWORD(*(sp - 1)))) && - (sp < m->endp && ISWORD(*sp))) - { /* yes */ - } - else - return (NULL); - break; - case OEOW: - if (((sp == m->endp && !(m->eflags & REG_NOTEOL)) || - (sp < m->endp && *sp == '\n' && - (m->g->cflags & REG_NEWLINE)) || - (sp < m->endp && !ISWORD(*sp))) && - (sp > m->beginp && ISWORD(*(sp - 1)))) - { /* yes */ - } - else - return (NULL); - break; - case O_QUEST: - break; - case OOR1: /* matches null but needs to skip */ - ss++; - s = m->g->strip[ss]; - do - { - assert(OP(s) == OOR2); - ss += OPND(s); - } while (OP(s = m->g->strip[ss]) != O_CH); - /* note that the ss++ gets us past the O_CH */ - break; - default: /* have to make a choice */ - hard = 1; - break; + case OCHAR: + if (sp == stop || *sp++ != (char) OPND(s)) + return (NULL); + break; + case OANY: + if (sp == stop) + return (NULL); + sp++; + break; + case OANYOF: + cs = &m->g->sets[OPND(s)]; + if (sp == stop || !CHIN(cs, *sp++)) + return (NULL); + break; + case OBOL: + if ((sp == m->beginp && !(m->eflags & REG_NOTBOL)) || + (sp < m->endp && *(sp - 1) == '\n' && + (m->g->cflags & REG_NEWLINE))) + { /* yes */ + } + else + return (NULL); + break; + case OEOL: + if ((sp == m->endp && !(m->eflags & REG_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags & REG_NEWLINE))) + { /* yes */ + } + else + return (NULL); + break; + case OBOW: + if (((sp == m->beginp && !(m->eflags & REG_NOTBOL)) || + (sp < m->endp && *(sp - 1) == '\n' && + (m->g->cflags & REG_NEWLINE)) || + (sp > m->beginp && + !ISWORD(*(sp - 1)))) && + (sp < m->endp && ISWORD(*sp))) + { /* yes */ + } + else + return (NULL); + break; + case OEOW: + if (((sp == m->endp && !(m->eflags & REG_NOTEOL)) || + (sp < m->endp && *sp == '\n' && + (m->g->cflags & REG_NEWLINE)) || + (sp < m->endp && !ISWORD(*sp))) && + (sp > m->beginp && ISWORD(*(sp - 1)))) + { /* yes */ + } + else + return (NULL); + break; + case O_QUEST: + break; + case OOR1: /* matches null but needs to skip */ + ss++; + s = m->g->strip[ss]; + do + { + assert(OP(s) == OOR2); + ss += OPND(s); + } while (OP(s = m->g->strip[ss]) != O_CH); + /* note that the ss++ gets us past the O_CH */ + break; + default: /* have to make a choice */ + hard = 1; + break; } if (!hard) { /* that was it! */ @@ -650,93 +650,93 @@ sopno lev; /* PLUS nesting level */ s = m->g->strip[ss]; switch (OP(s)) { - case OBACK_: /* the vilest depths */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - if (m->pmatch[i].rm_eo == -1) - return (NULL); - assert(m->pmatch[i].rm_so != -1); - len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; - assert(stop - m->beginp >= len); - if (sp > stop - len) - return (NULL); /* not enough left to match */ - ssp = m->offp + m->pmatch[i].rm_so; - if (memcmp(sp, ssp, len) != 0) + case OBACK_: /* the vilest depths */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + if (m->pmatch[i].rm_eo == -1) + return (NULL); + assert(m->pmatch[i].rm_so != -1); + len = m->pmatch[i].rm_eo - m->pmatch[i].rm_so; + assert(stop - m->beginp >= len); + if (sp > stop - len) + return (NULL); /* not enough left to match */ + ssp = m->offp + m->pmatch[i].rm_so; + if (memcmp(sp, ssp, len) != 0) + return (NULL); + while (m->g->strip[ss] != SOP(O_BACK, i)) + ss++; + return (backref(m, sp + len, stop, ss + 1, stopst, lev)); + break; + case OQUEST_: /* to null or not */ + dp = backref(m, sp, stop, ss + 1, stopst, lev); + if (dp != NULL) + return (dp); /* not */ + return (backref(m, sp, stop, ss + OPND(s) + 1, stopst, lev)); + break; + case OPLUS_: + assert(m->lastpos != NULL); + assert(lev + 1 <= m->g->nplus); + m->lastpos[lev + 1] = sp; + return (backref(m, sp, stop, ss + 1, stopst, lev + 1)); + break; + case O_PLUS: + if (sp == m->lastpos[lev]) /* last pass matched null */ + return (backref(m, sp, stop, ss + 1, stopst, lev - 1)); + /* try another pass */ + m->lastpos[lev] = sp; + dp = backref(m, sp, stop, ss - OPND(s) + 1, stopst, lev); + if (dp == NULL) + return (backref(m, sp, stop, ss + 1, stopst, lev - 1)); + else + return (dp); + break; + case OCH_: /* find the right one, if any */ + ssub = ss + 1; + esub = ss + OPND(s) - 1; + assert(OP(m->g->strip[esub]) == OOR1); + for (;;) + { /* find first matching branch */ + dp = backref(m, sp, stop, ssub, esub, lev); + if (dp != NULL) + return (dp); + /* that one missed, try next one */ + if (OP(m->g->strip[esub]) == O_CH) + return (NULL); /* there is none */ + esub++; + assert(OP(m->g->strip[esub]) == OOR2); + ssub = esub + 1; + esub += OPND(m->g->strip[esub]); + if (OP(m->g->strip[esub]) == OOR2) + esub--; + else + assert(OP(m->g->strip[esub]) == O_CH); + } + break; + case OLPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_so; + m->pmatch[i].rm_so = sp - m->offp; + dp = backref(m, sp, stop, ss + 1, stopst, lev); + if (dp != NULL) + return (dp); + m->pmatch[i].rm_so = offsave; return (NULL); - while (m->g->strip[ss] != SOP(O_BACK, i)) - ss++; - return (backref(m, sp + len, stop, ss + 1, stopst, lev)); - break; - case OQUEST_: /* to null or not */ - dp = backref(m, sp, stop, ss + 1, stopst, lev); - if (dp != NULL) - return (dp); /* not */ - return (backref(m, sp, stop, ss + OPND(s) + 1, stopst, lev)); - break; - case OPLUS_: - assert(m->lastpos != NULL); - assert(lev + 1 <= m->g->nplus); - m->lastpos[lev + 1] = sp; - return (backref(m, sp, stop, ss + 1, stopst, lev + 1)); - break; - case O_PLUS: - if (sp == m->lastpos[lev]) /* last pass matched null */ - return (backref(m, sp, stop, ss + 1, stopst, lev - 1)); - /* try another pass */ - m->lastpos[lev] = sp; - dp = backref(m, sp, stop, ss - OPND(s) + 1, stopst, lev); - if (dp == NULL) - return (backref(m, sp, stop, ss + 1, stopst, lev - 1)); - else - return (dp); - break; - case OCH_: /* find the right one, if any */ - ssub = ss + 1; - esub = ss + OPND(s) - 1; - assert(OP(m->g->strip[esub]) == OOR1); - for (;;) - { /* find first matching branch */ - dp = backref(m, sp, stop, ssub, esub, lev); + break; + case ORPAREN: /* must undo assignment if rest fails */ + i = OPND(s); + assert(0 < i && i <= m->g->nsub); + offsave = m->pmatch[i].rm_eo; + m->pmatch[i].rm_eo = sp - m->offp; + dp = backref(m, sp, stop, ss + 1, stopst, lev); if (dp != NULL) return (dp); - /* that one missed, try next one */ - if (OP(m->g->strip[esub]) == O_CH) - return (NULL); /* there is none */ - esub++; - assert(OP(m->g->strip[esub]) == OOR2); - ssub = esub + 1; - esub += OPND(m->g->strip[esub]); - if (OP(m->g->strip[esub]) == OOR2) - esub--; - else - assert(OP(m->g->strip[esub]) == O_CH); - } - break; - case OLPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_so; - m->pmatch[i].rm_so = sp - m->offp; - dp = backref(m, sp, stop, ss + 1, stopst, lev); - if (dp != NULL) - return (dp); - m->pmatch[i].rm_so = offsave; - return (NULL); - break; - case ORPAREN: /* must undo assignment if rest fails */ - i = OPND(s); - assert(0 < i && i <= m->g->nsub); - offsave = m->pmatch[i].rm_eo; - m->pmatch[i].rm_eo = sp - m->offp; - dp = backref(m, sp, stop, ss + 1, stopst, lev); - if (dp != NULL) - return (dp); - m->pmatch[i].rm_eo = offsave; - return (NULL); - break; - default: /* uh oh */ - assert(nope); - break; + m->pmatch[i].rm_eo = offsave; + return (NULL); + break; + default: /* uh oh */ + assert(nope); + break; } /* "can't happen" */ @@ -750,23 +750,23 @@ sopno lev; /* PLUS nesting level */ == static char *fast(register struct match *m, char *start, \ == char *stop, sopno startst, sopno stopst); */ -static char * /* where tentative match ended, or NULL */ +static char * /* where tentative match ended, or NULL */ fast(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; -sopno startst; -sopno stopst; +char *start; +char *stop; +sopno startst; +sopno stopst; { register states st = m->st; register states fresh = m->fresh; register states tmp = m->tmp; - register char *p = start; - register int c = (start == m->beginp) ? OUT : *(start - 1); - register int lastc; /* previous c */ - register int flagch; - register int i; - register char *coldp; /* last p after which no match was + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start - 1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *coldp; /* last p after which no match was * underway */ CLEAR(st); @@ -849,23 +849,23 @@ sopno stopst; == static char *slow(register struct match *m, char *start, \ == char *stop, sopno startst, sopno stopst); */ -static char * /* where it ended */ +static char * /* where it ended */ slow(m, start, stop, startst, stopst) register struct match *m; -char *start; -char *stop; -sopno startst; -sopno stopst; +char *start; +char *stop; +sopno startst; +sopno stopst; { register states st = m->st; register states empty = m->empty; register states tmp = m->tmp; - register char *p = start; - register int c = (start == m->beginp) ? OUT : *(start - 1); - register int lastc; /* previous c */ - register int flagch; - register int i; - register char *matchp; /* last p at which a match ended */ + register char *p = start; + register int c = (start == m->beginp) ? OUT : *(start - 1); + register int lastc; /* previous c */ + register int flagch; + register int i; + register char *matchp; /* last p at which a match ended */ AT("slow", start, stop, startst, stopst); CLEAR(st); @@ -952,119 +952,119 @@ sopno stopst; == #define NONCHAR(c) ((c) > CHAR_MAX) == #define NNONCHAR (CODEMAX-CHAR_MAX) */ -static states +static states step(g, start, stop, bef, ch, aft) register struct re_guts *g; -sopno start; /* start state within strip */ -sopno stop; /* state after stop state within strip */ +sopno start; /* start state within strip */ +sopno stop; /* state after stop state within strip */ register states bef; /* states reachable before */ -int ch; /* character or NONCHAR code */ +int ch; /* character or NONCHAR code */ register states aft; /* states already known reachable after */ { - register cset *cs; - register sop s; - register sopno pc; + register cset *cs; + register sop s; + register sopno pc; register onestate here; /* note, macros know this name */ - register sopno look; - register int i; + register sopno look; + register int i; for (pc = start, INIT(here, pc); pc != stop; pc++, INC(here)) { s = g->strip[pc]; switch (OP(s)) { - case OEND: - assert(pc == stop - 1); - break; - case OCHAR: - /* only characters can match */ - assert(!NONCHAR(ch) || ch != (char) OPND(s)); - if (ch == (char) OPND(s)) - FWD(aft, bef, 1); - break; - case OBOL: - if (ch == BOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OEOL: - if (ch == EOL || ch == BOLEOL) - FWD(aft, bef, 1); - break; - case OBOW: - if (ch == BOW) - FWD(aft, bef, 1); - break; - case OEOW: - if (ch == EOW) - FWD(aft, bef, 1); - break; - case OANY: - if (!NONCHAR(ch)) - FWD(aft, bef, 1); - break; - case OANYOF: - cs = &g->sets[OPND(s)]; - if (!NONCHAR(ch) && CHIN(cs, ch)) - FWD(aft, bef, 1); - break; - case OBACK_: /* ignored here */ - case O_BACK: - FWD(aft, aft, 1); - break; - case OPLUS_: /* forward, this is just an empty */ - FWD(aft, aft, 1); - break; - case O_PLUS: /* both forward and back */ - FWD(aft, aft, 1); - i = ISSETBACK(aft, OPND(s)); - BACK(aft, aft, OPND(s)); - if (!i && ISSETBACK(aft, OPND(s))) - { - /* oho, must reconsider loop body */ - pc -= OPND(s) + 1; - INIT(here, pc); - } - break; - case OQUEST_: /* two branches, both forward */ - FWD(aft, aft, 1); - FWD(aft, aft, OPND(s)); - break; - case O_QUEST: /* just an empty */ - FWD(aft, aft, 1); - break; - case OLPAREN: /* not significant here */ - case ORPAREN: - FWD(aft, aft, 1); - break; - case OCH_: /* mark the first two branches */ - FWD(aft, aft, 1); - assert(OP(g->strip[pc + OPND(s)]) == OOR2); - FWD(aft, aft, OPND(s)); - break; - case OOR1: /* done a branch, find the O_CH */ - if (ISSTATEIN(aft, here)) - { - for (look = 1; - OP(s = g->strip[pc + look]) != O_CH; - look += OPND(s)) - assert(OP(s) == OOR2); - FWD(aft, aft, look); - } - break; - case OOR2: /* propagate OCH_'s marking */ - FWD(aft, aft, 1); - if (OP(g->strip[pc + OPND(s)]) != O_CH) - { + case OEND: + assert(pc == stop - 1); + break; + case OCHAR: + /* only characters can match */ + assert(!NONCHAR(ch) || ch != (char) OPND(s)); + if (ch == (char) OPND(s)) + FWD(aft, bef, 1); + break; + case OBOL: + if (ch == BOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OEOL: + if (ch == EOL || ch == BOLEOL) + FWD(aft, bef, 1); + break; + case OBOW: + if (ch == BOW) + FWD(aft, bef, 1); + break; + case OEOW: + if (ch == EOW) + FWD(aft, bef, 1); + break; + case OANY: + if (!NONCHAR(ch)) + FWD(aft, bef, 1); + break; + case OANYOF: + cs = &g->sets[OPND(s)]; + if (!NONCHAR(ch) && CHIN(cs, ch)) + FWD(aft, bef, 1); + break; + case OBACK_: /* ignored here */ + case O_BACK: + FWD(aft, aft, 1); + break; + case OPLUS_: /* forward, this is just an empty */ + FWD(aft, aft, 1); + break; + case O_PLUS: /* both forward and back */ + FWD(aft, aft, 1); + i = ISSETBACK(aft, OPND(s)); + BACK(aft, aft, OPND(s)); + if (!i && ISSETBACK(aft, OPND(s))) + { + /* oho, must reconsider loop body */ + pc -= OPND(s) + 1; + INIT(here, pc); + } + break; + case OQUEST_: /* two branches, both forward */ + FWD(aft, aft, 1); + FWD(aft, aft, OPND(s)); + break; + case O_QUEST: /* just an empty */ + FWD(aft, aft, 1); + break; + case OLPAREN: /* not significant here */ + case ORPAREN: + FWD(aft, aft, 1); + break; + case OCH_: /* mark the first two branches */ + FWD(aft, aft, 1); assert(OP(g->strip[pc + OPND(s)]) == OOR2); FWD(aft, aft, OPND(s)); - } - break; - case O_CH: /* just empty */ - FWD(aft, aft, 1); - break; - default: /* ooooops... */ - assert(nope); - break; + break; + case OOR1: /* done a branch, find the O_CH */ + if (ISSTATEIN(aft, here)) + { + for (look = 1; + OP(s = g->strip[pc + look]) != O_CH; + look += OPND(s)) + assert(OP(s) == OOR2); + FWD(aft, aft, look); + } + break; + case OOR2: /* propagate OCH_'s marking */ + FWD(aft, aft, 1); + if (OP(g->strip[pc + OPND(s)]) != O_CH) + { + assert(OP(g->strip[pc + OPND(s)]) == OOR2); + FWD(aft, aft, OPND(s)); + } + break; + case O_CH: /* just empty */ + FWD(aft, aft, 1); + break; + default: /* ooooops... */ + assert(nope); + break; } } @@ -1081,15 +1081,15 @@ register states aft; /* states already known reachable after */ */ static void print(m, caption, st, ch, d) -struct match *m; -char *caption; -states st; -int ch; -FILE *d; +struct match *m; +char *caption; +states st; +int ch; +FILE *d; { register struct re_guts *g = m->g; - register int i; - register int first = 1; + register int i; + register int first = 1; if (!(m->eflags & REG_TRACE)) return; @@ -1115,12 +1115,12 @@ FILE *d; */ static void at(m, title, start, stop, startst, stopst) -struct match *m; -char *title; -char *start; -char *stop; -sopno startst; -sopno stopst; +struct match *m; +char *title; +char *start; +char *stop; +sopno startst; +sopno stopst; { if (!(m->eflags & REG_TRACE)) return; @@ -1143,11 +1143,11 @@ sopno stopst; * a matching debug.o, and this is convenient. It all disappears in * the non-debug compilation anyway, so it doesn't matter much. */ -static char * /* -> representation */ +static char * /* -> representation */ pchar(ch) -int ch; +int ch; { - static char pbuf[10]; + static char pbuf[10]; if (isprint(ch) || ch == ' ') sprintf(pbuf, "%c", ch); diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index dcb95173c06..da4f2020ce3 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -38,7 +38,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; +static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ @@ -62,64 +62,64 @@ static char sccsid[] = "@(#)regcomp.c 8.5 (Berkeley) 3/20/94"; */ struct parse { - char *next; /* next character in RE */ - char *end; /* end of string (-> NUL normally) */ - int error; /* has an error been seen? */ - sop *strip; /* malloced strip */ - sopno ssize; /* malloced strip size (allocated) */ - sopno slen; /* malloced strip length (used) */ - int ncsalloc; /* number of csets allocated */ + char *next; /* next character in RE */ + char *end; /* end of string (-> NUL normally) */ + int error; /* has an error been seen? */ + sop *strip; /* malloced strip */ + sopno ssize; /* malloced strip size (allocated) */ + sopno slen; /* malloced strip length (used) */ + int ncsalloc; /* number of csets allocated */ struct re_guts *g; #define NPAREN 10 /* we need to remember () 1-9 for back * refs */ - sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ - sopno pend[NPAREN]; /* -> ) ([0] unused) */ + sopno pbegin[NPAREN]; /* -> ( ([0] unused) */ + sopno pend[NPAREN]; /* -> ) ([0] unused) */ }; /* ========= begin header generated by ./mkh ========= */ #ifdef __cplusplus -extern "C" +extern "C" { #endif /* === regcomp.c === */ - static void p_ere(struct parse * p, int stop); - static void p_ere_exp(struct parse * p); - static void p_str(struct parse * p); - static void p_bre(struct parse * p, int end1, int end2); - static int p_simp_re(struct parse * p, int starordinary); - static int p_count(struct parse * p); - static void p_bracket(struct parse * p); - static void p_b_term(struct parse * p, cset * cs); - static void p_b_cclass(struct parse * p, cset * cs); - static void p_b_eclass(struct parse * p, cset * cs); - static char p_b_symbol(struct parse * p); - static char p_b_coll_elem(struct parse * p, int endc); - static char othercase(int ch); - static void bothcases(struct parse * p, int ch); - static void ordinary(struct parse * p, int ch); - static void nonnewline(struct parse * p); - static void repeat(struct parse * p, sopno start, int from, int to); - static int seterr(struct parse * p, int e); - static cset *allocset(struct parse * p); - static void freeset(struct parse * p, cset * cs); - static int freezeset(struct parse * p, cset * cs); - static int firstch(struct parse * p, cset * cs); - static int nch(struct parse * p, cset * cs); - static void mcadd(struct parse * p, cset * cs, char *cp); - static void mcinvert(struct parse * p, cset * cs); - static void mccase(struct parse * p, cset * cs); - static int isinsets(struct re_guts * g, int c); - static int samesets(struct re_guts * g, int c1, int c2); - static void categorize(struct parse * p, struct re_guts * g); - static sopno dupl(struct parse * p, sopno start, sopno finish); - static void doemit(struct parse * p, sop op, size_t opnd); - static void doinsert(struct parse * p, sop op, size_t opnd, sopno pos); - static void dofwd(struct parse * p, sopno pos, sop value); - static void enlarge(struct parse * p, sopno size); - static void stripsnug(struct parse * p, struct re_guts * g); - static void findmust(struct parse * p, struct re_guts * g); - static sopno pluscount(struct parse * p, struct re_guts * g); + static void p_ere(struct parse * p, int stop); + static void p_ere_exp(struct parse * p); + static void p_str(struct parse * p); + static void p_bre(struct parse * p, int end1, int end2); + static int p_simp_re(struct parse * p, int starordinary); + static int p_count(struct parse * p); + static void p_bracket(struct parse * p); + static void p_b_term(struct parse * p, cset * cs); + static void p_b_cclass(struct parse * p, cset * cs); + static void p_b_eclass(struct parse * p, cset * cs); + static char p_b_symbol(struct parse * p); + static char p_b_coll_elem(struct parse * p, int endc); + static char othercase(int ch); + static void bothcases(struct parse * p, int ch); + static void ordinary(struct parse * p, int ch); + static void nonnewline(struct parse * p); + static void repeat(struct parse * p, sopno start, int from, int to); + static int seterr(struct parse * p, int e); + static cset *allocset(struct parse * p); + static void freeset(struct parse * p, cset * cs); + static int freezeset(struct parse * p, cset * cs); + static int firstch(struct parse * p, cset * cs); + static int nch(struct parse * p, cset * cs); + static void mcadd(struct parse * p, cset * cs, char *cp); + static void mcinvert(struct parse * p, cset * cs); + static void mccase(struct parse * p, cset * cs); + static int isinsets(struct re_guts * g, int c); + static int samesets(struct re_guts * g, int c1, int c2); + static void categorize(struct parse * p, struct re_guts * g); + static sopno dupl(struct parse * p, sopno start, sopno finish); + static void doemit(struct parse * p, sop op, size_t opnd); + static void doinsert(struct parse * p, sop op, size_t opnd, sopno pos); + static void dofwd(struct parse * p, sopno pos, sop value); + static void enlarge(struct parse * p, sopno size); + static void stripsnug(struct parse * p, struct re_guts * g); + static void findmust(struct parse * p, struct re_guts * g); + static sopno pluscount(struct parse * p, struct re_guts * g); #ifdef __cplusplus } @@ -127,7 +127,7 @@ extern "C" #endif /* ========= end header generated by ./mkh ========= */ -static char nuls[10]; /* place to point scanner in event of +static char nuls[10]; /* place to point scanner in event of * error */ /* @@ -161,7 +161,7 @@ static char nuls[10]; /* place to point scanner in event of #define DROP(n) (p->slen -= (n)) #ifndef NDEBUG -static int never = 0; /* for use in asserts; shuts lint up */ +static int never = 0; /* for use in asserts; shuts lint up */ #else #define never 0 /* some <assert.h>s have bugs too */ @@ -181,14 +181,14 @@ static int never = 0; /* for use in asserts; shuts lint up */ */ int /* 0 success, otherwise REG_something */ pg95_regcomp(preg, pattern, cflags) -regex_t *preg; -const char *pattern; -int cflags; +regex_t *preg; +const char *pattern; +int cflags; { - struct parse pa; + struct parse pa; register struct re_guts *g; register struct parse *p = &pa; - register int i; + register int i; register size_t len; #ifdef REDEBUG @@ -292,13 +292,13 @@ int cflags; static void p_ere(p, stop) register struct parse *p; -int stop; /* character this ERE should end at */ +int stop; /* character this ERE should end at */ { - register char c; - register sopno prevback = 0; - register sopno prevfwd = 0; - register sopno conc; - register int first = 1; /* is this the first alternative? */ + register char c; + register sopno prevback = 0; + register sopno prevfwd = 0; + register sopno conc; + register int first = 1; /* is this the first alternative? */ for (;;) { @@ -342,12 +342,12 @@ static void p_ere_exp(p) register struct parse *p; { - register char c; - register sopno pos; - register int count; - register int count2; - register sopno subno; - int wascaret = 0; + register char c; + register sopno pos; + register int count; + register int count2; + register sopno subno; + int wascaret = 0; assert(MORE()); /* caller should have ensured this */ c = GETNEXT(); @@ -355,75 +355,76 @@ register struct parse *p; pos = HERE(); switch (c) { - case '(': - REQUIRE(MORE(), REG_EPAREN); - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - if (!SEE(')')) - p_ere(p, ')'); - if (subno < NPAREN) - { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - MUSTEAT(')', REG_EPAREN); - break; + case '(': + REQUIRE(MORE(), REG_EPAREN); + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + if (!SEE(')')) + p_ere(p, ')'); + if (subno < NPAREN) + { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + MUSTEAT(')', REG_EPAREN); + break; #ifndef POSIX_MISTAKE - case ')': /* happens only if no current unmatched ( */ - - /* - * You may ask, why the ifndef? Because I didn't notice this - * until slightly too late for 1003.2, and none of the other - * 1003.2 regular-expression reviewers noticed it at all. So an - * unmatched ) is legal POSIX, at least until we can get it fixed. - */ - SETERROR(REG_EPAREN); - break; + case ')': /* happens only if no current unmatched ( */ + + /* + * You may ask, why the ifndef? Because I didn't notice this + * until slightly too late for 1003.2, and none of the other + * 1003.2 regular-expression reviewers noticed it at all. So + * an unmatched ) is legal POSIX, at least until we can get it + * fixed. + */ + SETERROR(REG_EPAREN); + break; #endif - case '^': - EMIT(OBOL, 0); - p->g->iflags |= USEBOL; - p->g->nbol++; - wascaret = 1; - break; - case '$': - EMIT(OEOL, 0); - p->g->iflags |= USEEOL; - p->g->neol++; - break; - case '|': - SETERROR(REG_EMPTY); - break; - case '*': - case '+': - case '?': - SETERROR(REG_BADRPT); - break; - case '.': - if (p->g->cflags & REG_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; - case '\\': - REQUIRE(MORE(), REG_EESCAPE); - c = GETNEXT(); - ordinary(p, c); - break; - case '{': /* okay as ordinary except if digit + case '^': + EMIT(OBOL, 0); + p->g->iflags |= USEBOL; + p->g->nbol++; + wascaret = 1; + break; + case '$': + EMIT(OEOL, 0); + p->g->iflags |= USEEOL; + p->g->neol++; + break; + case '|': + SETERROR(REG_EMPTY); + break; + case '*': + case '+': + case '?': + SETERROR(REG_BADRPT); + break; + case '.': + if (p->g->cflags & REG_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case '\\': + REQUIRE(MORE(), REG_EESCAPE); + c = GETNEXT(); + ordinary(p, c); + break; + case '{': /* okay as ordinary except if digit * follows */ - REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT); - /* FALLTHROUGH */ - default: - ordinary(p, c); - break; + REQUIRE(!MORE() || !isdigit(PEEK()), REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c); + break; } if (!MORE()) @@ -438,51 +439,51 @@ register struct parse *p; REQUIRE(!wascaret, REG_BADRPT); switch (c) { - case '*': /* implemented as +? */ - /* this case does not require the (y|) trick, noKLUDGE */ - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - INSERT(OQUEST_, pos); - ASTERN(O_QUEST, pos); - break; - case '+': - INSERT(OPLUS_, pos); - ASTERN(O_PLUS, pos); - break; - case '?': - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, pos); /* offset slightly wrong */ - ASTERN(OOR1, pos); /* this one's right */ - AHEAD(pos); /* fix the OCH_ */ - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - break; - case '{': - count = p_count(p); - if (EAT(',')) - { - if (isdigit(PEEK())) + case '*': /* implemented as +? */ + /* this case does not require the (y|) trick, noKLUDGE */ + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + INSERT(OQUEST_, pos); + ASTERN(O_QUEST, pos); + break; + case '+': + INSERT(OPLUS_, pos); + ASTERN(O_PLUS, pos); + break; + case '?': + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, pos); /* offset slightly wrong */ + ASTERN(OOR1, pos); /* this one's right */ + AHEAD(pos); /* fix the OCH_ */ + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + break; + case '{': + count = p_count(p); + if (EAT(',')) { - count2 = p_count(p); - REQUIRE(count <= count2, REG_BADBR); + if (isdigit(PEEK())) + { + count2 = p_count(p); + REQUIRE(count <= count2, REG_BADBR); + } + else +/* single number with comma */ + count2 = INFINITY; } else -/* single number with comma */ - count2 = INFINITY; - } - else /* just a single number */ - count2 = count; - repeat(p, pos, count, count2); - if (!EAT('}')) - { /* error heuristics */ - while (MORE() && PEEK() != '}') - NEXT(); - REQUIRE(MORE(), REG_EBRACE); - SETERROR(REG_BADBR); - } - break; + count2 = count; + repeat(p, pos, count, count2); + if (!EAT('}')) + { /* error heuristics */ + while (MORE() && PEEK() != '}') + NEXT(); + REQUIRE(MORE(), REG_EBRACE); + SETERROR(REG_BADBR); + } + break; } if (!MORE()) @@ -522,12 +523,12 @@ register struct parse *p; static void p_bre(p, end1, end2) register struct parse *p; -register int end1; /* first terminating character */ -register int end2; /* second terminating character */ +register int end1; /* first terminating character */ +register int end2; /* second terminating character */ { - register sopno start = HERE(); - register int first = 1; /* first subexpression? */ - register int wasdollar = 0; + register sopno start = HERE(); + register int first = 1; /* first subexpression? */ + register int wasdollar = 0; if (EAT('^')) { @@ -558,14 +559,14 @@ register int end2; /* second terminating character */ static int /* was the simple RE an unbackslashed $? */ p_simp_re(p, starordinary) register struct parse *p; -int starordinary; /* is a leading * an ordinary character? */ +int starordinary; /* is a leading * an ordinary character? */ { - register int c; - register int count; - register int count2; - register sopno pos; - register int i; - register sopno subno; + register int c; + register int count; + register int count2; + register sopno pos; + register int i; + register sopno subno; #define BACKSL (1<<CHAR_BIT) @@ -580,70 +581,70 @@ int starordinary; /* is a leading * an ordinary character? */ } switch (c) { - case '.': - if (p->g->cflags & REG_NEWLINE) - nonnewline(p); - else - EMIT(OANY, 0); - break; - case '[': - p_bracket(p); - break; - case BACKSL | '{': - SETERROR(REG_BADRPT); - break; - case BACKSL | '(': - p->g->nsub++; - subno = p->g->nsub; - if (subno < NPAREN) - p->pbegin[subno] = HERE(); - EMIT(OLPAREN, subno); - /* the MORE here is an error heuristic */ - if (MORE() && !SEETWO('\\', ')')) - p_bre(p, '\\', ')'); - if (subno < NPAREN) - { - p->pend[subno] = HERE(); - assert(p->pend[subno] != 0); - } - EMIT(ORPAREN, subno); - REQUIRE(EATTWO('\\', ')'), REG_EPAREN); - break; - case BACKSL | ')': /* should not get here -- must be user */ - case BACKSL | '}': - SETERROR(REG_EPAREN); - break; - case BACKSL | '1': - case BACKSL | '2': - case BACKSL | '3': - case BACKSL | '4': - case BACKSL | '5': - case BACKSL | '6': - case BACKSL | '7': - case BACKSL | '8': - case BACKSL | '9': - i = (c & ~BACKSL) - '0'; - assert(i < NPAREN); - if (p->pend[i] != 0) - { - assert(i <= p->g->nsub); - EMIT(OBACK_, i); - assert(p->pbegin[i] != 0); - assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); - assert(OP(p->strip[p->pend[i]]) == ORPAREN); - dupl(p, p->pbegin[i] + 1, p->pend[i]); - EMIT(O_BACK, i); - } - else - SETERROR(REG_ESUBREG); - p->g->backrefs = 1; - break; - case '*': - REQUIRE(starordinary, REG_BADRPT); - /* FALLTHROUGH */ - default: - ordinary(p, c & ~BACKSL); - break; + case '.': + if (p->g->cflags & REG_NEWLINE) + nonnewline(p); + else + EMIT(OANY, 0); + break; + case '[': + p_bracket(p); + break; + case BACKSL | '{': + SETERROR(REG_BADRPT); + break; + case BACKSL | '(': + p->g->nsub++; + subno = p->g->nsub; + if (subno < NPAREN) + p->pbegin[subno] = HERE(); + EMIT(OLPAREN, subno); + /* the MORE here is an error heuristic */ + if (MORE() && !SEETWO('\\', ')')) + p_bre(p, '\\', ')'); + if (subno < NPAREN) + { + p->pend[subno] = HERE(); + assert(p->pend[subno] != 0); + } + EMIT(ORPAREN, subno); + REQUIRE(EATTWO('\\', ')'), REG_EPAREN); + break; + case BACKSL | ')': /* should not get here -- must be user */ + case BACKSL | '}': + SETERROR(REG_EPAREN); + break; + case BACKSL | '1': + case BACKSL | '2': + case BACKSL | '3': + case BACKSL | '4': + case BACKSL | '5': + case BACKSL | '6': + case BACKSL | '7': + case BACKSL | '8': + case BACKSL | '9': + i = (c & ~BACKSL) - '0'; + assert(i < NPAREN); + if (p->pend[i] != 0) + { + assert(i <= p->g->nsub); + EMIT(OBACK_, i); + assert(p->pbegin[i] != 0); + assert(OP(p->strip[p->pbegin[i]]) == OLPAREN); + assert(OP(p->strip[p->pend[i]]) == ORPAREN); + dupl(p, p->pbegin[i] + 1, p->pend[i]); + EMIT(O_BACK, i); + } + else + SETERROR(REG_ESUBREG); + p->g->backrefs = 1; + break; + case '*': + REQUIRE(starordinary, REG_BADRPT); + /* FALLTHROUGH */ + default: + ordinary(p, c & ~BACKSL); + break; } if (EAT('*')) @@ -694,8 +695,8 @@ static int /* the value */ p_count(p) register struct parse *p; { - register int count = 0; - register int ndigits = 0; + register int count = 0; + register int ndigits = 0; while (MORE() && isdigit(PEEK()) && count <= DUPMAX) { @@ -718,8 +719,8 @@ static void p_bracket(p) register struct parse *p; { - register cset *cs = allocset(p); - register int invert = 0; + register cset *cs = allocset(p); + register int invert = 0; /* Dept of Truly Sickening Special-Case Kludges */ if (p->next + 5 < p->end && strncmp(p->next, "[:<:]]", 6) == 0) @@ -752,8 +753,8 @@ register struct parse *p; if (p->g->cflags & REG_ICASE) { - register int i; - register int ci; + register int i; + register int ci; for (i = p->g->csetsize - 1; i >= 0; i--) if (CHIN(cs, i) && isalpha(i)) @@ -767,7 +768,7 @@ register struct parse *p; } if (invert) { - register int i; + register int i; for (i = p->g->csetsize - 1; i >= 0; i--) if (CHIN(cs, i)) @@ -798,67 +799,67 @@ register struct parse *p; static void p_b_term(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register char c; - register char start, - finish; - register int i; + register char c; + register char start, + finish; + register int i; /* classify what we've got */ switch ((MORE()) ? PEEK() : '\0') { - case '[': - c = (MORE2()) ? PEEK2() : '\0'; - break; - case '-': - SETERROR(REG_ERANGE); - return; /* NOTE RETURN */ - break; - default: - c = '\0'; - break; + case '[': + c = (MORE2()) ? PEEK2() : '\0'; + break; + case '-': + SETERROR(REG_ERANGE); + return; /* NOTE RETURN */ + break; + default: + c = '\0'; + break; } switch (c) { - case ':': /* character class */ - NEXT2(); - REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - REQUIRE(c != '-' && c != ']', REG_ECTYPE); - p_b_cclass(p, cs); - REQUIRE(MORE(), REG_EBRACK); - REQUIRE(EATTWO(':', ']'), REG_ECTYPE); - break; - case '=': /* equivalence class */ - NEXT2(); - REQUIRE(MORE(), REG_EBRACK); - c = PEEK(); - REQUIRE(c != '-' && c != ']', REG_ECOLLATE); - p_b_eclass(p, cs); - REQUIRE(MORE(), REG_EBRACK); - REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); - break; - default: /* symbol, ordinary character, or range */ + case ':': /* character class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECTYPE); + p_b_cclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO(':', ']'), REG_ECTYPE); + break; + case '=': /* equivalence class */ + NEXT2(); + REQUIRE(MORE(), REG_EBRACK); + c = PEEK(); + REQUIRE(c != '-' && c != ']', REG_ECOLLATE); + p_b_eclass(p, cs); + REQUIRE(MORE(), REG_EBRACK); + REQUIRE(EATTWO('=', ']'), REG_ECOLLATE); + break; + default: /* symbol, ordinary character, or range */ /* xxx revision needed for multichar stuff */ - start = p_b_symbol(p); - if (SEE('-') && MORE2() && PEEK2() != ']') - { - /* range */ - NEXT(); - if (EAT('-')) - finish = '-'; + start = p_b_symbol(p); + if (SEE('-') && MORE2() && PEEK2() != ']') + { + /* range */ + NEXT(); + if (EAT('-')) + finish = '-'; + else + finish = p_b_symbol(p); + } else - finish = p_b_symbol(p); - } - else - finish = start; + finish = start; /* xxx what about signed chars here... */ - REQUIRE(start <= finish, REG_ERANGE); - for (i = start; i <= finish; i++) - CHadd(cs, i); - break; + REQUIRE(start <= finish, REG_ERANGE); + for (i = start; i <= finish; i++) + CHadd(cs, i); + break; } } @@ -869,13 +870,13 @@ register cset *cs; static void p_b_cclass(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register char *sp = p->next; + register char *sp = p->next; register struct cclass *cp; register size_t len; - register char *u; - register char c; + register char *u; + register char c; while (MORE() && isalpha(PEEK())) NEXT(); @@ -906,9 +907,9 @@ register cset *cs; static void p_b_eclass(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register char c; + register char c; c = p_b_coll_elem(p, '='); CHadd(cs, c); @@ -922,7 +923,7 @@ static char /* value of symbol */ p_b_symbol(p) register struct parse *p; { - register char value; + register char value; REQUIRE(MORE(), REG_EBRACK); if (!EATTWO('[', '.')) @@ -941,11 +942,11 @@ register struct parse *p; static char /* value of collating element */ p_b_coll_elem(p, endc) register struct parse *p; -int endc; /* name ended by endc,']' */ +int endc; /* name ended by endc,']' */ { - register char *sp = p->next; + register char *sp = p->next; register struct cname *cp; - register int len; + register int len; while (MORE() && !SEETWO(endc, ']')) NEXT(); @@ -970,7 +971,7 @@ int endc; /* name ended by endc,']' */ */ static char /* if no counterpart, return ch */ othercase(ch) -int ch; +int ch; { assert(isalpha(ch)); if (isupper(ch)) @@ -991,11 +992,11 @@ int ch; static void bothcases(p, ch) register struct parse *p; -int ch; +int ch; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[3]; + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[3]; assert(othercase(ch) != ch);/* p_bracket() would recurse */ p->next = bracket; @@ -1016,7 +1017,7 @@ int ch; static void ordinary(p, ch) register struct parse *p; -register int ch; +register int ch; { register cat_t *cap = p->g->categories; @@ -1040,9 +1041,9 @@ static void nonnewline(p) register struct parse *p; { - register char *oldnext = p->next; - register char *oldend = p->end; - char bracket[4]; + register char *oldnext = p->next; + register char *oldend = p->end; + char bracket[4]; p->next = bracket; p->end = bracket + 3; @@ -1063,18 +1064,18 @@ register struct parse *p; static void repeat(p, start, from, to) register struct parse *p; -sopno start; /* operand from here to end of strip */ -int from; /* repeated from this number */ -int to; /* to this number of times (maybe +sopno start; /* operand from here to end of strip */ +int from; /* repeated from this number */ +int to; /* to this number of times (maybe * INFINITY) */ { - register sopno finish = HERE(); + register sopno finish = HERE(); #define N 2 #define INF 3 #define REP(f, t) ((f)*8 + (t)) #define MAP(n) (((n) <= 1) ? (n) : ((n) == INFINITY) ? INF : N) - register sopno copy; + register sopno copy; if (p->error != 0) /* head off possible runaway recursion */ return; @@ -1083,51 +1084,51 @@ int to; /* to this number of times (maybe switch (REP(MAP(from), MAP(to))) { - case REP(0, 0): /* must be user doing this */ - DROP(finish - start); /* drop the operand */ - break; - case REP(0, 1): /* as x{1,1}? */ - case REP(0, N): /* as x{1,n}? */ - case REP(0, INF): /* as x{1,}? */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); /* offset is wrong... */ - repeat(p, start + 1, 1, to); - ASTERN(OOR1, start); - AHEAD(start); /* ... fix it */ - EMIT(OOR2, 0); - AHEAD(THERE()); - ASTERN(O_CH, THERETHERE()); - break; - case REP(1, 1): /* trivial case */ - /* done */ - break; - case REP(1, N): /* as x?x{1,n-1} */ - /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ - INSERT(OCH_, start); - ASTERN(OOR1, start); - AHEAD(start); - EMIT(OOR2, 0); /* offset very wrong... */ - AHEAD(THERE()); /* ...so fix it */ - ASTERN(O_CH, THERETHERE()); - copy = dupl(p, start + 1, finish + 1); - assert(copy == finish + 4); - repeat(p, copy, 1, to - 1); - break; - case REP(1, INF): /* as x+ */ - INSERT(OPLUS_, start); - ASTERN(O_PLUS, start); - break; - case REP(N, N): /* as xx{m-1,n-1} */ - copy = dupl(p, start, finish); - repeat(p, copy, from - 1, to - 1); - break; - case REP(N, INF): /* as xx{n-1,INF} */ - copy = dupl(p, start, finish); - repeat(p, copy, from - 1, to); - break; - default: /* "can't happen" */ - SETERROR(REG_ASSERT); /* just in case */ - break; + case REP(0, 0): /* must be user doing this */ + DROP(finish - start); /* drop the operand */ + break; + case REP(0, 1): /* as x{1,1}? */ + case REP(0, N): /* as x{1,n}? */ + case REP(0, INF): /* as x{1,}? */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start);/* offset is wrong... */ + repeat(p, start + 1, 1, to); + ASTERN(OOR1, start); + AHEAD(start); /* ... fix it */ + EMIT(OOR2, 0); + AHEAD(THERE()); + ASTERN(O_CH, THERETHERE()); + break; + case REP(1, 1): /* trivial case */ + /* done */ + break; + case REP(1, N): /* as x?x{1,n-1} */ + /* KLUDGE: emit y? as (y|) until subtle bug gets fixed */ + INSERT(OCH_, start); + ASTERN(OOR1, start); + AHEAD(start); + EMIT(OOR2, 0); /* offset very wrong... */ + AHEAD(THERE()); /* ...so fix it */ + ASTERN(O_CH, THERETHERE()); + copy = dupl(p, start + 1, finish + 1); + assert(copy == finish + 4); + repeat(p, copy, 1, to - 1); + break; + case REP(1, INF): /* as x+ */ + INSERT(OPLUS_, start); + ASTERN(O_PLUS, start); + break; + case REP(N, N): /* as xx{m-1,n-1} */ + copy = dupl(p, start, finish); + repeat(p, copy, from - 1, to - 1); + break; + case REP(N, INF): /* as xx{n-1,INF} */ + copy = dupl(p, start, finish); + repeat(p, copy, from - 1, to); + break; + default: /* "can't happen" */ + SETERROR(REG_ASSERT); /* just in case */ + break; } } @@ -1138,7 +1139,7 @@ int to; /* to this number of times (maybe static int /* useless but makes type checking happy */ seterr(p, e) register struct parse *p; -int e; +int e; { if (p->error == 0) /* keep earliest error condition */ p->error = e; @@ -1151,16 +1152,16 @@ int e; - allocset - allocate a set of characters for [] == static cset *allocset(register struct parse *p); */ -static cset * +static cset * allocset(p) register struct parse *p; { - register int no = p->g->ncsets++; + register int no = p->g->ncsets++; register size_t nc; register size_t nbytes; - register cset *cs; + register cset *cs; register size_t css = (size_t) p->g->csetsize; - register int i; + register int i; if (no >= p->ncsalloc) { /* need another column of space */ @@ -1212,10 +1213,10 @@ register struct parse *p; static void freeset(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register int i; - register cset *top = &p->g->sets[p->g->ncsets]; + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; register size_t css = (size_t) p->g->csetsize; for (i = 0; i < css; i++) @@ -1237,12 +1238,12 @@ register cset *cs; static int /* set number */ freezeset(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register uch h = cs->hash; - register int i; - register cset *top = &p->g->sets[p->g->ncsets]; - register cset *cs2; + register uch h = cs->hash; + register int i; + register cset *top = &p->g->sets[p->g->ncsets]; + register cset *cs2; register size_t css = (size_t) p->g->csetsize; /* look for an earlier one which is the same */ @@ -1273,9 +1274,9 @@ register cset *cs; static int /* character; there is no "none" value */ firstch(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register int i; + register int i; register size_t css = (size_t) p->g->csetsize; for (i = 0; i < css; i++) @@ -1292,11 +1293,11 @@ register cset *cs; static int nch(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { - register int i; + register int i; register size_t css = (size_t) p->g->csetsize; - register int n = 0; + register int n = 0; for (i = 0; i < css; i++) if (CHIN(cs, i)) @@ -1312,8 +1313,8 @@ register cset *cs; static void mcadd(p, cs, cp) register struct parse *p; -register cset *cs; -register char *cp; +register cset *cs; +register char *cp; { register size_t oldend = cs->smultis; @@ -1405,7 +1406,7 @@ register char *cp; static void mcinvert(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { assert(cs->multis == NULL); /* xxx */ } @@ -1420,7 +1421,7 @@ register cset *cs; static void mccase(p, cs) register struct parse *p; -register cset *cs; +register cset *cs; { assert(cs->multis == NULL); /* xxx */ } @@ -1432,11 +1433,11 @@ register cset *cs; static int /* predicate */ isinsets(g, c) register struct re_guts *g; -int c; +int c; { - register uch *col; - register int i; - register int ncols = (g->ncsets + (CHAR_BIT - 1)) / CHAR_BIT; + register uch *col; + register int i; + register int ncols = (g->ncsets + (CHAR_BIT - 1)) / CHAR_BIT; register unsigned uc = (unsigned char) c; for (i = 0, col = g->setbits; i < ncols; i++, col += g->csetsize) @@ -1452,12 +1453,12 @@ int c; static int /* predicate */ samesets(g, c1, c2) register struct re_guts *g; -int c1; -int c2; +int c1; +int c2; { - register uch *col; - register int i; - register int ncols = (g->ncsets + (CHAR_BIT - 1)) / CHAR_BIT; + register uch *col; + register int i; + register int ncols = (g->ncsets + (CHAR_BIT - 1)) / CHAR_BIT; register unsigned uc1 = (unsigned char) c1; register unsigned uc2 = (unsigned char) c2; @@ -1473,13 +1474,13 @@ int c2; */ static void categorize(p, g) -struct parse *p; +struct parse *p; register struct re_guts *g; { register cat_t *cats = g->categories; - register int c; - register int c2; - register cat_t cat; + register int c; + register int c2; + register cat_t cat; /* avoid making error situations worse */ if (p->error != 0) @@ -1500,14 +1501,14 @@ register struct re_guts *g; - dupl - emit a duplicate of a bunch of sops == static sopno dupl(register struct parse *p, sopno start, sopno finish); */ -static sopno /* start of duplicate */ +static sopno /* start of duplicate */ dupl(p, start, finish) register struct parse *p; -sopno start; /* from here */ -sopno finish; /* to this less one */ +sopno start; /* from here */ +sopno finish; /* to this less one */ { - register sopno ret = HERE(); - register sopno len = finish - start; + register sopno ret = HERE(); + register sopno len = finish - start; assert(finish >= start); if (len == 0) @@ -1531,8 +1532,8 @@ sopno finish; /* to this less one */ static void doemit(p, op, opnd) register struct parse *p; -sop op; -size_t opnd; +sop op; +size_t opnd; { /* avoid making error situations worse */ if (p->error != 0) @@ -1557,13 +1558,13 @@ size_t opnd; static void doinsert(p, op, opnd, pos) register struct parse *p; -sop op; -size_t opnd; -sopno pos; +sop op; +size_t opnd; +sopno pos; { - register sopno sn; - register sop s; - register int i; + register sopno sn; + register sop s; + register int i; /* avoid making error situations worse */ if (p->error != 0) @@ -1600,8 +1601,8 @@ sopno pos; static void dofwd(p, pos, value) register struct parse *p; -register sopno pos; -sop value; +register sopno pos; +sop value; { /* avoid making error situations worse */ if (p->error != 0) @@ -1618,9 +1619,9 @@ sop value; static void enlarge(p, size) register struct parse *p; -register sopno size; +register sopno size; { - register sop *sp; + register sop *sp; if (p->ssize >= size) return; @@ -1665,16 +1666,16 @@ register struct re_guts *g; */ static void findmust(p, g) -struct parse *p; +struct parse *p; register struct re_guts *g; { - register sop *scan; - sop *start = 0; - register sop *newstart = 0; - register sopno newlen; - register sop s; - register char *cp; - register sopno i; + register sop *scan; + sop *start = 0; + register sop *newstart = 0; + register sopno newlen; + register sop s; + register char *cp; + register sopno i; /* avoid making error situations worse */ if (p->error != 0) @@ -1688,39 +1689,39 @@ register struct re_guts *g; s = *scan++; switch (OP(s)) { - case OCHAR: /* sequence member */ - if (newlen == 0) /* new sequence */ - newstart = scan - 1; - newlen++; - break; - case OPLUS_: /* things that don't break one */ - case OLPAREN: - case ORPAREN: - break; - case OQUEST_: /* things that must be skipped */ - case OCH_: - scan--; - do - { - scan += OPND(s); - s = *scan; - /* assert() interferes w debug printouts */ - if (OP(s) != O_QUEST && OP(s) != O_CH && - OP(s) != OOR2) + case OCHAR: /* sequence member */ + if (newlen == 0)/* new sequence */ + newstart = scan - 1; + newlen++; + break; + case OPLUS_: /* things that don't break one */ + case OLPAREN: + case ORPAREN: + break; + case OQUEST_: /* things that must be skipped */ + case OCH_: + scan--; + do { - g->iflags |= BAD; - return; + scan += OPND(s); + s = *scan; + /* assert() interferes w debug printouts */ + if (OP(s) != O_QUEST && OP(s) != O_CH && + OP(s) != OOR2) + { + g->iflags |= BAD; + return; + } + } while (OP(s) != O_QUEST && OP(s) != O_CH); + /* fallthrough */ + default: /* things that break a sequence */ + if (newlen > g->mlen) + { /* ends one */ + start = newstart; + g->mlen = newlen; } - } while (OP(s) != O_QUEST && OP(s) != O_CH); - /* fallthrough */ - default: /* things that break a sequence */ - if (newlen > g->mlen) - { /* ends one */ - start = newstart; - g->mlen = newlen; - } - newlen = 0; - break; + newlen = 0; + break; } } while (OP(s) != OEND); @@ -1751,15 +1752,15 @@ register struct re_guts *g; - pluscount - count + nesting == static sopno pluscount(register struct parse *p, register struct re_guts *g); */ -static sopno /* nesting depth */ +static sopno /* nesting depth */ pluscount(p, g) -struct parse *p; +struct parse *p; register struct re_guts *g; { - register sop *scan; - register sop s; - register sopno plusnest = 0; - register sopno maxnest = 0; + register sop *scan; + register sop s; + register sopno plusnest = 0; + register sopno maxnest = 0; if (p->error != 0) return (0); /* there may not be an OEND */ @@ -1770,14 +1771,14 @@ register struct re_guts *g; s = *scan++; switch (OP(s)) { - case OPLUS_: - plusnest++; - break; - case O_PLUS: - if (plusnest > maxnest) - maxnest = plusnest; - plusnest--; - break; + case OPLUS_: + plusnest++; + break; + case O_PLUS: + if (plusnest > maxnest) + maxnest = plusnest; + plusnest--; + break; } } while (OP(s) != OEND); if (plusnest != 0) diff --git a/src/backend/regex/regerror.c b/src/backend/regex/regerror.c index 9e6e0e02179..d5f92559836 100644 --- a/src/backend/regex/regerror.c +++ b/src/backend/regex/regerror.c @@ -38,7 +38,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; +static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ @@ -55,12 +55,12 @@ static char sccsid[] = "@(#)regerror.c 8.4 (Berkeley) 3/20/94"; /* ========= begin header generated by ./mkh ========= */ #ifdef __cplusplus -extern "C" +extern "C" { #endif /* === regerror.c === */ - static char *regatoi(const regex_t * preg, char *localbuf); + static char *regatoi(const regex_t * preg, char *localbuf); #ifdef __cplusplus } @@ -89,10 +89,10 @@ extern "C" */ static struct rerr { - int code; - char *name; - char *explain; -} rerrs[] = + int code; + char *name; + char *explain; +} rerrs[] = { { @@ -155,16 +155,16 @@ static struct rerr /* ARGSUSED */ size_t pg95_regerror(errcode, preg, errbuf, errbuf_size) -int errcode; -const regex_t *preg; -char *errbuf; -size_t errbuf_size; +int errcode; +const regex_t *preg; +char *errbuf; +size_t errbuf_size; { register struct rerr *r; register size_t len; - register int target = errcode & ~REG_ITOA; - register char *s; - char convbuf[50]; + register int target = errcode & ~REG_ITOA; + register char *s; + char convbuf[50]; if (errcode == REG_ATOI) s = regatoi(preg, convbuf); @@ -206,10 +206,10 @@ size_t errbuf_size; - regatoi - internal routine to implement REG_ATOI == static char *regatoi(const regex_t *preg, char *localbuf); */ -static char * +static char * regatoi(preg, localbuf) -const regex_t *preg; -char *localbuf; +const regex_t *preg; +char *localbuf; { register struct rerr *r; diff --git a/src/backend/regex/regexec.c b/src/backend/regex/regexec.c index 5e0021f4299..224856afec0 100644 --- a/src/backend/regex/regexec.c +++ b/src/backend/regex/regexec.c @@ -38,7 +38,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; +static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ @@ -61,7 +61,7 @@ static char sccsid[] = "@(#)regexec.c 8.3 (Berkeley) 3/20/94"; #include <regex/utils.h> #include <regex/regex2.h> -static int nope = 0; /* for use in asserts; shuts lint up */ +static int nope = 0; /* for use in asserts; shuts lint up */ /* macros for manipulating states, small version */ #define states long @@ -156,11 +156,11 @@ static int nope = 0; /* for use in asserts; shuts lint up */ */ int /* 0 success, REG_NOMATCH failure */ pg95_regexec(preg, string, nmatch, pmatch, eflags) -const regex_t *preg; -const char *string; -size_t nmatch; -regmatch_t pmatch[]; -int eflags; +const regex_t *preg; +const char *string; +size_t nmatch; +regmatch_t pmatch[]; +int eflags; { register struct re_guts *g = preg->re_g; diff --git a/src/backend/regex/regfree.c b/src/backend/regex/regfree.c index 26ca8863ed6..15735fa663e 100644 --- a/src/backend/regex/regfree.c +++ b/src/backend/regex/regfree.c @@ -38,7 +38,7 @@ */ #if defined(LIBC_SCCS) && !defined(lint) -static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; +static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; #endif /* LIBC_SCCS and not lint */ @@ -56,7 +56,7 @@ static char sccsid[] = "@(#)regfree.c 8.3 (Berkeley) 3/20/94"; */ void pg95_regfree(preg) -regex_t *preg; +regex_t *preg; { register struct re_guts *g; diff --git a/src/backend/rewrite/locks.c b/src/backend/rewrite/locks.c index 213fae9b321..6a62e8ddee3 100644 --- a/src/backend/rewrite/locks.c +++ b/src/backend/rewrite/locks.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.3 1997/09/07 04:48:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/Attic/locks.c,v 1.4 1997/09/08 02:28:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,52 +26,52 @@ * if we find at least one such match, we return true * otherwise, we return false */ -static bool +static bool nodeThisLockWasTriggered(Node * node, int varno, AttrNumber attnum) { if (node == NULL) return FALSE; switch (nodeTag(node)) { - case T_Var: - { - Var *var = (Var *) node; - - if (varno == var->varno && - (attnum == var->varattno || attnum == -1)) - return TRUE; - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; + case T_Var: + { + Var *var = (Var *) node; - return - nodeThisLockWasTriggered((Node *) expr->args, varno, attnum); - } - break; - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; + if (varno == var->varno && + (attnum == var->varattno || attnum == -1)) + return TRUE; + } + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - return - nodeThisLockWasTriggered(tle->expr, varno, attnum); - } - break; - case T_List: - { - List *l; + return + nodeThisLockWasTriggered((Node *) expr->args, varno, attnum); + } + break; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - foreach(l, (List *) node) + return + nodeThisLockWasTriggered(tle->expr, varno, attnum); + } + break; + case T_List: { - if (nodeThisLockWasTriggered(lfirst(l), varno, attnum)) - return TRUE; + List *l; + + foreach(l, (List *) node) + { + if (nodeThisLockWasTriggered(lfirst(l), varno, attnum)) + return TRUE; + } + return FALSE; } - return FALSE; - } - break; - default: - break; + break; + default: + break; } return (FALSE); } @@ -82,7 +82,7 @@ nodeThisLockWasTriggered(Node * node, int varno, AttrNumber attnum) * against the attnum if we find at least one such match, we return true * otherwise, we return false */ -static bool +static bool thisLockWasTriggered(int varno, AttrNumber attnum, Query * parsetree) @@ -97,15 +97,15 @@ thisLockWasTriggered(int varno, * matchLocks - * match the list of locks and returns the matching rules */ -List * +List * matchLocks(CmdType event, RuleLock * rulelocks, int varno, Query * parsetree) { - List *real_locks = NIL; - int nlocks; - int i; + List *real_locks = NIL; + int nlocks; + int i; Assert(rulelocks != NULL); /* we get called iff there is some lock */ Assert(parsetree != NULL); @@ -122,7 +122,7 @@ matchLocks(CmdType event, for (i = 0; i < nlocks; i++) { - RewriteRule *oneLock = rulelocks->rules[i]; + RewriteRule *oneLock = rulelocks->rules[i]; if (oneLock->event == event) { diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index 01b05c4cd0e..c849d7edab9 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.4 1997/09/07 04:48:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.5 1997/09/08 02:28:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ #include "rewrite/rewriteSupport.h" #include "tcop/tcopprot.h" -Oid LastOidProcessed = InvalidOid; +Oid LastOidProcessed = InvalidOid; /* * This is too small for many rule plans, but it'll have to do for now. @@ -43,8 +43,8 @@ Oid LastOidProcessed = InvalidOid; static void strcpyq(char *dest, char *source) { - char *current = source, - *destp = dest; + char *current = source, + *destp = dest; for (current = source; *current; current++) { @@ -75,7 +75,7 @@ strcpyq(char *dest, char *source) * evinstead - is an instead rule * actiontree - parsetree(s) of rule action */ -static Oid +static Oid InsertRule(char *rulname, int evtype, char *evobj, @@ -84,15 +84,15 @@ InsertRule(char *rulname, bool evinstead, char *actiontree) { - static char rulebuf[RULE_PLAN_SIZE]; - static char actionbuf[RULE_PLAN_SIZE]; - static char qualbuf[RULE_PLAN_SIZE]; - Oid eventrel_oid = InvalidOid; - AttrNumber evslot_index = InvalidAttrNumber; - Relation eventrel = NULL; - char *is_instead = "f"; - extern void eval_as_new_xact(); - char *template; + static char rulebuf[RULE_PLAN_SIZE]; + static char actionbuf[RULE_PLAN_SIZE]; + static char qualbuf[RULE_PLAN_SIZE]; + Oid eventrel_oid = InvalidOid; + AttrNumber evslot_index = InvalidAttrNumber; + Relation eventrel = NULL; + char *is_instead = "f"; + extern void eval_as_new_xact(); + char *template; eventrel = heap_openr(evobj); if (eventrel == NULL) @@ -172,7 +172,7 @@ ValidateRule(int event_type, */ if (is_instead && !*action && eslot_string && event_type == CMD_SELECT) { - char *temp_buffer = (char *) palloc(strlen(template) + 80); + char *temp_buffer = (char *) palloc(strlen(template) + 80); sprintf(temp_buffer, template, event_attype, get_typlen(event_attype), eslot_string, @@ -188,19 +188,19 @@ ValidateRule(int event_type, void DefineQueryRewrite(RuleStmt * stmt) { - CmdType event_type = stmt->event; - Attr *event_obj = stmt->object; - Node *event_qual = stmt->whereClause; - bool is_instead = stmt->instead; - List *action = stmt->actions; - Relation event_relation = NULL; - Oid ruleId; - Oid ev_relid = 0; - char *eslot_string = NULL; - int event_attno = 0; - Oid event_attype = 0; - char *actionP, - *event_qualP; + CmdType event_type = stmt->event; + Attr *event_obj = stmt->object; + Node *event_qual = stmt->whereClause; + bool is_instead = stmt->instead; + List *action = stmt->actions; + Relation event_relation = NULL; + Oid ruleId; + Oid ev_relid = 0; + char *eslot_string = NULL; + int event_attno = 0; + Oid event_attype = 0; + char *actionP, + *event_qualP; if (event_obj->attrs) eslot_string = strVal(lfirst(event_obj->attrs)); diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index 980956a4807..af15f6b7171 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.4 1997/09/07 04:48:07 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.5 1997/09/08 02:28:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,10 +32,10 @@ static void ApplyRetrieveRule(Query * parsetree, RewriteRule * rule, int rt_index, int relation_level, int *modified); -static List * +static List * fireRules(Query * parsetree, int rt_index, CmdType event, bool * instead_flag, List * locks, List ** qual_products); -static List *deepRewriteQuery(Query * parsetree); +static List *deepRewriteQuery(Query * parsetree); /* * gatherRewriteMeta - @@ -51,9 +51,9 @@ gatherRewriteMeta(Query * parsetree, CmdType event, bool * instead_flag) { - RewriteInfo *info; - int rt_length; - int result_reln; + RewriteInfo *info; + int rt_length; + int result_reln; info = (RewriteInfo *) palloc(sizeof(RewriteInfo)); info->rt_index = rt_index; @@ -90,18 +90,18 @@ gatherRewriteMeta(Query * parsetree, */ if (info->action != CMD_SELECT) { /* i.e update XXXXX */ - int new_result_reln = 0; + int new_result_reln = 0; result_reln = info->rule_action->resultRelation; switch (result_reln) { - case PRS2_CURRENT_VARNO: - new_result_reln = rt_index; - break; - case PRS2_NEW_VARNO: /* XXX */ - default: - new_result_reln = result_reln + rt_length; - break; + case PRS2_CURRENT_VARNO: + new_result_reln = rt_index; + break; + case PRS2_NEW_VARNO: /* XXX */ + default: + new_result_reln = result_reln + rt_length; + break; } info->rule_action->resultRelation = new_result_reln; } @@ -109,16 +109,16 @@ gatherRewriteMeta(Query * parsetree, return info; } -static List * +static List * OptimizeRIRRules(List * locks) { - List *attr_level = NIL, - *i; - List *relation_level = NIL; + List *attr_level = NIL, + *i; + List *relation_level = NIL; foreach(i, locks) { - RewriteRule *rule_lock = lfirst(i); + RewriteRule *rule_lock = lfirst(i); if (rule_lock->attrno == -1) relation_level = lappend(relation_level, rule_lock); @@ -132,16 +132,16 @@ OptimizeRIRRules(List * locks) * idea is to put instead rules before regular rules so that * excess semantically queasy queries aren't processed */ -static List * +static List * orderRules(List * locks) { - List *regular = NIL, - *i; - List *instead_rules = NIL; + List *regular = NIL, + *i; + List *instead_rules = NIL; foreach(i, locks) { - RewriteRule *rule_lock = (RewriteRule *) lfirst(i); + RewriteRule *rule_lock = (RewriteRule *) lfirst(i); if (rule_lock->isInstead) instead_rules = lappend(instead_rules, rule_lock); @@ -154,11 +154,11 @@ orderRules(List * locks) static int AllRetrieve(List * actions) { - List *n; + List *n; foreach(n, actions) { - Query *pt = lfirst(n); + Query *pt = lfirst(n); /* * in the old postgres code, we check whether command_type is a @@ -171,17 +171,17 @@ AllRetrieve(List * actions) return true; } -static List * +static List * FireRetrieveRulesAtQuery(Query * parsetree, int rt_index, Relation relation, bool * instead_flag, int rule_flag) { - List *i, - *locks; - RuleLock *rt_entry_locks = NULL; - List *work = NIL; + List *i, + *locks; + RuleLock *rt_entry_locks = NULL; + List *work = NIL; if ((rt_entry_locks = relation->rd_rules) == NULL) return NIL; @@ -191,7 +191,7 @@ FireRetrieveRulesAtQuery(Query * parsetree, /* find all retrieve instead */ foreach(i, locks) { - RewriteRule *rule_lock = (RewriteRule *) lfirst(i); + RewriteRule *rule_lock = (RewriteRule *) lfirst(i); if (!rule_lock->isInstead) continue; @@ -202,9 +202,9 @@ FireRetrieveRulesAtQuery(Query * parsetree, work = OptimizeRIRRules(locks); foreach(i, work) { - RewriteRule *rule_lock = lfirst(i); - int relation_level; - int modified = FALSE; + RewriteRule *rule_lock = lfirst(i); + int relation_level; + int modified = FALSE; relation_level = (rule_lock->attrno == -1); if (rule_lock->actions == NIL) @@ -248,13 +248,13 @@ ApplyRetrieveRule(Query * parsetree, int relation_level, int *modified) { - Query *rule_action = NULL; - Node *rule_qual; - List *rtable, - *rt; - int nothing, - rt_length; - int badsql = FALSE; + Query *rule_action = NULL; + Node *rule_qual; + List *rtable, + *rt; + int nothing, + rt_length; + int badsql = FALSE; rule_qual = rule->qual; if (rule->actions) @@ -274,7 +274,7 @@ ApplyRetrieveRule(Query * parsetree, rtable = copyObject(parsetree->rtable); foreach(rt, rtable) { - RangeTblEntry *rte = lfirst(rt); + RangeTblEntry *rte = lfirst(rt); /* * this is to prevent add_missing_vars_to_base_rels() from adding @@ -309,21 +309,21 @@ ApplyRetrieveRule(Query * parsetree, AddQual(parsetree, rule_action->qual); } -static List * +static List * ProcessRetrieveQuery(Query * parsetree, List * rtable, bool * instead_flag, bool rule) { - List *rt; - List *product_queries = NIL; - int rt_index = 0; + List *rt; + List *product_queries = NIL; + int rt_index = 0; foreach(rt, rtable) { - RangeTblEntry *rt_entry = lfirst(rt); - Relation rt_entry_relation = NULL; - List *result = NIL; + RangeTblEntry *rt_entry = lfirst(rt); + Relation rt_entry_relation = NULL; + List *result = NIL; rt_index++; rt_entry_relation = heap_openr(rt_entry->relname); @@ -346,12 +346,12 @@ ProcessRetrieveQuery(Query * parsetree, foreach(rt, rtable) { - RangeTblEntry *rt_entry = lfirst(rt); - Relation rt_entry_relation = NULL; - RuleLock *rt_entry_locks = NULL; - List *result = NIL; - List *locks = NIL; - List *dummy_products; + RangeTblEntry *rt_entry = lfirst(rt); + Relation rt_entry_relation = NULL; + RuleLock *rt_entry_locks = NULL; + List *result = NIL; + List *locks = NIL; + List *dummy_products; rt_index++; rt_entry_relation = heap_openr(rt_entry->relname); @@ -376,16 +376,16 @@ ProcessRetrieveQuery(Query * parsetree, return product_queries; } -static Query * +static Query * CopyAndAddQual(Query * parsetree, List * actions, Node * rule_qual, int rt_index, CmdType event) { - Query *new_tree = (Query *) copyObject(parsetree); - Node *new_qual = NULL; - Query *rule_action = NULL; + Query *new_tree = (Query *) copyObject(parsetree); + Node *new_qual = NULL; + Query *rule_action = NULL; if (actions) rule_action = lfirst(actions); @@ -393,8 +393,8 @@ CopyAndAddQual(Query * parsetree, new_qual = (Node *) copyObject(rule_qual); if (rule_action != NULL) { - List *rtable; - int rt_length; + List *rtable; + int rt_length; rtable = new_tree->rtable; rt_length = length(rtable); @@ -418,7 +418,7 @@ CopyAndAddQual(Query * parsetree, * sensible semantics. remember: reality is for dead birds -- glass * */ -static List * +static List * fireRules(Query * parsetree, int rt_index, CmdType event, @@ -426,9 +426,9 @@ fireRules(Query * parsetree, List * locks, List ** qual_products) { - RewriteInfo *info; - List *results = NIL; - List *i; + RewriteInfo *info; + List *results = NIL; + List *i; /* choose rule to fire from list of rules */ if (locks == NIL) @@ -445,12 +445,12 @@ fireRules(Query * parsetree, locks = orderRules(locks); /* instead rules first */ foreach(i, locks) { - RewriteRule *rule_lock = (RewriteRule *) lfirst(i); - Node *qual, - *event_qual; - List *actions; - List *r; - bool orig_instead_flag = *instead_flag; + RewriteRule *rule_lock = (RewriteRule *) lfirst(i); + Node *qual, + *event_qual; + List *actions; + List *r; + bool orig_instead_flag = *instead_flag; /* multiple rule action time */ *instead_flag = rule_lock->isInstead; @@ -463,8 +463,8 @@ fireRules(Query * parsetree, rt_index, event)); foreach(r, actions) { - Query *rule_action = lfirst(r); - Node *rule_qual = copyObject(event_qual); + Query *rule_action = lfirst(r); + Node *rule_qual = copyObject(event_qual); /*-------------------------------------------------- * Step 1: @@ -535,12 +535,12 @@ fireRules(Query * parsetree, return results; } -static List * +static List * RewriteQuery(Query * parsetree, bool * instead_flag, List ** qual_products) { - CmdType event; - List *product_queries = NIL; - int result_relation = 0; + CmdType event; + List *product_queries = NIL; + int result_relation = 0; Assert(parsetree != NULL); @@ -565,9 +565,9 @@ RewriteQuery(Query * parsetree, bool * instead_flag, List ** qual_products) /* * the statement is an update, insert or delete */ - RangeTblEntry *rt_entry; - Relation rt_entry_relation = NULL; - RuleLock *rt_entry_locks = NULL; + RangeTblEntry *rt_entry; + Relation rt_entry_relation = NULL; + RuleLock *rt_entry_locks = NULL; rt_entry = rt_fetch(result_relation, parsetree->rtable); rt_entry_relation = heap_openr(rt_entry->relname); @@ -576,7 +576,7 @@ RewriteQuery(Query * parsetree, bool * instead_flag, List ** qual_products) if (rt_entry_locks != NULL) { - List *locks = + List *locks = matchLocks(event, rt_entry_locks, result_relation, parsetree); product_queries = @@ -595,7 +595,7 @@ RewriteQuery(Query * parsetree, bool * instead_flag, List ** qual_products) /* * the statement is a select */ - Query *other; + Query *other; other = copyObject(parsetree); /* ApplyRetrieveRule changes the * range table */ @@ -613,14 +613,14 @@ RewriteQuery(Query * parsetree, bool * instead_flag, List ** qual_products) #define REWRITE_INVOKE_MAX 10 #endif -static int numQueryRewriteInvoked = 0; +static int numQueryRewriteInvoked = 0; /* * QueryRewrite - * rewrite one query via QueryRewrite system, possibly returning 0, or many * queries */ -List * +List * QueryRewrite(Query * parsetree) { numQueryRewriteInvoked = 0; @@ -635,14 +635,14 @@ QueryRewrite(Query * parsetree) * deepRewriteQuery - * rewrites the query and apply the rules again on the queries rewritten */ -static List * +static List * deepRewriteQuery(Query * parsetree) { - List *n; - List *rewritten = NIL; - List *result = NIL; - bool instead; - List *qual_products = NIL; + List *n; + List *rewritten = NIL; + List *result = NIL; + bool instead; + List *qual_products = NIL; if (++numQueryRewriteInvoked > REWRITE_INVOKE_MAX) { @@ -657,8 +657,8 @@ deepRewriteQuery(Query * parsetree) foreach(n, result) { - Query *pt = lfirst(n); - List *newstuff = NIL; + Query *pt = lfirst(n); + List *newstuff = NIL; newstuff = deepRewriteQuery(pt); if (newstuff != NIL) diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index b8b39b33281..8e6b7a21ba4 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.5 1997/09/07 04:48:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.6 1997/09/08 02:28:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,7 +28,7 @@ #include "nodes/plannodes.h" #include "optimizer/clauses.h" -static void ResolveNew(RewriteInfo * info, List * targetlist, Node ** node); +static void ResolveNew(RewriteInfo * info, List * targetlist, Node ** node); @@ -39,41 +39,41 @@ OffsetVarNodes(Node * node, int offset) return; switch (nodeTag(node)) { - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; - - OffsetVarNodes(tle->expr, offset); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - OffsetVarNodes((Node *) expr->args, offset); - } - break; - case T_Var: - { - Var *var = (Var *) node; + OffsetVarNodes(tle->expr, offset); + } + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - var->varno += offset; - var->varnoold += offset; - } - break; - case T_List: - { - List *l; + OffsetVarNodes((Node *) expr->args, offset); + } + break; + case T_Var: + { + Var *var = (Var *) node; - foreach(l, (List *) node) + var->varno += offset; + var->varnoold += offset; + } + break; + case T_List: { - OffsetVarNodes(lfirst(l), offset); + List *l; + + foreach(l, (List *) node) + { + OffsetVarNodes(lfirst(l), offset); + } } - } - break; - default: - /* ignore the others */ - break; + break; + default: + /* ignore the others */ + break; } } @@ -84,52 +84,52 @@ ChangeVarNodes(Node * node, int old_varno, int new_varno) return; switch (nodeTag(node)) { - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; - - ChangeVarNodes(tle->expr, old_varno, new_varno); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; - - ChangeVarNodes((Node *) expr->args, old_varno, new_varno); - } - break; - case T_Var: - { - Var *var = (Var *) node; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - if (var->varno == old_varno) + ChangeVarNodes(tle->expr, old_varno, new_varno); + } + break; + case T_Expr: { - var->varno = new_varno; - var->varnoold = new_varno; + Expr *expr = (Expr *) node; + + ChangeVarNodes((Node *) expr->args, old_varno, new_varno); } - } - break; - case T_List: - { - List *l; + break; + case T_Var: + { + Var *var = (Var *) node; - foreach(l, (List *) node) + if (var->varno == old_varno) + { + var->varno = new_varno; + var->varnoold = new_varno; + } + } + break; + case T_List: { - ChangeVarNodes(lfirst(l), old_varno, new_varno); + List *l; + + foreach(l, (List *) node) + { + ChangeVarNodes(lfirst(l), old_varno, new_varno); + } } - } - break; - default: - /* ignore the others */ - break; + break; + default: + /* ignore the others */ + break; } } void AddQual(Query * parsetree, Node * qual) { - Node *copy, - *old; + Node *copy, + *old; if (qual == NULL) return; @@ -146,7 +146,7 @@ AddQual(Query * parsetree, Node * qual) void AddNotQual(Query * parsetree, Node * qual) { - Node *copy; + Node *copy; if (qual == NULL) return; @@ -156,10 +156,10 @@ AddNotQual(Query * parsetree, Node * qual) AddQual(parsetree, copy); } -static Node * +static Node * make_null(Oid type) { - Const *c = makeNode(Const); + Const *c = makeNode(Const); c->consttype = type; c->constlen = get_typlen(type); @@ -172,15 +172,15 @@ make_null(Oid type) void FixResdomTypes(List * tlist) { - List *i; + List *i; foreach(i, tlist) { - TargetEntry *tle = lfirst(i); + TargetEntry *tle = lfirst(i); if (nodeTag(tle->expr) == T_Var) { - Var *var = (Var *) tle->expr; + Var *var = (Var *) tle->expr; tle->resdom->restype = var->vartype; tle->resdom->reslen = get_typlen(var->vartype); @@ -188,14 +188,14 @@ FixResdomTypes(List * tlist) } } -static Node * +static Node * FindMatchingNew(List * tlist, int attno) { - List *i; + List *i; foreach(i, tlist) { - TargetEntry *tle = lfirst(i); + TargetEntry *tle = lfirst(i); if (tle->resdom->resno == attno) { @@ -205,15 +205,15 @@ FindMatchingNew(List * tlist, int attno) return NULL; } -static Node * +static Node * FindMatchingTLEntry(List * tlist, char *e_attname) { - List *i; + List *i; foreach(i, tlist) { - TargetEntry *tle = lfirst(i); - char *resname; + TargetEntry *tle = lfirst(i); + char *resname; resname = tle->resdom->resname; if (!strcmp(e_attname, resname)) @@ -225,60 +225,60 @@ FindMatchingTLEntry(List * tlist, char *e_attname) static void ResolveNew(RewriteInfo * info, List * targetlist, Node ** nodePtr) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; switch (nodeTag(node)) { - case T_TargetEntry: - ResolveNew(info, targetlist, &((TargetEntry *) node)->expr); - break; - case T_Expr: - ResolveNew(info, targetlist, (Node **) (&(((Expr *) node)->args))); - break; - case T_Var: - { - int this_varno = (int) ((Var *) node)->varno; - Node *n; - - if (this_varno == info->new_varno) + case T_TargetEntry: + ResolveNew(info, targetlist, &((TargetEntry *) node)->expr); + break; + case T_Expr: + ResolveNew(info, targetlist, (Node **) (&(((Expr *) node)->args))); + break; + case T_Var: { - n = FindMatchingNew(targetlist, - ((Var *) node)->varattno); - if (n == NULL) + int this_varno = (int) ((Var *) node)->varno; + Node *n; + + if (this_varno == info->new_varno) { - if (info->event == CMD_UPDATE) + n = FindMatchingNew(targetlist, + ((Var *) node)->varattno); + if (n == NULL) { - ((Var *) node)->varno = info->current_varno; - ((Var *) node)->varnoold = info->current_varno; + if (info->event == CMD_UPDATE) + { + ((Var *) node)->varno = info->current_varno; + ((Var *) node)->varnoold = info->current_varno; + } + else + { + *nodePtr = make_null(((Var *) node)->vartype); + } } else { - *nodePtr = make_null(((Var *) node)->vartype); + *nodePtr = n; } } - else - { - *nodePtr = n; - } + break; } - break; - } - case T_List: - { - List *l; - - foreach(l, (List *) node) + case T_List: { - ResolveNew(info, targetlist, (Node **) & (lfirst(l))); + List *l; + + foreach(l, (List *) node) + { + ResolveNew(info, targetlist, (Node **) & (lfirst(l))); + } + break; } + default: + /* ignore the others */ break; - } - default: - /* ignore the others */ - break; } } @@ -299,86 +299,86 @@ nodeHandleRIRAttributeRule(Node ** nodePtr, int *modified, int *badsql) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; switch (nodeTag(node)) { - case T_List: - { - List *i; - - foreach(i, (List *) node) + case T_List: { - nodeHandleRIRAttributeRule((Node **) (&(lfirst(i))), rtable, - targetlist, rt_index, attr_num, - modified, badsql); + List *i; + + foreach(i, (List *) node) + { + nodeHandleRIRAttributeRule((Node **) (&(lfirst(i))), rtable, + targetlist, rt_index, attr_num, + modified, badsql); + } } - } - break; - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; + break; + case T_TargetEntry: + { + TargetEntry *tle = (TargetEntry *) node; - nodeHandleRIRAttributeRule(&tle->expr, rtable, targetlist, + nodeHandleRIRAttributeRule(&tle->expr, rtable, targetlist, rt_index, attr_num, modified, badsql); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; - - nodeHandleRIRAttributeRule((Node **) (&(expr->args)), rtable, - targetlist, rt_index, attr_num, - modified, badsql); - } - break; - case T_Var: - { - int this_varno = (int) ((Var *) node)->varno; - NameData name_to_look_for; - - memset(name_to_look_for.data, 0, NAMEDATALEN); - - if (this_varno == rt_index && - ((Var *) node)->varattno == attr_num) + } + break; + case T_Expr: { - if (((Var *) node)->vartype == 32) - { /* HACK */ - *nodePtr = make_null(((Var *) node)->vartype); - *modified = TRUE; - *badsql = TRUE; - break; - } - else - { - namestrcpy(&name_to_look_for, - (char *) get_attname(getrelid(this_varno, - rtable), - attr_num)); - } + Expr *expr = (Expr *) node; + + nodeHandleRIRAttributeRule((Node **) (&(expr->args)), rtable, + targetlist, rt_index, attr_num, + modified, badsql); } - if (name_to_look_for.data[0]) + break; + case T_Var: { - Node *n; + int this_varno = (int) ((Var *) node)->varno; + NameData name_to_look_for; - n = FindMatchingTLEntry(targetlist, (char *) &name_to_look_for); - if (n == NULL) + memset(name_to_look_for.data, 0, NAMEDATALEN); + + if (this_varno == rt_index && + ((Var *) node)->varattno == attr_num) { - *nodePtr = make_null(((Var *) node)->vartype); + if (((Var *) node)->vartype == 32) + { /* HACK */ + *nodePtr = make_null(((Var *) node)->vartype); + *modified = TRUE; + *badsql = TRUE; + break; + } + else + { + namestrcpy(&name_to_look_for, + (char *) get_attname(getrelid(this_varno, + rtable), + attr_num)); + } } - else + if (name_to_look_for.data[0]) { - *nodePtr = n; + Node *n; + + n = FindMatchingTLEntry(targetlist, (char *) &name_to_look_for); + if (n == NULL) + { + *nodePtr = make_null(((Var *) node)->vartype); + } + else + { + *nodePtr = n; + } + *modified = TRUE; } - *modified = TRUE; } - } - break; - default: - /* ignore the others */ - break; + break; + default: + /* ignore the others */ + break; } } @@ -410,69 +410,69 @@ nodeHandleViewRule(Node ** nodePtr, int rt_index, int *modified) { - Node *node = *nodePtr; + Node *node = *nodePtr; if (node == NULL) return; switch (nodeTag(node)) { - case T_List: - { - List *l; + case T_List: + { + List *l; - foreach(l, (List *) node) + foreach(l, (List *) node) + { + nodeHandleViewRule((Node **) (&(lfirst(l))), + rtable, targetlist, + rt_index, modified); + } + } + break; + case T_TargetEntry: { - nodeHandleViewRule((Node **) (&(lfirst(l))), - rtable, targetlist, + TargetEntry *tle = (TargetEntry *) node; + + nodeHandleViewRule(&(tle->expr), rtable, targetlist, rt_index, modified); } - } - break; - case T_TargetEntry: - { - TargetEntry *tle = (TargetEntry *) node; - - nodeHandleViewRule(&(tle->expr), rtable, targetlist, - rt_index, modified); - } - break; - case T_Expr: - { - Expr *expr = (Expr *) node; - - nodeHandleViewRule((Node **) (&(expr->args)), - rtable, targetlist, - rt_index, modified); - } - break; - case T_Var: - { - Var *var = (Var *) node; - int this_varno = var->varno; - Node *n; + break; + case T_Expr: + { + Expr *expr = (Expr *) node; - if (this_varno == rt_index) + nodeHandleViewRule((Node **) (&(expr->args)), + rtable, targetlist, + rt_index, modified); + } + break; + case T_Var: { - n = FindMatchingTLEntry(targetlist, - get_attname(getrelid(this_varno, - rtable), - var->varattno)); - if (n == NULL) - { - *nodePtr = make_null(((Var *) node)->vartype); - } - else + Var *var = (Var *) node; + int this_varno = var->varno; + Node *n; + + if (this_varno == rt_index) { - *nodePtr = n; + n = FindMatchingTLEntry(targetlist, + get_attname(getrelid(this_varno, + rtable), + var->varattno)); + if (n == NULL) + { + *nodePtr = make_null(((Var *) node)->vartype); + } + else + { + *nodePtr = n; + } + *modified = TRUE; } - *modified = TRUE; + break; } + default: + /* ignore the others */ break; - } - default: - /* ignore the others */ - break; } } diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index 58ccc5865b0..0955acf6fd6 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.3 1997/09/07 04:48:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.4 1997/09/08 02:28:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,11 +31,11 @@ * RewriteGetRuleEventRel *----------------------------------------------------------------------- */ -char * +char * RewriteGetRuleEventRel(char *rulename) { - HeapTuple htp; - Oid eventrel; + HeapTuple htp; + Oid eventrel; htp = SearchSysCacheTuple(REWRITENAME, PointerGetDatum(rulename), 0, 0, 0); @@ -69,15 +69,15 @@ RewriteGetRuleEventRel(char *rulename) void RemoveRewriteRule(char *ruleName) { - Relation RewriteRelation = NULL; - HeapScanDesc scanDesc = NULL; - ScanKeyData scanKeyData; - HeapTuple tuple = NULL; - Oid ruleId = (Oid) 0; - Oid eventRelationOid = (Oid) NULL; - Datum eventRelationOidDatum = (Datum) NULL; - Buffer buffer = (Buffer) NULL; - bool isNull = false; + Relation RewriteRelation = NULL; + HeapScanDesc scanDesc = NULL; + ScanKeyData scanKeyData; + HeapTuple tuple = NULL; + Oid ruleId = (Oid) 0; + Oid eventRelationOid = (Oid) NULL; + Datum eventRelationOidDatum = (Datum) NULL; + Buffer buffer = (Buffer) NULL; + bool isNull = false; /* * Open the pg_rewrite relation. @@ -145,10 +145,10 @@ RemoveRewriteRule(char *ruleName) void RelationRemoveRules(Oid relid) { - Relation RewriteRelation = NULL; - HeapScanDesc scanDesc = NULL; - ScanKeyData scanKeyData; - HeapTuple tuple = NULL; + Relation RewriteRelation = NULL; + HeapScanDesc scanDesc = NULL; + ScanKeyData scanKeyData; + HeapTuple tuple = NULL; /* * Open the pg_rewrite relation. diff --git a/src/backend/rewrite/rewriteSupport.c b/src/backend/rewrite/rewriteSupport.c index 8d3beb1c10f..b9059e9dca0 100644 --- a/src/backend/rewrite/rewriteSupport.c +++ b/src/backend/rewrite/rewriteSupport.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.7 1997/09/07 04:48:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteSupport.c,v 1.8 1997/09/08 02:28:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,18 +37,18 @@ * list of parsetrees for the rule (in parseTrees) */ #ifdef NOT_USED -static Node * +static Node * RuleIdGetActionInfo(Oid ruleoid, bool * instead_flag, Query ** parseTrees) { - HeapTuple ruletuple; - char *ruleaction = NULL; - bool action_is_null = false; - bool instead_is_null = false; - Relation ruleRelation = NULL; - TupleDesc ruleTupdesc = NULL; - Query *ruleparse = NULL; - char *rule_evqual_string = NULL; - Node *rule_evqual = NULL; + HeapTuple ruletuple; + char *ruleaction = NULL; + bool action_is_null = false; + bool instead_is_null = false; + Relation ruleRelation = NULL; + TupleDesc ruleTupdesc = NULL; + Query *ruleparse = NULL; + char *rule_evqual_string = NULL; + Node *rule_evqual = NULL; ruleRelation = heap_openr(RewriteRelationName); ruleTupdesc = RelationGetTupleDescriptor(ruleRelation); @@ -92,10 +92,10 @@ RuleIdGetActionInfo(Oid ruleoid, bool * instead_flag, Query ** parseTrees) int IsDefinedRewriteRule(char *ruleName) { - Relation RewriteRelation = NULL; - HeapScanDesc scanDesc = NULL; - ScanKeyData scanKey; - HeapTuple tuple = NULL; + Relation RewriteRelation = NULL; + HeapScanDesc scanDesc = NULL; + ScanKeyData scanKey; + HeapTuple tuple = NULL; /* @@ -124,11 +124,11 @@ IsDefinedRewriteRule(char *ruleName) static void setRelhasrulesInRelation(Oid relationId, bool relhasrules) { - Relation relationRelation; - HeapTuple tuple; - HeapTuple newTuple; - Relation idescs[Num_pg_class_indices]; - Form_pg_class relp; + Relation relationRelation; + HeapTuple tuple; + HeapTuple newTuple; + Relation idescs[Num_pg_class_indices]; + Form_pg_class relp; /* * Lock a relation given its Oid. Go to the RelationRelation (i.e. @@ -172,10 +172,10 @@ prs2_addToRelation(Oid relid, Node * qual, List * actions) { - Relation relation; - RewriteRule *thisRule; - RuleLock *rulelock; - MemoryContext oldcxt; + Relation relation; + RewriteRule *thisRule; + RuleLock *rulelock; + MemoryContext oldcxt; /* * create an in memory RewriteRule data structure which is cached by @@ -217,7 +217,7 @@ prs2_addToRelation(Oid relid, } else { - int numlock; + int numlock; rulelock = relation->rd_rules; numlock = rulelock->numLocks; @@ -239,11 +239,11 @@ prs2_addToRelation(Oid relid, void prs2_deleteFromRelation(Oid relid, Oid ruleId) { - RuleLock *rulelock; - Relation relation; - int numlock; - int i; - MemoryContext oldcxt; + RuleLock *rulelock; + Relation relation; + int numlock; + int i; + MemoryContext oldcxt; relation = heap_open(relid); rulelock = relation->rd_rules; diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 4ce064d6713..a0f45eca094 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.11 1997/09/07 04:48:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.12 1997/09/08 02:28:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,33 +43,33 @@ * deallocations in a circular buffer in shared memory. */ #ifdef BMTRACE -bmtrace *TraceBuf; -long *CurTraceBuf; +bmtrace *TraceBuf; +long *CurTraceBuf; #define BMT_LIMIT 200 #endif /* BMTRACE */ -int ShowPinTrace = 0; +int ShowPinTrace = 0; -int NBuffers = NDBUFS; /* NDBUFS defined in miscadmin.h */ -int Data_Descriptors; -int Free_List_Descriptor; -int Lookup_List_Descriptor; -int Num_Descriptors; +int NBuffers = NDBUFS; /* NDBUFS defined in miscadmin.h */ +int Data_Descriptors; +int Free_List_Descriptor; +int Lookup_List_Descriptor; +int Num_Descriptors; -BufferDesc *BufferDescriptors; -BufferBlock BufferBlocks; +BufferDesc *BufferDescriptors; +BufferBlock BufferBlocks; #ifndef HAS_TEST_AND_SET -long *NWaitIOBackendP; +long *NWaitIOBackendP; #endif extern IpcSemaphoreId WaitIOSemId; -long *PrivateRefCount;/* also used in freelist.c */ -long *LastRefCount; /* refcounts of last ExecMain level */ -long *CommitInfoNeedsSave; /* to write buffers where we have - * filled in */ +long *PrivateRefCount; /* also used in freelist.c */ +long *LastRefCount; /* refcounts of last ExecMain level */ +long *CommitInfoNeedsSave;/* to write buffers where we have filled + * in */ /* t_tmin (or t_tmax) */ @@ -124,14 +124,14 @@ long *CommitInfoNeedsSave; /* to write buffers where we have * */ -SPINLOCK BufMgrLock; +SPINLOCK BufMgrLock; -long int ReadBufferCount; -long int ReadLocalBufferCount; -long int BufferHitCount; -long int LocalBufferHitCount; -long int BufferFlushCount; -long int LocalBufferFlushCount; +long int ReadBufferCount; +long int ReadLocalBufferCount; +long int BufferHitCount; +long int LocalBufferHitCount; +long int BufferFlushCount; +long int LocalBufferFlushCount; /* @@ -143,9 +143,9 @@ long int LocalBufferFlushCount; void InitBufferPool(IPCKey key) { - bool foundBufs, - foundDescs; - int i; + bool foundBufs, + foundDescs; + int i; /* check padding of BufferDesc and BufferHdr */ @@ -189,7 +189,7 @@ InitBufferPool(IPCKey key) #ifndef HAS_TEST_AND_SET { - bool foundNWaitIO; + bool foundNWaitIO; NWaitIOBackendP = (long *) ShmemInitStruct("#Backends Waiting IO", sizeof(long), @@ -208,8 +208,8 @@ InitBufferPool(IPCKey key) } else { - BufferDesc *buf; - unsigned long block; + BufferDesc *buf; + unsigned long block; buf = BufferDescriptors; block = (unsigned long) BufferBlocks; @@ -249,7 +249,7 @@ InitBufferPool(IPCKey key) #ifndef HAS_TEST_AND_SET { - int status; + int status; WaitIOSemId = IpcSemaphoreCreate(IPCKeyGetWaitIOSemaphoreKey(key), 1, IPCProtection, 0, 1, &status); @@ -270,10 +270,10 @@ InitBufferPool(IPCKey key) int BufferShmemSize() { - int size = 0; - int nbuckets; - int nsegs; - int tmp; + int size = 0; + int nbuckets; + int nsegs; + int tmp; nbuckets = 1 << (int) my_log2((NBuffers - 1) / DEF_FFACTOR + 1); nsegs = 1 << (int) my_log2((nbuckets - 1) / DEF_SEGSIZE + 1); diff --git a/src/backend/storage/buffer/buf_table.c b/src/backend/storage/buffer/buf_table.c index 41b2b4d8ee0..1fc31580a58 100644 --- a/src/backend/storage/buffer/buf_table.c +++ b/src/backend/storage/buffer/buf_table.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.5 1997/09/07 04:48:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_table.c,v 1.6 1997/09/08 02:28:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,13 +34,13 @@ #include "storage/spin.h" #include "utils/hsearch.h" -static HTAB *SharedBufHash; +static HTAB *SharedBufHash; typedef struct lookup { - BufferTag key; - Buffer id; -} LookupEnt; + BufferTag key; + Buffer id; +} LookupEnt; /* * Initialize shmem hash table for mapping buffers @@ -48,8 +48,8 @@ typedef struct lookup void InitBufTable() { - HASHCTL info; - int hash_flags; + HASHCTL info; + int hash_flags; /* assume lock is held */ @@ -73,11 +73,11 @@ InitBufTable() } -BufferDesc * +BufferDesc * BufTableLookup(BufferTag * tagPtr) { - LookupEnt *result; - bool found; + LookupEnt *result; + bool found; if (tagPtr->blockNum == P_NEW) return (NULL); @@ -103,8 +103,8 @@ BufTableLookup(BufferTag * tagPtr) bool BufTableDelete(BufferDesc * buf) { - LookupEnt *result; - bool found; + LookupEnt *result; + bool found; /* * buffer not initialized or has been removed from table already. @@ -132,8 +132,8 @@ BufTableDelete(BufferDesc * buf) bool BufTableInsert(BufferDesc * buf) { - LookupEnt *result; - bool found; + LookupEnt *result; + bool found; /* cannot insert it twice */ Assert(buf->flags & BM_DELETED); diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 2a53e6bd78c..4e7ff8c967c 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.20 1997/09/07 04:48:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.21 1997/09/08 02:28:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -77,14 +77,14 @@ extern long int LocalBufferHitCount; extern long int BufferFlushCount; extern long int LocalBufferFlushCount; -static int WriteMode = BUFFER_LATE_WRITE; /* Delayed write is +static int WriteMode = BUFFER_LATE_WRITE; /* Delayed write is * default */ -static void WaitIO(BufferDesc * buf, SPINLOCK spinlock); +static void WaitIO(BufferDesc * buf, SPINLOCK spinlock); #ifndef HAS_TEST_AND_SET -static void SignalIO(BufferDesc * buf); -extern long *NWaitIOBackendP;/* defined in buf_init.c */ +static void SignalIO(BufferDesc * buf); +extern long *NWaitIOBackendP; /* defined in buf_init.c */ #endif /* HAS_TEST_AND_SET */ @@ -94,9 +94,9 @@ ReadBufferWithBufferLock(Relation relation, BlockNumber blockNum, static BufferDesc * BufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr, bool bufferLockHeld); -static int FlushBuffer(Buffer buffer, bool release); -static void BufferSync(void); -static int BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld); +static int FlushBuffer(Buffer buffer, bool release); +static void BufferSync(void); +static int BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld); /* --------------------------------------------------- * RelationGetBufferWithBuffer @@ -109,8 +109,8 @@ RelationGetBufferWithBuffer(Relation relation, BlockNumber blockNumber, Buffer buffer) { - BufferDesc *bufHdr; - LRelId lrelId; + BufferDesc *bufHdr; + LRelId lrelId; if (BufferIsValid(buffer)) { @@ -154,7 +154,7 @@ RelationGetBufferWithBuffer(Relation relation, * opened already. */ -extern int ShowPinTrace; +extern int ShowPinTrace; #undef ReadBuffer /* conflicts with macro when BUFMGR_DEBUG @@ -176,10 +176,10 @@ ReadBuffer(Relation reln, BlockNumber blockNum) * XXX caller must have already acquired BufMgrLock */ #ifdef NOT_USED -static bool +static bool is_userbuffer(Buffer buffer) { - BufferDesc *buf = &BufferDescriptors[buffer - 1]; + BufferDesc *buf = &BufferDescriptors[buffer - 1]; if (IsSystemRelationName(buf->sb_relname)) return false; @@ -195,12 +195,12 @@ ReadBuffer_Debug(char *file, Relation reln, BlockNumber blockNum) { - Buffer buffer; + Buffer buffer; buffer = ReadBufferWithBufferLock(reln, blockNum, false); if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf = &BufferDescriptors[buffer - 1]; + BufferDesc *buf = &BufferDescriptors[buffer - 1]; fprintf(stderr, "PIN(RD) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -219,16 +219,16 @@ refcount = %ld, file: %s, line: %d\n", * is yet another effort to reduce the number of * semops in the system. */ -static Buffer +static Buffer ReadBufferWithBufferLock(Relation reln, BlockNumber blockNum, bool bufferLockHeld) { - BufferDesc *bufHdr; - int extend; /* extending the file by one block */ - int status; - bool found; - bool isLocalBuf; + BufferDesc *bufHdr; + int extend; /* extending the file by one block */ + int status; + bool found; + bool isLocalBuf; extend = (blockNum == P_NEW); isLocalBuf = reln->rd_islocal; @@ -357,11 +357,11 @@ BufferAlloc(Relation reln, bool * foundPtr, bool bufferLockHeld) { - BufferDesc *buf, - *buf2; - BufferTag newTag; /* identity of requested block */ - bool inProgress; /* buffer undergoing IO */ - bool newblock = FALSE; + BufferDesc *buf, + *buf2; + BufferTag newTag; /* identity of requested block */ + bool inProgress; /* buffer undergoing IO */ + bool newblock = FALSE; /* create a new tag so we can lookup the buffer */ /* assume that the relation is already open */ @@ -458,7 +458,7 @@ BufferAlloc(Relation reln, if (buf->flags & BM_DIRTY) { - bool smok; + bool smok; /* * Set BM_IO_IN_PROGRESS to keep anyone from doing anything @@ -693,7 +693,7 @@ BufferAlloc(Relation reln, int WriteBuffer(Buffer buffer) { - BufferDesc *bufHdr; + BufferDesc *bufHdr; if (WriteMode == BUFFER_FLUSH_WRITE) { @@ -727,7 +727,7 @@ WriteBuffer_Debug(char *file, int line, Buffer buffer) WriteBuffer(buffer); if (ShowPinTrace && BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf; + BufferDesc *buf; buf = &BufferDescriptors[buffer - 1]; fprintf(stderr, "UNPIN(WR) %ld relname = %s, blockNum = %d, \ @@ -761,8 +761,8 @@ refcount = %ld, file: %s, line: %d\n", void DirtyBufferCopy(Oid dbid, Oid relid, BlockNumber blkno, char *dest) { - BufferDesc *buf; - BufferTag btag; + BufferDesc *buf; + BufferTag btag; btag.relId.relId = relid; btag.relId.dbId = dbid; @@ -803,10 +803,10 @@ DirtyBufferCopy(Oid dbid, Oid relid, BlockNumber blkno, char *dest) static int FlushBuffer(Buffer buffer, bool release) { - BufferDesc *bufHdr; - Oid bufdb; - Relation bufrel; - int status; + BufferDesc *bufHdr; + Oid bufdb; + Relation bufrel; + int status; if (BufferIsLocal(buffer)) return FlushLocalBuffer(buffer, release); @@ -871,7 +871,7 @@ FlushBuffer(Buffer buffer, bool release) int WriteNoReleaseBuffer(Buffer buffer) { - BufferDesc *bufHdr; + BufferDesc *bufHdr; if (WriteMode == BUFFER_FLUSH_WRITE) { @@ -908,8 +908,8 @@ ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum) { - BufferDesc *bufHdr; - Buffer retbuf; + BufferDesc *bufHdr; + Buffer retbuf; if (BufferIsLocal(buffer)) { @@ -972,12 +972,12 @@ ReleaseAndReadBuffer(Buffer buffer, static void BufferSync() { - int i; - Oid bufdb; - Oid bufrel; - Relation reln; - BufferDesc *bufHdr; - int status; + int i; + Oid bufdb; + Oid bufrel; + Relation reln; + BufferDesc *bufHdr; + int status; SpinAcquire(BufMgrLock); for (i = 0, bufHdr = BufferDescriptors; i < NBuffers; i++, bufHdr++) @@ -1114,12 +1114,12 @@ WaitIO(BufferDesc * buf, SPINLOCK spinlock) } #else /* HAS_TEST_AND_SET */ -IpcSemaphoreId WaitIOSemId; +IpcSemaphoreId WaitIOSemId; static void WaitIO(BufferDesc * buf, SPINLOCK spinlock) { - bool inProgress; + bool inProgress; for (;;) { @@ -1149,16 +1149,15 @@ SignalIO(BufferDesc * buf) #endif /* HAS_TEST_AND_SET */ -long NDirectFileRead;/* some I/O's are direct file access. +long NDirectFileRead; /* some I/O's are direct file access. * bypass bufmgr */ -long NDirectFileWrite; /* e.g., I/O in psort and - * hashjoin. */ +long NDirectFileWrite; /* e.g., I/O in psort and hashjoin. */ void PrintBufferUsage(FILE * statfp) { - float hitrate; - float localhitrate; + float hitrate; + float localhitrate; if (ReadBufferCount == 0) hitrate = 0.0; @@ -1202,7 +1201,7 @@ ResetBufferUsage() void ResetBufferPool() { - register int i; + register int i; for (i = 1; i <= NBuffers; i++) { @@ -1230,8 +1229,8 @@ ResetBufferPool() int BufferPoolCheckLeak() { - register int i; - int error = 0; + register int i; + int error = 0; for (i = 1; i <= NBuffers; i++) { @@ -1315,8 +1314,8 @@ BufferGetBlockNumber(Buffer buffer) Relation BufferGetRelation(Buffer buffer) { - Relation relation; - Oid relid; + Relation relation; + Oid relid; Assert(BufferIsValid(buffer)); Assert(!BufferIsLocal(buffer)); /* not supported for local buffers */ @@ -1349,10 +1348,10 @@ BufferGetRelation(Buffer buffer) static int BufferReplace(BufferDesc * bufHdr, bool bufferLockHeld) { - Relation reln; - Oid bufdb, - bufrel; - int status; + Relation reln; + Oid bufdb, + bufrel; + int status; if (!bufferLockHeld) SpinAcquire(BufMgrLock); @@ -1446,9 +1445,9 @@ BufferGetBlock(Buffer buffer) void ReleaseRelationBuffers(Relation rdesc) { - register int i; - int holding = 0; - BufferDesc *buf; + register int i; + int holding = 0; + BufferDesc *buf; if (rdesc->rd_islocal) { @@ -1503,8 +1502,8 @@ ReleaseRelationBuffers(Relation rdesc) void DropBuffers(Oid dbid) { - register int i; - BufferDesc *buf; + register int i; + BufferDesc *buf; SpinAcquire(BufMgrLock); for (i = 1; i <= NBuffers; i++) @@ -1528,8 +1527,8 @@ DropBuffers(Oid dbid) void PrintBufferDescs() { - int i; - BufferDesc *buf = BufferDescriptors; + int i; + BufferDesc *buf = BufferDescriptors; if (IsUnderPostmaster) { @@ -1559,8 +1558,8 @@ blockNum=%d, flags=0x%x, refcount=%d %d)", void PrintPinnedBufs() { - int i; - BufferDesc *buf = BufferDescriptors; + int i; + BufferDesc *buf = BufferDescriptors; SpinAcquire(BufMgrLock); for (i = 0; i < NBuffers; ++i, ++buf) @@ -1587,7 +1586,7 @@ blockNum=%d, flags=0x%x, refcount=%d %d)\n", void BufferPoolBlowaway() { - register int i; + register int i; BufferSync(); for (i = 1; i <= NBuffers; i++) @@ -1630,7 +1629,7 @@ IncrBufferRefCount(Buffer buffer) int ReleaseBuffer(Buffer buffer) { - BufferDesc *bufHdr; + BufferDesc *bufHdr; if (BufferIsLocal(buffer)) { @@ -1678,7 +1677,7 @@ IncrBufferRefCount_Debug(char *file, int line, Buffer buffer) IncrBufferRefCount(buffer); if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf = &BufferDescriptors[buffer - 1]; + BufferDesc *buf = &BufferDescriptors[buffer - 1]; fprintf(stderr, "PIN(Incr) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -1696,7 +1695,7 @@ ReleaseBuffer_Debug(char *file, int line, Buffer buffer) ReleaseBuffer(buffer); if (ShowPinTrace && !BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf = &BufferDescriptors[buffer - 1]; + BufferDesc *buf = &BufferDescriptors[buffer - 1]; fprintf(stderr, "UNPIN(Rel) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -1715,15 +1714,15 @@ ReleaseAndReadBuffer_Debug(char *file, Relation relation, BlockNumber blockNum) { - bool bufferValid; - Buffer b; + bool bufferValid; + Buffer b; bufferValid = BufferIsValid(buffer); b = ReleaseAndReadBuffer(buffer, relation, blockNum); if (ShowPinTrace && bufferValid && BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf = &BufferDescriptors[buffer - 1]; + BufferDesc *buf = &BufferDescriptors[buffer - 1]; fprintf(stderr, "UNPIN(Rel&Rd) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -1732,7 +1731,7 @@ refcount = %ld, file: %s, line: %d\n", } if (ShowPinTrace && BufferIsLocal(buffer) && is_userbuffer(buffer)) { - BufferDesc *buf = &BufferDescriptors[b - 1]; + BufferDesc *buf = &BufferDescriptors[b - 1]; fprintf(stderr, "PIN(Rel&Rd) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -1754,10 +1753,10 @@ refcount = %ld, file: %s, line: %d\n", _bm_trace(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType) { - static int mypid = 0; - long start, - cur; - bmtrace *tb; + static int mypid = 0; + long start, + cur; + bmtrace *tb; if (mypid == 0) mypid = getpid(); @@ -1810,9 +1809,9 @@ okay: _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo, int allocType, long start, long cur) { - FILE *fp; - bmtrace *tb; - int i; + FILE *fp; + bmtrace *tb; + int i; tb = &TraceBuf[cur]; @@ -1839,21 +1838,21 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo, switch (tb->bmt_op) { - case BMT_ALLOCFND: - fprintf(fp, "allocate (found)\n"); - break; + case BMT_ALLOCFND: + fprintf(fp, "allocate (found)\n"); + break; - case BMT_ALLOCNOTFND: - fprintf(fp, "allocate (not found)\n"); - break; + case BMT_ALLOCNOTFND: + fprintf(fp, "allocate (not found)\n"); + break; - case BMT_DEALLOC: - fprintf(fp, "deallocate\n"); - break; + case BMT_DEALLOC: + fprintf(fp, "deallocate\n"); + break; - default: - fprintf(fp, "unknown op type %d\n", tb->bmt_op); - break; + default: + fprintf(fp, "unknown op type %d\n", tb->bmt_op); + break; } } @@ -1868,21 +1867,21 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo, switch (allocType) { - case BMT_ALLOCFND: - fprintf(fp, "allocate (found)\n"); - break; + case BMT_ALLOCFND: + fprintf(fp, "allocate (found)\n"); + break; - case BMT_ALLOCNOTFND: - fprintf(fp, "allocate (not found)\n"); - break; + case BMT_ALLOCNOTFND: + fprintf(fp, "allocate (not found)\n"); + break; - case BMT_DEALLOC: - fprintf(fp, "deallocate\n"); - break; + case BMT_DEALLOC: + fprintf(fp, "deallocate\n"); + break; - default: - fprintf(fp, "unknown op type %d\n", allocType); - break; + default: + fprintf(fp, "unknown op type %d\n", allocType); + break; } FreeFile(fp); @@ -1895,7 +1894,7 @@ _bm_die(Oid dbId, Oid relId, int blkNo, int bufNo, void BufferRefCountReset(int *refcountsave) { - int i; + int i; for (i = 0; i < NBuffers; i++) { @@ -1908,7 +1907,7 @@ BufferRefCountReset(int *refcountsave) void BufferRefCountRestore(int *refcountsave) { - int i; + int i; for (i = 0; i < NBuffers; i++) { @@ -1921,7 +1920,7 @@ BufferRefCountRestore(int *refcountsave) int SetBufferWriteMode(int mode) { - int old; + int old; old = WriteMode; WriteMode = mode; diff --git a/src/backend/storage/buffer/freelist.c b/src/backend/storage/buffer/freelist.c index 94a8e84b8c6..027a6a94670 100644 --- a/src/backend/storage/buffer/freelist.c +++ b/src/backend/storage/buffer/freelist.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.5 1997/09/07 04:48:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/freelist.c,v 1.6 1997/09/08 02:28:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -84,7 +84,7 @@ AddBufferToFreelist(BufferDesc * bf) void PinBuffer(BufferDesc * buf) { - long b; + long b; /* Assert (buf->refcount < 25); */ @@ -119,7 +119,7 @@ PinBuffer_Debug(char *file, int line, BufferDesc * buf) PinBuffer(buf); if (ShowPinTrace) { - Buffer buffer = BufferDescriptorGetBuffer(buf); + Buffer buffer = BufferDescriptorGetBuffer(buf); fprintf(stderr, "PIN(Pin) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -138,7 +138,7 @@ refcount = %ld, file: %s, line: %d\n", void UnpinBuffer(BufferDesc * buf) { - long b = BufferDescriptorGetBuffer(buf) - 1; + long b = BufferDescriptorGetBuffer(buf) - 1; Assert(buf->refcount); Assert(PrivateRefCount[b] > 0); @@ -165,7 +165,7 @@ UnpinBuffer_Debug(char *file, int line, BufferDesc * buf) UnpinBuffer(buf); if (ShowPinTrace) { - Buffer buffer = BufferDescriptorGetBuffer(buf); + Buffer buffer = BufferDescriptorGetBuffer(buf); fprintf(stderr, "UNPIN(Unpin) %ld relname = %s, blockNum = %d, \ refcount = %ld, file: %s, line: %d\n", @@ -180,10 +180,10 @@ refcount = %ld, file: %s, line: %d\n", * GetFreeBuffer() -- get the 'next' buffer from the freelist. * */ -BufferDesc * +BufferDesc * GetFreeBuffer() { - BufferDesc *buf; + BufferDesc *buf; if (Free_List_Descriptor == SharedFreeList->freeNext) { @@ -242,8 +242,8 @@ InitFreeList(bool init) void DBG_FreeListCheck(int nfree) { - int i; - BufferDesc *buf; + int i; + BufferDesc *buf; buf = &(BufferDescriptors[SharedFreeList->freeNext]); for (i = 0; i < nfree; i++, buf = &(BufferDescriptors[buf->freeNext])) @@ -291,7 +291,7 @@ DBG_FreeListCheck(int nfree) static void PrintBufferFreeList() { - BufferDesc *buf; + BufferDesc *buf; if (SharedFreeList->freeNext == Free_List_Descriptor) { @@ -302,7 +302,7 @@ PrintBufferFreeList() buf = &(BufferDescriptors[SharedFreeList->freeNext]); for (;;) { - int i = (buf - BufferDescriptors); + int i = (buf - BufferDescriptors); printf("[%-2d] (%s, %d) flags=0x%x, refcnt=%d %ld, nxt=%ld prv=%ld)\n", i, buf->sb_relname, buf->tag.blockNum, diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 072830b3dd6..3916abc2a76 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.9 1997/09/07 04:48:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.10 1997/09/08 02:28:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,11 +50,11 @@ extern long int LocalBufferFlushCount; -int NLocBuffer = 64; -BufferDesc *LocalBufferDescriptors = NULL; -long *LocalRefCount = NULL; +int NLocBuffer = 64; +BufferDesc *LocalBufferDescriptors = NULL; +long *LocalRefCount = NULL; -static int nextFreeLocalBuf = 0; +static int nextFreeLocalBuf = 0; /*#define LBDEBUG*/ @@ -62,11 +62,11 @@ static int nextFreeLocalBuf = 0; * LocalBufferAlloc - * allocate a local buffer. We do round robin allocation for now. */ -BufferDesc * +BufferDesc * LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr) { - int i; - BufferDesc *bufHdr = (BufferDesc *) NULL; + int i; + BufferDesc *bufHdr = (BufferDesc *) NULL; if (blockNum == P_NEW) { @@ -99,7 +99,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr) /* need to get a new buffer (round robin for now) */ for (i = 0; i < NLocBuffer; i++) { - int b = (nextFreeLocalBuf + i) % NLocBuffer; + int b = (nextFreeLocalBuf + i) % NLocBuffer; if (LocalRefCount[b] == 0) { @@ -119,7 +119,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr) */ if (bufHdr->flags & BM_DIRTY) { - Relation bufrel = RelationIdCacheGetRelation(bufHdr->tag.relId.relId); + Relation bufrel = RelationIdCacheGetRelation(bufHdr->tag.relId.relId); Assert(bufrel != NULL); @@ -142,7 +142,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr) */ if (bufHdr->data == (SHMEM_OFFSET) 0) { - char *data = (char *) malloc(BLCKSZ); + char *data = (char *) malloc(BLCKSZ); bufHdr->data = MAKE_OFFSET(data); } @@ -158,7 +158,7 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr) int WriteLocalBuffer(Buffer buffer, bool release) { - int bufid; + int bufid; Assert(BufferIsLocal(buffer)); @@ -185,9 +185,9 @@ WriteLocalBuffer(Buffer buffer, bool release) int FlushLocalBuffer(Buffer buffer, bool release) { - int bufid; - Relation bufrel; - BufferDesc *bufHdr; + int bufid; + Relation bufrel; + BufferDesc *bufHdr; Assert(BufferIsLocal(buffer)); @@ -221,7 +221,7 @@ FlushLocalBuffer(Buffer buffer, bool release) void InitLocalBuffer(void) { - int i; + int i; /* * these aren't going away. I'm not gonna use palloc. @@ -233,7 +233,7 @@ InitLocalBuffer(void) for (i = 0; i < NLocBuffer; i++) { - BufferDesc *buf = &LocalBufferDescriptors[i]; + BufferDesc *buf = &LocalBufferDescriptors[i]; /* * negative to indicate local buffer. This is tricky: shared @@ -258,12 +258,12 @@ InitLocalBuffer(void) void LocalBufferSync(void) { - int i; + int i; for (i = 0; i < NLocBuffer; i++) { - BufferDesc *buf = &LocalBufferDescriptors[i]; - Relation bufrel; + BufferDesc *buf = &LocalBufferDescriptors[i]; + Relation bufrel; if (buf->flags & BM_DIRTY) { @@ -290,11 +290,11 @@ LocalBufferSync(void) void ResetLocalBufferPool(void) { - int i; + int i; for (i = 0; i < NLocBuffer; i++) { - BufferDesc *buf = &LocalBufferDescriptors[i]; + BufferDesc *buf = &LocalBufferDescriptors[i]; buf->tag.relId.relId = InvalidOid; buf->flags &= ~BM_DIRTY; diff --git a/src/backend/storage/file/fd.c b/src/backend/storage/file/fd.c index 2e998f27196..aa09bbdfb6b 100644 --- a/src/backend/storage/file/fd.c +++ b/src/backend/storage/file/fd.c @@ -6,7 +6,7 @@ * Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Id: fd.c,v 1.23 1997/09/07 04:48:25 momjian Exp $ + * $Id: fd.c,v 1.24 1997/09/08 02:28:38 momjian Exp $ * * NOTES: * @@ -99,33 +99,33 @@ typedef struct vfd { - signed short fd; - unsigned short fdstate; + signed short fd; + unsigned short fdstate; #define FD_DIRTY (1 << 0) - File nextFree; - File lruMoreRecently; - File lruLessRecently; - long seekPos; - char *fileName; - int fileFlags; - int fileMode; -} Vfd; + File nextFree; + File lruMoreRecently; + File lruLessRecently; + long seekPos; + char *fileName; + int fileFlags; + int fileMode; +} Vfd; /* * Virtual File Descriptor array pointer and size. This grows as * needed. */ -static Vfd *VfdCache; -static Size SizeVfdCache = 0; +static Vfd *VfdCache; +static Size SizeVfdCache = 0; /* * Number of file descriptors known to be open. */ -static int nfile = 0; +static int nfile = 0; -static char Sep_char = '/'; +static char Sep_char = '/'; /* * Private Routines @@ -154,23 +154,23 @@ static char Sep_char = '/'; * FreeVfd - free a file record * */ -static void Delete(File file); -static void LruDelete(File file); -static void Insert(File file); -static int LruInsert(File file); -static void AssertLruRoom(void); -static File AllocateVfd(void); -static void FreeVfd(File file); - -static int FileAccess(File file); -static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode); -static char *filepath(char *filename); -static long pg_nofile(void); +static void Delete(File file); +static void LruDelete(File file); +static void Insert(File file); +static int LruInsert(File file); +static void AssertLruRoom(void); +static File AllocateVfd(void); +static void FreeVfd(File file); + +static int FileAccess(File file); +static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode); +static char *filepath(char *filename); +static long pg_nofile(void); int pg_fsync(int fd) { - extern int fsyncOff; + extern int fsyncOff; return fsyncOff ? 0 : fsync(fd); } @@ -180,7 +180,7 @@ pg_fsync(int fd) long pg_nofile(void) { - static long no_files = 0; + static long no_files = 0; if (no_files == 0) { @@ -207,9 +207,9 @@ pg_nofile(void) static void _dump_lru() { - int mru = VfdCache[0].lruLessRecently; - Vfd *vfdP = &VfdCache[mru]; - char buf[2048]; + int mru = VfdCache[0].lruLessRecently; + Vfd *vfdP = &VfdCache[mru]; + char buf[2048]; sprintf(buf, "LRU: MOST %d ", mru); while (mru != 0) @@ -227,7 +227,7 @@ _dump_lru() static void Delete(File file) { - Vfd *fileP; + Vfd *fileP; DO_DB(elog(DEBUG, "Delete %d (%s)", file, VfdCache[file].fileName)); @@ -248,8 +248,8 @@ Delete(File file) static void LruDelete(File file) { - Vfd *fileP; - int returnValue; + Vfd *fileP; + int returnValue; DO_DB(elog(DEBUG, "LruDelete %d (%s)", file, VfdCache[file].fileName)); @@ -285,7 +285,7 @@ LruDelete(File file) static void Insert(File file) { - Vfd *vfdP; + Vfd *vfdP; DO_DB(elog(DEBUG, "Insert %d (%s)", file, VfdCache[file].fileName)); @@ -304,8 +304,8 @@ Insert(File file) static int LruInsert(File file) { - Vfd *vfdP; - int returnValue; + Vfd *vfdP; + int returnValue; DO_DB(elog(DEBUG, "LruInsert %d (%s)", file, VfdCache[file].fileName)); @@ -384,11 +384,11 @@ AssertLruRoom() LruDelete(VfdCache[0].lruMoreRecently); } -static File +static File AllocateVfd() { - Index i; - File file; + Index i; + File file; DO_DB(elog(DEBUG, "AllocateVfd. Size %d", SizeVfdCache)); @@ -458,12 +458,12 @@ FreeVfd(File file) VfdCache[0].nextFree = file; } -static char * +static char * filepath(char *filename) { - char *buf; - char basename[16]; - int len; + char *buf; + char basename[16]; + int len; if (*filename != Sep_char) { @@ -488,7 +488,7 @@ filepath(char *filename) static int FileAccess(File file) { - int returnValue; + int returnValue; DO_DB(elog(DEBUG, "FileAccess %d (%s)", file, VfdCache[file].fileName)); @@ -539,13 +539,13 @@ FileInvalidate(File file) #endif /* VARARGS2 */ -static File +static File fileNameOpenFile(FileName fileName, int fileFlags, int fileMode) { - File file; - Vfd *vfdP; + File file; + Vfd *vfdP; DO_DB(elog(DEBUG, "fileNameOpenFile: %s %x %o", fileName, fileFlags, fileMode)); @@ -600,8 +600,8 @@ tryAgain: File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode) { - File fd; - char *fname; + File fd; + char *fname; fname = filepath(fileName); fd = fileNameOpenFile(fname, fileFlags, fileMode); @@ -621,7 +621,7 @@ PathNameOpenFile(FileName fileName, int fileFlags, int fileMode) void FileClose(File file) { - int returnValue; + int returnValue; DO_DB(elog(DEBUG, "FileClose: %d (%s)", file, VfdCache[file].fileName)); @@ -662,7 +662,7 @@ FileClose(File file) void FileUnlink(File file) { - int returnValue; + int returnValue; DO_DB(elog(DEBUG, "FileUnlink: %d (%s)", file, VfdCache[file].fileName)); @@ -699,7 +699,7 @@ FileUnlink(File file) int FileRead(File file, char *buffer, int amount) { - int returnCode; + int returnCode; DO_DB(elog(DEBUG, "FileRead: %d (%s) %d %p", file, VfdCache[file].fileName, amount, buffer)); @@ -717,7 +717,7 @@ FileRead(File file, char *buffer, int amount) int FileWrite(File file, char *buffer, int amount) { - int returnCode; + int returnCode; DO_DB(elog(DEBUG, "FileWrite: %d (%s) %d %p", file, VfdCache[file].fileName, amount, buffer)); @@ -738,7 +738,7 @@ FileWrite(File file, char *buffer, int amount) long FileSeek(File file, long offset, int whence) { - int returnCode; + int returnCode; DO_DB(elog(DEBUG, "FileSeek: %d (%s) %ld %d", file, VfdCache[file].fileName, offset, whence)); @@ -747,20 +747,20 @@ FileSeek(File file, long offset, int whence) { switch (whence) { - case SEEK_SET: - VfdCache[file].seekPos = offset; - return offset; - case SEEK_CUR: - VfdCache[file].seekPos = VfdCache[file].seekPos + offset; - return VfdCache[file].seekPos; - case SEEK_END: - FileAccess(file); - returnCode = VfdCache[file].seekPos = - lseek(VfdCache[file].fd, offset, whence); - return returnCode; - default: - elog(WARN, "FileSeek: invalid whence: %d", whence); - break; + case SEEK_SET: + VfdCache[file].seekPos = offset; + return offset; + case SEEK_CUR: + VfdCache[file].seekPos = VfdCache[file].seekPos + offset; + return VfdCache[file].seekPos; + case SEEK_END: + FileAccess(file); + returnCode = VfdCache[file].seekPos = + lseek(VfdCache[file].fd, offset, whence); + return returnCode; + default: + elog(WARN, "FileSeek: invalid whence: %d", whence); + break; } } else @@ -790,7 +790,7 @@ FileTell(File file) int FileTruncate(File file, int offset) { - int returnCode; + int returnCode; DO_DB(elog(DEBUG, "FileTruncate %d (%s)", file, VfdCache[file].fileName)); @@ -804,7 +804,7 @@ FileTruncate(File file, int offset) int FileSync(File file) { - int returnCode; + int returnCode; /* * If the file isn't open, then we don't need to sync it; we always @@ -828,8 +828,8 @@ FileSync(File file) int FileNameUnlink(char *filename) { - int retval; - char *fname; + int retval; + char *fname; fname = filepath(filename); retval = unlink(fname); @@ -846,13 +846,13 @@ FileNameUnlink(char *filename) * allocatedFiles keeps track of how many have been allocated so we * can give a warning if there are too few left. */ -static int allocatedFiles = 0; +static int allocatedFiles = 0; -FILE * +FILE * AllocateFile(char *name, char *mode) { - FILE *file; - int fdleft; + FILE *file; + int fdleft; DO_DB(elog(DEBUG, "AllocateFile: Allocated %d.", allocatedFiles)); @@ -895,7 +895,7 @@ FreeFile(FILE * file) void closeAllVfds() { - int i; + int i; Assert(FileIsNotOpen(0)); /* Make sure ring not corrupted */ for (i = 1; i < SizeVfdCache; i++) diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index 3dd6d2ec094..af59de7cca8 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.12 1997/09/07 04:48:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.13 1997/09/08 02:28:44 momjian Exp $ * * NOTES * @@ -44,14 +44,14 @@ #endif #if defined(bsd44) -int UsePrivateMemory = 1; +int UsePrivateMemory = 1; #else -int UsePrivateMemory = 0; +int UsePrivateMemory = 0; #endif -static void IpcMemoryDetach(int status, char *shmaddr); +static void IpcMemoryDetach(int status, char *shmaddr); /* ---------------------------------------------------------------- * exit() handling stuff @@ -62,26 +62,26 @@ static void IpcMemoryDetach(int status, char *shmaddr); static struct ONEXIT { - void (*function) (); - caddr_t arg; -} onexit_list[MAX_ON_EXITS]; + void (*function) (); + caddr_t arg; +} onexit_list[MAX_ON_EXITS]; -static int onexit_index; -static void IpcConfigTip(void); +static int onexit_index; +static void IpcConfigTip(void); typedef struct _PrivateMemStruct { - int id; - char *memptr; -} PrivateMem; + int id; + char *memptr; +} PrivateMem; -PrivateMem IpcPrivateMem[16]; +PrivateMem IpcPrivateMem[16]; static int PrivateMemoryCreate(IpcMemoryKey memKey, uint32 size) { - static int memid = 0; + static int memid = 0; UsePrivateMemory = 1; @@ -94,7 +94,7 @@ PrivateMemoryCreate(IpcMemoryKey memKey, return (memid++); } -static char * +static char * PrivateMemoryAttach(IpcMemoryId memid) { return (IpcPrivateMem[memid].memptr); @@ -110,12 +110,12 @@ PrivateMemoryAttach(IpcMemoryId memid) * -cim 2/6/90 * ---------------------------------------------------------------- */ -static int exitpg_inprogress = 0; +static int exitpg_inprogress = 0; void exitpg(int code) { - int i; + int i; /* ---------------- * if exitpg_inprocess is true, then it means that we @@ -147,7 +147,7 @@ exitpg(int code) void quasi_exitpg() { - int i; + int i; /* ---------------- * if exitpg_inprocess is true, then it means that we @@ -179,7 +179,7 @@ quasi_exitpg() * ---------------------------------------------------------------- */ int - on_exitpg(void (*function) (), caddr_t arg) + on_exitpg(void (*function) (), caddr_t arg) { if (onexit_index >= MAX_ON_EXITS) return (-1); @@ -200,7 +200,7 @@ static void IPCPrivateSemaphoreKill(int status, int semId) /* caddr_t */ { - union semun semun; + union semun semun; semctl(semId, 0, IPC_RMID, semun); } @@ -259,11 +259,11 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, int removeOnExit, int *status) { - int i; - int errStatus; - int semId; - u_short array[IPC_NMAXSEM]; - union semun semun; + int i; + int errStatus; + int semId; + u_short array[IPC_NMAXSEM]; + union semun semun; /* get a semaphore if non-existent */ /* check arguments */ @@ -332,13 +332,13 @@ IpcSemaphoreCreate(IpcSemaphoreKey semKey, /* note: the xxx_return variables are only used for debugging. */ /****************************************************************************/ #ifdef NOT_USED -static int IpcSemaphoreSet_return; +static int IpcSemaphoreSet_return; void IpcSemaphoreSet(int semId, int semno, int value) { - int errStatus; - union semun semun; + int errStatus; + union semun semun; semun.val = value; errStatus = semctl(semId, semno, SETVAL, semun); @@ -360,8 +360,8 @@ IpcSemaphoreSet(int semId, int semno, int value) void IpcSemaphoreKill(IpcSemaphoreKey key) { - int semId; - union semun semun; + int semId; + union semun semun; /* kill semaphore if existent */ @@ -375,14 +375,14 @@ IpcSemaphoreKill(IpcSemaphoreKey key) /* */ /* note: the xxx_return variables are only used for debugging. */ /****************************************************************************/ -static int IpcSemaphoreLock_return; +static int IpcSemaphoreLock_return; void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock) { - extern int errno; - int errStatus; - struct sembuf sops; + extern int errno; + int errStatus; + struct sembuf sops; sops.sem_op = lock; sops.sem_flg = 0; @@ -419,14 +419,14 @@ IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock) /* */ /* note: the xxx_return variables are only used for debugging. */ /****************************************************************************/ -static int IpcSemaphoreUnlock_return; +static int IpcSemaphoreUnlock_return; void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock) { - extern int errno; - int errStatus; - struct sembuf sops; + extern int errno; + int errStatus; + struct sembuf sops; sops.sem_op = -lock; sops.sem_flg = 0; @@ -462,8 +462,8 @@ IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock) int IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem) { - int semncnt; - union semun dummy; /* for Solaris */ + int semncnt; + union semun dummy; /* for Solaris */ semncnt = semctl(semId, sem, GETNCNT, dummy); return semncnt; @@ -472,8 +472,8 @@ IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem) int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem) { - int semval; - union semun dummy; /* for Solaris */ + int semval; + union semun dummy; /* for Solaris */ semval = semctl(semId, sem, GETVAL, dummy); return semval; @@ -489,7 +489,7 @@ IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem) IpcMemoryId IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) { - IpcMemoryId shmid; + IpcMemoryId shmid; if (memKey == PrivateIPCKey) { @@ -523,7 +523,7 @@ IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission) IpcMemoryId IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size) { - IpcMemoryId shmid; + IpcMemoryId shmid; shmid = shmget(memKey, size, 0); @@ -560,10 +560,10 @@ IpcMemoryDetach(int status, char *shmaddr) /* CALL IT: addr = (struct <MemoryStructure> *) IpcMemoryAttach(memId); */ /* */ /****************************************************************************/ -char * +char * IpcMemoryAttach(IpcMemoryId memId) { - char *memAddress; + char *memAddress; if (UsePrivateMemory) { @@ -596,7 +596,7 @@ IpcMemoryAttach(IpcMemoryId memId) void IpcMemoryKill(IpcMemoryKey memKey) { - IpcMemoryId shmid; + IpcMemoryId shmid; if (!UsePrivateMemory && (shmid = shmget(memKey, 0, 0)) >= 0) { @@ -615,26 +615,26 @@ IpcMemoryKill(IpcMemoryKey memKey) * supply of locks. * ------------------ */ -static SLock *SLockArray = NULL; -static SLock **FreeSLockPP; -static int *UnusedSLockIP; +static SLock *SLockArray = NULL; +static SLock **FreeSLockPP; +static int *UnusedSLockIP; static slock_t *SLockMemoryLock; static IpcMemoryId SLockMemoryId = -1; struct ipcdummy { /* to get alignment/size right */ - SLock *free; - int unused; - slock_t memlock; - SLock slocks[NSLOCKS]; + SLock *free; + int unused; + slock_t memlock; + SLock slocks[NSLOCKS]; }; -static int SLockMemorySize = sizeof(struct ipcdummy); +static int SLockMemorySize = sizeof(struct ipcdummy); void CreateAndInitSLockMemory(IPCKey key) { - int id; - SLock *slckP; + int id; + SLock *slckP; SLockMemoryId = IpcMemoryCreate(key, SLockMemorySize, @@ -687,7 +687,7 @@ shlock = %d, exlock =%d)\n", LOCK->locklock, \ void ExclusiveLock(int lockid) { - SLock *slckP; + SLock *slckP; slckP = &(SLockArray[lockid]); #ifdef LOCKDEBUG @@ -699,29 +699,29 @@ ex_try_again: S_LOCK(&(slckP->locklock)); switch (slckP->flag) { - case NOLOCK: - slckP->flag = EXCLUSIVELOCK; - S_LOCK(&(slckP->exlock)); - S_LOCK(&(slckP->shlock)); - S_UNLOCK(&(slckP->locklock)); + case NOLOCK: + slckP->flag = EXCLUSIVELOCK; + S_LOCK(&(slckP->exlock)); + S_LOCK(&(slckP->shlock)); + S_UNLOCK(&(slckP->locklock)); #ifdef LOCKDEBUG - printf("OUT: "); - PRINT_LOCK(slckP); + printf("OUT: "); + PRINT_LOCK(slckP); #endif - return; - case SHAREDLOCK: - case EXCLUSIVELOCK: - S_UNLOCK(&(slckP->locklock)); - S_LOCK(&(slckP->exlock)); - S_UNLOCK(&(slckP->exlock)); - goto ex_try_again; + return; + case SHAREDLOCK: + case EXCLUSIVELOCK: + S_UNLOCK(&(slckP->locklock)); + S_LOCK(&(slckP->exlock)); + S_UNLOCK(&(slckP->exlock)); + goto ex_try_again; } } void ExclusiveUnlock(int lockid) { - SLock *slckP; + SLock *slckP; slckP = &(SLockArray[lockid]); #ifdef LOCKDEBUG diff --git a/src/backend/storage/ipc/ipci.c b/src/backend/storage/ipc/ipci.c index 4aad8e85f54..b6740b524d7 100644 --- a/src/backend/storage/ipc/ipci.c +++ b/src/backend/storage/ipc/ipci.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.6 1997/09/07 04:48:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipci.c,v 1.7 1997/09/08 02:28:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ SystemPortAddressCreateIPCKey(SystemPortAddress address) void CreateSharedMemoryAndSemaphores(IPCKey key) { - int size; + int size; #ifdef HAS_TEST_AND_SET /* --------------- @@ -114,7 +114,7 @@ CreateSharedMemoryAndSemaphores(IPCKey key) void AttachSharedMemoryAndSemaphores(IPCKey key) { - int size; + int size; /* ---------------- * create rather than attach if using private key diff --git a/src/backend/storage/ipc/s_lock.c b/src/backend/storage/ipc/s_lock.c index 70f0deb62c9..3f75c5bc79b 100644 --- a/src/backend/storage/ipc/s_lock.c +++ b/src/backend/storage/ipc/s_lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.22 1997/09/07 04:48:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/s_lock.c,v 1.23 1997/09/08 02:28:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -161,7 +161,7 @@ S_LOCK_FREE(slock_t * lock) defined(sparc_solaris) /* for xxxxx_solaris, this is defined in port/.../tas.s */ -static int tas(slock_t * lock); +static int tas(slock_t * lock); void S_LOCK(slock_t * lock) @@ -227,9 +227,9 @@ S_INIT_LOCK(slock_t * lock) * a "set" slock_t has a single word cleared. a "clear" slock_t has * all words set to non-zero. */ -static slock_t clear_lock = {-1, -1, -1, -1}; +static slock_t clear_lock = {-1, -1, -1, -1}; -static int tas(slock_t * lock); +static int tas(slock_t * lock); void S_LOCK(slock_t * lock) @@ -253,7 +253,7 @@ S_INIT_LOCK(slock_t * lock) int S_LOCK_FREE(slock_t * lock) { - register int *lock_word = (int *) (((long) lock + 15) & ~15); + register int *lock_word = (int *) (((long) lock + 15) & ~15); return (*lock_word != 0); } @@ -266,7 +266,7 @@ S_LOCK_FREE(slock_t * lock) #if defined(sun3) -static int tas(slock_t * lock); +static int tas(slock_t * lock); void S_LOCK(slock_t * lock) @@ -320,7 +320,7 @@ tas_dummy() #define asm(x) __asm__(x) #endif -static int tas(slock_t * lock); +static int tas(slock_t * lock); static int tas_dummy() @@ -388,7 +388,7 @@ S_INIT_LOCK(unsigned char *addr) void S_LOCK(slock_t * lock) { - slock_t res; + slock_t res; do { @@ -416,7 +416,7 @@ S_INIT_LOCK(slock_t * lock) void S_LOCK(slock_t * lock) { - slock_t res; + slock_t res; do { @@ -456,7 +456,7 @@ S_INIT_LOCK(slock_t * lock) void S_LOCK(slock_t * lock) { - slock_t res; + slock_t res; do { diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 63848171a1f..5a1af74584d 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.11 1997/09/07 04:48:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.12 1997/09/08 02:28:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,23 +70,23 @@ /* shared memory global variables */ -unsigned long ShmemBase = 0; /* start and end address of shared memory */ +unsigned long ShmemBase = 0; /* start and end address of shared memory */ static unsigned long ShmemEnd = 0; static unsigned long ShmemSize = 0; /* current size (and default) */ -SPINLOCK ShmemLock; /* lock for shared memory allocation */ +SPINLOCK ShmemLock; /* lock for shared memory allocation */ -SPINLOCK BindingLock; /* lock for binding table access */ +SPINLOCK BindingLock; /* lock for binding table access */ static unsigned long *ShmemFreeStart = NULL; /* pointer to the OFFSET * of first free shared * memory */ static unsigned long *ShmemBindingTabOffset = NULL; /* start of the binding * table (for bootstrap) */ -static int ShmemBootstrap = FALSE; /* flag becomes true when shared +static int ShmemBootstrap = FALSE; /* flag becomes true when shared * mem is created by POSTMASTER */ -static HTAB *BindingTable = NULL; +static HTAB *BindingTable = NULL; /* --------------------- * ShmemBindingTabReset() - Resets the binding table to NULL.... @@ -142,15 +142,15 @@ ShmemCreate(unsigned int key, unsigned int size) int InitShmem(unsigned int key, unsigned int size) { - Pointer sharedRegion; - unsigned long currFreeSpace; + Pointer sharedRegion; + unsigned long currFreeSpace; - HASHCTL info; - int hash_flags; - BindingEnt *result, - item; - bool found; - IpcMemoryId shmid; + HASHCTL info; + int hash_flags; + BindingEnt *result, + item; + bool found; + IpcMemoryId shmid; /* if zero key, use default memory size */ if (size) @@ -223,8 +223,8 @@ InitShmem(unsigned int key, unsigned int size) /* * Now, check the binding table for an entry to the binding table. If - * there is an entry there, someone else created the table. - * Otherwise, we did and we have to initialize it. + * there is an entry there, someone else created the table. Otherwise, + * we did and we have to initialize it. */ memset(item.key, 0, BTABLE_KEYSIZE); strncpy(item.key, "BindingTable", BTABLE_KEYSIZE); @@ -276,11 +276,11 @@ InitShmem(unsigned int key, unsigned int size) * of space. Has to return a real pointer in order * to be compatable with malloc(). */ -long * +long * ShmemAlloc(unsigned long size) { - unsigned long tmpFree; - long *newSpace; + unsigned long tmpFree; + long *newSpace; /* * ensure space is word aligned. @@ -338,15 +338,15 @@ ShmemIsValid(unsigned long addr) * table at once. Use SpinAlloc() to create a spinlock * for the structure before creating the structure itself. */ -HTAB * +HTAB * ShmemInitHash(char *name, /* table string name for binding */ long init_size, /* initial size */ long max_size, /* max size of the table */ HASHCTL * infoP, /* info about key and bucket size */ int hash_flags) /* info about infoP */ { - bool found; - long *location; + bool found; + long *location; /* * shared memory hash tables have a fixed max size so that the control @@ -402,9 +402,9 @@ ShmemInitHash(char *name, /* table string name for binding */ bool ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr) { - BindingEnt *result, - item; - bool found; + BindingEnt *result, + item; + bool found; Assert(BindingTable); memset(item.key, 0, BTABLE_KEYSIZE); @@ -448,10 +448,10 @@ ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr) SHMEM_OFFSET ShmemPIDDestroy(int pid) { - BindingEnt *result, - item; - bool found; - SHMEM_OFFSET location = 0; + BindingEnt *result, + item; + bool found; + SHMEM_OFFSET location = 0; Assert(BindingTable); @@ -496,12 +496,12 @@ ShmemPIDDestroy(int pid) * the object is already in the binding table (hence, already * initialized). */ -long * +long * ShmemInitStruct(char *name, unsigned long size, bool * foundPtr) { - BindingEnt *result, - item; - long *structPtr; + BindingEnt *result, + item; + long *structPtr; strncpy(item.key, name, BTABLE_KEYSIZE); item.location = BAD_LOCATION; @@ -512,7 +512,7 @@ ShmemInitStruct(char *name, unsigned long size, bool * foundPtr) { /* Assert() is a macro now. substitutes inside quotes. */ #ifndef NO_ASSERT_CHECKING - char *strname = "BindingTable"; + char *strname = "BindingTable"; #endif @@ -613,8 +613,8 @@ ShmemInitStruct(char *name, unsigned long size, bool * foundPtr) bool TransactionIdIsInProgress(TransactionId xid) { - BindingEnt *result; - PROC *proc; + BindingEnt *result; + PROC *proc; Assert(BindingTable); diff --git a/src/backend/storage/ipc/shmqueue.c b/src/backend/storage/ipc/shmqueue.c index 8080fc70208..d4cf06f1718 100644 --- a/src/backend/storage/ipc/shmqueue.c +++ b/src/backend/storage/ipc/shmqueue.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.4 1997/09/07 04:48:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmqueue.c,v 1.5 1997/09/08 02:28:56 momjian Exp $ * * NOTES * @@ -76,8 +76,8 @@ SHMQueueElemInit(SHM_QUEUE * queue) void SHMQueueDelete(SHM_QUEUE * queue) { - SHM_QUEUE *nextElem = (SHM_QUEUE *) MAKE_PTR((queue)->next); - SHM_QUEUE *prevElem = (SHM_QUEUE *) MAKE_PTR((queue)->prev); + SHM_QUEUE *nextElem = (SHM_QUEUE *) MAKE_PTR((queue)->next); + SHM_QUEUE *prevElem = (SHM_QUEUE *) MAKE_PTR((queue)->prev); Assert(SHM_PTR_VALID(queue)); Assert(SHM_PTR_VALID(nextElem)); @@ -99,10 +99,10 @@ SHMQueueDelete(SHM_QUEUE * queue) void dumpQ(SHM_QUEUE * q, char *s) { - char elem[16]; - char buf[1024]; - SHM_QUEUE *start = q; - int count = 0; + char elem[16]; + char buf[1024]; + SHM_QUEUE *start = q; + int count = 0; sprintf(buf, "q prevs: %x", MAKE_OFFSET(q)); q = (SHM_QUEUE *) MAKE_PTR(q->prev); @@ -154,8 +154,8 @@ dumpQ(SHM_QUEUE * q, char *s) void SHMQueueInsertHD(SHM_QUEUE * queue, SHM_QUEUE * elem) { - SHM_QUEUE *prevPtr = (SHM_QUEUE *) MAKE_PTR((queue)->prev); - SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem); + SHM_QUEUE *prevPtr = (SHM_QUEUE *) MAKE_PTR((queue)->prev); + SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem); Assert(SHM_PTR_VALID(queue)); Assert(SHM_PTR_VALID(elem)); @@ -179,8 +179,8 @@ SHMQueueInsertHD(SHM_QUEUE * queue, SHM_QUEUE * elem) void SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem) { - SHM_QUEUE *nextPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next); - SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem); + SHM_QUEUE *nextPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next); + SHMEM_OFFSET elemOffset = MAKE_OFFSET(elem); Assert(SHM_PTR_VALID(queue)); Assert(SHM_PTR_VALID(elem)); @@ -224,7 +224,7 @@ SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem) void SHMQueueFirst(SHM_QUEUE * queue, Pointer * nextPtrPtr, SHM_QUEUE * nextQueue) { - SHM_QUEUE *elemPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next); + SHM_QUEUE *elemPtr = (SHM_QUEUE *) MAKE_PTR((queue)->next); Assert(SHM_PTR_VALID(queue)); *nextPtrPtr = (Pointer) (((unsigned long) *nextPtrPtr) + diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index af16c8a7196..44f7b2b6e96 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.8 1997/09/07 04:48:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.9 1997/09/08 02:28:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,13 +22,13 @@ #include "storage/sinvaladt.h" #include "storage/spin.h" -extern SISeg *shmInvalBuffer; /* the shared buffer segment, set by */ +extern SISeg *shmInvalBuffer; /* the shared buffer segment, set by */ /* SISegmentAttach() */ extern BackendId MyBackendId; extern BackendTag MyBackendTag; -SPINLOCK SInvalLock = (SPINLOCK) NULL; +SPINLOCK SInvalLock = (SPINLOCK) NULL; /****************************************************************************/ /* CreateSharedInvalidationState(key) Create a buffer segment */ @@ -38,7 +38,7 @@ SPINLOCK SInvalLock = (SPINLOCK) NULL; void CreateSharedInvalidationState(IPCKey key) { - int status; + int status; /* * REMOVED SISyncKill(IPCKeyGetSIBufferMemorySemaphoreKey(key)); @@ -62,7 +62,7 @@ CreateSharedInvalidationState(IPCKey key) void AttachSharedInvalidationState(IPCKey key) { - int status; + int status; if (key == PrivateIPCKey) { @@ -165,8 +165,8 @@ RegisterSharedInvalid(int cacheId, /* XXX */ /* should be called by a backend */ /****************************************************************************/ void - InvalidateSharedInvalid(void (*invalFunction) (), - void (*resetFunction) ()) + InvalidateSharedInvalid(void (*invalFunction) (), + void (*resetFunction) ()) { SpinAcquire(SInvalLock); SIReadEntryData(shmInvalBuffer, MyBackendId, diff --git a/src/backend/storage/ipc/sinvaladt.c b/src/backend/storage/ipc/sinvaladt.c index 43c4d7c0ac2..368b2675bd1 100644 --- a/src/backend/storage/ipc/sinvaladt.c +++ b/src/backend/storage/ipc/sinvaladt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.6 1997/09/07 04:48:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinvaladt.c,v 1.7 1997/09/08 02:29:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,19 +49,19 @@ * ---------------- */ #ifdef HAS_TEST_AND_SET -int SharedInvalidationLockId; +int SharedInvalidationLockId; #else -IpcSemaphoreId SharedInvalidationSemaphore; +IpcSemaphoreId SharedInvalidationSemaphore; #endif -SISeg *shmInvalBuffer; +SISeg *shmInvalBuffer; extern BackendId MyBackendId; -static void CleanupInvalidationState(int status, SISeg * segInOutP); +static void CleanupInvalidationState(int status, SISeg * segInOutP); static BackendId SIAssignBackendId(SISeg * segInOutP, BackendTag backendTag); -static int SIGetNumEntries(SISeg * segP); +static int SIGetNumEntries(SISeg * segP); /************************************************************************/ /* SISetActiveProcess(segP, backendId) set the backend status active */ @@ -85,8 +85,8 @@ SISetActiveProcess(SISeg * segInOutP, BackendId backendId) int SIBackendInit(SISeg * segInOutP) { - LRelId LtCreateRelId(); - TransactionId LMITransactionIdCopy(); + LRelId LtCreateRelId(); + TransactionId LMITransactionIdCopy(); Assert(MyBackendTag > 0); @@ -108,11 +108,11 @@ SIBackendInit(SISeg * segInOutP) * SIAssignBackendId * ---------------- */ -static BackendId +static BackendId SIAssignBackendId(SISeg * segInOutP, BackendTag backendTag) { - Index index; - ProcState *stateP; + Index index; + ProcState *stateP; stateP = NULL; @@ -211,12 +211,12 @@ CleanupInvalidationState(int status, /* XXX */ static SISegOffsets * SIComputeSize(int *segSize) { - int A, - B, - a, - b, - totalSize; - SISegOffsets *oP; + int A, + B, + a, + b, + totalSize; + SISegOffsets *oP; A = 0; a = SizeSISeg; /* offset to first data entry */ @@ -245,7 +245,7 @@ SISetStartEntrySection(SISeg * segP, Offset offset) /************************************************************************/ /* SIGetStartEntrySection(segP) - returnss the offset */ /************************************************************************/ -static Offset +static Offset SIGetStartEntrySection(SISeg * segP) { return (segP->startEntrySection); @@ -273,7 +273,7 @@ SISetEndEntryChain(SISeg * segP, Offset offset) /************************************************************************/ /* SIGetEndEntryChain(segP) - returnss the offset */ /************************************************************************/ -static Offset +static Offset SIGetEndEntryChain(SISeg * segP) { return (segP->endEntryChain); @@ -291,7 +291,7 @@ SISetStartEntryChain(SISeg * segP, Offset offset) /************************************************************************/ /* SIGetStartEntryChain(segP) - returns the offset */ /************************************************************************/ -static Offset +static Offset SIGetStartEntryChain(SISeg * segP) { return (segP->startEntryChain); @@ -300,7 +300,7 @@ SIGetStartEntryChain(SISeg * segP) /************************************************************************/ /* SISetNumEntries(segP, num) sets the current nuber of entries */ /************************************************************************/ -static bool +static bool SISetNumEntries(SISeg * segP, int num) { if (num <= MAXNUMMESSAGES) @@ -327,7 +327,7 @@ SIGetNumEntries(SISeg * segP) /************************************************************************/ /* SISetMaxNumEntries(segP, num) sets the maximal number of entries */ /************************************************************************/ -static bool +static bool SISetMaxNumEntries(SISeg * segP, int num) { if (num <= MAXNUMMESSAGES) @@ -354,7 +354,7 @@ SIGetProcStateLimit(SISeg * segP, int i) /************************************************************************/ /* SIIncNumEntries(segP, num) increments the current nuber of entries */ /************************************************************************/ -static bool +static bool SIIncNumEntries(SISeg * segP, int num) { if ((segP->numEntries + num) <= MAXNUMMESSAGES) @@ -371,7 +371,7 @@ SIIncNumEntries(SISeg * segP, int num) /************************************************************************/ /* SIDecNumEntries(segP, num) decrements the current nuber of entries */ /************************************************************************/ -static bool +static bool SIDecNumEntries(SISeg * segP, int num) { if ((segP->numEntries - num) >= 0) @@ -397,7 +397,7 @@ SISetStartFreeSpace(SISeg * segP, Offset offset) /************************************************************************/ /* SIGetStartFreeSpace(segP) - returns the offset */ /************************************************************************/ -static Offset +static Offset SIGetStartFreeSpace(SISeg * segP) { return (segP->startFreeSpace); @@ -411,8 +411,8 @@ SIGetStartFreeSpace(SISeg * segP) static SISegEntry * SIGetFirstDataEntry(SISeg * segP) { - SISegEntry *eP; - Offset startChain; + SISegEntry *eP; + Offset startChain; startChain = SIGetStartEntryChain(segP); @@ -432,8 +432,8 @@ SIGetFirstDataEntry(SISeg * segP) static SISegEntry * SIGetLastDataEntry(SISeg * segP) { - SISegEntry *eP; - Offset endChain; + SISegEntry *eP; + Offset endChain; endChain = SIGetEndEntryChain(segP); @@ -452,7 +452,7 @@ SIGetLastDataEntry(SISeg * segP) static SISegEntry * SIGetNextDataEntry(SISeg * segP, Offset offset) { - SISegEntry *eP; + SISegEntry *eP; if (offset == InvalidOffset) return (NULL); @@ -471,8 +471,8 @@ static SISegEntry * SIGetNthDataEntry(SISeg * segP, int n) /* must range from 1 to MaxMessages */ { - SISegEntry *eP; - int i; + SISegEntry *eP; + int i; if (n <= 0) return (NULL); @@ -490,7 +490,7 @@ SIGetNthDataEntry(SISeg * segP, /************************************************************************/ /* SIEntryOffset(segP, entryP) returns the offset for an pointer */ /************************************************************************/ -static Offset +static Offset SIEntryOffset(SISeg * segP, SISegEntry * entryP) { /* relative to B !! */ @@ -506,9 +506,9 @@ SIEntryOffset(SISeg * segP, SISegEntry * entryP) bool SISetDataEntry(SISeg * segP, SharedInvalidData * data) { - Offset offsetToNewData; - SISegEntry *eP, - *lastP; + Offset offsetToNewData; + SISegEntry *eP, + *lastP; if (!SIIncNumEntries(segP, 1)) return (false); /* no space */ @@ -545,7 +545,7 @@ SISetDataEntry(SISeg * segP, SharedInvalidData * data) static void SIDecProcLimit(SISeg * segP, int num) { - int i; + int i; for (i = 0; i < MaxBackendId; i++) { @@ -570,7 +570,7 @@ SIDecProcLimit(SISeg * segP, int num) bool SIDelDataEntry(SISeg * segP) { - SISegEntry *e1P; + SISegEntry *e1P; if (!SIDecNumEntries(segP, 1)) { @@ -602,7 +602,7 @@ SIDelDataEntry(SISeg * segP) void SISetProcStateInvalid(SISeg * segP) { - int i; + int i; for (i = 0; i < MaxBackendId; i++) { @@ -630,8 +630,8 @@ SIReadEntryData(SISeg * segP, void (*invalFunction) (), void (*resetFunction) ()) { - int i = 0; - SISegEntry *data; + int i = 0; + SISegEntry *data; Assert(segP->procState[backendId - 1].tag == MyBackendTag); @@ -675,9 +675,9 @@ SIReadEntryData(SISeg * segP, void SIDelExpiredDataEntries(SISeg * segP) { - int min, - i, - h; + int min, + i, + h; min = 9999999; for (i = 0; i < MaxBackendId; i++) @@ -711,10 +711,10 @@ SIDelExpiredDataEntries(SISeg * segP) static void SISegInit(SISeg * segP) { - SISegOffsets *oP; - int segSize, - i; - SISegEntry *eP; + SISegOffsets *oP; + int segSize, + i; + SISegEntry *eP; oP = SIComputeSize(&segSize); /* set sempahore ids in the segment */ @@ -771,12 +771,12 @@ SISegmentKill(int key) /* the corresponding key for the segment */ /* SISegmentGet(key, size) - get a shared segment of size <size> */ /* returns a segment id */ /************************************************************************/ -static IpcMemoryId +static IpcMemoryId SISegmentGet(int key, /* the corresponding key for the segment */ int size, /* size of segment in bytes */ bool create) { - IpcMemoryId shmid; + IpcMemoryId shmid; if (create) { @@ -811,10 +811,10 @@ SISegmentAttach(IpcMemoryId shmid) int SISegmentInit(bool killExistingSegment, IPCKey key) { - SISegOffsets *oP; - int segSize; - IpcMemoryId shmId; - bool create; + SISegOffsets *oP; + int segSize; + IpcMemoryId shmId; + bool create; if (killExistingSegment) { diff --git a/src/backend/storage/ipc/spin.c b/src/backend/storage/ipc/spin.c index e93d5894a58..3443c2db95b 100644 --- a/src/backend/storage/ipc/spin.c +++ b/src/backend/storage/ipc/spin.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.7 1997/09/07 04:48:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/Attic/spin.c,v 1.8 1997/09/08 02:29:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,7 +36,7 @@ #endif /* globals used in this file */ -IpcSemaphoreId SpinLockId; +IpcSemaphoreId SpinLockId; #ifdef HAS_TEST_AND_SET /* real spin lock implementations */ @@ -97,8 +97,8 @@ SpinRelease(SPINLOCK lock) #else /* HAS_TEST_AND_SET */ /* Spinlocks are implemented using SysV semaphores */ -static bool AttachSpinLocks(IPCKey key); -static bool SpinIsLocked(SPINLOCK lock); +static bool AttachSpinLocks(IPCKey key); +static bool SpinIsLocked(SPINLOCK lock); /* * SpinAcquire -- try to grab a spinlock @@ -125,10 +125,10 @@ SpinRelease(SPINLOCK lock) IpcSemaphoreUnlock(SpinLockId, lock, IpcExclusiveLock); } -static bool +static bool SpinIsLocked(SPINLOCK lock) { - int semval; + int semval; semval = IpcSemaphoreGetValue(SpinLockId, lock); return (semval < IpcSemaphoreDefaultStartValue); @@ -143,8 +143,8 @@ bool CreateSpinlocks(IPCKey key) { - int status; - IpcSemaphoreId semid; + int status; + IpcSemaphoreId semid; semid = IpcSemaphoreCreate(key, MAX_SPINS, IPCProtection, IpcSemaphoreDefaultStartValue, 1, &status); @@ -169,10 +169,10 @@ CreateSpinlocks(IPCKey key) /* * Attach to existing spinlock set */ -static bool +static bool AttachSpinLocks(IPCKey key) { - IpcSemaphoreId id; + IpcSemaphoreId id; id = semget(key, MAX_SPINS, 0); if (id < 0) diff --git a/src/backend/storage/large_object/inv_api.c b/src/backend/storage/large_object/inv_api.c index dfde8f469c5..bacd56b4548 100644 --- a/src/backend/storage/large_object/inv_api.c +++ b/src/backend/storage/large_object/inv_api.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.14 1997/09/07 04:48:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/large_object/inv_api.c,v 1.15 1997/09/08 02:29:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -67,12 +67,12 @@ static HeapTuple inv_newtuple(LargeObjectDesc * obj_desc, Buffer buffer, Page page, char *dbuf, int nwrite); static HeapTuple inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP); -static int inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes); +static int inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes); static int inv_wrold(LargeObjectDesc * obj_desc, char *dbuf, int nbytes, HeapTuple htup, Buffer buffer); -static void inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup); -static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln); +static void inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup); +static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln); /* * inv_create -- create a new large object. @@ -86,17 +86,17 @@ static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln); LargeObjectDesc * inv_create(int flags) { - int file_oid; + int file_oid; LargeObjectDesc *retval; - Relation r; - Relation indr; - int smgr; - char archchar; - TupleDesc tupdesc; - AttrNumber attNums[1]; - Oid classObjectId[1]; - char objname[NAMEDATALEN]; - char indname[NAMEDATALEN]; + Relation r; + Relation indr; + int smgr; + char archchar; + TupleDesc tupdesc; + AttrNumber attNums[1]; + Oid classObjectId[1]; + char objname[NAMEDATALEN]; + char indname[NAMEDATALEN]; /* parse flags */ smgr = flags & INV_SMGRMASK; @@ -217,9 +217,9 @@ LargeObjectDesc * inv_open(Oid lobjId, int flags) { LargeObjectDesc *retval; - Relation r; - char *indname; - Relation indrel; + Relation r; + char *indname; + Relation indrel; r = heap_open(lobjId); @@ -288,7 +288,7 @@ inv_close(LargeObjectDesc * obj_desc) int inv_destroy(Oid lobjId) { - Relation r; + Relation r; r = (Relation) RelationIdGetRelation(lobjId); if (!RelationIsValid(r) || r->rd_rel->relkind == RELKIND_INDEX) @@ -348,9 +348,9 @@ inv_stat(LargeObjectDesc * obj_desc, struct pgstat * stbuf) int inv_seek(LargeObjectDesc * obj_desc, int offset, int whence) { - int oldOffset; - Datum d; - ScanKeyData skey; + int oldOffset; + Datum d; + ScanKeyData skey; Assert(PointerIsValid(obj_desc)); @@ -433,14 +433,14 @@ inv_tell(LargeObjectDesc * obj_desc) int inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes) { - HeapTuple htup; - Buffer b; - int nread; - int off; - int ncopy; - Datum d; + HeapTuple htup; + Buffer b; + int nread; + int off; + int ncopy; + Datum d; struct varlena *fsblock; - bool isNull; + bool isNull; Assert(PointerIsValid(obj_desc)); Assert(buf != NULL); @@ -497,10 +497,10 @@ inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes) int inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes) { - HeapTuple htup; - Buffer b; - int nwritten; - int tuplen; + HeapTuple htup; + Buffer b; + int nwritten; + int tuplen; Assert(PointerIsValid(obj_desc)); Assert(buf != NULL); @@ -575,16 +575,16 @@ inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes) * A heap tuple containing the desired block, or NULL if no * such tuple exists. */ -static HeapTuple +static HeapTuple inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP) { - HeapTuple htup; + HeapTuple htup; RetrieveIndexResult res; - Datum d; - int firstbyte, - lastbyte; + Datum d; + int firstbyte, + lastbyte; struct varlena *fsblock; - bool isNull; + bool isNull; /* * If we've exhausted the current block, we need to get the next one. @@ -601,7 +601,7 @@ inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP) /* initialize scan key if not done */ if (obj_desc->iscan == (IndexScanDesc) NULL) { - ScanKeyData skey; + ScanKeyData skey; ScanKeyEntryInitialize(&skey, 0x0, 1, INT4GE_PROC_OID, Int32GetDatum(0)); @@ -693,12 +693,12 @@ inv_fetchtup(LargeObjectDesc * obj_desc, Buffer * bufP) static int inv_wrnew(LargeObjectDesc * obj_desc, char *buf, int nbytes) { - Relation hr; - HeapTuple ntup; - Buffer buffer; - Page page; - int nblocks; - int nwritten; + Relation hr; + HeapTuple ntup; + Buffer buffer; + Page page; + int nblocks; + int nwritten; hr = obj_desc->heap_r; @@ -768,19 +768,19 @@ inv_wrold(LargeObjectDesc * obj_desc, HeapTuple htup, Buffer buffer) { - Relation hr; - HeapTuple ntup; - Buffer newbuf; - Page page; - Page newpage; - int tupbytes; - Datum d; + Relation hr; + HeapTuple ntup; + Buffer newbuf; + Page page; + Page newpage; + int tupbytes; + Datum d; struct varlena *fsblock; - int nwritten, - nblocks, - freespc; - bool isNull; - int keep_offset; + int nwritten, + nblocks, + freespc; + bool isNull; + int keep_offset; /* * Since we're using a no-overwrite storage manager, the way we @@ -938,23 +938,23 @@ inv_wrold(LargeObjectDesc * obj_desc, return (nwritten); } -static HeapTuple +static HeapTuple inv_newtuple(LargeObjectDesc * obj_desc, Buffer buffer, Page page, char *dbuf, int nwrite) { - HeapTuple ntup; - PageHeader ph; - int tupsize; - int hoff; - Offset lower; - Offset upper; - ItemId itemId; - OffsetNumber off; - OffsetNumber limit; - char *attptr; + HeapTuple ntup; + PageHeader ph; + int tupsize; + int hoff; + Offset lower; + Offset upper; + ItemId itemId; + OffsetNumber off; + OffsetNumber limit; + char *attptr; /* compute tuple size -- no nulls */ hoff = sizeof(HeapTupleData) - sizeof(ntup->t_bits); @@ -1035,7 +1035,7 @@ inv_newtuple(LargeObjectDesc * obj_desc, * * mer fixed disk layout of varlenas to get rid of the need for * this. * * - * *((int32 *) attptr) = nwrite + sizeof(int32); * attptr += + *((int32 *) attptr) = nwrite + sizeof(int32); * attptr += * sizeof(int32); */ @@ -1064,8 +1064,8 @@ static void inv_indextup(LargeObjectDesc * obj_desc, HeapTuple htup) { InsertIndexResult res; - Datum v[1]; - char n[1]; + Datum v[1]; + char n[1]; n[0] = ' '; v[0] = Int32GetDatum(obj_desc->highbyte); @@ -1173,13 +1173,13 @@ ItemPointerFormExternal(ItemPointer pointer) static int _inv_getsize(Relation hreln, TupleDesc hdesc, Relation ireln) { - IndexScanDesc iscan; + IndexScanDesc iscan; RetrieveIndexResult res; - Buffer buf; - HeapTuple htup; - Datum d; - long size; - bool isNull; + Buffer buf; + HeapTuple htup; + Datum d; + long size; + bool isNull; /* scan backwards from end */ iscan = index_beginscan(ireln, (bool) 1, 0, (ScanKey) NULL); diff --git a/src/backend/storage/lmgr/lmgr.c b/src/backend/storage/lmgr/lmgr.c index 555303fa14e..495a11f76a5 100644 --- a/src/backend/storage/lmgr/lmgr.c +++ b/src/backend/storage/lmgr/lmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.6 1997/09/07 04:48:51 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lmgr.c,v 1.7 1997/09/08 02:29:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,7 +48,7 @@ #include "storage/bufmgr.h" #include "access/transam.h" /* for AmiTransactionId */ -static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId); +static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId); /* ---------------- * @@ -67,9 +67,9 @@ static void LRelIdAssign(LRelId * lRelId, Oid dbId, Oid relId); #define TupleLevelLockLimit 10 -extern Oid MyDatabaseId; +extern Oid MyDatabaseId; -static LRelId VariableRelationLRelId = { +static LRelId VariableRelationLRelId = { RelOid_pg_variable, InvalidOid }; @@ -93,7 +93,7 @@ elog(NOTICE, "RelationGetLRelId(%s) invalid lockInfo", \ LRelId RelationGetLRelId(Relation relation) { - LockInfo linfo; + LockInfo linfo; /* ---------------- * sanity checks @@ -199,11 +199,11 @@ LRelIdContainsMyDatabaseId(LRelId lRelId) void RelationInitLockInfo(Relation relation) { - LockInfo info; - char *relname; - Oid relationid; - bool processingVariable; - extern Oid MyDatabaseId; /* XXX use include */ + LockInfo info; + char *relname; + Oid relationid; + bool processingVariable; + extern Oid MyDatabaseId; /* XXX use include */ extern GlobalMemory CacheCxt; /* ---------------- @@ -228,7 +228,7 @@ RelationInitLockInfo(Relation relation) */ if (!PointerIsValid(info)) { - MemoryContext oldcxt; + MemoryContext oldcxt; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); info = (LockInfo) palloc(sizeof(LockInfoData)); @@ -366,7 +366,7 @@ elog(DEBUG, "RelationSetLockForRead(%s[%d,%d]) called", \ void RelationSetLockForRead(Relation relation) { - LockInfo linfo; + LockInfo linfo; /* ---------------- * sanity checks @@ -416,7 +416,7 @@ elog(DEBUG, "RelationUnsetLockForRead(%s[%d,%d]) called", \ void RelationUnsetLockForRead(Relation relation) { - LockInfo linfo; + LockInfo linfo; /* ---------------- * sanity check @@ -462,7 +462,7 @@ elog(DEBUG, "RelationSetLockForWrite(%s[%d,%d]) called", \ void RelationSetLockForWrite(Relation relation) { - LockInfo linfo; + LockInfo linfo; /* ---------------- * sanity checks @@ -512,7 +512,7 @@ elog(DEBUG, "RelationUnsetLockForWrite(%s[%d,%d]) called", \ void RelationUnsetLockForWrite(Relation relation) { - LockInfo linfo; + LockInfo linfo; /* ---------------- * sanity checks @@ -560,8 +560,8 @@ elog(DEBUG, "RelationSetLockForTupleRead(%s[%d,%d], 0x%x) called", \ void RelationSetLockForTupleRead(Relation relation, ItemPointer itemPointer) { - LockInfo linfo; - TransactionId curXact; + LockInfo linfo; + TransactionId curXact; /* ---------------- * sanity checks diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 7e592945f1b..3bcef3549c8 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.12 1997/09/07 04:48:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.13 1997/09/08 02:29:15 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -63,9 +63,9 @@ WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock, #else /* LOCK_MGR_DEBUG */ -int lockDebug = 0; -unsigned int lock_debug_oid_min = BootstrapObjectIdData; -static char *lock_types[] = { +int lockDebug = 0; +unsigned int lock_debug_oid_min = BootstrapObjectIdData; +static char *lock_types[] = { "NONE", "WRITE", "READ", @@ -127,19 +127,19 @@ static char *lock_types[] = { #endif /* LOCK_MGR_DEBUG */ -SPINLOCK LockMgrLock; /* in Shmem or created in +SPINLOCK LockMgrLock; /* in Shmem or created in * CreateSpinlocks() */ /* This is to simplify/speed up some bit arithmetic */ -static MASK BITS_OFF[MAX_LOCKTYPES]; -static MASK BITS_ON[MAX_LOCKTYPES]; +static MASK BITS_OFF[MAX_LOCKTYPES]; +static MASK BITS_ON[MAX_LOCKTYPES]; /* ----------------- * XXX Want to move this to this file * ----------------- */ -static bool LockingIsDisabled; +static bool LockingIsDisabled; /* ------------------- * map from tableId to the lock table structure @@ -151,7 +151,7 @@ static LOCKTAB *AllTables[MAX_TABLES]; * no zero-th table * ------------------- */ -static int NumTables = 1; +static int NumTables = 1; /* ------------------- * InitLocks -- Init the lock module. Create a private data @@ -161,8 +161,8 @@ static int NumTables = 1; void InitLocks() { - int i; - int bit; + int i; + int bit; bit = 1; /* ------------------- @@ -199,7 +199,7 @@ LockTypeInit(LOCKTAB * ltable, int *prioP, int ntypes) { - int i; + int i; ltable->ctl->nLockTypes = ntypes; ntypes++; @@ -226,12 +226,12 @@ LockTabInit(char *tabName, int *prioP, int ntypes) { - LOCKTAB *ltable; - char *shmemName; - HASHCTL info; - int hash_flags; - bool found; - int status = TRUE; + LOCKTAB *ltable; + char *shmemName; + HASHCTL info; + int hash_flags; + bool found; + int status = TRUE; if (ntypes > MAX_LOCKTYPES) { @@ -378,7 +378,7 @@ LockTabInit(char *tabName, LockTableId LockTabRename(LockTableId tableId) { - LockTableId newTableId; + LockTableId newTableId; if (NumTables >= MAX_TABLES) { @@ -454,18 +454,18 @@ LockTabRename(LockTableId tableId) bool LockAcquire(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt) { - XIDLookupEnt *result, - item; - HTAB *xidTable; - bool found; - LOCK *lock = NULL; - SPINLOCK masterLock; - LOCKTAB *ltable; - int status; - TransactionId myXid; + XIDLookupEnt *result, + item; + HTAB *xidTable; + bool found; + LOCK *lock = NULL; + SPINLOCK masterLock; + LOCKTAB *ltable; + int status; + TransactionId myXid; #ifdef USER_LOCKS - int is_user_lock; + int is_user_lock; is_user_lock = (tableId == 0); if (is_user_lock) @@ -661,15 +661,15 @@ LockResolveConflicts(LOCKTAB * ltable, LOCKT lockt, TransactionId xid) { - XIDLookupEnt *result, - item; - int *myHolders; - int nLockTypes; - HTAB *xidTable; - bool found; - int bitmask; - int i, - tmpMask; + XIDLookupEnt *result, + item; + int *myHolders; + int nLockTypes; + HTAB *xidTable; + bool found; + int bitmask; + int i, + tmpMask; nLockTypes = ltable->ctl->nLockTypes; xidTable = ltable->xidHash; @@ -772,9 +772,9 @@ LockResolveConflicts(LOCKTAB * ltable, static int WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock, LOCKT lockt) { - PROC_QUEUE *waitQueue = &(lock->waitProcs); + PROC_QUEUE *waitQueue = &(lock->waitProcs); - int prio = ltable->ctl->prio[lockt]; + int prio = ltable->ctl->prio[lockt]; /* * the waitqueue is ordered by priority. I insert myself according to @@ -821,17 +821,17 @@ WaitOnLock(LOCKTAB * ltable, LockTableId tableId, LOCK * lock, LOCKT lockt) bool LockRelease(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt) { - LOCK *lock = NULL; - SPINLOCK masterLock; - bool found; - LOCKTAB *ltable; - XIDLookupEnt *result, - item; - HTAB *xidTable; - bool wakeupNeeded = true; + LOCK *lock = NULL; + SPINLOCK masterLock; + bool found; + LOCKTAB *ltable; + XIDLookupEnt *result, + item; + HTAB *xidTable; + bool wakeupNeeded = true; #ifdef USER_LOCKS - int is_user_lock; + int is_user_lock; is_user_lock = (tableId == 0); if (is_user_lock) @@ -1125,23 +1125,23 @@ GrantLock(LOCK * lock, LOCKT lockt) bool LockReleaseAll(LockTableId tableId, SHM_QUEUE * lockQueue) { - PROC_QUEUE *waitQueue; - int done; - XIDLookupEnt *xidLook = NULL; - XIDLookupEnt *tmp = NULL; - SHMEM_OFFSET end = MAKE_OFFSET(lockQueue); - SPINLOCK masterLock; - LOCKTAB *ltable; - int i, - nLockTypes; - LOCK *lock; - bool found; + PROC_QUEUE *waitQueue; + int done; + XIDLookupEnt *xidLook = NULL; + XIDLookupEnt *tmp = NULL; + SHMEM_OFFSET end = MAKE_OFFSET(lockQueue); + SPINLOCK masterLock; + LOCKTAB *ltable; + int i, + nLockTypes; + LOCK *lock; + bool found; #ifdef USER_LOCKS - int is_user_lock_table, - my_pid, - count, - nskip; + int is_user_lock_table, + my_pid, + count, + nskip; is_user_lock_table = (tableId == 0); my_pid = getpid(); @@ -1359,11 +1359,11 @@ next_item: int LockShmemSize() { - int size = 0; - int nLockBuckets, - nLockSegs; - int nXidBuckets, - nXidSegs; + int size = 0; + int nLockBuckets, + nLockSegs; + int nXidBuckets, + nXidSegs; nLockBuckets = 1 << (int) my_log2((NLOCKENTS - 1) / DEF_FFACTOR + 1); nLockSegs = 1 << (int) my_log2((nLockBuckets - 1) / DEF_SEGSIZE + 1); @@ -1409,20 +1409,20 @@ LockingDisabled() void DumpLocks() { - SHMEM_OFFSET location; - PROC *proc; - SHM_QUEUE *lockQueue; - int done; - XIDLookupEnt *xidLook = NULL; - XIDLookupEnt *tmp = NULL; - SHMEM_OFFSET end; - SPINLOCK masterLock; - int nLockTypes; - LOCK *lock; - int pid, - count; - int tableId = 1; - LOCKTAB *ltable; + SHMEM_OFFSET location; + PROC *proc; + SHM_QUEUE *lockQueue; + int done; + XIDLookupEnt *xidLook = NULL; + XIDLookupEnt *tmp = NULL; + SHMEM_OFFSET end; + SPINLOCK masterLock; + int nLockTypes; + LOCK *lock; + int pid, + count; + int tableId = 1; + LOCKTAB *ltable; pid = getpid(); ShmemPIDLookup(pid, &location); diff --git a/src/backend/storage/lmgr/multi.c b/src/backend/storage/lmgr/multi.c index d5466fce04c..529c889b163 100644 --- a/src/backend/storage/lmgr/multi.c +++ b/src/backend/storage/lmgr/multi.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.5 1997/09/07 04:49:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/multi.c,v 1.6 1997/09/08 02:29:16 momjian Exp $ * * NOTES: * (1) The lock.c module assumes that the caller here is doing @@ -43,7 +43,7 @@ MultiRelease(LockTableId tableId, LOCKTAG * tag, LOCKT lockt, * WRITE conflict between the tuple's intent lock and the relation's * write lock. */ -static int MultiConflicts[] = { +static int MultiConflicts[] = { (int) NULL, /* All reads and writes at any level conflict with a write lock */ (1 << WRITE_LOCK) | (1 << WRITE_INTENT) | (1 << READ_LOCK) | (1 << READ_INTENT), @@ -65,7 +65,7 @@ static int MultiConflicts[] = { * write locks have higher priority than read locks and extend locks. May * want to treat INTENT locks differently. */ -static int MultiPrios[] = { +static int MultiPrios[] = { (int) NULL, 2, 1, @@ -78,8 +78,8 @@ static int MultiPrios[] = { * Lock table identifier for this lock table. The multi-level * lock table is ONE lock table, not three. */ -LockTableId MultiTableId = (LockTableId) NULL; -LockTableId ShortTermTableId = (LockTableId) NULL; +LockTableId MultiTableId = (LockTableId) NULL; +LockTableId ShortTermTableId = (LockTableId) NULL; /* * Create the lock table described by MultiConflicts and Multiprio. @@ -87,7 +87,7 @@ LockTableId ShortTermTableId = (LockTableId) NULL; LockTableId InitMultiLevelLockm() { - int tableId; + int tableId; /* ----------------------- * If we're already initialized just return the table id. @@ -122,7 +122,7 @@ InitMultiLevelLockm() bool MultiLockReln(LockInfo linfo, LOCKT lockt) { - LOCKTAG tag; + LOCKTAG tag; /* * LOCKTAG has two bytes of padding, unfortunately. The hash function @@ -145,7 +145,7 @@ MultiLockReln(LockInfo linfo, LOCKT lockt) bool MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) { - LOCKTAG tag; + LOCKTAG tag; /* * LOCKTAG has two bytes of padding, unfortunately. The hash function @@ -167,7 +167,7 @@ MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) bool MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) { - LOCKTAG tag; + LOCKTAG tag; /* * LOCKTAG has two bytes of padding, unfortunately. The hash function @@ -197,18 +197,18 @@ MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) * Returns: TRUE if lock is set, FALSE if not * Side Effects: */ -static bool +static bool MultiAcquire(LockTableId tableId, LOCKTAG * tag, LOCKT lockt, LOCK_LEVEL level) { - LOCKT locks[N_LEVELS]; - int i, - status; - LOCKTAG xxTag, - *tmpTag = &xxTag; - int retStatus = TRUE; + LOCKT locks[N_LEVELS]; + int i, + status; + LOCKTAG xxTag, + *tmpTag = &xxTag; + int retStatus = TRUE; /* * Three levels implemented. If we set a low level (e.g. Tuple) lock, @@ -221,24 +221,24 @@ MultiAcquire(LockTableId tableId, */ switch (level) { - case RELN_LEVEL: - locks[0] = lockt; - locks[1] = NO_LOCK; - locks[2] = NO_LOCK; - break; - case PAGE_LEVEL: - locks[0] = lockt + INTENT; - locks[1] = lockt; - locks[2] = NO_LOCK; - break; - case TUPLE_LEVEL: - locks[0] = lockt + INTENT; - locks[1] = lockt + INTENT; - locks[2] = lockt; - break; - default: - elog(WARN, "MultiAcquire: bad lock level"); - return (FALSE); + case RELN_LEVEL: + locks[0] = lockt; + locks[1] = NO_LOCK; + locks[2] = NO_LOCK; + break; + case PAGE_LEVEL: + locks[0] = lockt + INTENT; + locks[1] = lockt; + locks[2] = NO_LOCK; + break; + case TUPLE_LEVEL: + locks[0] = lockt + INTENT; + locks[1] = lockt + INTENT; + locks[2] = lockt; + break; + default: + elog(WARN, "MultiAcquire: bad lock level"); + return (FALSE); } /* @@ -257,30 +257,30 @@ MultiAcquire(LockTableId tableId, { switch (i) { - case RELN_LEVEL: - /* ------------- - * Set the block # and offset to invalid - * ------------- - */ - BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber); - tmpTag->tupleId.ip_posid = InvalidOffsetNumber; - break; - case PAGE_LEVEL: - /* ------------- - * Copy the block #, set the offset to invalid - * ------------- - */ - BlockIdCopy(&(tmpTag->tupleId.ip_blkid), - &(tag->tupleId.ip_blkid)); - tmpTag->tupleId.ip_posid = InvalidOffsetNumber; - break; - case TUPLE_LEVEL: - /* -------------- - * Copy the entire tuple id. - * -------------- - */ - ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId); - break; + case RELN_LEVEL: + /* ------------- + * Set the block # and offset to invalid + * ------------- + */ + BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber); + tmpTag->tupleId.ip_posid = InvalidOffsetNumber; + break; + case PAGE_LEVEL: + /* ------------- + * Copy the block #, set the offset to invalid + * ------------- + */ + BlockIdCopy(&(tmpTag->tupleId.ip_blkid), + &(tag->tupleId.ip_blkid)); + tmpTag->tupleId.ip_posid = InvalidOffsetNumber; + break; + case TUPLE_LEVEL: + /* -------------- + * Copy the entire tuple id. + * -------------- + */ + ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId); + break; } status = LockAcquire(tableId, tmpTag, locks[i]); @@ -311,7 +311,7 @@ MultiAcquire(LockTableId tableId, bool MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) { - LOCKTAG tag; + LOCKTAG tag; /* ------------------ * LOCKTAG has two bytes of padding, unfortunately. The @@ -337,7 +337,7 @@ MultiReleasePage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt) bool MultiReleaseReln(LockInfo linfo, LOCKT lockt) { - LOCKTAG tag; + LOCKTAG tag; /* ------------------ * LOCKTAG has two bytes of padding, unfortunately. The @@ -357,40 +357,40 @@ MultiReleaseReln(LockInfo linfo, LOCKT lockt) * * Returns: TRUE if successful, FALSE otherwise. */ -static bool +static bool MultiRelease(LockTableId tableId, LOCKTAG * tag, LOCKT lockt, LOCK_LEVEL level) { - LOCKT locks[N_LEVELS]; - int i, - status; - LOCKTAG xxTag, - *tmpTag = &xxTag; + LOCKT locks[N_LEVELS]; + int i, + status; + LOCKTAG xxTag, + *tmpTag = &xxTag; /* * same level scheme as MultiAcquire(). */ switch (level) { - case RELN_LEVEL: - locks[0] = lockt; - locks[1] = NO_LOCK; - locks[2] = NO_LOCK; - break; - case PAGE_LEVEL: - locks[0] = lockt + INTENT; - locks[1] = lockt; - locks[2] = NO_LOCK; - break; - case TUPLE_LEVEL: - locks[0] = lockt + INTENT; - locks[1] = lockt + INTENT; - locks[2] = lockt; - break; - default: - elog(WARN, "MultiRelease: bad lockt"); + case RELN_LEVEL: + locks[0] = lockt; + locks[1] = NO_LOCK; + locks[2] = NO_LOCK; + break; + case PAGE_LEVEL: + locks[0] = lockt + INTENT; + locks[1] = lockt; + locks[2] = NO_LOCK; + break; + case TUPLE_LEVEL: + locks[0] = lockt + INTENT; + locks[1] = lockt + INTENT; + locks[2] = lockt; + break; + default: + elog(WARN, "MultiRelease: bad lockt"); } /* @@ -411,26 +411,26 @@ MultiRelease(LockTableId tableId, { switch (i) { - case RELN_LEVEL: - /* ------------- - * Set the block # and offset to invalid - * ------------- - */ - BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber); - tmpTag->tupleId.ip_posid = InvalidOffsetNumber; - break; - case PAGE_LEVEL: - /* ------------- - * Copy the block #, set the offset to invalid - * ------------- - */ - BlockIdCopy(&(tmpTag->tupleId.ip_blkid), - &(tag->tupleId.ip_blkid)); - tmpTag->tupleId.ip_posid = InvalidOffsetNumber; - break; - case TUPLE_LEVEL: - ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId); - break; + case RELN_LEVEL: + /* ------------- + * Set the block # and offset to invalid + * ------------- + */ + BlockIdSet(&(tmpTag->tupleId.ip_blkid), InvalidBlockNumber); + tmpTag->tupleId.ip_posid = InvalidOffsetNumber; + break; + case PAGE_LEVEL: + /* ------------- + * Copy the block #, set the offset to invalid + * ------------- + */ + BlockIdCopy(&(tmpTag->tupleId.ip_blkid), + &(tag->tupleId.ip_blkid)); + tmpTag->tupleId.ip_posid = InvalidOffsetNumber; + break; + case TUPLE_LEVEL: + ItemPointerCopy(&tmpTag->tupleId, &tag->tupleId); + break; } status = LockRelease(tableId, tmpTag, locks[i]); if (!status) diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index e3872091dfc..ddcb4ac7248 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.19 1997/09/07 04:49:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.20 1997/09/08 02:29:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,7 @@ * This is so that we can support more backends. (system-wide semaphore * sets run out pretty fast.) -ay 4/95 * - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.19 1997/09/07 04:49:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.20 1997/09/08 02:29:17 momjian Exp $ */ #include <sys/time.h> #include <unistd.h> @@ -76,8 +76,8 @@ #include "storage/spin.h" #include "storage/proc.h" -static void HandleDeadLock(int sig); -static PROC *ProcWakeup(PROC * proc, int errType); +static void HandleDeadLock(int sig); +static PROC *ProcWakeup(PROC * proc, int errType); /* * timeout (in seconds) for resolving possible deadlock @@ -93,21 +93,21 @@ static PROC *ProcWakeup(PROC * proc, int errType); * memory. -mer 17 July 1991 * -------------------- */ -SPINLOCK ProcStructLock; +SPINLOCK ProcStructLock; /* * For cleanup routines. Don't cleanup if the initialization * has not happened. */ -static bool ProcInitialized = FALSE; +static bool ProcInitialized = FALSE; static PROC_HDR *ProcGlobal = NULL; -PROC *MyProc = NULL; +PROC *MyProc = NULL; -static void ProcKill(int exitStatus, int pid); -static void ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum); -static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum); +static void ProcKill(int exitStatus, int pid); +static void ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum); +static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum); /* * InitProcGlobal - @@ -120,7 +120,7 @@ static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum); void InitProcGlobal(IPCKey key) { - bool found = false; + bool found = false; /* attach to the free list */ ProcGlobal = (PROC_HDR *) @@ -132,7 +132,7 @@ InitProcGlobal(IPCKey key) */ if (!found) { - int i; + int i; ProcGlobal->numProcs = 0; ProcGlobal->freeProcs = INVALID_OFFSET; @@ -150,11 +150,11 @@ InitProcGlobal(IPCKey key) void InitProcess(IPCKey key) { - bool found = false; - int pid; - int semstat; - unsigned long location, - myOffset; + bool found = false; + int pid; + int semstat; + unsigned long location, + myOffset; /* ------------------ * Routine called if deadlock timer goes off. See ProcSleep() @@ -223,10 +223,10 @@ InitProcess(IPCKey key) if (IsUnderPostmaster) { - IPCKey semKey; - int semNum; - int semId; - union semun semun; + IPCKey semKey; + int semNum; + int semId; + union semun semun; ProcGetNewSemKeyAndNum(&semKey, &semNum); @@ -318,8 +318,8 @@ ProcReleaseLocks() bool ProcRemove(int pid) { - SHMEM_OFFSET location; - PROC *proc; + SHMEM_OFFSET location; + PROC *proc; location = INVALID_OFFSET; @@ -347,8 +347,8 @@ ProcRemove(int pid) static void ProcKill(int exitStatus, int pid) { - PROC *proc; - SHMEM_OFFSET location; + PROC *proc; + SHMEM_OFFSET location; /* -------------------- * If this is a FATAL exit the postmaster will have to kill all the @@ -417,11 +417,11 @@ ProcKill(int exitStatus, int pid) * Side Effects: Initializes the queue if we allocated one */ #ifdef NOT_USED -PROC_QUEUE * +PROC_QUEUE * ProcQueueAlloc(char *name) { - bool found; - PROC_QUEUE *queue = (PROC_QUEUE *) + bool found; + PROC_QUEUE *queue = (PROC_QUEUE *) ShmemInitStruct(name, (unsigned) sizeof(PROC_QUEUE), &found); if (!queue) @@ -468,10 +468,10 @@ ProcSleep(PROC_QUEUE * queue, int prio, LOCK * lock) { - int i; - PROC *proc; + int i; + PROC *proc; struct itimerval timeval, - dummy; + dummy; proc = (PROC *) MAKE_PTR(queue->links.prev); for (i = 0; i < queue->size; i++) @@ -555,10 +555,10 @@ ProcSleep(PROC_QUEUE * queue, * remove the process from the wait queue and set its links invalid. * RETURN: the next process in the wait queue. */ -static PROC * +static PROC * ProcWakeup(PROC * proc, int errType) { - PROC *retProc; + PROC *retProc; /* assume that spinlock has been acquired */ @@ -599,8 +599,8 @@ ProcGetId() int ProcLockWakeup(PROC_QUEUE * queue, char *ltable, char *lock) { - PROC *proc; - int count; + PROC *proc; + int count; if (!queue->size) return (STATUS_NOT_FOUND); @@ -659,8 +659,8 @@ ProcAddLock(SHM_QUEUE * elem) static void HandleDeadLock(int sig) { - LOCK *lock; - int size; + LOCK *lock; + int size; LockLockTable(); @@ -743,7 +743,7 @@ HandleDeadLock(int sig) void ProcReleaseSpins(PROC * proc) { - int i; + int i; if (!proc) proc = MyProc; @@ -774,9 +774,9 @@ ProcReleaseSpins(PROC * proc) static void ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum) { - int i; - int32 *freeSemMap = ProcGlobal->freeSemMap; - unsigned int fullmask; + int i; + int32 *freeSemMap = ProcGlobal->freeSemMap; + unsigned int fullmask; /* * we hold ProcStructLock when entering this routine. We scan through @@ -785,8 +785,8 @@ ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum) fullmask = ~0 >> (32 - PROC_NSEMS_PER_SET); for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++) { - int mask = 1; - int j; + int mask = 1; + int j; if (freeSemMap[i] == fullmask) continue; /* none free for this set */ @@ -821,9 +821,9 @@ ProcGetNewSemKeyAndNum(IPCKey * key, int *semNum) static void ProcFreeSem(IpcSemaphoreKey semKey, int semNum) { - int mask; - int i; - int32 *freeSemMap = ProcGlobal->freeSemMap; + int mask; + int i; + int32 *freeSemMap = ProcGlobal->freeSemMap; i = semKey - ProcGlobal->currKey; mask = ~(1 << semNum); @@ -841,8 +841,8 @@ ProcFreeSem(IpcSemaphoreKey semKey, int semNum) void ProcFreeAllSemaphores() { - int i; - int32 *freeSemMap = ProcGlobal->freeSemMap; + int i; + int32 *freeSemMap = ProcGlobal->freeSemMap; for (i = 0; i < MAX_PROC_SEMS / PROC_NSEMS_PER_SET; i++) { diff --git a/src/backend/storage/lmgr/single.c b/src/backend/storage/lmgr/single.c index 80220368437..9e33b366173 100644 --- a/src/backend/storage/lmgr/single.c +++ b/src/backend/storage/lmgr/single.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.3 1997/09/07 04:49:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/Attic/single.c,v 1.4 1997/09/08 02:29:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ bool SingleLockReln(LockInfo linfo, LOCKT lockt, int action) { - LOCKTAG tag; + LOCKTAG tag; /* * LOCKTAG has two bytes of padding, unfortunately. The hash function @@ -66,7 +66,7 @@ SingleLockPage(LockInfo linfo, LOCKT lockt, int action) { - LOCKTAG tag; + LOCKTAG tag; /* * LOCKTAG has two bytes of padding, unfortunately. The hash function diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 75e1b5da9e7..b888bb9ea2a 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.9 1997/09/07 04:49:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.10 1997/09/08 02:29:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ static void PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr, char *location, Size size); -static bool PageManagerShuffle = true; /* default is shuffle mode */ +static bool PageManagerShuffle = true; /* default is shuffle mode */ /* ---------------------------------------------------------------- * Page support functions @@ -44,7 +44,7 @@ static bool PageManagerShuffle = true; /* default is shuffle mode */ void PageInit(Page page, Size pageSize, Size specialSize) { - PageHeader p = (PageHeader) page; + PageHeader p = (PageHeader) page; Assert(pageSize == BLCKSZ); Assert(pageSize > @@ -98,16 +98,16 @@ PageAddItem(Page page, OffsetNumber offsetNumber, ItemIdFlags flags) { - register i; - Size alignedSize; - Offset lower; - Offset upper; - ItemId itemId; - ItemId fromitemId, - toitemId; - OffsetNumber limit; + register i; + Size alignedSize; + Offset lower; + Offset upper; + ItemId itemId; + ItemId fromitemId, + toitemId; + OffsetNumber limit; - bool shuffled = false; + bool shuffled = false; /* * Find first unallocated offsetNumber @@ -185,10 +185,10 @@ PageAddItem(Page page, Page PageGetTempPage(Page page, Size specialSize) { - Size pageSize; - Size size; - Page temp; - PageHeader thdr; + Size pageSize; + Size size; + Page temp; + PageHeader thdr; pageSize = PageGetPageSize(page); @@ -219,7 +219,7 @@ PageGetTempPage(Page page, Size specialSize) void PageRestoreTempPage(Page tempPage, Page oldPage) { - Size pageSize; + Size pageSize; pageSize = PageGetPageSize(tempPage); memmove((char *) oldPage, (char *) tempPage, pageSize); @@ -238,8 +238,8 @@ PageRestoreTempPage(Page tempPage, Page oldPage) OffsetNumber PageGetMaxOffsetNumber(Page page) { - LocationIndex low; - OffsetNumber i; + LocationIndex low; + OffsetNumber i; low = ((PageHeader) page)->pd_lower; i = (low - (sizeof(PageHeaderData) - sizeof(ItemIdData))) @@ -254,8 +254,8 @@ PageGetMaxOffsetNumber(Page page) */ struct itemIdSortData { - int offsetindex;/* linp array index */ - ItemIdData itemiddata; + int offsetindex; /* linp array index */ + ItemIdData itemiddata; }; static int @@ -278,14 +278,14 @@ itemidcompare(void *itemidp1, void *itemidp2) void PageRepairFragmentation(Page page) { - int i; + int i; struct itemIdSortData *itemidbase, - *itemidptr; - ItemId lp; - int nline, - nused; - Offset upper; - Size alignedSize; + *itemidptr; + ItemId lp; + int nline, + nused; + Offset upper; + Size alignedSize; nline = (int16) PageGetMaxOffsetNumber(page); nused = 0; @@ -359,7 +359,7 @@ PageRepairFragmentation(Page page) Size PageGetFreeSpace(Page page) { - Size space; + Size space; space = ((PageHeader) page)->pd_upper - ((PageHeader) page)->pd_lower; @@ -400,13 +400,13 @@ PageManagerModeSet(PageManagerMode mode) void PageIndexTupleDelete(Page page, OffsetNumber offnum) { - PageHeader phdr; - char *addr; - ItemId tup; - Size size; - char *locn; - int nbytes; - int offidx; + PageHeader phdr; + char *addr; + ItemId tup; + Size size; + char *locn; + int nbytes; + int offidx; phdr = (PageHeader) page; @@ -478,8 +478,8 @@ PageIndexTupleDeleteAdjustLinePointers(PageHeader phdr, char *location, Size size) { - int i; - unsigned offset; + int i; + unsigned offset; /* location is an index into the page... */ offset = (unsigned) (location - (char *) phdr); diff --git a/src/backend/storage/smgr/md.c b/src/backend/storage/smgr/md.c index 7a2903fff5c..755d29266e6 100644 --- a/src/backend/storage/smgr/md.c +++ b/src/backend/storage/smgr/md.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.19 1997/09/07 04:49:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/md.c,v 1.20 1997/09/08 02:29:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,17 +43,17 @@ typedef struct _MdfdVec { - int mdfd_vfd; /* fd number in vfd pool */ - uint16 mdfd_flags; /* clean, dirty, free */ - int mdfd_lstbcnt; /* most recent block count */ - int mdfd_nextFree; /* next free vector */ + int mdfd_vfd; /* fd number in vfd pool */ + uint16 mdfd_flags; /* clean, dirty, free */ + int mdfd_lstbcnt; /* most recent block count */ + int mdfd_nextFree; /* next free vector */ struct _MdfdVec *mdfd_chain;/* for large relations */ -} MdfdVec; +} MdfdVec; -static int Nfds = 100; +static int Nfds = 100; static MdfdVec *Md_fdvec = (MdfdVec *) NULL; -static int Md_Free = -1; -static int CurFd = 0; +static int Md_Free = -1; +static int CurFd = 0; static MemoryContext MdCxt; #define MDFD_DIRTY (uint16) 0x01 @@ -64,8 +64,8 @@ static MemoryContext MdCxt; /* routines declared here */ static MdfdVec *_mdfd_openseg(Relation reln, int segno, int oflags); static MdfdVec *_mdfd_getseg(Relation reln, int blkno, int oflag); -static int _fdvec_alloc(void); -static void _fdvec_free(int); +static int _fdvec_alloc(void); +static void _fdvec_free(int); static BlockNumber _mdnblocks(File file, Size blcksz); /* @@ -82,8 +82,8 @@ static BlockNumber _mdnblocks(File file, Size blcksz); int mdinit() { - MemoryContext oldcxt; - int i; + MemoryContext oldcxt; + int i; MdCxt = (MemoryContext) CreateGlobalMemory("MdSmgr"); if (MdCxt == (MemoryContext) NULL) @@ -113,9 +113,9 @@ mdinit() int mdcreate(Relation reln) { - int fd, - vfd; - char *path; + int fd, + vfd; + char *path; path = relpath(&(reln->rd_rel->relname.data[0])); fd = FileNameOpenFile(path, O_RDWR | O_CREAT | O_EXCL, 0600); @@ -158,13 +158,13 @@ mdcreate(Relation reln) int mdunlink(Relation reln) { - int fd; - int i; - MdfdVec *v, - *ov; - MemoryContext oldcxt; - char fname[NAMEDATALEN]; - char tname[NAMEDATALEN + 10]; /* leave room for overflow + int fd; + int i; + MdfdVec *v, + *ov; + MemoryContext oldcxt; + char fname[NAMEDATALEN]; + char tname[NAMEDATALEN + 10]; /* leave room for overflow * suffixes */ /* @@ -215,9 +215,9 @@ mdunlink(Relation reln) int mdextend(Relation reln, char *buffer) { - long pos; - int nblocks; - MdfdVec *v; + long pos; + int nblocks; + MdfdVec *v; nblocks = mdnblocks(reln); v = _mdfd_getseg(reln, nblocks, O_CREAT); @@ -250,9 +250,9 @@ mdextend(Relation reln, char *buffer) int mdopen(Relation reln) { - char *path; - int fd; - int vfd; + char *path; + int fd; + int vfd; path = relpath(&(reln->rd_rel->relname.data[0])); @@ -290,10 +290,10 @@ mdopen(Relation reln) int mdclose(Relation reln) { - int fd; - MdfdVec *v, - *ov; - MemoryContext oldcxt; + int fd; + MdfdVec *v, + *ov; + MemoryContext oldcxt; fd = RelationGetFile(reln); @@ -338,10 +338,10 @@ mdclose(Relation reln) int mdread(Relation reln, BlockNumber blocknum, char *buffer) { - int status; - long seekpos; - int nbytes; - MdfdVec *v; + int status; + long seekpos; + int nbytes; + MdfdVec *v; v = _mdfd_getseg(reln, blocknum, 0); @@ -381,9 +381,9 @@ mdread(Relation reln, BlockNumber blocknum, char *buffer) int mdwrite(Relation reln, BlockNumber blocknum, char *buffer) { - int status; - long seekpos; - MdfdVec *v; + int status; + long seekpos; + MdfdVec *v; v = _mdfd_getseg(reln, blocknum, 0); @@ -416,9 +416,9 @@ mdwrite(Relation reln, BlockNumber blocknum, char *buffer) int mdflush(Relation reln, BlockNumber blocknum, char *buffer) { - int status; - long seekpos; - MdfdVec *v; + int status; + long seekpos; + MdfdVec *v; v = _mdfd_getseg(reln, blocknum, 0); @@ -465,12 +465,12 @@ mdblindwrt(char *dbstr, BlockNumber blkno, char *buffer) { - int fd; - int segno; - long seekpos; - int status; - char *path; - int nchars; + int fd; + int segno; + long seekpos; + int status; + char *path; + int nchars; /* be sure we have enough space for the '.segno', if any */ segno = blkno / RELSEG_SIZE; @@ -532,10 +532,10 @@ mdblindwrt(char *dbstr, int mdnblocks(Relation reln) { - int fd; - MdfdVec *v; - int nblocks; - int segno; + int fd; + MdfdVec *v; + int nblocks; + int segno; fd = RelationGetFile(reln); v = &Md_fdvec[fd]; @@ -580,9 +580,9 @@ mdnblocks(Relation reln) int mdtruncate(Relation reln, int nblocks) { - int fd; - MdfdVec *v; - int curnblk; + int fd; + MdfdVec *v; + int curnblk; curnblk = mdnblocks(reln); if (curnblk / RELSEG_SIZE > 0) @@ -615,8 +615,8 @@ mdtruncate(Relation reln, int nblocks) int mdcommit() { - int i; - MdfdVec *v; + int i; + MdfdVec *v; for (i = 0; i < CurFd; i++) { @@ -644,8 +644,8 @@ mdcommit() int mdabort() { - int i; - MdfdVec *v; + int i; + MdfdVec *v; for (i = 0; i < CurFd; i++) { @@ -666,10 +666,10 @@ static int _fdvec_alloc() { - MdfdVec *nvec; - int fdvec, - i; - MemoryContext oldcxt; + MdfdVec *nvec; + int fdvec, + i; + MemoryContext oldcxt; if (Md_Free >= 0) /* get from free list */ { @@ -738,12 +738,12 @@ _fdvec_free(int fdvec) static MdfdVec * _mdfd_openseg(Relation reln, int segno, int oflags) { - MemoryContext oldcxt; - MdfdVec *v; - int fd; - bool dofree; - char *path, - *fullpath; + MemoryContext oldcxt; + MdfdVec *v; + int fd; + bool dofree; + char *path, + *fullpath; /* be sure we have enough space for the '.segno', if any */ path = relpath(RelationGetRelationName(reln)->data); @@ -790,10 +790,10 @@ _mdfd_openseg(Relation reln, int segno, int oflags) static MdfdVec * _mdfd_getseg(Relation reln, int blkno, int oflag) { - MdfdVec *v; - int segno; - int fd; - int i; + MdfdVec *v; + int segno; + int fd; + int i; fd = RelationGetFile(reln); if (fd < 0) @@ -823,10 +823,10 @@ _mdfd_getseg(Relation reln, int blkno, int oflag) return (v); } -static BlockNumber +static BlockNumber _mdnblocks(File file, Size blcksz) { - long len; + long len; len = FileSeek(file, 0L, SEEK_END) - 1; return ((BlockNumber) ((len < 0) ? 0 : 1 + len / blcksz)); diff --git a/src/backend/storage/smgr/mm.c b/src/backend/storage/smgr/mm.c index d0015e4f138..a365410bb1b 100644 --- a/src/backend/storage/smgr/mm.c +++ b/src/backend/storage/smgr/mm.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.5 1997/09/07 04:49:22 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/Attic/mm.c,v 1.6 1997/09/08 02:29:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,10 +37,10 @@ typedef struct MMCacheTag { - Oid mmct_dbid; - Oid mmct_relid; - BlockNumber mmct_blkno; -} MMCacheTag; + Oid mmct_dbid; + Oid mmct_relid; + BlockNumber mmct_blkno; +} MMCacheTag; /* * Shared-memory hash table for main memory relations contains @@ -49,9 +49,9 @@ typedef struct MMCacheTag typedef struct MMHashEntry { - MMCacheTag mmhe_tag; - int mmhe_bufno; -} MMHashEntry; + MMCacheTag mmhe_tag; + int mmhe_bufno; +} MMHashEntry; /* * MMRelTag -- Unique identifier for each relation that is stored in the @@ -60,9 +60,9 @@ typedef struct MMHashEntry typedef struct MMRelTag { - Oid mmrt_dbid; - Oid mmrt_relid; -} MMRelTag; + Oid mmrt_dbid; + Oid mmrt_relid; +} MMRelTag; /* * Shared-memory hash table for # blocks in main memory relations contains @@ -71,31 +71,31 @@ typedef struct MMRelTag typedef struct MMRelHashEntry { - MMRelTag mmrhe_tag; - int mmrhe_nblocks; -} MMRelHashEntry; + MMRelTag mmrhe_tag; + int mmrhe_nblocks; +} MMRelHashEntry; #define MMNBUFFERS 10 #define MMNRELATIONS 2 -SPINLOCK MMCacheLock; -extern bool IsPostmaster; -extern Oid MyDatabaseId; +SPINLOCK MMCacheLock; +extern bool IsPostmaster; +extern Oid MyDatabaseId; -static int *MMCurTop; -static int *MMCurRelno; +static int *MMCurTop; +static int *MMCurRelno; static MMCacheTag *MMBlockTags; -static char *MMBlockCache; -static HTAB *MMCacheHT; -static HTAB *MMRelCacheHT; +static char *MMBlockCache; +static HTAB *MMCacheHT; +static HTAB *MMRelCacheHT; int mminit() { - char *mmcacheblk; - int mmsize = 0; - bool found; - HASHCTL info; + char *mmcacheblk; + int mmsize = 0; + bool found; + HASHCTL info; SpinAcquire(MMCacheLock); @@ -169,8 +169,8 @@ int mmcreate(Relation reln) { MMRelHashEntry *entry; - bool found; - MMRelTag tag; + bool found; + MMRelTag tag; SpinAcquire(MMCacheLock); @@ -217,12 +217,12 @@ mmcreate(Relation reln) int mmunlink(Relation reln) { - int i; - Oid reldbid; - MMHashEntry *entry; + int i; + Oid reldbid; + MMHashEntry *entry; MMRelHashEntry *rentry; - bool found; - MMRelTag rtag; + bool found; + MMRelTag rtag; if (reln->rd_rel->relisshared) reldbid = (Oid) 0; @@ -277,13 +277,13 @@ int mmextend(Relation reln, char *buffer) { MMRelHashEntry *rentry; - MMHashEntry *entry; - int i; - Oid reldbid; - int offset; - bool found; - MMRelTag rtag; - MMCacheTag tag; + MMHashEntry *entry; + int i; + Oid reldbid; + int offset; + bool found; + MMRelTag rtag; + MMCacheTag tag; if (reln->rd_rel->relisshared) reldbid = (Oid) 0; @@ -380,10 +380,10 @@ mmclose(Relation reln) int mmread(Relation reln, BlockNumber blocknum, char *buffer) { - MMHashEntry *entry; - bool found; - int offset; - MMCacheTag tag; + MMHashEntry *entry; + bool found; + int offset; + MMCacheTag tag; if (reln->rd_rel->relisshared) tag.mmct_dbid = (Oid) 0; @@ -427,10 +427,10 @@ mmread(Relation reln, BlockNumber blocknum, char *buffer) int mmwrite(Relation reln, BlockNumber blocknum, char *buffer) { - MMHashEntry *entry; - bool found; - int offset; - MMCacheTag tag; + MMHashEntry *entry; + bool found; + int offset; + MMCacheTag tag; if (reln->rd_rel->relisshared) tag.mmct_dbid = (Oid) 0; @@ -500,10 +500,10 @@ mmblindwrt(char *dbstr, int mmnblocks(Relation reln) { - MMRelTag rtag; + MMRelTag rtag; MMRelHashEntry *rentry; - bool found; - int nblocks; + bool found; + int nblocks; if (reln->rd_rel->relisshared) rtag.mmrt_dbid = (Oid) 0; @@ -565,10 +565,10 @@ mmabort() int MMShmemSize() { - int size = 0; - int nbuckets; - int nsegs; - int tmp; + int size = 0; + int nbuckets; + int nsegs; + int tmp; /* * first compute space occupied by the (dbid,relid,blkno) hash table diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index 9fc395da0d9..b3a2648336d 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.9 1997/09/07 04:49:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.10 1997/09/08 02:29:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,33 +23,33 @@ #include "utils/rel.h" #include "utils/palloc.h" -static void smgrshutdown(int dummy); +static void smgrshutdown(int dummy); typedef struct f_smgr { - int (*smgr_init) (); /* may be NULL */ - int (*smgr_shutdown) (); /* may be NULL */ - int (*smgr_create) (); - int (*smgr_unlink) (); - int (*smgr_extend) (); - int (*smgr_open) (); - int (*smgr_close) (); - int (*smgr_read) (); - int (*smgr_write) (); - int (*smgr_flush) (); - int (*smgr_blindwrt) (); - int (*smgr_nblocks) (); - int (*smgr_truncate) (); - int (*smgr_commit) (); /* may be NULL */ - int (*smgr_abort) (); /* may be NULL */ -} f_smgr; + int (*smgr_init) ();/* may be NULL */ + int (*smgr_shutdown) (); /* may be NULL */ + int (*smgr_create) (); + int (*smgr_unlink) (); + int (*smgr_extend) (); + int (*smgr_open) (); + int (*smgr_close) (); + int (*smgr_read) (); + int (*smgr_write) (); + int (*smgr_flush) (); + int (*smgr_blindwrt) (); + int (*smgr_nblocks) (); + int (*smgr_truncate) (); + int (*smgr_commit) (); /* may be NULL */ + int (*smgr_abort) (); /* may be NULL */ +} f_smgr; /* * The weird placement of commas in this init block is to keep the compiler * happy, regardless of what storage managers we have (or don't have). */ -static f_smgr smgrsw[] = { +static f_smgr smgrsw[] = { /* magnetic disk */ {mdinit, NULL, mdcreate, mdunlink, mdextend, mdopen, mdclose, @@ -72,13 +72,13 @@ static f_smgr smgrsw[] = { * write-once storage managers. */ -static bool smgrwo[] = { +static bool smgrwo[] = { false, /* magnetic disk */ #ifdef MAIN_MEMORY false, /* main memory */ #endif /* MAIN_MEMORY */ }; -static int NSmgr = lengthof(smgrsw); +static int NSmgr = lengthof(smgrsw); /* * smgrinit(), smgrshutdown() -- Initialize or shut down all storage @@ -88,7 +88,7 @@ static int NSmgr = lengthof(smgrsw); int smgrinit() { - int i; + int i; for (i = 0; i < NSmgr; i++) { @@ -108,7 +108,7 @@ smgrinit() static void smgrshutdown(int dummy) { - int i; + int i; for (i = 0; i < NSmgr; i++) { @@ -129,7 +129,7 @@ smgrshutdown(int dummy) int smgrcreate(int16 which, Relation reln) { - int fd; + int fd; if ((fd = (*(smgrsw[which].smgr_create)) (reln)) < 0) elog(WARN, "cannot open %s", @@ -146,7 +146,7 @@ smgrcreate(int16 which, Relation reln) int smgrunlink(int16 which, Relation reln) { - int status; + int status; if ((status = (*(smgrsw[which].smgr_unlink)) (reln)) == SM_FAIL) elog(WARN, "cannot unlink %s", @@ -164,7 +164,7 @@ smgrunlink(int16 which, Relation reln) int smgrextend(int16 which, Relation reln, char *buffer) { - int status; + int status; status = (*(smgrsw[which].smgr_extend)) (reln, buffer); @@ -184,7 +184,7 @@ smgrextend(int16 which, Relation reln, char *buffer) int smgropen(int16 which, Relation reln) { - int fd; + int fd; if ((fd = (*(smgrsw[which].smgr_open)) (reln)) < 0) elog(WARN, "cannot open %s", @@ -228,7 +228,7 @@ smgrclose(int16 which, Relation reln) int smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer) { - int status; + int status; status = (*(smgrsw[which].smgr_read)) (reln, blocknum, buffer); @@ -250,7 +250,7 @@ smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer) int smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer) { - int status; + int status; status = (*(smgrsw[which].smgr_write)) (reln, blocknum, buffer); @@ -267,7 +267,7 @@ smgrwrite(int16 which, Relation reln, BlockNumber blocknum, char *buffer) int smgrflush(int16 which, Relation reln, BlockNumber blocknum, char *buffer) { - int status; + int status; status = (*(smgrsw[which].smgr_flush)) (reln, blocknum, buffer); @@ -299,9 +299,9 @@ smgrblindwrt(int16 which, BlockNumber blkno, char *buffer) { - char *dbstr; - char *relstr; - int status; + char *dbstr; + char *relstr; + int status; dbstr = pstrdup(dbname); relstr = pstrdup(relname); @@ -329,7 +329,7 @@ smgrblindwrt(int16 which, int smgrnblocks(int16 which, Relation reln) { - int nblocks; + int nblocks; if ((nblocks = (*(smgrsw[which].smgr_nblocks)) (reln)) < 0) elog(WARN, "cannot count blocks for %s", @@ -348,7 +348,7 @@ smgrnblocks(int16 which, Relation reln) int smgrtruncate(int16 which, Relation reln, int nblocks) { - int newblks; + int newblks; newblks = nblocks; if (smgrsw[which].smgr_truncate) @@ -368,7 +368,7 @@ smgrtruncate(int16 which, Relation reln, int nblocks) int smgrcommit() { - int i; + int i; for (i = 0; i < NSmgr; i++) { @@ -386,7 +386,7 @@ smgrcommit() int smgrabort() { - int i; + int i; for (i = 0; i < NSmgr; i++) { diff --git a/src/backend/storage/smgr/smgrtype.c b/src/backend/storage/smgr/smgrtype.c index 64fb53c9c2e..9439dbc0a2e 100644 --- a/src/backend/storage/smgr/smgrtype.c +++ b/src/backend/storage/smgr/smgrtype.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.3 1997/09/07 04:49:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgrtype.c,v 1.4 1997/09/08 02:29:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,8 +20,8 @@ typedef struct smgrid { - char *smgr_name; -} smgrid; + char *smgr_name; +} smgrid; /* * StorageManager[] -- List of defined storage managers. @@ -30,19 +30,19 @@ typedef struct smgrid * which of these is (or is not) defined. */ -static smgrid StorageManager[] = { +static smgrid StorageManager[] = { {"magnetic disk"}, #ifdef MAIN_MEMORY {"main memory"} #endif /* MAIN_MEMORY */ }; -static int NStorageManagers = lengthof(StorageManager); +static int NStorageManagers = lengthof(StorageManager); int2 smgrin(char *s) { - int i; + int i; for (i = 0; i < NStorageManagers; i++) { @@ -53,10 +53,10 @@ smgrin(char *s) return 0; } -char * +char * smgrout(int2 i) { - char *s; + char *s; if (i >= NStorageManagers || i < 0) elog(WARN, "Illegal storage manager id %d", i); diff --git a/src/backend/tcop/aclchk.c b/src/backend/tcop/aclchk.c index db6932586b7..a12c544e2eb 100644 --- a/src/backend/tcop/aclchk.c +++ b/src/backend/tcop/aclchk.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/Attic/aclchk.c,v 1.14 1997/09/07 04:49:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/Attic/aclchk.c,v 1.15 1997/09/08 02:29:40 momjian Exp $ * * NOTES * See acl.h. @@ -36,7 +36,7 @@ #include "parser/catalog_utils.h" #include "fmgr.h" -static int32 aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode); +static int32 aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode); /* * Enable use of user relations in place of real system catalogs. @@ -60,7 +60,7 @@ static int32 aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode); /* warning messages, now more explicit. */ /* should correspond to the order of the ACLCHK_* result codes above. */ -char *aclcheck_error_strings[] = { +char *aclcheck_error_strings[] = { "No error.", "Permission denied.", "Table does not exist.", @@ -72,7 +72,7 @@ static dumpacl(Acl * acl) { register unsigned i; - AclItem *aip; + AclItem *aip; elog(DEBUG, "acl size = %d, # acls = %d", ACL_SIZE(acl), ACL_NUM(acl)); @@ -92,21 +92,21 @@ ChangeAcl(char *relname, unsigned modechg) { register unsigned i; - Acl *old_acl = (Acl *) NULL, - *new_acl; - Relation relation; + Acl *old_acl = (Acl *) NULL, + *new_acl; + Relation relation; static ScanKeyData relkey[1] = { {0, Anum_pg_class_relname, NameEqualRegProcedure} }; - HeapScanDesc hsdp; - HeapTuple htp; - Buffer buffer; - Datum values[Natts_pg_class]; - char nulls[Natts_pg_class]; - char replaces[Natts_pg_class]; + HeapScanDesc hsdp; + HeapTuple htp; + Buffer buffer; + Datum values[Natts_pg_class]; + char nulls[Natts_pg_class]; + char replaces[Natts_pg_class]; ItemPointerData tmp_ipd; - Relation idescs[Num_pg_class_indices]; - int free_old_acl = 0; + Relation idescs[Num_pg_class_indices]; + int free_old_acl = 0; /* * Find the pg_class tuple matching 'relname' and extract the ACL. If @@ -191,8 +191,8 @@ ChangeAcl(char *relname, AclId get_grosysid(char *groname) { - HeapTuple htp; - AclId id = 0; + HeapTuple htp; + AclId id = 0; htp = SearchSysCacheTuple(GRONAME, PointerGetDatum(groname), 0, 0, 0); @@ -207,11 +207,11 @@ get_grosysid(char *groname) return (id); } -char * +char * get_groname(AclId grosysid) { - HeapTuple htp; - char *name = NULL; + HeapTuple htp; + char *name = NULL; htp = SearchSysCacheTuple(GROSYSID, PointerGetDatum(grosysid), 0, 0, 0); @@ -226,16 +226,16 @@ get_groname(AclId grosysid) return (name); } -static int32 +static int32 in_group(AclId uid, AclId gid) { - Relation relation; - HeapTuple htp; - Acl *tmp; - unsigned i, - num; - AclId *aidp; - int32 found = 0; + Relation relation; + HeapTuple htp; + Acl *tmp; + unsigned i, + num; + AclId *aidp; + int32 found = 0; relation = heap_openr(GroupRelationName); if (!RelationIsValid(relation)) @@ -276,14 +276,14 @@ in_group(AclId uid, AclId gid) * Returns 1 if the 'id' of type 'idtype' has ACL entries in 'acl' to satisfy * any one of the requirements of 'mode'. Returns 0 otherwise. */ -static int32 +static int32 aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode) { register unsigned i; register AclItem *aip, - *aidat; - unsigned num, - found_group; + *aidat; + unsigned num, + found_group; /* if no acl is found, use world default */ if (!acl) @@ -309,65 +309,66 @@ aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode) switch (idtype) { - case ACL_IDTYPE_UID: - for (i = 1, aip = aidat + 1; /* skip world entry */ - i < num && aip->ai_idtype == ACL_IDTYPE_UID; - ++i, ++aip) - { - if (aip->ai_id == id) + case ACL_IDTYPE_UID: + for (i = 1, aip = aidat + 1; /* skip world entry */ + i < num && aip->ai_idtype == ACL_IDTYPE_UID; + ++i, ++aip) { + if (aip->ai_id == id) + { #ifdef ACLDEBUG_TRACE - elog(DEBUG, "aclcheck: found %d/%d", - aip->ai_id, aip->ai_mode); + elog(DEBUG, "aclcheck: found %d/%d", + aip->ai_id, aip->ai_mode); #endif - return ((aip->ai_mode & mode) ? ACLCHECK_OK : ACLCHECK_NO_PRIV); + return ((aip->ai_mode & mode) ? ACLCHECK_OK : ACLCHECK_NO_PRIV); + } } - } - for (found_group = 0; - i < num && aip->ai_idtype == ACL_IDTYPE_GID; - ++i, ++aip) - { - if (in_group(id, aip->ai_id)) + for (found_group = 0; + i < num && aip->ai_idtype == ACL_IDTYPE_GID; + ++i, ++aip) { - if (aip->ai_mode & mode) + if (in_group(id, aip->ai_id)) { - found_group = 1; - break; + if (aip->ai_mode & mode) + { + found_group = 1; + break; + } } } - } - if (found_group) - { + if (found_group) + { #ifdef ACLDEBUG_TRACE - elog(DEBUG, "aclcheck: all groups ok"); + elog(DEBUG, "aclcheck: all groups ok"); #endif - return ACLCHECK_OK; - } - break; - case ACL_IDTYPE_GID: - for (i = 1, aip = aidat + 1; /* skip world entry and UIDs */ - i < num && aip->ai_idtype == ACL_IDTYPE_UID; - ++i, ++aip) - ; - for (; - i < num && aip->ai_idtype == ACL_IDTYPE_GID; - ++i, ++aip) - { - if (aip->ai_id == id) + return ACLCHECK_OK; + } + break; + case ACL_IDTYPE_GID: + for (i = 1, aip = aidat + 1; /* skip world entry and + * UIDs */ + i < num && aip->ai_idtype == ACL_IDTYPE_UID; + ++i, ++aip) + ; + for (; + i < num && aip->ai_idtype == ACL_IDTYPE_GID; + ++i, ++aip) { + if (aip->ai_id == id) + { #ifdef ACLDEBUG_TRACE - elog(DEBUG, "aclcheck: found %d/%d", - aip->ai_id, aip->ai_mode); + elog(DEBUG, "aclcheck: found %d/%d", + aip->ai_id, aip->ai_mode); #endif - return ((aip->ai_mode & mode) ? ACLCHECK_OK : ACLCHECK_NO_PRIV); + return ((aip->ai_mode & mode) ? ACLCHECK_OK : ACLCHECK_NO_PRIV); + } } - } - break; - case ACL_IDTYPE_WORLD: - break; - default: - elog(WARN, "aclcheck: bogus ACL id type: %d", idtype); - break; + break; + case ACL_IDTYPE_WORLD: + break; + default: + elog(WARN, "aclcheck: bogus ACL id type: %d", idtype); + break; } #ifdef ACLDEBUG_TRACE @@ -379,12 +380,12 @@ aclcheck(Acl * acl, AclId id, AclIdType idtype, AclMode mode) int32 pg_aclcheck(char *relname, char *usename, AclMode mode) { - HeapTuple htp; - AclId id; - Acl *acl = (Acl *) NULL, - *tmp; - int32 result; - Relation relation; + HeapTuple htp; + AclId id; + Acl *acl = (Acl *) NULL, + *tmp; + int32 result; + Relation relation; htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename), 0, 0, 0); @@ -463,7 +464,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) * if the acl is null, by default the owner can do whatever he * wants to with it */ - Oid ownerId; + Oid ownerId; relation = heap_openr(RelationRelationName); ownerId = (Oid) heap_getattr(htp, InvalidBuffer, @@ -477,7 +478,7 @@ pg_aclcheck(char *relname, char *usename, AclMode mode) static ScanKeyData relkey[1] = { {0, Anum_pg_class_relname, NameEqualRegProcedure} }; - HeapScanDesc hsdp; + HeapScanDesc hsdp; relation = heap_openr(RelationRelationName); if (!RelationIsValid(relation)) @@ -517,9 +518,9 @@ pg_ownercheck(char *usename, char *value, int cacheid) { - HeapTuple htp; - AclId user_id, - owner_id = 0; + HeapTuple htp; + AclId user_id, + owner_id = 0; htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename), 0, 0, 0); @@ -544,34 +545,34 @@ pg_ownercheck(char *usename, 0, 0, 0); switch (cacheid) { - case OPROID: - if (!HeapTupleIsValid(htp)) - elog(WARN, "pg_ownercheck: operator %ld not found", - PointerGetDatum(value)); - owner_id = ((OperatorTupleForm) GETSTRUCT(htp))->oprowner; - break; - case PRONAME: - if (!HeapTupleIsValid(htp)) - elog(WARN, "pg_ownercheck: function \"%s\" not found", - value); - owner_id = ((Form_pg_proc) GETSTRUCT(htp))->proowner; - break; - case RELNAME: - if (!HeapTupleIsValid(htp)) - elog(WARN, "pg_ownercheck: class \"%s\" not found", - value); - owner_id = ((Form_pg_class) GETSTRUCT(htp))->relowner; - break; - case TYPNAME: - if (!HeapTupleIsValid(htp)) - elog(WARN, "pg_ownercheck: type \"%s\" not found", - value); - owner_id = ((TypeTupleForm) GETSTRUCT(htp))->typowner; - break; - default: - elog(WARN, "pg_ownercheck: invalid cache id: %d", - cacheid); - break; + case OPROID: + if (!HeapTupleIsValid(htp)) + elog(WARN, "pg_ownercheck: operator %ld not found", + PointerGetDatum(value)); + owner_id = ((OperatorTupleForm) GETSTRUCT(htp))->oprowner; + break; + case PRONAME: + if (!HeapTupleIsValid(htp)) + elog(WARN, "pg_ownercheck: function \"%s\" not found", + value); + owner_id = ((Form_pg_proc) GETSTRUCT(htp))->proowner; + break; + case RELNAME: + if (!HeapTupleIsValid(htp)) + elog(WARN, "pg_ownercheck: class \"%s\" not found", + value); + owner_id = ((Form_pg_class) GETSTRUCT(htp))->relowner; + break; + case TYPNAME: + if (!HeapTupleIsValid(htp)) + elog(WARN, "pg_ownercheck: type \"%s\" not found", + value); + owner_id = ((TypeTupleForm) GETSTRUCT(htp))->typowner; + break; + default: + elog(WARN, "pg_ownercheck: invalid cache id: %d", + cacheid); + break; } return (user_id == owner_id); @@ -583,9 +584,9 @@ pg_func_ownercheck(char *usename, int nargs, Oid * arglist) { - HeapTuple htp; - AclId user_id, - owner_id; + HeapTuple htp; + AclId user_id, + owner_id; htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename), 0, 0, 0); @@ -624,9 +625,9 @@ pg_aggr_ownercheck(char *usename, char *aggname, Oid basetypeID) { - HeapTuple htp; - AclId user_id, - owner_id; + HeapTuple htp; + AclId user_id, + owner_id; htp = SearchSysCacheTuple(USENAME, PointerGetDatum(usename), 0, 0, 0); diff --git a/src/backend/tcop/dest.c b/src/backend/tcop/dest.c index 1c0306b18d9..cbe8d5444ad 100644 --- a/src/backend/tcop/dest.c +++ b/src/backend/tcop/dest.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.11 1997/09/07 04:49:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/dest.c,v 1.12 1997/09/08 02:29:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,7 +43,7 @@ #include "commands/async.h" -static char CommandInfo[32] = {0}; +static char CommandInfo[32] = {0}; /* ---------------- * output functions @@ -54,37 +54,37 @@ donothing(HeapTuple tuple, TupleDesc attrdesc) { } -extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); +extern void spi_printtup(HeapTuple tuple, TupleDesc tupdesc); -void (* - DestToFunction(CommandDest dest)) (HeapTuple, TupleDesc) +void (* + DestToFunction(CommandDest dest)) (HeapTuple, TupleDesc) { switch (dest) { - case RemoteInternal: - return printtup_internal; - break; + case RemoteInternal: + return printtup_internal; + break; - case Remote: - return printtup; - break; + case Remote: + return printtup; + break; - case Local: - return be_printtup; - break; + case Local: + return be_printtup; + break; - case Debug: - return debugtup; - break; + case Debug: + return debugtup; + break; - case SPI: - return spi_printtup; - break; + case SPI: + return spi_printtup; + break; - case None: - default: - return donothing; - break; + case None: + default: + return donothing; + break; } /* @@ -101,33 +101,33 @@ void (* void EndCommand(char *commandTag, CommandDest dest) { - char buf[64]; + char buf[64]; switch (dest) { - case RemoteInternal: - case Remote: - /* ---------------- - * tell the fe that the query is over - * ---------------- - */ - pq_putnchar("C", 1); - sprintf(buf, "%s%s", commandTag, CommandInfo); - CommandInfo[0] = 0; - pq_putstr(buf); - pq_flush(); - break; - - case Local: - case Debug: - break; - case CopyEnd: - pq_putnchar("Z", 1); - pq_flush(); - break; - case None: - default: - break; + case RemoteInternal: + case Remote: + /* ---------------- + * tell the fe that the query is over + * ---------------- + */ + pq_putnchar("C", 1); + sprintf(buf, "%s%s", commandTag, CommandInfo); + CommandInfo[0] = 0; + pq_putstr(buf); + pq_flush(); + break; + + case Local: + case Debug: + break; + case CopyEnd: + pq_putnchar("Z", 1); + pq_flush(); + break; + case None: + default: + break; } } @@ -168,54 +168,55 @@ NullCommand(CommandDest dest) { switch (dest) { - case RemoteInternal: - case Remote: - { -#if 0 - - /* - * Do any asynchronous notification. If front end wants to - * poll, it can send null queries to call this function. - */ - PQNotifyList *nPtr; - MemoryContext orig; - - if (notifyContext == NULL) + case RemoteInternal: + case Remote: { - notifyContext = CreateGlobalMemory("notify"); - } - orig = MemoryContextSwitchTo((MemoryContext) notifyContext); +#if 0 - for (nPtr = PQnotifies(); - nPtr != NULL; - nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node)) - { - pq_putnchar("A", 1); - pq_putint(0, 4); - pq_putstr(nPtr->relname); - pq_putint(nPtr->be_pid, 4); - PQremoveNotify(nPtr); - } - pq_flush(); - PQcleanNotify(); /* garbage collect */ - MemoryContextSwitchTo(orig); + /* + * Do any asynchronous notification. If front end wants + * to poll, it can send null queries to call this + * function. + */ + PQNotifyList *nPtr; + MemoryContext orig; + + if (notifyContext == NULL) + { + notifyContext = CreateGlobalMemory("notify"); + } + orig = MemoryContextSwitchTo((MemoryContext) notifyContext); + + for (nPtr = PQnotifies(); + nPtr != NULL; + nPtr = (PQNotifyList *) SLGetSucc(&nPtr->Node)) + { + pq_putnchar("A", 1); + pq_putint(0, 4); + pq_putstr(nPtr->relname); + pq_putint(nPtr->be_pid, 4); + PQremoveNotify(nPtr); + } + pq_flush(); + PQcleanNotify();/* garbage collect */ + MemoryContextSwitchTo(orig); #endif - /* ---------------- - * tell the fe that the last of the queries has finished - * ---------------- - */ + /* ---------------- + * tell the fe that the last of the queries has finished + * ---------------- + */ /* pq_putnchar("I", 1); */ - pq_putstr("I"); - /* pq_putint(0, 4); */ - pq_flush(); - } - break; - - case Local: - case Debug: - case None: - default: - break; + pq_putstr("I"); + /* pq_putint(0, 4); */ + pq_flush(); + } + break; + + case Local: + case Debug: + case None: + default: + break; } } @@ -232,103 +233,103 @@ BeginCommand(char *pname, char *tag, CommandDest dest) { - PortalEntry *entry; + PortalEntry *entry; AttributeTupleForm *attrs = tupdesc->attrs; - int natts = tupdesc->natts; - int i; - char *p; + int natts = tupdesc->natts; + int i; + char *p; switch (dest) { - case RemoteInternal: - case Remote: - /* ---------------- - * if this is a "retrieve portal" query, just return - * because nothing needs to be sent to the fe. - * ---------------- - */ - CommandInfo[0] = 0; - if (isIntoPortal) - return; - - /* ---------------- - * if portal name not specified for remote query, - * use the "blank" portal. - * ---------------- - */ - if (pname == NULL) - pname = "blank"; - - /* ---------------- - * send fe info on tuples we're about to send - * ---------------- - */ - pq_flush(); - pq_putnchar("P", 1); /* new portal.. */ - pq_putstr(pname); /* portal name */ - - /* ---------------- - * if this is a retrieve, then we send back the tuple - * descriptor of the tuples. "retrieve into" is an - * exception because no tuples are returned in that case. - * ---------------- - */ - if (operation == CMD_SELECT && !isIntoRel) - { - pq_putnchar("T", 1);/* type info to follow.. */ - pq_putint(natts, 2);/* number of attributes in tuples */ - - for (i = 0; i < natts; ++i) + case RemoteInternal: + case Remote: + /* ---------------- + * if this is a "retrieve portal" query, just return + * because nothing needs to be sent to the fe. + * ---------------- + */ + CommandInfo[0] = 0; + if (isIntoPortal) + return; + + /* ---------------- + * if portal name not specified for remote query, + * use the "blank" portal. + * ---------------- + */ + if (pname == NULL) + pname = "blank"; + + /* ---------------- + * send fe info on tuples we're about to send + * ---------------- + */ + pq_flush(); + pq_putnchar("P", 1);/* new portal.. */ + pq_putstr(pname); /* portal name */ + + /* ---------------- + * if this is a retrieve, then we send back the tuple + * descriptor of the tuples. "retrieve into" is an + * exception because no tuples are returned in that case. + * ---------------- + */ + if (operation == CMD_SELECT && !isIntoRel) { - pq_putstr(attrs[i]->attname.data); /* if 16 char name + pq_putnchar("T", 1); /* type info to follow.. */ + pq_putint(natts, 2); /* number of attributes in tuples */ + + for (i = 0; i < natts; ++i) + { + pq_putstr(attrs[i]->attname.data); /* if 16 char name * oops.. */ - pq_putint((int) attrs[i]->atttypid, 4); - pq_putint(attrs[i]->attlen, 2); + pq_putint((int) attrs[i]->atttypid, 4); + pq_putint(attrs[i]->attlen, 2); + } } - } - pq_flush(); - break; - - case Local: - /* ---------------- - * prepare local portal buffer for query results - * and setup result for PQexec() - * ---------------- - */ - entry = be_currentportal(); - if (pname != NULL) - pbuf_setportalinfo(entry, pname); - - if (operation == CMD_SELECT && !isIntoRel) - { - be_typeinit(entry, tupdesc, natts); - p = (char *) palloc(strlen(entry->name) + 2); - p[0] = 'P'; - strcpy(p + 1, entry->name); - } - else - { - p = (char *) palloc(strlen(tag) + 2); - p[0] = 'C'; - strcpy(p + 1, tag); - } - entry->result = p; - break; - - case Debug: - /* ---------------- - * show the return type of the tuples - * ---------------- - */ - if (pname == NULL) - pname = "blank"; - - showatts(pname, tupdesc); - break; - - case None: - default: - break; + pq_flush(); + break; + + case Local: + /* ---------------- + * prepare local portal buffer for query results + * and setup result for PQexec() + * ---------------- + */ + entry = be_currentportal(); + if (pname != NULL) + pbuf_setportalinfo(entry, pname); + + if (operation == CMD_SELECT && !isIntoRel) + { + be_typeinit(entry, tupdesc, natts); + p = (char *) palloc(strlen(entry->name) + 2); + p[0] = 'P'; + strcpy(p + 1, entry->name); + } + else + { + p = (char *) palloc(strlen(tag) + 2); + p[0] = 'C'; + strcpy(p + 1, tag); + } + entry->result = p; + break; + + case Debug: + /* ---------------- + * show the return type of the tuples + * ---------------- + */ + if (pname == NULL) + pname = "blank"; + + showatts(pname, tupdesc); + break; + + case None: + default: + break; } } @@ -337,17 +338,17 @@ UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples) { switch (operation) { - case CMD_INSERT: - if (tuples > 1) - lastoid = InvalidOid; - sprintf(CommandInfo, " %u %u", lastoid, tuples); - break; - case CMD_DELETE: - case CMD_UPDATE: - sprintf(CommandInfo, " %u", tuples); - break; - default: - CommandInfo[0] = 0; + case CMD_INSERT: + if (tuples > 1) + lastoid = InvalidOid; + sprintf(CommandInfo, " %u %u", lastoid, tuples); + break; + case CMD_DELETE: + case CMD_UPDATE: + sprintf(CommandInfo, " %u", tuples); + break; + default: + CommandInfo[0] = 0; } return; } diff --git a/src/backend/tcop/fastpath.c b/src/backend/tcop/fastpath.c index 27c01ff1a17..bc7845ca409 100644 --- a/src/backend/tcop/fastpath.c +++ b/src/backend/tcop/fastpath.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.5 1997/09/07 04:49:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/fastpath.c,v 1.6 1997/09/08 02:29:47 momjian Exp $ * * NOTES * This cruft is the server side of PQfn. @@ -128,14 +128,14 @@ SendFunctionResult(Oid fid, /* function id */ */ struct fp_info { - Oid funcid; - int nargs; - bool argbyval[MAXFMGRARGS]; - int32 arglen[MAXFMGRARGS]; /* signed (for varlena) */ - bool retbyval; - int32 retlen; /* signed (for varlena) */ - TransactionId xid; - CommandId cid; + Oid funcid; + int nargs; + bool argbyval[MAXFMGRARGS]; + int32 arglen[MAXFMGRARGS]; /* signed (for varlena) */ + bool retbyval; + int32 retlen; /* signed (for varlena) */ + TransactionId xid; + CommandId cid; }; /* @@ -184,13 +184,13 @@ valid_fp_info(Oid func_id, struct fp_info * fip) static void update_fp_info(Oid func_id, struct fp_info * fip) { - Oid *argtypes; /* an oid8 */ - Oid rettype; - HeapTuple func_htp, - type_htp; - TypeTupleForm tp; - Form_pg_proc pp; - int i; + Oid *argtypes; /* an oid8 */ + Oid rettype; + HeapTuple func_htp, + type_htp; + TypeTupleForm tp; + Form_pg_proc pp; + int i; Assert(OidIsValid(func_id)); Assert(fip != (struct fp_info *) NULL); @@ -272,14 +272,14 @@ update_fp_info(Oid func_id, struct fp_info * fip) int HandleFunctionRequest() { - Oid fid; - int argsize; - int nargs; - char *arg[8]; - char *retval; - int i; - uint32 palloced; - char *p; + Oid fid; + int argsize; + int nargs; + char *arg[8]; + char *retval; + int i; + uint32 palloced; + char *p; struct fp_info *fip; fid = (Oid) pq_getint(4); /* function oid */ diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index f70d30434bb..c010072199d 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.43 1997/09/07 04:49:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.44 1997/09/08 02:29:48 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -90,65 +90,65 @@ #include "libpq/pqsignal.h" #include "rewrite/rewriteHandler.h" /* for QueryRewrite() */ -static void quickdie(SIGNAL_ARGS); +static void quickdie(SIGNAL_ARGS); /* ---------------- * global variables * ---------------- */ -static bool DebugPrintQuery = false; -static bool DebugPrintPlan = false; -static bool DebugPrintParse = false; -static bool DebugPrintRewrittenParsetree = false; +static bool DebugPrintQuery = false; +static bool DebugPrintPlan = false; +static bool DebugPrintParse = false; +static bool DebugPrintRewrittenParsetree = false; /*static bool EnableRewrite = true; , never changes why have it*/ -CommandDest whereToSendOutput; +CommandDest whereToSendOutput; #ifdef LOCK_MGR_DEBUG -extern int lockDebug; +extern int lockDebug; #endif -extern int lockingOff; -extern int NBuffers; +extern int lockingOff; +extern int NBuffers; -int dontExecute = 0; -static int ShowStats; -static bool IsEmptyQuery = false; +int dontExecute = 0; +static int ShowStats; +static bool IsEmptyQuery = false; -char relname[80]; /* current relation name */ +char relname[80]; /* current relation name */ #if defined(nextstep) -jmp_buf Warn_restart; +jmp_buf Warn_restart; #define sigsetjmp(x,y) setjmp(x) #define siglongjmp longjmp #else -sigjmp_buf Warn_restart; +sigjmp_buf Warn_restart; #endif /* defined(nextstep) */ -int InWarn; +int InWarn; -extern int NBuffers; +extern int NBuffers; -static int EchoQuery = 0; /* default don't echo */ -time_t tim; -char pg_pathname[256]; -static int ShowParserStats; -static int ShowPlannerStats; -int ShowExecutorStats; -FILE *StatFp; +static int EchoQuery = 0; /* default don't echo */ +time_t tim; +char pg_pathname[256]; +static int ShowParserStats; +static int ShowPlannerStats; +int ShowExecutorStats; +FILE *StatFp; typedef struct frontend { - bool fn_connected; - Port fn_port; - FILE *fn_Pfin; /* the input fd */ - FILE *fn_Pfout; /* the output fd */ - bool fn_done; /* set after the frontend closes its + bool fn_connected; + Port fn_port; + FILE *fn_Pfin; /* the input fd */ + FILE *fn_Pfout; /* the output fd */ + bool fn_done; /* set after the frontend closes its * connection */ -} FrontEnd; +} FrontEnd; -static Dllist *frontendList; +static Dllist *frontendList; /* ---------------- * people who want to use EOF should #define DONTUSENEWLINE in @@ -156,11 +156,11 @@ static Dllist *frontendList; * ---------------- */ #ifndef TCOP_DONTUSENEWLINE -int UseNewLine = 1; /* Use newlines query delimiters (the +int UseNewLine = 1; /* Use newlines query delimiters (the * default) */ #else -int UseNewLine = 0; /* Use EOF as query delimiters */ +int UseNewLine = 0; /* Use EOF as query delimiters */ #endif /* TCOP_DONTUSENEWLINE */ @@ -169,13 +169,13 @@ int UseNewLine = 0; /* Use EOF as query delimiters */ * plans * ---------------- */ -int BushyPlanFlag = 0; /* default to false -- consider - * only left-deep trees */ +int BushyPlanFlag = 0; /* default to false -- consider only + * left-deep trees */ /* ** Flags for expensive function optimization -- JMH 3/9/92 */ -int XfuncMode = 0; +int XfuncMode = 0; /* * ---------------- @@ -188,15 +188,15 @@ int XfuncMode = 0; * happens once. -cim 6/9/91 * ---------------- */ -int _exec_repeat_ = 1; +int _exec_repeat_ = 1; /* ---------------------------------------------------------------- * decls for routines only used in this file * ---------------------------------------------------------------- */ -static char InteractiveBackend(char *inBuf); -static char SocketBackend(char *inBuf, bool multiplexedBackend); -static char ReadCommand(char *inBuf, bool multiplexedBackend); +static char InteractiveBackend(char *inBuf); +static char SocketBackend(char *inBuf, bool multiplexedBackend); +static char ReadCommand(char *inBuf, bool multiplexedBackend); /* ---------------------------------------------------------------- @@ -213,10 +213,10 @@ static char ReadCommand(char *inBuf, bool multiplexedBackend); static char InteractiveBackend(char *inBuf) { - char *stuff = inBuf; /* current place in input buffer */ - int c; /* character read from getc() */ - bool end = false;/* end-of-input flag */ - bool backslashSeen = false; /* have we seen a \ ? */ + char *stuff = inBuf; /* current place in input buffer */ + int c; /* character read from getc() */ + bool end = false; /* end-of-input flag */ + bool backslashSeen = false; /* have we seen a \ ? */ /* ---------------- * display a prompt and obtain input from the user @@ -314,8 +314,8 @@ InteractiveBackend(char *inBuf) static char SocketBackend(char *inBuf, bool multiplexedBackend) { - char qtype[2]; - char result = '\0'; + char qtype[2]; + char result = '\0'; /* ---------------- * get input from the frontend @@ -338,43 +338,43 @@ SocketBackend(char *inBuf, bool multiplexedBackend) switch (*qtype) { - /* ---------------- - * 'Q': user entered a query - * ---------------- - */ - case 'Q': - pq_getstr(inBuf, MAX_PARSE_BUFFER); - result = 'Q'; - break; + /* ---------------- + * 'Q': user entered a query + * ---------------- + */ + case 'Q': + pq_getstr(inBuf, MAX_PARSE_BUFFER); + result = 'Q'; + break; - /* ---------------- - * 'F': calling user/system functions - * ---------------- - */ - case 'F': - pq_getstr(inBuf, MAX_PARSE_BUFFER); /* ignore the rest of the + /* ---------------- + * 'F': calling user/system functions + * ---------------- + */ + case 'F': + pq_getstr(inBuf, MAX_PARSE_BUFFER); /* ignore the rest of the * line */ - result = 'F'; - break; + result = 'F'; + break; - /* ---------------- - * 'X': frontend is exiting - * ---------------- - */ - case 'X': - result = 'X'; - break; + /* ---------------- + * 'X': frontend is exiting + * ---------------- + */ + case 'X': + result = 'X'; + break; - /* ---------------- - * otherwise we got garbage from the frontend. - * - * XXX are we certain that we want to do an elog(FATAL) here? - * -cim 1/24/90 - * ---------------- - */ - default: - elog(FATAL, "Socket command type %c unknown\n", *qtype); - break; + /* ---------------- + * otherwise we got garbage from the frontend. + * + * XXX are we certain that we want to do an elog(FATAL) here? + * -cim 1/24/90 + * ---------------- + */ + default: + elog(FATAL, "Socket command type %c unknown\n", *qtype); + break; } return result; } @@ -395,21 +395,21 @@ ReadCommand(char *inBuf, bool multiplexedBackend) return InteractiveBackend(inBuf); } -List * +List * pg_plan(char *query_string, /* string to execute */ Oid * typev, /* argument types */ int nargs, /* number of arguments */ QueryTreeList ** queryListP, /* pointer to the parse trees */ CommandDest dest) /* where results should go */ { - QueryTreeList *querytree_list; - int i; - List *plan_list = NIL; - Plan *plan; - int j; - QueryTreeList *new_list; - List *rewritten = NIL; - Query *querytree; + QueryTreeList *querytree_list; + int i; + List *plan_list = NIL; + Plan *plan; + int j; + QueryTreeList *new_list; + List *rewritten = NIL; + Query *querytree; /* ---------------- * (1) parse the request string into a list of parse trees @@ -468,8 +468,8 @@ pg_plan(char *query_string, /* string to execute */ rewritten = QueryRewrite(querytree); if (rewritten != NULL) { - int len, - k; + int len, + k; len = length(rewritten); if (len == 1) @@ -506,8 +506,8 @@ pg_plan(char *query_string, /* string to execute */ */ for (i = 0; i < querytree_list->len; i++) { - List *l; - List *rt = NULL; + List *l; + List *rt = NULL; querytree = querytree_list->qtrees[i]; @@ -522,12 +522,12 @@ pg_plan(char *query_string, /* string to execute */ foreach(l, rt) { - RangeTblEntry *rte = lfirst(l); - TimeRange *timequal = rte->timeRange; + RangeTblEntry *rte = lfirst(l); + TimeRange *timequal = rte->timeRange; if (timequal) { - int timecode = (rte->timeRange->endDate == NULL) ? 0 : 1; + int timecode = (rte->timeRange->endDate == NULL) ? 0 : 1; rte->timeQual = makeTimeRange(rte->timeRange->startDate, rte->timeRange->endDate, @@ -573,7 +573,7 @@ pg_plan(char *query_string, /* string to execute */ * that the command ended. -cim 6/1/90 * ---------------- */ - char *tag = "*ABORT STATE*"; + char *tag = "*ABORT STATE*"; EndCommand(tag, dest); @@ -658,12 +658,12 @@ pg_eval_dest(char *query_string,/* string to execute */ int nargs, /* number of arguments */ CommandDest dest) /* where results should go */ { - List *plan_list; - Plan *plan; - Query *querytree; - int i, - j; - QueryTreeList *querytree_list; + List *plan_list; + Plan *plan; + Query *querytree; + int i, + j; + QueryTreeList *querytree_list; /* plan the queries */ plan_list = pg_plan(query_string, typev, nargs, &querytree_list, dest); @@ -865,41 +865,41 @@ usage(char *progname) int PostgresMain(int argc, char *argv[]) { - int flagC; - int flagQ; - int flagE; - int flagEu; - int flag; - - char *DBName = NULL; - int errs = 0; - - char firstchar; - char parser_input[MAX_PARSE_BUFFER]; - char *userName; - - bool multiplexedBackend; - char *hostName; /* the host name of the backend server */ - char hostbuf[MAXHOSTNAMELEN]; - int serverSock; - int serverPortnum = 0; - int nSelected; /* number of descriptors ready from + int flagC; + int flagQ; + int flagE; + int flagEu; + int flag; + + char *DBName = NULL; + int errs = 0; + + char firstchar; + char parser_input[MAX_PARSE_BUFFER]; + char *userName; + + bool multiplexedBackend; + char *hostName; /* the host name of the backend server */ + char hostbuf[MAXHOSTNAMELEN]; + int serverSock; + int serverPortnum = 0; + int nSelected; /* number of descriptors ready from * select(); */ - int maxFd = 0; /* max file descriptor + 1 */ - fd_set rmask, - basemask; - FrontEnd *newFE, - *currentFE = NULL; - int numFE = 0; /* keep track of number of active + int maxFd = 0; /* max file descriptor + 1 */ + fd_set rmask, + basemask; + FrontEnd *newFE, + *currentFE = NULL; + int numFE = 0; /* keep track of number of active * frontends */ - Port *newPort; - int newFd; - Dlelem *curr; - int status; + Port *newPort; + int newFd; + Dlelem *curr; + int status; - extern int optind; - extern char *optarg; - extern short DebugLvl; + extern int optind; + extern char *optarg; + extern short DebugLvl; /* ---------------- * register signal handlers. @@ -950,256 +950,261 @@ PostgresMain(int argc, char *argv[]) switch (flag) { - case 'b': - /* ---------------- - * set BushyPlanFlag to true. - * ---------------- - */ - BushyPlanFlag = 1; - break; - case 'B': - /* ---------------- - * specify the size of buffer pool - * ---------------- - */ - NBuffers = atoi(optarg); - break; - - case 'C': - /* ---------------- - * don't print version string (don't know why this is 'C' --mao) - * ---------------- - */ - flagC = 1; - break; - - case 'D': /* PGDATA directory */ - DataDir = optarg; - - case 'd': /* debug level */ - flagQ = 0; - DebugLvl = (short) atoi(optarg); - if (DebugLvl > 1) - DebugPrintQuery = true; - if (DebugLvl > 2) - { - DebugPrintParse = true; - DebugPrintPlan = true; - DebugPrintRewrittenParsetree = true; - } - break; - - case 'E': - /* ---------------- - * E - echo the query the user entered - * ---------------- - */ - flagE = 1; - break; + case 'b': + /* ---------------- + * set BushyPlanFlag to true. + * ---------------- + */ + BushyPlanFlag = 1; + break; + case 'B': + /* ---------------- + * specify the size of buffer pool + * ---------------- + */ + NBuffers = atoi(optarg); + break; - case 'e': - /* -------------------------- - * Use european date formats. - * -------------------------- - */ - flagEu = 1; - break; + case 'C': + /* ---------------- + * don't print version string (don't know why this is 'C' --mao) + * ---------------- + */ + flagC = 1; + break; - case 'F': - /* -------------------- - * turn off fsync - * -------------------- - */ - fsyncOff = 1; - break; + case 'D': /* PGDATA directory */ + DataDir = optarg; - case 'f': - /* ----------------- - * f - forbid generation of certain plans - * ----------------- - */ - switch (optarg[0]) - { - case 's': /* seqscan */ - _enable_seqscan_ = false; + case 'd': /* debug level */ + flagQ = 0; + DebugLvl = (short) atoi(optarg); + if (DebugLvl > 1) + DebugPrintQuery = true; + if (DebugLvl > 2) + { + DebugPrintParse = true; + DebugPrintPlan = true; + DebugPrintRewrittenParsetree = true; + } break; - case 'i': /* indexscan */ - _enable_indexscan_ = false; + + case 'E': + /* ---------------- + * E - echo the query the user entered + * ---------------- + */ + flagE = 1; break; - case 'n': /* nestloop */ - _enable_nestloop_ = false; + + case 'e': + /* -------------------------- + * Use european date formats. + * -------------------------- + */ + flagEu = 1; break; - case 'm': /* mergejoin */ - _enable_mergesort_ = false; + + case 'F': + /* -------------------- + * turn off fsync + * -------------------- + */ + fsyncOff = 1; break; - case 'h': /* hashjoin */ - _enable_hashjoin_ = false; + + case 'f': + /* ----------------- + * f - forbid generation of certain plans + * ----------------- + */ + switch (optarg[0]) + { + case 's': /* seqscan */ + _enable_seqscan_ = false; + break; + case 'i': /* indexscan */ + _enable_indexscan_ = false; + break; + case 'n': /* nestloop */ + _enable_nestloop_ = false; + break; + case 'm': /* mergejoin */ + _enable_mergesort_ = false; + break; + case 'h': /* hashjoin */ + _enable_hashjoin_ = false; + break; + default: + errs++; + } break; - default: - errs++; - } - break; - case 'i': - dontExecute = 1; - break; + case 'i': + dontExecute = 1; + break; - case 'K': + case 'K': #ifdef LOCK_MGR_DEBUG - lockDebug = atoi(optarg); + lockDebug = atoi(optarg); #else - fprintf(stderr, "Lock debug not compiled in\n"); + fprintf(stderr, "Lock debug not compiled in\n"); #endif - break; - - case 'L': - /* -------------------- - * turn off locking - * -------------------- - */ - lockingOff = 1; - break; - - case 'm': + break; - /* - * start up a listening backend that can respond to multiple - * front-ends. (Note: all the front-end connections are - * still connected to a single-threaded backend. Requests are - * FCFS. Everything is in one transaction - */ - multiplexedBackend = true; - serverPortnum = atoi(optarg); - break; - case 'M': - exit(PostmasterMain(argc, argv)); - break; - case 'N': - /* ---------------- - * N - Don't use newline as a query delimiter - * ---------------- - */ - UseNewLine = 0; - break; + case 'L': + /* -------------------- + * turn off locking + * -------------------- + */ + lockingOff = 1; + break; - case 'o': - /* ---------------- - * o - send output (stdout and stderr) to the given file - * ---------------- - */ - strNcpy(OutputFileName, optarg, MAXPGPATH); - break; + case 'm': - case 'p': /* started by postmaster */ - /* ---------------- - * p - special flag passed if backend was forked - * by a postmaster. - * ---------------- - */ - IsUnderPostmaster = true; - break; + /* + * start up a listening backend that can respond to + * multiple front-ends. (Note: all the front-end + * connections are still connected to a single-threaded + * backend. Requests are FCFS. Everything is in one + * transaction + */ + multiplexedBackend = true; + serverPortnum = atoi(optarg); + break; + case 'M': + exit(PostmasterMain(argc, argv)); + break; + case 'N': + /* ---------------- + * N - Don't use newline as a query delimiter + * ---------------- + */ + UseNewLine = 0; + break; - case 'P': - /* ---------------- - * P - Use the passed file descriptor number as the port - * on which to communicate with the user. This is ONLY - * useful for debugging when fired up by the postmaster. - * ---------------- - */ - Portfd = atoi(optarg); - break; + case 'o': + /* ---------------- + * o - send output (stdout and stderr) to the given file + * ---------------- + */ + strNcpy(OutputFileName, optarg, MAXPGPATH); + break; - case 'Q': - /* ---------------- - * Q - set Quiet mode (reduce debugging output) - * ---------------- - */ - flagQ = 1; - break; + case 'p': /* started by postmaster */ + /* ---------------- + * p - special flag passed if backend was forked + * by a postmaster. + * ---------------- + */ + IsUnderPostmaster = true; + break; - case 'S': - /* ---------------- - * S - amount of sort memory to use in 1k bytes - * ---------------- - */ - SortMem = atoi(optarg); - break; + case 'P': + /* ---------------- + * P - Use the passed file descriptor number as the port + * on which to communicate with the user. This is ONLY + * useful for debugging when fired up by the postmaster. + * ---------------- + */ + Portfd = atoi(optarg); + break; - case 's': - /* ---------------- - * s - report usage statistics (timings) after each query - * ---------------- - */ - ShowStats = 1; - StatFp = stderr; - break; + case 'Q': + /* ---------------- + * Q - set Quiet mode (reduce debugging output) + * ---------------- + */ + flagQ = 1; + break; - case 't': - /* ---------------- - * tell postgres to report usage statistics (timings) for - * each query - * - * -tpa[rser] = print stats for parser time of each query - * -tpl[anner] = print stats for planner time of each query - * -te[xecutor] = print stats for executor time of each query - * caution: -s can not be used together with -t. - * ---------------- - */ - StatFp = stderr; - switch (optarg[0]) - { - case 'p': - if (optarg[1] == 'a') - ShowParserStats = 1; - else if (optarg[1] == 'l') - ShowPlannerStats = 1; - else - errs++; + case 'S': + /* ---------------- + * S - amount of sort memory to use in 1k bytes + * ---------------- + */ + SortMem = atoi(optarg); break; - case 'e': - ShowExecutorStats = 1; + + case 's': + /* ---------------- + * s - report usage statistics (timings) after each query + * ---------------- + */ + ShowStats = 1; + StatFp = stderr; break; - default: - errs++; + + case 't': + /* ---------------- + * tell postgres to report usage statistics (timings) for + * each query + * + * -tpa[rser] = print stats for parser time of each query + * -tpl[anner] = print stats for planner time of each query + * -te[xecutor] = print stats for executor time of each query + * caution: -s can not be used together with -t. + * ---------------- + */ + StatFp = stderr; + switch (optarg[0]) + { + case 'p': + if (optarg[1] == 'a') + ShowParserStats = 1; + else if (optarg[1] == 'l') + ShowPlannerStats = 1; + else + errs++; + break; + case 'e': + ShowExecutorStats = 1; + break; + default: + errs++; + break; + } break; - } - break; - case 'x': + case 'x': #if 0 /* planner/xfunc.h */ - /* control joey hellerstein's expensive function optimization */ - if (XfuncMode != 0) - { - fprintf(stderr, "only one -x flag is allowed\n"); - errs++; - break; - } - if (strcmp(optarg, "off") == 0) - XfuncMode = XFUNC_OFF; - else if (strcmp(optarg, "nor") == 0) - XfuncMode = XFUNC_NOR; - else if (strcmp(optarg, "nopull") == 0) - XfuncMode = XFUNC_NOPULL; - else if (strcmp(optarg, "nopm") == 0) - XfuncMode = XFUNC_NOPM; - else if (strcmp(optarg, "pullall") == 0) - XfuncMode = XFUNC_PULLALL; - else if (strcmp(optarg, "wait") == 0) - XfuncMode = XFUNC_WAIT; - else - { - fprintf(stderr, "use -x {off,nor,nopull,nopm,pullall,wait}\n"); - errs++; - } + + /* + * control joey hellerstein's expensive function + * optimization + */ + if (XfuncMode != 0) + { + fprintf(stderr, "only one -x flag is allowed\n"); + errs++; + break; + } + if (strcmp(optarg, "off") == 0) + XfuncMode = XFUNC_OFF; + else if (strcmp(optarg, "nor") == 0) + XfuncMode = XFUNC_NOR; + else if (strcmp(optarg, "nopull") == 0) + XfuncMode = XFUNC_NOPULL; + else if (strcmp(optarg, "nopm") == 0) + XfuncMode = XFUNC_NOPM; + else if (strcmp(optarg, "pullall") == 0) + XfuncMode = XFUNC_PULLALL; + else if (strcmp(optarg, "wait") == 0) + XfuncMode = XFUNC_WAIT; + else + { + fprintf(stderr, "use -x {off,nor,nopull,nopm,pullall,wait}\n"); + errs++; + } #endif - break; + break; - default: - /* ---------------- - * default: bad command line option - * ---------------- - */ - errs++; + default: + /* ---------------- + * default: bad command line option + * ---------------- + */ + errs++; } /* ---------------- @@ -1309,7 +1314,7 @@ PostgresMain(int argc, char *argv[]) /* add the original FrontEnd to the list */ if (IsUnderPostmaster == true) { - FrontEnd *fe = malloc(sizeof(FrontEnd)); + FrontEnd *fe = malloc(sizeof(FrontEnd)); FD_SET(Portfd, &basemask); maxFd = Max(serverSock, Portfd) + 1; @@ -1380,7 +1385,7 @@ PostgresMain(int argc, char *argv[]) if (IsUnderPostmaster == false) { puts("\nPOSTGRES backend interactive interface"); - puts("$Revision: 1.43 $ $Date: 1997/09/07 04:49:33 $"); + puts("$Revision: 1.44 $ $Date: 1997/09/08 02:29:48 $"); } /* ---------------- @@ -1447,8 +1452,8 @@ PostgresMain(int argc, char *argv[]) curr = DLGetHead(frontendList); while (curr) { - FrontEnd *fe = (FrontEnd *) DLE_VAL(curr); - Port *port = &(fe->fn_port); + FrontEnd *fe = (FrontEnd *) DLE_VAL(curr); + Port *port = &(fe->fn_port); /* this is lifted from postmaster.c */ if (FD_ISSET(port->sock, &rmask)) @@ -1476,7 +1481,7 @@ PostgresMain(int argc, char *argv[]) } if (fe->fn_done) { - Dlelem *c = curr; + Dlelem *c = curr; curr = DLGetSucc(curr); DLRemove(c); @@ -1497,83 +1502,83 @@ PostgresMain(int argc, char *argv[]) /* process the command */ switch (firstchar) { - /* ---------------- - * 'F' indicates a fastpath call. - * XXX HandleFunctionRequest - * ---------------- - */ - case 'F': - IsEmptyQuery = false; - - /* start an xact for this function invocation */ - if (!Quiet) - { - time(&tim); - printf("\tStartTransactionCommand() at %s\n", ctime(&tim)); - } - - StartTransactionCommand(); - HandleFunctionRequest(); - break; - - /* ---------------- - * 'Q' indicates a user query - * ---------------- - */ - case 'Q': - fflush(stdout); - - if (strspn(parser_input, " \t\n") == strlen(parser_input)) - { - /* ---------------- - * if there is nothing in the input buffer, don't bother - * trying to parse and execute anything.. - * ---------------- - */ - IsEmptyQuery = true; - } - else - { /* ---------------- - * otherwise, process the input string. + * 'F' indicates a fastpath call. + * XXX HandleFunctionRequest * ---------------- */ + case 'F': IsEmptyQuery = false; - if (ShowStats) - ResetUsage(); - /* start an xact for this query */ + /* start an xact for this function invocation */ if (!Quiet) { time(&tim); printf("\tStartTransactionCommand() at %s\n", ctime(&tim)); } + StartTransactionCommand(); + HandleFunctionRequest(); + break; - pg_eval(parser_input, (char **) NULL, (Oid *) NULL, 0); + /* ---------------- + * 'Q' indicates a user query + * ---------------- + */ + case 'Q': + fflush(stdout); - if (ShowStats) - ShowUsage(); - } - break; + if (strspn(parser_input, " \t\n") == strlen(parser_input)) + { + /* ---------------- + * if there is nothing in the input buffer, don't bother + * trying to parse and execute anything.. + * ---------------- + */ + IsEmptyQuery = true; + } + else + { + /* ---------------- + * otherwise, process the input string. + * ---------------- + */ + IsEmptyQuery = false; + if (ShowStats) + ResetUsage(); + + /* start an xact for this query */ + if (!Quiet) + { + time(&tim); + printf("\tStartTransactionCommand() at %s\n", ctime(&tim)); + } + StartTransactionCommand(); - /* ---------------- - * 'X' means that the frontend is closing down the socket - * ---------------- - */ - case 'X': - IsEmptyQuery = true; - if (multiplexedBackend) - { - FD_CLR(currentFE->fn_port.sock, &basemask); - currentFE->fn_done = true; - numFE--; - } - pq_close(); - break; + pg_eval(parser_input, (char **) NULL, (Oid *) NULL, 0); - default: - elog(WARN, "unknown frontend message was recieved"); + if (ShowStats) + ShowUsage(); + } + break; + + /* ---------------- + * 'X' means that the frontend is closing down the socket + * ---------------- + */ + case 'X': + IsEmptyQuery = true; + if (multiplexedBackend) + { + FD_CLR(currentFE->fn_port.sock, &basemask); + currentFE->fn_done = true; + numFE--; + } + pq_close(); + break; + + default: + elog(WARN, "unknown frontend message was recieved"); } /* ---------------- @@ -1610,8 +1615,8 @@ PostgresMain(int argc, char *argv[]) #include <sys/resource.h> #endif /* HAVE_GETRUSAGE */ -struct rusage Save_r; -struct timeval Save_t; +struct rusage Save_r; +struct timeval Save_t; void ResetUsage(void) @@ -1627,11 +1632,11 @@ ResetUsage(void) void ShowUsage(void) { - struct timeval user, - sys; - struct timeval elapse_t; + struct timeval user, + sys; + struct timeval elapse_t; struct timezone tz; - struct rusage r; + struct rusage r; getrusage(RUSAGE_SELF, &r); gettimeofday(&elapse_t, &tz); diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index ca649291355..46a2000cf05 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.8 1997/09/07 04:49:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.9 1997/09/08 02:29:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,20 +38,20 @@ #include "commands/command.h" -static char *CreateOperationTag(int operationType); -static void ProcessQueryDesc(QueryDesc * queryDesc); +static char *CreateOperationTag(int operationType); +static void ProcessQueryDesc(QueryDesc * queryDesc); /* ---------------------------------------------------------------- * CreateQueryDesc * ---------------------------------------------------------------- */ -QueryDesc * +QueryDesc * CreateQueryDesc(Query * parsetree, Plan * plantree, CommandDest dest) { - QueryDesc *qd = (QueryDesc *) palloc(sizeof(QueryDesc)); + QueryDesc *qd = (QueryDesc *) palloc(sizeof(QueryDesc)); qd->operation = parsetree->commandType; /* operation */ qd->parsetree = parsetree; /* parse tree */ @@ -66,12 +66,12 @@ CreateQueryDesc(Query * parsetree, * Note: this may someday take parameters -cim 9/18/89 * ---------------------------------------------------------------- */ -EState * +EState * CreateExecutorState(void) { - EState *state; - extern int NBuffers; - long *refcount; + EState *state; + extern int NBuffers; + long *refcount; /* ---------------- * create a new executor state @@ -114,30 +114,30 @@ CreateExecutorState(void) * query operation. * ---------------------------------------------------------------- */ -static char * +static char * CreateOperationTag(int operationType) { - char *tag; + char *tag; switch (operationType) { - case CMD_SELECT: - tag = "SELECT"; - break; - case CMD_INSERT: - tag = "INSERT"; - break; - case CMD_DELETE: - tag = "DELETE"; - break; - case CMD_UPDATE: - tag = "UPDATE"; - break; - default: - elog(DEBUG, "CreateOperationTag: unknown operation type %d", - operationType); - tag = NULL; - break; + case CMD_SELECT: + tag = "SELECT"; + break; + case CMD_INSERT: + tag = "INSERT"; + break; + case CMD_DELETE: + tag = "DELETE"; + break; + case CMD_UPDATE: + tag = "UPDATE"; + break; + default: + elog(DEBUG, "CreateOperationTag: unknown operation type %d", + operationType); + tag = NULL; + break; } return tag; @@ -156,8 +156,8 @@ ProcessPortal(char *portalName, TupleDesc attinfo, CommandDest dest) { - Portal portal; - MemoryContext portalContext; + Portal portal; + MemoryContext portalContext; /* ---------------- * convert the current blank portal into the user-specified @@ -205,17 +205,17 @@ ProcessPortal(char *portalName, static void ProcessQueryDesc(QueryDesc * queryDesc) { - Query *parseTree; - Plan *plan; - int operation; - char *tag; - EState *state; - TupleDesc attinfo; - - bool isRetrieveIntoPortal; - bool isRetrieveIntoRelation; - char *intoName = NULL; - CommandDest dest; + Query *parseTree; + Plan *plan; + int operation; + char *tag; + EState *state; + TupleDesc attinfo; + + bool isRetrieveIntoPortal; + bool isRetrieveIntoRelation; + char *intoName = NULL; + CommandDest dest; /* ---------------- * get info from the query desc @@ -362,9 +362,9 @@ ProcessQuery(Query * parsetree, int nargs, CommandDest dest) { - QueryDesc *queryDesc; - extern int dontExecute;/* from postgres.c */ - extern void print_plan(Plan * p, Query * parsetree); /* from print.c */ + QueryDesc *queryDesc; + extern int dontExecute; /* from postgres.c */ + extern void print_plan(Plan * p, Query * parsetree); /* from print.c */ queryDesc = CreateQueryDesc(parsetree, plan, dest); diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index d309ac69a27..33fe08c4551 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.22 1997/09/07 04:49:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.23 1997/09/08 02:29:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -78,648 +78,652 @@ void ProcessUtility(Node * parsetree, CommandDest dest) { - char *commandTag = NULL; - char *relname; - char *relationName; - char *userName; + char *commandTag = NULL; + char *relname; + char *relationName; + char *userName; userName = GetPgUserName(); switch (nodeTag(parsetree)) { - /* - * ******************************** transactions ******************************** - * - */ - case T_TransactionStmt: - { - TransactionStmt *stmt = (TransactionStmt *) parsetree; + /* + * ******************************** transactions ******************************** + * + */ + case T_TransactionStmt: + { + TransactionStmt *stmt = (TransactionStmt *) parsetree; - switch (stmt->command) + switch (stmt->command) + { + case BEGIN_TRANS: + commandTag = "BEGIN"; + CHECK_IF_ABORTED(); + BeginTransactionBlock(); + break; + + case END_TRANS: + commandTag = "END"; + EndTransactionBlock(); + break; + + case ABORT_TRANS: + commandTag = "ABORT"; + UserAbortTransactionBlock(); + break; + } + } + break; + + /* + * ******************************** portal manipulation ******************************** + * + */ + case T_ClosePortalStmt: { - case BEGIN_TRANS: - commandTag = "BEGIN"; - CHECK_IF_ABORTED(); - BeginTransactionBlock(); - break; + ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree; - case END_TRANS: - commandTag = "END"; - EndTransactionBlock(); - break; + commandTag = "CLOSE"; + CHECK_IF_ABORTED(); - case ABORT_TRANS: - commandTag = "ABORT"; - UserAbortTransactionBlock(); - break; + PerformPortalClose(stmt->portalname, dest); } - } - break; - - /* - * ******************************** portal manipulation ******************************** - * - */ - case T_ClosePortalStmt: - { - ClosePortalStmt *stmt = (ClosePortalStmt *) parsetree; - - commandTag = "CLOSE"; - CHECK_IF_ABORTED(); + break; - PerformPortalClose(stmt->portalname, dest); - } - break; + case T_FetchStmt: + { + FetchStmt *stmt = (FetchStmt *) parsetree; + char *portalName = stmt->portalname; + bool forward; + int count; + + commandTag = "FETCH"; + CHECK_IF_ABORTED(); - case T_FetchStmt: - { - FetchStmt *stmt = (FetchStmt *) parsetree; - char *portalName = stmt->portalname; - bool forward; - int count; + forward = (bool) (stmt->direction == FORWARD); - commandTag = "FETCH"; - CHECK_IF_ABORTED(); + /* + * parser ensures that count is >= 0 and 'fetch ALL' -> 0 + */ - forward = (bool) (stmt->direction == FORWARD); + count = stmt->howMany; + PerformPortalFetch(portalName, forward, count, commandTag, dest); + } + break; /* - * parser ensures that count is >= 0 and 'fetch ALL' -> 0 + * ******************************** relation and attribute + * manipulation ******************************** + * */ - - count = stmt->howMany; - PerformPortalFetch(portalName, forward, count, commandTag, dest); - } - break; - - /* - * ******************************** relation and attribute - * manipulation ******************************** - * - */ - case T_CreateStmt: - commandTag = "CREATE"; - CHECK_IF_ABORTED(); - - DefineRelation((CreateStmt *) parsetree); - break; - - case T_DestroyStmt: - { - DestroyStmt *stmt = (DestroyStmt *) parsetree; - List *arg; - List *args = stmt->relNames; - Relation rel; - - commandTag = "DROP"; + case T_CreateStmt: + commandTag = "CREATE"; CHECK_IF_ABORTED(); - foreach(arg, args) + DefineRelation((CreateStmt *) parsetree); + break; + + case T_DestroyStmt: { - relname = strVal(lfirst(arg)); - if (IsSystemRelationName(relname)) - elog(WARN, "class \"%s\" is a system catalog", - relname); - rel = heap_openr(relname); - if (RelationIsValid(rel)) + DestroyStmt *stmt = (DestroyStmt *) parsetree; + List *arg; + List *args = stmt->relNames; + Relation rel; + + commandTag = "DROP"; + CHECK_IF_ABORTED(); + + foreach(arg, args) { - if (stmt->sequence && - rel->rd_rel->relkind != RELKIND_SEQUENCE) - elog(WARN, "Use DROP TABLE to drop table '%s'", + relname = strVal(lfirst(arg)); + if (IsSystemRelationName(relname)) + elog(WARN, "class \"%s\" is a system catalog", relname); - if (!(stmt->sequence) && - rel->rd_rel->relkind == RELKIND_SEQUENCE) - elog(WARN, "Use DROP SEQUENCE to drop sequence '%s'", - relname); - heap_close(rel); - } + rel = heap_openr(relname); + if (RelationIsValid(rel)) + { + if (stmt->sequence && + rel->rd_rel->relkind != RELKIND_SEQUENCE) + elog(WARN, "Use DROP TABLE to drop table '%s'", + relname); + if (!(stmt->sequence) && + rel->rd_rel->relkind == RELKIND_SEQUENCE) + elog(WARN, "Use DROP SEQUENCE to drop sequence '%s'", + relname); + heap_close(rel); + } #ifndef NO_SECURITY - if (!pg_ownercheck(userName, relname, RELNAME)) - elog(WARN, "you do not own class \"%s\"", - relname); + if (!pg_ownercheck(userName, relname, RELNAME)) + elog(WARN, "you do not own class \"%s\"", + relname); #endif + } + foreach(arg, args) + { + relname = strVal(lfirst(arg)); + RemoveRelation(relname); + } } - foreach(arg, args) + break; + + case T_PurgeStmt: { - relname = strVal(lfirst(arg)); - RemoveRelation(relname); + PurgeStmt *stmt = (PurgeStmt *) parsetree; + + commandTag = "PURGE"; + CHECK_IF_ABORTED(); + + RelationPurge(stmt->relname, + stmt->beforeDate, /* absolute time string */ + stmt->afterDate); /* relative time string */ } - } - break; + break; + + case T_CopyStmt: + { + CopyStmt *stmt = (CopyStmt *) parsetree; - case T_PurgeStmt: - { - PurgeStmt *stmt = (PurgeStmt *) parsetree; + commandTag = "COPY"; + CHECK_IF_ABORTED(); - commandTag = "PURGE"; - CHECK_IF_ABORTED(); + DoCopy(stmt->relname, + stmt->binary, + stmt->oids, + (bool) (stmt->direction == FROM), + (bool) (stmt->filename == NULL), - RelationPurge(stmt->relname, - stmt->beforeDate, /* absolute time string */ - stmt->afterDate); /* relative time string */ - } - break; + /* + * null filename means copy to/from stdout/stdin, rather + * than to/from a file. + */ + stmt->filename, + stmt->delimiter); + } + break; - case T_CopyStmt: - { - CopyStmt *stmt = (CopyStmt *) parsetree; + case T_AddAttrStmt: + { + AddAttrStmt *stmt = (AddAttrStmt *) parsetree; - commandTag = "COPY"; - CHECK_IF_ABORTED(); + commandTag = "ADD"; + CHECK_IF_ABORTED(); - DoCopy(stmt->relname, - stmt->binary, - stmt->oids, - (bool) (stmt->direction == FROM), - (bool) (stmt->filename == NULL), + /* + * owner checking done in PerformAddAttribute (now + * recursive) + */ + PerformAddAttribute(stmt->relname, + userName, + stmt->inh, + stmt->colDef); + } + break; /* - * null filename means copy to/from stdout/stdin, rather than - * to/from a file. + * schema */ - stmt->filename, - stmt->delimiter); - } - break; - - case T_AddAttrStmt: - { - AddAttrStmt *stmt = (AddAttrStmt *) parsetree; - - commandTag = "ADD"; - CHECK_IF_ABORTED(); + case T_RenameStmt: + { + RenameStmt *stmt = (RenameStmt *) parsetree; - /* owner checking done in PerformAddAttribute (now recursive) */ - PerformAddAttribute(stmt->relname, - userName, - stmt->inh, - stmt->colDef); - } - break; - - /* - * schema - */ - case T_RenameStmt: - { - RenameStmt *stmt = (RenameStmt *) parsetree; - - commandTag = "RENAME"; - CHECK_IF_ABORTED(); + commandTag = "RENAME"; + CHECK_IF_ABORTED(); - relname = stmt->relname; - if (IsSystemRelationName(relname)) - elog(WARN, "class \"%s\" is a system catalog", - relname); + relname = stmt->relname; + if (IsSystemRelationName(relname)) + elog(WARN, "class \"%s\" is a system catalog", + relname); #ifndef NO_SECURITY - if (!pg_ownercheck(userName, relname, RELNAME)) - elog(WARN, "you do not own class \"%s\"", - relname); + if (!pg_ownercheck(userName, relname, RELNAME)) + elog(WARN, "you do not own class \"%s\"", + relname); #endif - /* ---------------- - * XXX using len == 3 to tell the difference - * between "rename rel to newrel" and - * "rename att in rel to newatt" will not - * work soon because "rename type/operator/rule" - * stuff is being added. - cim 10/24/90 - * ---------------- - * [another piece of amuzing but useless anecdote -- ay] - */ - if (stmt->column == NULL) - { /* ---------------- - * rename relation - * - * Note: we also rename the "type" tuple - * corresponding to the relation. + * XXX using len == 3 to tell the difference + * between "rename rel to newrel" and + * "rename att in rel to newatt" will not + * work soon because "rename type/operator/rule" + * stuff is being added. - cim 10/24/90 * ---------------- + * [another piece of amuzing but useless anecdote -- ay] */ - renamerel(relname, /* old name */ - stmt->newname); /* new name */ - TypeRename(relname, /* old name */ - stmt->newname); /* new name */ - } - else - { - /* ---------------- - * rename attribute - * ---------------- - */ - renameatt(relname, /* relname */ - stmt->column, /* old att name */ - stmt->newname, /* new att name */ - userName, - stmt->inh); /* recursive? */ + if (stmt->column == NULL) + { + /* ---------------- + * rename relation + * + * Note: we also rename the "type" tuple + * corresponding to the relation. + * ---------------- + */ + renamerel(relname, /* old name */ + stmt->newname); /* new name */ + TypeRename(relname, /* old name */ + stmt->newname); /* new name */ + } + else + { + /* ---------------- + * rename attribute + * ---------------- + */ + renameatt(relname, /* relname */ + stmt->column, /* old att name */ + stmt->newname, /* new att name */ + userName, + stmt->inh); /* recursive? */ + } } - } - break; + break; - case T_ChangeACLStmt: - { - ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree; - List *i; - AclItem *aip; - unsigned modechg; + case T_ChangeACLStmt: + { + ChangeACLStmt *stmt = (ChangeACLStmt *) parsetree; + List *i; + AclItem *aip; + unsigned modechg; - commandTag = "CHANGE"; - CHECK_IF_ABORTED(); + commandTag = "CHANGE"; + CHECK_IF_ABORTED(); - aip = stmt->aclitem; - modechg = stmt->modechg; + aip = stmt->aclitem; + modechg = stmt->modechg; #ifndef NO_SECURITY - foreach(i, stmt->relNames) - { - relname = strVal(lfirst(i)); - if (!pg_ownercheck(userName, relname, RELNAME)) - elog(WARN, "you do not own class \"%s\"", - relname); - } + foreach(i, stmt->relNames) + { + relname = strVal(lfirst(i)); + if (!pg_ownercheck(userName, relname, RELNAME)) + elog(WARN, "you do not own class \"%s\"", + relname); + } #endif - foreach(i, stmt->relNames) - { - relname = strVal(lfirst(i)); - ChangeAcl(relname, aip, modechg); - } + foreach(i, stmt->relNames) + { + relname = strVal(lfirst(i)); + ChangeAcl(relname, aip, modechg); + } - } - break; + } + break; - /* - * ******************************** object creation / destruction ******************************** - * - */ - case T_DefineStmt: - { - DefineStmt *stmt = (DefineStmt *) parsetree; + /* + * ******************************** object creation / + * destruction ******************************** + * + */ + case T_DefineStmt: + { + DefineStmt *stmt = (DefineStmt *) parsetree; - commandTag = "CREATE"; - CHECK_IF_ABORTED(); + commandTag = "CREATE"; + CHECK_IF_ABORTED(); - switch (stmt->defType) - { - case OPERATOR: - DefineOperator(stmt->defname, /* operator name */ - stmt->definition); /* rest */ - break; - case P_TYPE: + switch (stmt->defType) { - DefineType(stmt->defname, stmt->definition); + case OPERATOR: + DefineOperator(stmt->defname, /* operator name */ + stmt->definition); /* rest */ + break; + case P_TYPE: + { + DefineType(stmt->defname, stmt->definition); + } + break; + case AGGREGATE: + DefineAggregate(stmt->defname, /* aggregate name */ + stmt->definition); /* rest */ + break; } - break; - case AGGREGATE: - DefineAggregate(stmt->defname, /* aggregate name */ - stmt->definition); /* rest */ - break; } - } - break; + break; + + case T_ViewStmt: /* CREATE VIEW */ + { + ViewStmt *stmt = (ViewStmt *) parsetree; - case T_ViewStmt: /* CREATE VIEW */ - { - ViewStmt *stmt = (ViewStmt *) parsetree; + commandTag = "CREATE"; + CHECK_IF_ABORTED(); + DefineView(stmt->viewname, stmt->query); /* retrieve parsetree */ + } + break; + case T_ProcedureStmt: /* CREATE FUNCTION */ commandTag = "CREATE"; CHECK_IF_ABORTED(); - DefineView(stmt->viewname, stmt->query); /* retrieve parsetree */ - } - break; + CreateFunction((ProcedureStmt *) parsetree, dest); /* everything */ + break; - case T_ProcedureStmt: /* CREATE FUNCTION */ - commandTag = "CREATE"; - CHECK_IF_ABORTED(); - CreateFunction((ProcedureStmt *) parsetree, dest); /* everything */ - break; + case T_IndexStmt: /* CREATE INDEX */ + { + IndexStmt *stmt = (IndexStmt *) parsetree; - case T_IndexStmt: /* CREATE INDEX */ - { - IndexStmt *stmt = (IndexStmt *) parsetree; + commandTag = "CREATE"; + CHECK_IF_ABORTED(); + /* XXX no support for ARCHIVE indices, yet */ + DefineIndex(stmt->relname, /* relation name */ + stmt->idxname, /* index name */ + stmt->accessMethod, /* am name */ + stmt->indexParams, /* parameters */ + stmt->withClause, + stmt->unique, + (Expr *) stmt->whereClause, + stmt->rangetable); + } + break; - commandTag = "CREATE"; - CHECK_IF_ABORTED(); - /* XXX no support for ARCHIVE indices, yet */ - DefineIndex(stmt->relname, /* relation name */ - stmt->idxname, /* index name */ - stmt->accessMethod, /* am name */ - stmt->indexParams, /* parameters */ - stmt->withClause, - stmt->unique, - (Expr *) stmt->whereClause, - stmt->rangetable); - } - break; - - case T_RuleStmt: /* CREATE RULE */ - { - RuleStmt *stmt = (RuleStmt *) parsetree; - int aclcheck_result; + case T_RuleStmt: /* CREATE RULE */ + { + RuleStmt *stmt = (RuleStmt *) parsetree; + int aclcheck_result; #ifndef NO_SECURITY - relname = stmt->object->relname; - aclcheck_result = pg_aclcheck(relname, userName, ACL_RU); - if (aclcheck_result != ACLCHECK_OK) - elog(WARN, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]); + relname = stmt->object->relname; + aclcheck_result = pg_aclcheck(relname, userName, ACL_RU); + if (aclcheck_result != ACLCHECK_OK) + elog(WARN, "%s: %s", relname, aclcheck_error_strings[aclcheck_result]); #endif + commandTag = "CREATE"; + CHECK_IF_ABORTED(); + DefineQueryRewrite(stmt); + } + break; + + case T_CreateSeqStmt: commandTag = "CREATE"; CHECK_IF_ABORTED(); - DefineQueryRewrite(stmt); - } - break; - - case T_CreateSeqStmt: - commandTag = "CREATE"; - CHECK_IF_ABORTED(); - DefineSequence((CreateSeqStmt *) parsetree); - break; + DefineSequence((CreateSeqStmt *) parsetree); + break; - case T_ExtendStmt: - { - ExtendStmt *stmt = (ExtendStmt *) parsetree; + case T_ExtendStmt: + { + ExtendStmt *stmt = (ExtendStmt *) parsetree; - commandTag = "EXTEND"; - CHECK_IF_ABORTED(); + commandTag = "EXTEND"; + CHECK_IF_ABORTED(); - ExtendIndex(stmt->idxname, /* index name */ - (Expr *) stmt->whereClause, /* where */ - stmt->rangetable); - } - break; + ExtendIndex(stmt->idxname, /* index name */ + (Expr *) stmt->whereClause, /* where */ + stmt->rangetable); + } + break; - case T_RemoveStmt: - { - RemoveStmt *stmt = (RemoveStmt *) parsetree; + case T_RemoveStmt: + { + RemoveStmt *stmt = (RemoveStmt *) parsetree; - commandTag = "DROP"; - CHECK_IF_ABORTED(); + commandTag = "DROP"; + CHECK_IF_ABORTED(); - switch (stmt->removeType) - { - case INDEX: - relname = stmt->name; - if (IsSystemRelationName(relname)) - elog(WARN, "class \"%s\" is a system catalog index", - relname); + switch (stmt->removeType) + { + case INDEX: + relname = stmt->name; + if (IsSystemRelationName(relname)) + elog(WARN, "class \"%s\" is a system catalog index", + relname); #ifndef NO_SECURITY - if (!pg_ownercheck(userName, relname, RELNAME)) - elog(WARN, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]); + if (!pg_ownercheck(userName, relname, RELNAME)) + elog(WARN, "%s: %s", relname, aclcheck_error_strings[ACLCHECK_NOT_OWNER]); #endif - RemoveIndex(relname); - break; - case RULE: - { - char *rulename = stmt->name; - int aclcheck_result; + RemoveIndex(relname); + break; + case RULE: + { + char *rulename = stmt->name; + int aclcheck_result; #ifndef NO_SECURITY - relationName = RewriteGetRuleEventRel(rulename); - aclcheck_result = pg_aclcheck(relationName, userName, ACL_RU); - if (aclcheck_result != ACLCHECK_OK) - { - elog(WARN, "%s: %s", relationName, aclcheck_error_strings[aclcheck_result]); - } + relationName = RewriteGetRuleEventRel(rulename); + aclcheck_result = pg_aclcheck(relationName, userName, ACL_RU); + if (aclcheck_result != ACLCHECK_OK) + { + elog(WARN, "%s: %s", relationName, aclcheck_error_strings[aclcheck_result]); + } #endif - RemoveRewriteRule(rulename); - } - break; - case P_TYPE: + RemoveRewriteRule(rulename); + } + break; + case P_TYPE: #ifndef NO_SECURITY - /* XXX moved to remove.c */ + /* XXX moved to remove.c */ #endif - RemoveType(stmt->name); - break; - case VIEW: - { - char *viewName = stmt->name; - char *ruleName; + RemoveType(stmt->name); + break; + case VIEW: + { + char *viewName = stmt->name; + char *ruleName; #ifndef NO_SECURITY - ruleName = MakeRetrieveViewRuleName(viewName); - relationName = RewriteGetRuleEventRel(ruleName); - if (!pg_ownercheck(userName, relationName, RELNAME)) - elog(WARN, "%s: %s", relationName, aclcheck_error_strings[ACLCHECK_NOT_OWNER]); - pfree(ruleName); + ruleName = MakeRetrieveViewRuleName(viewName); + relationName = RewriteGetRuleEventRel(ruleName); + if (!pg_ownercheck(userName, relationName, RELNAME)) + elog(WARN, "%s: %s", relationName, aclcheck_error_strings[ACLCHECK_NOT_OWNER]); + pfree(ruleName); #endif - RemoveView(viewName); + RemoveView(viewName); + } + break; } break; } break; - } - break; - case T_RemoveAggrStmt: - { - RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree; + case T_RemoveAggrStmt: + { + RemoveAggrStmt *stmt = (RemoveAggrStmt *) parsetree; - commandTag = "DROP"; - CHECK_IF_ABORTED(); - RemoveAggregate(stmt->aggname, stmt->aggtype); - } - break; + commandTag = "DROP"; + CHECK_IF_ABORTED(); + RemoveAggregate(stmt->aggname, stmt->aggtype); + } + break; - case T_RemoveFuncStmt: - { - RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree; + case T_RemoveFuncStmt: + { + RemoveFuncStmt *stmt = (RemoveFuncStmt *) parsetree; - commandTag = "DROP"; - CHECK_IF_ABORTED(); - RemoveFunction(stmt->funcname, - length(stmt->args), - stmt->args); - } - break; - - case T_RemoveOperStmt: - { - RemoveOperStmt *stmt = (RemoveOperStmt *) parsetree; - char *type1 = (char *) NULL; - char *type2 = (char *) NULL; + commandTag = "DROP"; + CHECK_IF_ABORTED(); + RemoveFunction(stmt->funcname, + length(stmt->args), + stmt->args); + } + break; - commandTag = "DROP"; - CHECK_IF_ABORTED(); + case T_RemoveOperStmt: + { + RemoveOperStmt *stmt = (RemoveOperStmt *) parsetree; + char *type1 = (char *) NULL; + char *type2 = (char *) NULL; - if (lfirst(stmt->args) != NULL) - type1 = strVal(lfirst(stmt->args)); - if (lsecond(stmt->args) != NULL) - type2 = strVal(lsecond(stmt->args)); - RemoveOperator(stmt->opname, type1, type2); - } - break; - - case T_VersionStmt: - { - elog(WARN, "CREATE VERSION is not currently implemented"); - } - break; - - case T_CreatedbStmt: - { - CreatedbStmt *stmt = (CreatedbStmt *) parsetree; - - commandTag = "CREATEDB"; - CHECK_IF_ABORTED(); - createdb(stmt->dbname); - } - break; + commandTag = "DROP"; + CHECK_IF_ABORTED(); - case T_DestroydbStmt: - { - DestroydbStmt *stmt = (DestroydbStmt *) parsetree; + if (lfirst(stmt->args) != NULL) + type1 = strVal(lfirst(stmt->args)); + if (lsecond(stmt->args) != NULL) + type2 = strVal(lsecond(stmt->args)); + RemoveOperator(stmt->opname, type1, type2); + } + break; - commandTag = "DESTROYDB"; - CHECK_IF_ABORTED(); - destroydb(stmt->dbname); - } - break; + case T_VersionStmt: + { + elog(WARN, "CREATE VERSION is not currently implemented"); + } + break; - /* Query-level asynchronous notification */ - case T_NotifyStmt: - { - NotifyStmt *stmt = (NotifyStmt *) parsetree; + case T_CreatedbStmt: + { + CreatedbStmt *stmt = (CreatedbStmt *) parsetree; - commandTag = "NOTIFY"; - CHECK_IF_ABORTED(); + commandTag = "CREATEDB"; + CHECK_IF_ABORTED(); + createdb(stmt->dbname); + } + break; + + case T_DestroydbStmt: + { + DestroydbStmt *stmt = (DestroydbStmt *) parsetree; - Async_Notify(stmt->relname); - } - break; + commandTag = "DESTROYDB"; + CHECK_IF_ABORTED(); + destroydb(stmt->dbname); + } + break; - case T_ListenStmt: - { - ListenStmt *stmt = (ListenStmt *) parsetree; + /* Query-level asynchronous notification */ + case T_NotifyStmt: + { + NotifyStmt *stmt = (NotifyStmt *) parsetree; - commandTag = "LISTEN"; - CHECK_IF_ABORTED(); + commandTag = "NOTIFY"; + CHECK_IF_ABORTED(); - Async_Listen(stmt->relname, MasterPid); - } - break; - - /* - * ******************************** dynamic loader ******************************** - * - */ - case T_LoadStmt: - { - LoadStmt *stmt = (LoadStmt *) parsetree; - FILE *fp; - char *filename; - - commandTag = "LOAD"; - CHECK_IF_ABORTED(); + Async_Notify(stmt->relname); + } + break; - filename = stmt->filename; - closeAllVfds(); - if ((fp = AllocateFile(filename, "r")) == NULL) - elog(WARN, "LOAD: could not open file %s", filename); - FreeFile(fp); - load_file(filename); - } - break; + case T_ListenStmt: + { + ListenStmt *stmt = (ListenStmt *) parsetree; - case T_ClusterStmt: - { - ClusterStmt *stmt = (ClusterStmt *) parsetree; + commandTag = "LISTEN"; + CHECK_IF_ABORTED(); - commandTag = "CLUSTER"; - CHECK_IF_ABORTED(); + Async_Listen(stmt->relname, MasterPid); + } + break; - cluster(stmt->relname, stmt->indexname); - } - break; + /* + * ******************************** dynamic loader ******************************** + * + */ + case T_LoadStmt: + { + LoadStmt *stmt = (LoadStmt *) parsetree; + FILE *fp; + char *filename; + + commandTag = "LOAD"; + CHECK_IF_ABORTED(); + + filename = stmt->filename; + closeAllVfds(); + if ((fp = AllocateFile(filename, "r")) == NULL) + elog(WARN, "LOAD: could not open file %s", filename); + FreeFile(fp); + load_file(filename); + } + break; - case T_VacuumStmt: - commandTag = "VACUUM"; - CHECK_IF_ABORTED(); - vacuum(((VacuumStmt *) parsetree)->vacrel, - ((VacuumStmt *) parsetree)->verbose, - ((VacuumStmt *) parsetree)->analyze, - ((VacuumStmt *) parsetree)->va_spec); - break; + case T_ClusterStmt: + { + ClusterStmt *stmt = (ClusterStmt *) parsetree; - case T_ExplainStmt: - { - ExplainStmt *stmt = (ExplainStmt *) parsetree; + commandTag = "CLUSTER"; + CHECK_IF_ABORTED(); - commandTag = "EXPLAIN"; + cluster(stmt->relname, stmt->indexname); + } + break; + + case T_VacuumStmt: + commandTag = "VACUUM"; CHECK_IF_ABORTED(); + vacuum(((VacuumStmt *) parsetree)->vacrel, + ((VacuumStmt *) parsetree)->verbose, + ((VacuumStmt *) parsetree)->analyze, + ((VacuumStmt *) parsetree)->va_spec); + break; + + case T_ExplainStmt: + { + ExplainStmt *stmt = (ExplainStmt *) parsetree; + + commandTag = "EXPLAIN"; + CHECK_IF_ABORTED(); - ExplainQuery(stmt->query, stmt->verbose, dest); - } - break; + ExplainQuery(stmt->query, stmt->verbose, dest); + } + break; - /* - * ******************************** Tioga-related statements ******************************* - */ - case T_RecipeStmt: - { - RecipeStmt *stmt = (RecipeStmt *) parsetree; + /* + * ******************************** Tioga-related statements ******************************* + */ + case T_RecipeStmt: + { + RecipeStmt *stmt = (RecipeStmt *) parsetree; - commandTag = "EXECUTE RECIPE"; + commandTag = "EXECUTE RECIPE"; + CHECK_IF_ABORTED(); + beginRecipe(stmt); + } + break; + + /* + * ******************************** set variable statements ******************************* + */ + case T_VariableSetStmt: + { + VariableSetStmt *n = (VariableSetStmt *) parsetree; + + SetPGVariable(n->name, n->value); + commandTag = "SET VARIABLE"; + } + break; + + case T_VariableShowStmt: + { + VariableShowStmt *n = (VariableShowStmt *) parsetree; + + GetPGVariable(n->name); + commandTag = "SHOW VARIABLE"; + } + break; + + case T_VariableResetStmt: + { + VariableResetStmt *n = (VariableResetStmt *) parsetree; + + ResetPGVariable(n->name); + commandTag = "RESET VARIABLE"; + } + break; + + /* + * ******************************** TRIGGER statements ******************************* + */ + case T_CreateTrigStmt: + commandTag = "CREATE"; + CHECK_IF_ABORTED(); + + CreateTrigger((CreateTrigStmt *) parsetree); + break; + + case T_DropTrigStmt: + commandTag = "DROP"; CHECK_IF_ABORTED(); - beginRecipe(stmt); - } - break; - - /* - * ******************************** set variable statements ******************************* - */ - case T_VariableSetStmt: - { - VariableSetStmt *n = (VariableSetStmt *) parsetree; - - SetPGVariable(n->name, n->value); - commandTag = "SET VARIABLE"; - } - break; - - case T_VariableShowStmt: - { - VariableShowStmt *n = (VariableShowStmt *) parsetree; - - GetPGVariable(n->name); - commandTag = "SHOW VARIABLE"; - } - break; - - case T_VariableResetStmt: - { - VariableResetStmt *n = (VariableResetStmt *) parsetree; - - ResetPGVariable(n->name); - commandTag = "RESET VARIABLE"; - } - break; - - /* - * ******************************** TRIGGER statements ******************************* - */ - case T_CreateTrigStmt: - commandTag = "CREATE"; - CHECK_IF_ABORTED(); - - CreateTrigger((CreateTrigStmt *) parsetree); - break; - - case T_DropTrigStmt: - commandTag = "DROP"; - CHECK_IF_ABORTED(); - - DropTrigger((DropTrigStmt *) parsetree); - break; - - /* - * ******************************** default ******************************** - * - */ - default: - elog(WARN, "ProcessUtility: command #%d unsupported", - nodeTag(parsetree)); - break; + + DropTrigger((DropTrigStmt *) parsetree); + break; + + /* + * ******************************** default ******************************** + * + */ + default: + elog(WARN, "ProcessUtility: command #%d unsupported", + nodeTag(parsetree)); + break; } /* ---------------- diff --git a/src/backend/tcop/variable.c b/src/backend/tcop/variable.c index d394881ab3a..d702bbaa08e 100644 --- a/src/backend/tcop/variable.c +++ b/src/backend/tcop/variable.c @@ -2,7 +2,7 @@ * Routines for handling of 'SET var TO', 'SHOW var' and 'RESET var' * statements. * - * $Id: variable.c,v 1.14 1997/09/07 04:49:37 momjian Exp $ + * $Id: variable.c,v 1.15 1997/09/08 02:29:52 momjian Exp $ * */ @@ -15,11 +15,11 @@ #include "utils/builtins.h" #include "optimizer/internal.h" -extern Cost _cpu_page_wight_; -extern Cost _cpu_index_page_wight_; -extern bool _use_geqo_; -extern int32 _use_geqo_rels_; -extern bool _use_right_sided_plans_; +extern Cost _cpu_page_wight_; +extern Cost _cpu_index_page_wight_; +extern bool _use_geqo_; +extern int32 _use_geqo_rels_; +extern bool _use_right_sided_plans_; /*-----------------------------------------------------------------------*/ #if USE_EURODATES @@ -38,8 +38,8 @@ struct PGVariables PGVariables = static const char * get_token(char **tok, char **val, const char *str) { - const char *start; - int len = 0; + const char *start; + int len = 0; *tok = NULL; if (val != NULL) @@ -157,9 +157,9 @@ reset_null(const char *value) static bool parse_geqo(const char *value) { - const char *rest; - char *tok, - *val; + const char *rest; + char *tok, + *val; rest = get_token(&tok, &val, value); if (tok == NULL) @@ -170,7 +170,7 @@ parse_geqo(const char *value) if (strcasecmp(tok, "on") == 0) { - int32 geqo_rels = GEQO_RELS; + int32 geqo_rels = GEQO_RELS; if (val != NULL) { @@ -259,7 +259,7 @@ reset_r_plans() static bool parse_cost_heap(const char *value) { - float32 res = float4in((char *) value); + float32 res = float4in((char *) value); _cpu_page_wight_ = *res; @@ -284,7 +284,7 @@ reset_cost_heap() static bool parse_cost_index(const char *value) { - float32 res = float4in((char *) value); + float32 res = float4in((char *) value); _cpu_index_page_wight_ = *res; @@ -309,9 +309,9 @@ reset_cost_index() static bool parse_date(const char *value) { - char *tok; - int dcnt = 0, - ecnt = 0; + char *tok; + int dcnt = 0, + ecnt = 0; while ((value = get_token(&tok, NULL, value)) != 0) { @@ -365,20 +365,20 @@ parse_date(const char *value) static bool show_date() { - char buf[64]; + char buf[64]; strcpy(buf, "DateStyle is "); switch (DateStyle) { - case USE_ISO_DATES: - strcat(buf, "ISO"); - break; - case USE_SQL_DATES: - strcat(buf, "SQL"); - break; - default: - strcat(buf, "Postgres"); - break; + case USE_ISO_DATES: + strcat(buf, "ISO"); + break; + case USE_SQL_DATES: + strcat(buf, "SQL"); + break; + default: + strcat(buf, "Postgres"); + break; }; strcat(buf, " with "); strcat(buf, ((EuroDates) ? "European" : "US (NonEuropean)")); @@ -401,11 +401,11 @@ reset_date() /*-----------------------------------------------------------------------*/ struct VariableParsers { - const char *name; - bool(*parser) (const char *); - bool(*show) (); - bool(*reset) (); -} VariableParsers[] = + const char *name; + bool(*parser) (const char *); + bool(*show) (); + bool(*reset) (); +} VariableParsers[] = { { diff --git a/src/backend/tioga/Arr_TgRecipe.h b/src/backend/tioga/Arr_TgRecipe.h index c6992732c7f..9cfec9585e9 100644 --- a/src/backend/tioga/Arr_TgRecipe.h +++ b/src/backend/tioga/Arr_TgRecipe.h @@ -33,11 +33,11 @@ typedef struct Arr_TgString { - size_t num; - size_t size; - size_t valSize; - TgString *val; -} Arr_TgString; + size_t num; + size_t size; + size_t valSize; + TgString *val; +} Arr_TgString; #define newArr_TgString() \ (Arr_TgString *) NewVarray(ARR_TgString_INITIAL_SIZE, sizeof(TgString)) @@ -69,11 +69,11 @@ typedef struct Arr_TgString typedef struct Arr_TgElementPtr { - size_t num; - size_t size; - size_t valSize; - TgElementPtr *val; -} Arr_TgElementPtr; + size_t num; + size_t size; + size_t valSize; + TgElementPtr *val; +} Arr_TgElementPtr; #define newArr_TgElementPtr() \ (Arr_TgElementPtr *) NewVarray(ARR_TgElementPtr_INITIAL_SIZE, sizeof(TgElementPtr)) @@ -105,11 +105,11 @@ typedef struct Arr_TgElementPtr typedef struct Arr_TgNodePtr { - size_t num; - size_t size; - size_t valSize; - TgNodePtr *val; -} Arr_TgNodePtr; + size_t num; + size_t size; + size_t valSize; + TgNodePtr *val; +} Arr_TgNodePtr; #define newArr_TgNodePtr() \ (Arr_TgNodePtr *) NewVarray(ARR_TgNodePtr_INITIAL_SIZE, sizeof(TgNodePtr)) diff --git a/src/backend/tioga/Varray.c b/src/backend/tioga/Varray.c index 6279616f7ba..20f9b7d6e9b 100644 --- a/src/backend/tioga/Varray.c +++ b/src/backend/tioga/Varray.c @@ -10,7 +10,7 @@ #include <stdlib.h> #include "Varray.h" -Varray * +Varray * NewVarray(size_t nobj, size_t size) /* * NewVarray -- allocate a Varray to contain an array of val each of which @@ -18,7 +18,7 @@ NewVarray(size_t nobj, size_t size) * returns NULL otherwise. */ { - Varray *result; + Varray *result; if (nobj == 0) nobj = VARRAY_INITIAL_SIZE; diff --git a/src/backend/tioga/Varray.h b/src/backend/tioga/Varray.h index 82251d78b3f..496b04520ab 100644 --- a/src/backend/tioga/Varray.h +++ b/src/backend/tioga/Varray.h @@ -11,14 +11,14 @@ typedef struct _varray { - size_t nobj; /* number of objects in this array */ - size_t maxObj; /* max. number of objects in this array */ - size_t size; /* size of each element in the array */ - void *val; /* array of elements */ -} Varray; + size_t nobj; /* number of objects in this array */ + size_t maxObj; /* max. number of objects in this array */ + size_t size; /* size of each element in the array */ + void *val; /* array of elements */ +} Varray; /* type for custom copying function */ -typedef void (*CopyingFunct) (void *from, void *to); +typedef void (*CopyingFunct) (void *from, void *to); #define VARRAY_INITIAL_SIZE 32 @@ -40,7 +40,7 @@ typedef void (*CopyingFunct) (void *from, void *to); ((N) < (ARRAY)->nobj ? VARRAY_NTH((ARRAY)->val, (ARRAY)->size, (N)) \ : NULL) -extern Varray *NewVarray(size_t nobj, size_t size); -extern int AppendVarray(Varray * array, void *value, CopyingFunct copy); +extern Varray *NewVarray(size_t nobj, size_t size); +extern int AppendVarray(Varray * array, void *value, CopyingFunct copy); #endif /* _VARRAY_H_ */ diff --git a/src/backend/tioga/tgRecipe.c b/src/backend/tioga/tgRecipe.c index effc221610e..e5156fe7769 100644 --- a/src/backend/tioga/tgRecipe.c +++ b/src/backend/tioga/tgRecipe.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.4 1997/09/07 04:49:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tioga/Attic/tgRecipe.c,v 1.5 1997/09/08 02:30:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,13 +44,13 @@ static Arr_TgString *TextArray2ArrTgString(char *str); "select * from Edge e where e.belongsTo = '%s'" /* static functions only used here */ -static void fillTgElement(TgElement * elem, PortalBuffer * pbuf, int tupno); -static void fillTgNode(TgRecipe * r, TgNode * node, PortalBuffer * pbuf, int tupno); +static void fillTgElement(TgElement * elem, PortalBuffer * pbuf, int tupno); +static void fillTgNode(TgRecipe * r, TgNode * node, PortalBuffer * pbuf, int tupno); static TgRecipe *fillTgRecipe(PortalBuffer * pbuf, int tupno); -static void lookupEdges(TgRecipe * r, char *name); -static void fillAllNodes(TgRecipe * r, char *name); -static void fillAllElements(TgRecipe * r, char *name); -static TgNode * +static void lookupEdges(TgRecipe * r, char *name); +static void fillAllNodes(TgRecipe * r, char *name); +static void fillAllElements(TgRecipe * r, char *name); +static TgNode * connectTee(TgRecipe * r, TgNodePtr fromNode, TgNodePtr toNode, int fromPort, int toPort); @@ -62,15 +62,15 @@ connectTee(TgRecipe * r, TgNodePtr fromNode, TgNodePtr toNode, * always returns a valid Arr_TgString. It could be a newly initialized one with * zero elements */ -Arr_TgString * +Arr_TgString * TextArray2ArrTgString(char *str) { - Arr_TgString *result; + Arr_TgString *result; - char *beginQuote; - char *endQuote; - int nextlen; - char *word; + char *beginQuote; + char *endQuote; + int nextlen; + char *word; result = newArr_TgString(); @@ -123,12 +123,12 @@ findElemInRecipe() XXX Currently, this is done by linear search. Change to using a hash table. -------------------------------------- */ -TgElement * +TgElement * findElemInRecipe(TgRecipe * r, char *elemName) { - int i; + int i; Arr_TgElementPtr *arr = r->elements; - TgElement *e; + TgElement *e; for (i = 0; i < arr->num; i++) { @@ -147,12 +147,12 @@ findNodeInRecipe() XXX Currently, this is done by linear search. Change to using a hash table. -------------------------------------- */ -TgNode * +TgNode * findNodeInRecipe(TgRecipe * r, char *nodeName) { - int i; - Arr_TgNodePtr *arr = r->allNodes; - TgNode *n; + int i; + Arr_TgNodePtr *arr = r->allNodes; + TgNode *n; for (i = 0; i < arr->num; i++) { @@ -176,16 +176,16 @@ fillTgNode void fillTgNode(TgRecipe * r, TgNode * node, PortalBuffer * pbuf, int tupno) { - char *nodeType; - char *nodeElem; - char *locString; /* ascii string rep of the point */ - static int attnums_initialized = 0; - static int nodeName_attnum; - static int nodeElem_attnum; - static int nodeType_attnum; - static int loc_attnum; - TgNodePtr BlankNodePtr; - int i; + char *nodeType; + char *nodeElem; + char *locString; /* ascii string rep of the point */ + static int attnums_initialized = 0; + static int nodeName_attnum; + static int nodeElem_attnum; + static int nodeType_attnum; + static int loc_attnum; + TgNodePtr BlankNodePtr; + int i; if (!attnums_initialized) { @@ -211,8 +211,8 @@ fillTgNode(TgRecipe * r, TgNode * node, PortalBuffer * pbuf, int tupno) } else { - float x, - y; + float x, + y; sscanf(locString, "(%f, %f)", &x, &y); node->loc.x = x; @@ -261,21 +261,21 @@ fillTgElement void fillTgElement(TgElement * elem, PortalBuffer * pbuf, int tupno) { - char *srcLang, - *elemType; - static int attnums_initialized = 0; - static int elemName_attnum; - static int elemType_attnum; - static int inPorts_attnum; - static int inTypes_attnum; - static int outPorts_attnum; - static int outTypes_attnum; - static int doc_attnum; - static int keywords_attnum; - static int icon_attnum; - static int srcLang_attnum; - static int src_attnum; - static int owner_attnum; + char *srcLang, + *elemType; + static int attnums_initialized = 0; + static int elemName_attnum; + static int elemType_attnum; + static int inPorts_attnum; + static int inTypes_attnum; + static int outPorts_attnum; + static int outTypes_attnum; + static int doc_attnum; + static int keywords_attnum; + static int icon_attnum; + static int srcLang_attnum; + static int src_attnum; + static int owner_attnum; if (!attnums_initialized) { @@ -351,25 +351,25 @@ lookupEdges - void lookupEdges(TgRecipe * r, char *name) { - char qbuf[MAX_QBUF_LENGTH]; - int i; - char *pqres; - char *pbufname; - PortalBuffer *pbuf; - int ntups; - int fromNode_attnum; - int fromPort_attnum; - int toPort_attnum; - int toNode_attnum; - char *toNode, - *fromNode; - char *toPortStr, - *fromPortStr; - int toPort, - fromPort; - - TgNodePtr fromNodePtr, - toNodePtr; + char qbuf[MAX_QBUF_LENGTH]; + int i; + char *pqres; + char *pbufname; + PortalBuffer *pbuf; + int ntups; + int fromNode_attnum; + int fromPort_attnum; + int toPort_attnum; + int toNode_attnum; + char *toNode, + *fromNode; + char *toPortStr, + *fromPortStr; + int toPort, + fromPort; + + TgNodePtr fromNodePtr, + toNodePtr; sprintf(qbuf, Q_LOOKUP_EDGES_IN_RECIPE, name); pqres = PQexec(qbuf); @@ -434,7 +434,7 @@ lookupEdges(TgRecipe * r, char *name) */ if (fromNodePtr->outNodes->val[fromPort - 1] != NULL) { - TgNodePtr tn; + TgNodePtr tn; tn = connectTee(r, fromNodePtr, toNodePtr, fromPort, toPort); addArr_TgNodePtr(r->allNodes, &tn); @@ -456,15 +456,15 @@ lookupEdges(TgRecipe * r, char *name) returns the teeNode created */ -static TgNode * +static TgNode * connectTee(TgRecipe * r, TgNodePtr fromNode, TgNodePtr toNode, int fromPort, int toPort) { - TgNodePtr origToNode; - TgNodePtr tn; - TgNodePtr BlankNodePtr; - int origToPort; - int i; + TgNodePtr origToNode; + TgNodePtr tn; + TgNodePtr BlankNodePtr; + int origToPort; + int i; /* the toNode formerly pointed to */ origToNode = fromNode->outNodes->val[fromPort - 1]; @@ -527,14 +527,14 @@ fillAllNodes void fillAllNodes(TgRecipe * r, char *name) { - char qbuf[MAX_QBUF_LENGTH]; - int i; - char *pqres; - char *pbufname; - PortalBuffer *pbuf; - int ntups; - TgElement *elem; - TgNode *node; + char qbuf[MAX_QBUF_LENGTH]; + int i; + char *pqres; + char *pbufname; + PortalBuffer *pbuf; + int ntups; + TgElement *elem; + TgNode *node; /* 1) fill out the elements that are in the recipe */ sprintf(qbuf, Q_RETRIEVE_ELEMENTS_IN_RECIPE, name); @@ -585,13 +585,13 @@ fillAllElements void fillAllElements(TgRecipe * r, char *name) { - char qbuf[MAX_QBUF_LENGTH]; - int i; - char *pqres; - char *pbufname; - PortalBuffer *pbuf; - int ntups; - TgElement *elem; + char qbuf[MAX_QBUF_LENGTH]; + int i; + char *pqres; + char *pbufname; + PortalBuffer *pbuf; + int ntups; + TgElement *elem; sprintf(qbuf, Q_RETRIEVE_ELEMENTS_IN_RECIPE, name); pqres = PQexec(qbuf); @@ -620,12 +620,12 @@ fillTgRecipe takes a query result in the PortalBuffer containing a Recipe and converts it to a C TgRecipe strcture ------------------------------------ */ -TgRecipe * +TgRecipe * fillTgRecipe(PortalBuffer * pbuf, int tupno) { - TgRecipe *r; - int i, - j; + TgRecipe *r; + int i, + j; /* 1) set up the recipe structure */ r = (TgRecipe *) malloc(sizeof(TgRecipe)); @@ -665,7 +665,7 @@ fillTgRecipe(PortalBuffer * pbuf, int tupno) /* tee nodes are nodes with the node type TG_TEE_NODE */ for (i = 0; i < r->allNodes->num; i++) { - TgNode *nptr = r->allNodes->val[i]; + TgNode *nptr = r->allNodes->val[i]; if (nptr->nodeType == TG_EYE_NODE) addArr_TgNodePtr(r->eyes, &nptr); @@ -693,15 +693,15 @@ fillTgRecipe(PortalBuffer * pbuf, int tupno) retrieveRecipe find the recipe with the given name ------------------------------------ */ -TgRecipe * +TgRecipe * retrieveRecipe(char *name) { - char qbuf[MAX_QBUF_LENGTH]; - TgRecipe *recipe; - char *pqres; - char *pbufname; - PortalBuffer *pbuf; - int ntups; + char qbuf[MAX_QBUF_LENGTH]; + TgRecipe *recipe; + char *pqres; + char *pbufname; + PortalBuffer *pbuf; + int ntups; sprintf(qbuf, Q_RETRIEVE_RECIPE_BYNAME, name); @@ -755,8 +755,8 @@ copyTgRecipePtr(TgRecipePtr * from, TgRecipePtr * to) void copyTgString(TgString * from, TgString * to) { - TgString fromTgString = *from; - TgString toTgString; + TgString fromTgString = *from; + TgString toTgString; toTgString = (TgString) malloc(strlen(fromTgString) + 1); strcpy(toTgString, fromTgString); diff --git a/src/backend/tioga/tgRecipe.h b/src/backend/tioga/tgRecipe.h index 669092982bc..ba4f9d0badc 100644 --- a/src/backend/tioga/tgRecipe.h +++ b/src/backend/tioga/tgRecipe.h @@ -11,7 +11,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tgRecipe.h,v 1.2 1997/09/07 04:49:50 momjian Exp $ + * $Id: tgRecipe.h,v 1.3 1997/09/08 02:30:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,10 +25,11 @@ #include "libpq-fe.h" typedef struct { - double x, - y; -} Point; /* this should match whatever is in + double x, + y; +} Point; /* this should match whatever is in + * * geo-decls.h */ #endif /* TIOGA_FRONTEND */ @@ -38,7 +39,7 @@ typedef enum TG_INGRED, TG_EYE, TG_RECIPE -} TgElemType; +} TgElemType; typedef enum { @@ -46,7 +47,7 @@ typedef enum TG_C, TG_RECIPE_GRAPH, TG_COMPILED -} TgSrcLangType; +} TgSrcLangType; typedef enum { @@ -56,12 +57,12 @@ typedef enum TG_TEE_NODE /* tee nodes are not stored in the db we * create them when we read the recipe * back */ -} TgNodeType; +} TgNodeType; /* -- type definition for setting up in memory Tioga recipe structure -- */ /* -- see 'recipe-schema.sql' for their corresponding database types -- */ -typedef char *TgString; +typedef char *TgString; typedef struct _tgelement *TgElementPtr; typedef struct _tgnode *TgNodePtr; @@ -74,61 +75,61 @@ typedef struct _tgrecipe *TgRecipePtr; /* C structure representation of a Tioga Element */ typedef struct _tgelement { - char *elemName; /* name of function this element represent */ - TgElemType elemType; /* type of this element */ - Arr_TgString *inPorts; /* names of inputs */ - Arr_TgString *inTypes; /* name of input types */ - Arr_TgString *outPorts; /* type of output */ - Arr_TgString *outTypes; /* name of output types */ - char *doc; /* description of this element */ - Arr_TgString *keywords; /* keywords used to search for this + char *elemName; /* name of function this element represent */ + TgElemType elemType; /* type of this element */ + Arr_TgString *inPorts; /* names of inputs */ + Arr_TgString *inTypes; /* name of input types */ + Arr_TgString *outPorts; /* type of output */ + Arr_TgString *outTypes; /* name of output types */ + char *doc; /* description of this element */ + Arr_TgString *keywords; /* keywords used to search for this * element */ - char *icon; /* iconic representation */ - char *src; /* source code for this element */ - TgSrcLangType srcLang; /* source language */ - char *owner; /* owner recipe name */ -} TgElement; + char *icon; /* iconic representation */ + char *src; /* source code for this element */ + TgSrcLangType srcLang; /* source language */ + char *owner; /* owner recipe name */ +} TgElement; /* C structure representation of a Tioga Node */ typedef struct _tgnode { - char *nodeName; /* name of this node */ - TgNodeType nodeType; /* type of this node */ - Point loc; /* screen location of the node. */ - TgElement *nodeElem; /* the underlying element of this node */ - Arr_TgNodePtr *inNodes; /* variable array of in node pointers a + char *nodeName; /* name of this node */ + TgNodeType nodeType; /* type of this node */ + Point loc; /* screen location of the node. */ + TgElement *nodeElem; /* the underlying element of this node */ + Arr_TgNodePtr *inNodes; /* variable array of in node pointers a * NULL TgNodePtr indicates a run-time * parameter */ - Arr_TgNodePtr *outNodes; /* variable array of out node pointers. */ -} TgNode; + Arr_TgNodePtr *outNodes; /* variable array of out node pointers. */ +} TgNode; /* C structure representation of a Tioga Recipe */ typedef struct _tgrecipe { - TgElement elmValue; /* "inherits" TgElement attributes. */ - Arr_TgNodePtr *allNodes; /* array of all nodes for this recipe. */ - Arr_TgNodePtr *rootNodes; /* array of root nodes for this recipe. -- + TgElement elmValue; /* "inherits" TgElement attributes. */ + Arr_TgNodePtr *allNodes; /* array of all nodes for this recipe. */ + Arr_TgNodePtr *rootNodes; /* array of root nodes for this recipe. -- * root nodes are nodes with no parents */ - Arr_TgNodePtr *eyes; /* array of pointers for the browser nodes + Arr_TgNodePtr *eyes; /* array of pointers for the browser nodes * recipe, execution of recipe starts by * traversing the recipe C structure from * the eye nodes pointed by these * pointers. */ - Arr_TgNodePtr *tees; /* array of pointers of all the tee nodes */ + Arr_TgNodePtr *tees; /* array of pointers of all the tee nodes */ Arr_TgElementPtr *elements; /* array of all the elements in this * recipe, elements may be shared by * multiple nodes */ -} TgRecipe; +} TgRecipe; /* functions defined in tgRecipe.c */ extern TgRecipe *retrieveRecipe(char *name); extern TgElement *findElemInRecipe(TgRecipe * r, char *elemName); -extern TgNode *findNodeInRecipe(TgRecipe * r, char *nodeName); +extern TgNode *findNodeInRecipe(TgRecipe * r, char *nodeName); /* ---- copyXXX functions ---- */ -extern void copyTgElementPtr(TgElementPtr *, TgElementPtr *); -extern void copyTgNodePtr(TgNodePtr *, TgNodePtr *); -extern void copyTgRecipePtr(TgRecipePtr *, TgRecipePtr *); -extern void copyTgString(TgString *, TgString *); +extern void copyTgElementPtr(TgElementPtr *, TgElementPtr *); +extern void copyTgNodePtr(TgNodePtr *, TgNodePtr *); +extern void copyTgRecipePtr(TgRecipePtr *, TgRecipePtr *); +extern void copyTgString(TgString *, TgString *); diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index d4b8f1ca0b6..d0acb4c6941 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.14 1997/09/07 04:49:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.15 1997/09/08 02:30:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,10 +21,10 @@ #include "utils/syscache.h" #include "miscadmin.h" -static char *getid(char *s, char *n); -static int32 aclitemeq(AclItem * a1, AclItem * a2); -static int32 aclitemgt(AclItem * a1, AclItem * a2); -static char *aclparse(char *s, AclItem * aip, unsigned *modechg); +static char *getid(char *s, char *n); +static int32 aclitemeq(AclItem * a1, AclItem * a2); +static int32 aclitemgt(AclItem * a1, AclItem * a2); +static char *aclparse(char *s, AclItem * aip, unsigned *modechg); #define ACL_IDTYPE_GID_KEYWORD "group" #define ACL_IDTYPE_UID_KEYWORD "user" @@ -41,11 +41,11 @@ static char *aclparse(char *s, AclItem * aip, unsigned *modechg); * - loads the identifier into 'name'. (If no identifier is found, 'name' * contains an empty string). */ -static char * +static char * getid(char *s, char *n) { - unsigned len; - char *id; + unsigned len; + char *id; Assert(s && n); @@ -82,11 +82,11 @@ getid(char *s, char *n) * UID/GID, id type identifier and mode type values. * - loads 'modechg' with the mode change flag. */ -static char * +static char * aclparse(char *s, AclItem * aip, unsigned *modechg) { - HeapTuple htp; - char name[NAMEDATALEN]; + HeapTuple htp; + char name[NAMEDATALEN]; Assert(s && aip && modechg); @@ -113,18 +113,18 @@ aclparse(char *s, AclItem * aip, unsigned *modechg) switch (*s) { - case ACL_MODECHG_ADD_CHR: - *modechg = ACL_MODECHG_ADD; - break; - case ACL_MODECHG_DEL_CHR: - *modechg = ACL_MODECHG_DEL; - break; - case ACL_MODECHG_EQL_CHR: - *modechg = ACL_MODECHG_EQL; - break; - default: - elog(WARN, "aclparse: mode change flag must use \"%s\"", - ACL_MODECHG_STR); + case ACL_MODECHG_ADD_CHR: + *modechg = ACL_MODECHG_ADD; + break; + case ACL_MODECHG_DEL_CHR: + *modechg = ACL_MODECHG_DEL; + break; + case ACL_MODECHG_EQL_CHR: + *modechg = ACL_MODECHG_EQL; + break; + default: + elog(WARN, "aclparse: mode change flag must use \"%s\"", + ACL_MODECHG_STR); } aip->ai_mode = ACL_NO; @@ -132,39 +132,39 @@ aclparse(char *s, AclItem * aip, unsigned *modechg) { switch (*s) { - case ACL_MODE_AP_CHR: - aip->ai_mode |= ACL_AP; - break; - case ACL_MODE_RD_CHR: - aip->ai_mode |= ACL_RD; - break; - case ACL_MODE_WR_CHR: - aip->ai_mode |= ACL_WR; - break; - case ACL_MODE_RU_CHR: - aip->ai_mode |= ACL_RU; - break; - default: - elog(WARN, "aclparse: mode flags must use \"%s\"", - ACL_MODE_STR); + case ACL_MODE_AP_CHR: + aip->ai_mode |= ACL_AP; + break; + case ACL_MODE_RD_CHR: + aip->ai_mode |= ACL_RD; + break; + case ACL_MODE_WR_CHR: + aip->ai_mode |= ACL_WR; + break; + case ACL_MODE_RU_CHR: + aip->ai_mode |= ACL_RU; + break; + default: + elog(WARN, "aclparse: mode flags must use \"%s\"", + ACL_MODE_STR); } } switch (aip->ai_idtype) { - case ACL_IDTYPE_UID: - htp = SearchSysCacheTuple(USENAME, PointerGetDatum(name), - 0, 0, 0); - if (!HeapTupleIsValid(htp)) - elog(WARN, "aclparse: non-existent user \"%s\"", name); - aip->ai_id = ((Form_pg_user) GETSTRUCT(htp))->usesysid; - break; - case ACL_IDTYPE_GID: - aip->ai_id = get_grosysid(name); - break; - case ACL_IDTYPE_WORLD: - aip->ai_id = ACL_ID_WORLD; - break; + case ACL_IDTYPE_UID: + htp = SearchSysCacheTuple(USENAME, PointerGetDatum(name), + 0, 0, 0); + if (!HeapTupleIsValid(htp)) + elog(WARN, "aclparse: non-existent user \"%s\"", name); + aip->ai_id = ((Form_pg_user) GETSTRUCT(htp))->usesysid; + break; + case ACL_IDTYPE_GID: + aip->ai_id = get_grosysid(name); + break; + case ACL_IDTYPE_WORLD: + aip->ai_id = ACL_ID_WORLD; + break; } #ifdef ACLDEBUG_TRACE @@ -181,11 +181,11 @@ aclparse(char *s, AclItem * aip, unsigned *modechg) * RETURNS: * the new Acl */ -Acl * +Acl * makeacl(int n) { - Acl *new_acl; - Size size; + Acl *new_acl; + Size size; if (n < 0) elog(WARN, "makeacl: invalid size: %d\n", n); @@ -209,11 +209,11 @@ makeacl(int n) * RETURNS: * the new AclItem */ -AclItem * +AclItem * aclitemin(char *s) { - unsigned modechg; - AclItem *aip; + unsigned modechg; + AclItem *aip; if (!s) elog(WARN, "aclitemin: null string"); @@ -239,18 +239,18 @@ aclitemin(char *s) * RETURNS: * the new string */ -char * +char * aclitemout(AclItem * aip) { - register char *p; - char *out; - HeapTuple htp; - unsigned i; - static AclItem default_aclitem = {ACL_ID_WORLD, + register char *p; + char *out; + HeapTuple htp; + unsigned i; + static AclItem default_aclitem = {ACL_ID_WORLD, ACL_IDTYPE_WORLD, ACL_WORLD_DEFAULT}; - extern char *int2out(); - char *tmpname; + extern char *int2out(); + char *tmpname; if (!aip) aip = &default_aclitem; @@ -262,33 +262,33 @@ aclitemout(AclItem * aip) switch (aip->ai_idtype) { - case ACL_IDTYPE_UID: - htp = SearchSysCacheTuple(USESYSID, ObjectIdGetDatum(aip->ai_id), - 0, 0, 0); - if (!HeapTupleIsValid(htp)) - { - char *tmp = int2out(aip->ai_id); + case ACL_IDTYPE_UID: + htp = SearchSysCacheTuple(USESYSID, ObjectIdGetDatum(aip->ai_id), + 0, 0, 0); + if (!HeapTupleIsValid(htp)) + { + char *tmp = int2out(aip->ai_id); - elog(NOTICE, "aclitemout: usesysid %d not found", - aip->ai_id); - strcat(p, tmp); - pfree(tmp); - } - else - strncat(p, (char *) &((Form_pg_user) - GETSTRUCT(htp))->usename, - sizeof(NameData)); - break; - case ACL_IDTYPE_GID: - strcat(p, "group "); - tmpname = get_groname(aip->ai_id); - strncat(p, tmpname, NAMEDATALEN); - break; - case ACL_IDTYPE_WORLD: - break; - default: - elog(WARN, "aclitemout: bad ai_idtype: %d", aip->ai_idtype); - break; + elog(NOTICE, "aclitemout: usesysid %d not found", + aip->ai_id); + strcat(p, tmp); + pfree(tmp); + } + else + strncat(p, (char *) &((Form_pg_user) + GETSTRUCT(htp))->usename, + sizeof(NameData)); + break; + case ACL_IDTYPE_GID: + strcat(p, "group "); + tmpname = get_groname(aip->ai_id); + strncat(p, tmpname, NAMEDATALEN); + break; + case ACL_IDTYPE_WORLD: + break; + default: + elog(WARN, "aclitemout: bad ai_idtype: %d", aip->ai_idtype); + break; } while (*p) ++p; @@ -311,7 +311,7 @@ aclitemout(AclItem * aip) * RETURNS: * a boolean value indicating = or > */ -static int32 +static int32 aclitemeq(AclItem * a1, AclItem * a2) { if (!a1 && !a2) @@ -321,7 +321,7 @@ aclitemeq(AclItem * a1, AclItem * a2) return (a1->ai_idtype == a2->ai_idtype && a1->ai_id == a2->ai_id); } -static int32 +static int32 aclitemgt(AclItem * a1, AclItem * a2) { if (a1 && !a2) @@ -332,11 +332,11 @@ aclitemgt(AclItem * a1, AclItem * a2) (a1->ai_idtype == a2->ai_idtype && a1->ai_id > a2->ai_id)); } -Acl * +Acl * aclownerdefault(AclId ownerid) { - Acl *acl; - AclItem *aip; + Acl *acl; + AclItem *aip; acl = makeacl(2); aip = ACL_DAT(acl); @@ -349,11 +349,11 @@ aclownerdefault(AclId ownerid) return (acl); } -Acl * +Acl * acldefault(void) { - Acl *acl; - AclItem *aip; + Acl *acl; + AclItem *aip; acl = makeacl(1); aip = ACL_DAT(acl); @@ -363,15 +363,15 @@ acldefault(void) return (acl); } -Acl * +Acl * aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg) { - Acl *new_acl; - AclItem *old_aip, - *new_aip; - unsigned src, - dst, - num; + Acl *new_acl; + AclItem *old_aip, + *new_aip; + unsigned src, + dst, + num; if (!old_acl || ACL_NUM(old_acl) < 1) { @@ -435,18 +435,18 @@ aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg) } switch (modechg) { - case ACL_MODECHG_ADD: - new_aip[dst].ai_mode = - old_aip[src].ai_mode | mod_aip->ai_mode; - break; - case ACL_MODECHG_DEL: - new_aip[dst].ai_mode = - old_aip[src].ai_mode & ~mod_aip->ai_mode; - break; - case ACL_MODECHG_EQL: - new_aip[dst].ai_mode = - mod_aip->ai_mode; - break; + case ACL_MODECHG_ADD: + new_aip[dst].ai_mode = + old_aip[src].ai_mode | mod_aip->ai_mode; + break; + case ACL_MODECHG_DEL: + new_aip[dst].ai_mode = + old_aip[src].ai_mode & ~mod_aip->ai_mode; + break; + case ACL_MODECHG_EQL: + new_aip[dst].ai_mode = + mod_aip->ai_mode; + break; } /* @@ -458,7 +458,7 @@ aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg) { if (new_aip[dst].ai_mode == 0) { - int i; + int i; for (i = dst + 1; i < num; i++) { @@ -480,21 +480,21 @@ aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg) * aclinsert * */ -Acl * +Acl * aclinsert(Acl * old_acl, AclItem * mod_aip) { return (aclinsert3(old_acl, mod_aip, ACL_MODECHG_EQL)); } -Acl * +Acl * aclremove(Acl * old_acl, AclItem * mod_aip) { - Acl *new_acl; - AclItem *old_aip, - *new_aip; - unsigned dst, - old_num, - new_num; + Acl *new_acl; + AclItem *old_aip, + *new_aip; + unsigned dst, + old_num, + new_num; if (!old_acl || ACL_NUM(old_acl) < 1) { @@ -549,9 +549,9 @@ aclremove(Acl * old_acl, AclItem * mod_aip) int32 aclcontains(Acl * acl, AclItem * aip) { - unsigned i, - num; - AclItem *aidat; + unsigned i, + num; + AclItem *aidat; if (!acl || !aip || ((num = ACL_NUM(acl)) < 1)) return (0); @@ -574,12 +574,12 @@ aclcontains(Acl * acl, AclItem * aip) * the CALLER is reponsible for free'ing the string returned */ -char * +char * aclmakepriv(char *old_privlist, char new_priv) { - char *priv; - int i; - int l; + char *priv; + int i; + int l; Assert(strlen(old_privlist) < 5); priv = malloc(5); /* at most "rwaR" */ ; @@ -628,10 +628,10 @@ aclmakepriv(char *old_privlist, char new_priv) * the CALLER is responsible for freeing the memory allocated */ -char * +char * aclmakeuser(char *user_type, char *user) { - char *user_list; + char *user_list; user_list = malloc(strlen(user) + 3); sprintf(user_list, "%s %s", user_type, user); @@ -652,12 +652,12 @@ aclmakeuser(char *user_type, char *user) * then calling aclparse; */ -ChangeACLStmt * +ChangeACLStmt * makeAclStmt(char *privileges, List * rel_list, char *grantee, char grant_or_revoke) { - ChangeACLStmt *n = makeNode(ChangeACLStmt); - char str[MAX_PARSE_BUFFER]; + ChangeACLStmt *n = makeNode(ChangeACLStmt); + char str[MAX_PARSE_BUFFER]; n->aclitem = (AclItem *) palloc(sizeof(AclItem)); /* the grantee string is "G <group_name>", "U <user_name>", or "ALL" */ diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 073b0a1fd01..15a60311798 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.16 1997/09/07 04:49:55 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.17 1997/09/08 02:30:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,15 +42,15 @@ */ /*-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-=--=-=-=-=-=-=-=-*/ -static int _ArrayCount(char *str, int dim[], int typdelim); -static char * +static int _ArrayCount(char *str, int dim[], int typdelim); +static char * _ReadArrayStr(char *arrayStr, int nitems, int ndim, int dim[], func_ptr inputproc, Oid typelem, char typdelim, int typlen, bool typbyval, char typalign, int *nbytes); #ifdef LOARRAY -static char * +static char * _ReadLOArray(char *str, int *nbytes, int *fd, bool * chunkFlag, int ndim, int dim[], int baseSize); @@ -62,26 +62,26 @@ static void system_cache_lookup(Oid element_type, bool input, int *typlen, bool * typbyval, char *typdelim, Oid * typelem, Oid * proc, char *typalign); -static Datum _ArrayCast(char *value, bool byval, int len); +static Datum _ArrayCast(char *value, bool byval, int len); #ifdef LOARRAY -static char *_AdvanceBy1word(char *str, char **word); +static char *_AdvanceBy1word(char *str, char **word); #endif static void _ArrayRange(int st[], int endp[], int bsize, char *destPtr, ArrayType * array, int from); -static int _ArrayClipCount(int stI[], int endpI[], ArrayType * array); +static int _ArrayClipCount(int stI[], int endpI[], ArrayType * array); static void _LOArrayRange(int st[], int endp[], int bsize, int srcfd, int destfd, ArrayType * array, int isSrcLO, bool * isNull); static void _ReadArray(int st[], int endp[], int bsize, int srcfd, int destfd, ArrayType * array, int isDestLO, bool * isNull); -static ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest); -static SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]); -static int array_read(char *destptr, int eltsize, int nitems, char *srcptr); -static char *array_seek(char *ptr, int eltsize, int nitems); +static ArrayCastAndSet(char *src, bool typbyval, int typlen, char *dest); +static SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]); +static int array_read(char *destptr, int eltsize, int nitems, char *srcptr); +static char *array_seek(char *ptr, int eltsize, int nitems); /*--------------------------------------------------------------------- * array_in : @@ -91,31 +91,31 @@ static char *array_seek(char *ptr, int eltsize, int nitems); * the internal representation of the input array *-------------------------------------------------------------------- */ -char * +char * array_in(char *string, /* input array in external form */ Oid element_type) /* type OID of an array element */ { - int typlen; - bool typbyval, - done; - char typdelim; - Oid typinput; - Oid typelem; - char *string_save, - *p, - *q, - *r; - func_ptr inputproc; - int i, - nitems, - dummy; - int32 nbytes; - char *dataPtr; - ArrayType *retval = NULL; - int ndim, - dim[MAXDIM], - lBound[MAXDIM]; - char typalign; + int typlen; + bool typbyval, + done; + char typdelim; + Oid typinput; + Oid typelem; + char *string_save, + *p, + *q, + *r; + func_ptr inputproc; + int i, + nitems, + dummy; + int32 nbytes; + char *dataPtr; + ArrayType *retval = NULL; + int ndim, + dim[MAXDIM], + lBound[MAXDIM]; + char typalign; system_cache_lookup(element_type, true, &typlen, &typbyval, &typdelim, &typelem, &typinput, &typalign); @@ -125,7 +125,7 @@ array_in(char *string, /* input array in external form */ string_save = (char *) palloc(strlen(string) + 3); strcpy(string_save, string); - /* --- read array dimensions ---------- */ + /* --- read array dimensions ---------- */ p = q = string_save; done = false; for (ndim = 0; !done;) @@ -197,7 +197,7 @@ array_in(char *string, /* input array in external form */ nitems = getNitems(ndim, dim); if (nitems == 0) { - char *emptyArray = palloc(sizeof(ArrayType)); + char *emptyArray = palloc(sizeof(ArrayType)); memset(emptyArray, 0, sizeof(ArrayType)); *(int32 *) emptyArray = sizeof(ArrayType); @@ -232,9 +232,9 @@ array_in(char *string, /* input array in external form */ else { #ifdef LOARRAY - int dummy, - bytes; - bool chunked = false; + int dummy, + bytes; + bool chunked = false; dataPtr = _ReadLOArray(p, &bytes, &dummy, &chunked, ndim, dim, typlen); @@ -264,13 +264,13 @@ array_in(char *string, /* input array in external form */ static int _ArrayCount(char *str, int dim[], int typdelim) { - int nest_level = 0, - i; - int ndim = 0, - temp[MAXDIM]; - bool scanning_string = false; - bool eoArray = false; - char *q; + int nest_level = 0, + i; + int ndim = 0, + temp[MAXDIM]; + bool scanning_string = false; + bool eoArray = false; + char *q; for (i = 0; i < MAXDIM; ++i) { @@ -283,51 +283,55 @@ _ArrayCount(char *str, int dim[], int typdelim) q = str; while (eoArray != true) { - bool done = false; + bool done = false; while (!done) { switch (*q) { - case '\\': - /* skip escaped characters (\ and ") inside strings */ - if (scanning_string && *(q + 1)) - { - q++; - } - break; - case '\0': - /* Signal a premature end of the string. DZ - 2-9-1996 */ - elog(WARN, "malformed array constant: %s", str); - break; - case '\"': - scanning_string = !scanning_string; - break; - case '{': - if (!scanning_string) - { - temp[nest_level] = 0; - nest_level++; - } - break; - case '}': - if (!scanning_string) - { + case '\\': + /* skip escaped characters (\ and ") inside strings */ + if (scanning_string && *(q + 1)) + { + q++; + } + break; + case '\0': + + /* + * Signal a premature end of the string. DZ - + * 2-9-1996 + */ + elog(WARN, "malformed array constant: %s", str); + break; + case '\"': + scanning_string = !scanning_string; + break; + case '{': + if (!scanning_string) + { + temp[nest_level] = 0; + nest_level++; + } + break; + case '}': + if (!scanning_string) + { + if (!ndim) + ndim = nest_level; + nest_level--; + if (nest_level) + temp[nest_level - 1]++; + if (nest_level == 0) + eoArray = done = true; + } + break; + default: if (!ndim) ndim = nest_level; - nest_level--; - if (nest_level) - temp[nest_level - 1]++; - if (nest_level == 0) - eoArray = done = true; - } - break; - default: - if (!ndim) - ndim = nest_level; - if (*q == typdelim && !scanning_string) - done = true; - break; + if (*q == typdelim && !scanning_string) + done = true; + break; } if (!done) q++; @@ -358,7 +362,7 @@ _ArrayCount(char *str, int dim[], int typdelim) * nbytes is set to the size of the array in its internal representation. *--------------------------------------------------------------------------- */ -static char * +static char * _ReadArrayStr(char *arrayStr, int nitems, int ndim, @@ -372,16 +376,16 @@ _ReadArrayStr(char *arrayStr, char typalign, int *nbytes) { - int i, - nest_level = 0; - char *p, - *q, - *r, - **values; - bool scanning_string = false; - int indx[MAXDIM], - prod[MAXDIM]; - bool eoArray = false; + int i, + nest_level = 0; + char *p, + *q, + *r, + **values; + bool scanning_string = false; + int indx[MAXDIM], + prod[MAXDIM]; + bool eoArray = false; mda_get_prod(ndim, dim, prod); for (i = 0; i < ndim; indx[i++] = 0); @@ -392,64 +396,64 @@ _ReadArrayStr(char *arrayStr, while (!eoArray) { - bool done = false; - int i = -1; + bool done = false; + int i = -1; while (!done) { switch (*q) { - case '\\': - /* Crunch the string on top of the backslash. */ - for (r = q; *r != '\0'; r++) - *r = *(r + 1); - break; - case '\"': - if (!scanning_string) - { - while (p != q) - p++; - p++; /* get p past first doublequote */ - } - else - *q = '\0'; - scanning_string = !scanning_string; - break; - case '{': - if (!scanning_string) - { - p++; - nest_level++; - if (nest_level > ndim) - elog(WARN, "array_in: illformed array constant"); - indx[nest_level - 1] = 0; - indx[ndim - 1] = 0; - } - break; - case '}': - if (!scanning_string) - { - if (i == -1) - i = tuple2linear(ndim, indx, prod); - nest_level--; - if (nest_level == 0) - eoArray = done = true; - else + case '\\': + /* Crunch the string on top of the backslash. */ + for (r = q; *r != '\0'; r++) + *r = *(r + 1); + break; + case '\"': + if (!scanning_string) { + while (p != q) + p++; + p++; /* get p past first doublequote */ + } + else *q = '\0'; - indx[nest_level - 1]++; + scanning_string = !scanning_string; + break; + case '{': + if (!scanning_string) + { + p++; + nest_level++; + if (nest_level > ndim) + elog(WARN, "array_in: illformed array constant"); + indx[nest_level - 1] = 0; + indx[ndim - 1] = 0; } - } - break; - default: - if (*q == typdelim && !scanning_string) - { - if (i == -1) - i = tuple2linear(ndim, indx, prod); - done = true; - indx[ndim - 1]++; - } - break; + break; + case '}': + if (!scanning_string) + { + if (i == -1) + i = tuple2linear(ndim, indx, prod); + nest_level--; + if (nest_level == 0) + eoArray = done = true; + else + { + *q = '\0'; + indx[nest_level - 1]++; + } + } + break; + default: + if (*q == typdelim && !scanning_string) + { + if (i == -1) + i = tuple2linear(ndim, indx, prod); + done = true; + indx[ndim - 1]++; + } + break; } if (!done) q++; @@ -513,7 +517,7 @@ _ReadArrayStr(char *arrayStr, *---------------------------------------------------------------------------- */ #ifdef LOARRAY -static char * +static char * _ReadLOArray(char *str, int *nbytes, int *fd, @@ -522,18 +526,18 @@ _ReadLOArray(char *str, int dim[], int baseSize) { - char *inputfile, - *accessfile = NULL, - *chunkfile = NULL; - char *retStr, - *_AdvanceBy1word(); - Oid lobjId; + char *inputfile, + *accessfile = NULL, + *chunkfile = NULL; + char *retStr, + *_AdvanceBy1word(); + Oid lobjId; str = _AdvanceBy1word(str, &inputfile); while (str != NULL) { - char *word; + char *word; str = _AdvanceBy1word(str, &word); @@ -566,7 +570,7 @@ _ReadLOArray(char *str, if (accessfile) { - FILE *afd; + FILE *afd; if ((afd = AllocateFile(accessfile, "r")) == NULL) elog(WARN, "unable to open access pattern file"); @@ -588,11 +592,11 @@ _CopyArrayEls(char **values, char typalign, bool typbyval) { - int i; + int i; for (i = 0; i < nitems; i++) { - int inc; + int inc; inc = ArrayCastAndSet(values[i], typbyval, typlen, p); p += inc; @@ -608,40 +612,40 @@ _CopyArrayEls(char **values, * containing the array in its external format. *------------------------------------------------------------------------- */ -char * +char * array_out(ArrayType * v, Oid element_type) { - int typlen; - bool typbyval; - char typdelim; - Oid typoutput, - typelem; - func_ptr outputproc; - char typalign; - - char *p, - *retval, - **values, - delim[2]; - int nitems, - overall_length, - i, - j, - k, - indx[MAXDIM]; - bool dummy_bool; - int dummy_int; - int ndim, - *dim; + int typlen; + bool typbyval; + char typdelim; + Oid typoutput, + typelem; + func_ptr outputproc; + char typalign; + + char *p, + *retval, + **values, + delim[2]; + int nitems, + overall_length, + i, + j, + k, + indx[MAXDIM]; + bool dummy_bool; + int dummy_int; + int ndim, + *dim; if (v == (ArrayType *) NULL) return ((char *) NULL); if (ARR_IS_LO(v) == true) { - char *p, - *save_p; - int nbytes; + char *p, + *save_p; + int nbytes; /* get a wide string to print to */ p = array_dims(v, &dummy_bool); @@ -666,7 +670,7 @@ array_out(ArrayType * v, Oid element_type) if (nitems == 0) { - char *emptyArray = palloc(3); + char *emptyArray = palloc(3); emptyArray[0] = '{'; emptyArray[1] = '}'; @@ -683,16 +687,16 @@ array_out(ArrayType * v, Oid element_type) { switch (typlen) { - case 1: - values[i] = (*outputproc) (*p, typelem); - break; - case 2: - values[i] = (*outputproc) (*(int16 *) p, typelem); - break; - case 3: - case 4: - values[i] = (*outputproc) (*(int32 *) p, typelem); - break; + case 1: + values[i] = (*outputproc) (*p, typelem); + break; + case 2: + values[i] = (*outputproc) (*(int16 *) p, typelem); + break; + case 3: + case 4: + values[i] = (*outputproc) (*(int32 *) p, typelem); + break; } p += typlen; } @@ -766,15 +770,15 @@ array_out(ArrayType * v, Oid element_type) * returns the dimension of the array pointed to by "v" *---------------------------------------------------------------------------- */ -char * +char * array_dims(ArrayType * v, bool * isNull) { - char *p, - *save_p; - int nbytes, - i; - int *dimv, - *lb; + char *p, + *save_p; + int nbytes, + i; + int *dimv, + *lb; if (v == (ArrayType *) NULL) RETURN_NULL; @@ -814,14 +818,14 @@ array_ref(ArrayType * array, int arraylen, bool * isNull) { - int i, - ndim, - *dim, - *lb, - offset, - nbytes; + int i, + ndim, + *dim, + *lb, + offset, + nbytes; struct varlena *v = NULL; - char *retval = NULL; + char *retval = NULL; if (array == (ArrayType *) NULL) RETURN_NULL; @@ -848,8 +852,8 @@ array_ref(ArrayType * array, if (ARR_IS_LO(array)) { - char *lo_name; - int fd = 0; + char *lo_name; + int fd = 0; /* We are assuming fixed element lengths here */ offset *= elmlen; @@ -876,7 +880,7 @@ array_ref(ArrayType * array, retval = (char *) _ArrayCast((char *) VARDATA(v), reftype, elmlen); if (reftype == 0) { /* not by value */ - char *tempdata = palloc(elmlen); + char *tempdata = palloc(elmlen); memmove(tempdata, retval, elmlen); retval = tempdata; @@ -896,9 +900,9 @@ array_ref(ArrayType * array, } else { - bool done = false; - char *temp; - int bytes = nbytes; + bool done = false; + char *temp; + int bytes = nbytes; temp = ARR_DATA_PTR(array); i = 0; @@ -935,14 +939,14 @@ array_clip(ArrayType * array, int len, bool * isNull) { - int i, - ndim, - *dim, - *lb, - nbytes; - ArrayType *newArr; - int bytes, - span[MAXDIM]; + int i, + ndim, + *dim, + *lb, + nbytes; + ArrayType *newArr; + int bytes, + span[MAXDIM]; /* timer_start(); */ if (array == (ArrayType *) NULL) @@ -966,14 +970,14 @@ array_clip(ArrayType * array, if (ARR_IS_LO(array)) { #ifdef LOARRAY - char *lo_name; + char *lo_name; #endif - char *newname = NULL; - int fd = 0, - newfd = 0, - isDestLO = true, - rsize; + char *newname = NULL; + int fd = 0, + newfd = 0, + isDestLO = true, + rsize; if (len < 0) elog(WARN, "array_clip: array of variable length objects not supported"); @@ -994,7 +998,7 @@ array_clip(ArrayType * array, rsize = compute_size(lowerIndx, upperIndx, n, len); if (rsize < MAX_BUFF_SIZE) { - char *buff; + char *buff; rsize += 4; buff = palloc(rsize); @@ -1068,7 +1072,7 @@ array_clip(ArrayType * array, * returns a pointer to the modified array. *----------------------------------------------------------------------------- */ -char * +char * array_set(ArrayType * array, int n, int indx[], @@ -1078,12 +1082,12 @@ array_set(ArrayType * array, int arraylen, bool * isNull) { - int ndim, - *dim, - *lb, - offset, - nbytes; - char *pos; + int ndim, + *dim, + *lb, + offset, + nbytes; + char *pos; if (array == (ArrayType *) NULL) RETURN_NULL; @@ -1113,13 +1117,13 @@ array_set(ArrayType * array, if (ARR_IS_LO(array)) { - int fd = 0; + int fd = 0; struct varlena *v; /* We are assuming fixed element lengths here */ offset *= elmlen; #ifdef LOARRAY - char *lo_name; + char *lo_name; lo_name = ARR_DATA_PTR(array); if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0) @@ -1151,15 +1155,15 @@ array_set(ArrayType * array, } else { - ArrayType *newarray; - char *elt_ptr; - int oldsize, - newsize, - oldlen, - newlen, - lth0, - lth1, - lth2; + ArrayType *newarray; + char *elt_ptr; + int oldsize, + newsize, + oldlen, + newlen, + lth0, + lth1, + lth2; elt_ptr = array_seek(ARR_DATA_PTR(array), -1, offset); oldlen = INTALIGN(*(int32 *) elt_ptr); @@ -1203,7 +1207,7 @@ array_set(ArrayType * array, * returns a pointer to the modified array. *---------------------------------------------------------------------------- */ -char * +char * array_assgn(ArrayType * array, int n, int upperIndx[], @@ -1213,10 +1217,10 @@ array_assgn(ArrayType * array, int len, bool * isNull) { - int i, - ndim, - *dim, - *lb; + int i, + ndim, + *dim, + *lb; if (array == (ArrayType *) NULL) RETURN_NULL; @@ -1239,11 +1243,11 @@ array_assgn(ArrayType * array, if (ARR_IS_LO(array)) { - int fd = 0, - newfd = 0; + int fd = 0, + newfd = 0; #ifdef LOARRAY - char *lo_name; + char *lo_name; lo_name = (char *) ARR_DATA_PTR(array); if ((fd = LOopen(lo_name, ARR_IS_INV(array) ? INV_WRITE : O_WRONLY)) < 0) @@ -1303,8 +1307,8 @@ system_cache_lookup(Oid element_type, Oid * proc, char *typalign) { - HeapTuple typeTuple; - TypeTupleForm typeStruct; + HeapTuple typeTuple; + TypeTupleForm typeStruct; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(element_type), 0, 0, 0); @@ -1331,23 +1335,23 @@ system_cache_lookup(Oid element_type, } } -static Datum +static Datum _ArrayCast(char *value, bool byval, int len) { if (byval) { switch (len) { - case 1: - return ((Datum) * value); - case 2: - return ((Datum) * (int16 *) value); - case 3: - case 4: - return ((Datum) * (int32 *) value); - default: - elog(WARN, "array_ref: byval and elt len > 4!"); - break; + case 1: + return ((Datum) * value); + case 2: + return ((Datum) * (int16 *) value); + case 3: + case 4: + return ((Datum) * (int32 *) value); + default: + elog(WARN, "array_ref: byval and elt len > 4!"); + break; } } else @@ -1364,7 +1368,7 @@ ArrayCastAndSet(char *src, int typlen, char *dest) { - int inc; + int inc; if (typlen > 0) { @@ -1372,15 +1376,15 @@ ArrayCastAndSet(char *src, { switch (typlen) { - case 1: - *dest = DatumGetChar(src); - break; - case 2: - *(int16 *) dest = DatumGetInt16(src); - break; - case 4: - *(int32 *) dest = (int32) src; - break; + case 1: + *dest = DatumGetChar(src); + break; + case 2: + *(int16 *) dest = DatumGetInt16(src); + break; + case 4: + *(int32 *) dest = (int32) src; + break; } } else @@ -1398,11 +1402,11 @@ ArrayCastAndSet(char *src, } #ifdef LOARRAY -static char * +static char * _AdvanceBy1word(char *str, char **word) { - char *retstr, - *space; + char *retstr, + *space; *word = NULL; if (str == NULL) @@ -1425,7 +1429,7 @@ _AdvanceBy1word(char *str, char **word) static int SanityCheckInput(int ndim, int n, int dim[], int lb[], int indx[]) { - int i; + int i; /* Do Sanity check on input */ if (n != ndim) @@ -1444,18 +1448,18 @@ _ArrayRange(int st[], ArrayType * array, int from) { - int n, - *dim, - *lb, - st_pos, - prod[MAXDIM]; - int span[MAXDIM], - dist[MAXDIM], - indx[MAXDIM]; - int i, - j, - inc; - char *srcPtr; + int n, + *dim, + *lb, + st_pos, + prod[MAXDIM]; + int span[MAXDIM], + dist[MAXDIM], + indx[MAXDIM]; + int i, + j, + inc; + char *srcPtr; n = ARR_NDIM(array); dim = ARR_DIMS(array); @@ -1485,21 +1489,21 @@ _ArrayRange(int st[], static int _ArrayClipCount(int stI[], int endpI[], ArrayType * array) { - int n, - *dim, - *lb, - st_pos, - prod[MAXDIM]; - int span[MAXDIM], - dist[MAXDIM], - indx[MAXDIM]; - int i, - j, - inc, - st[MAXDIM], - endp[MAXDIM]; - int count = 0; - char *ptr; + int n, + *dim, + *lb, + st_pos, + prod[MAXDIM]; + int span[MAXDIM], + dist[MAXDIM], + indx[MAXDIM]; + int i, + j, + inc, + st[MAXDIM], + endp[MAXDIM]; + int count = 0; + char *ptr; n = ARR_NDIM(array); dim = ARR_DIMS(array); @@ -1523,10 +1527,10 @@ _ArrayClipCount(int stI[], int endpI[], ArrayType * array) return count; } -static char * +static char * array_seek(char *ptr, int eltsize, int nitems) { - int i; + int i; if (eltsize > 0) return (ptr + eltsize * nitems); @@ -1538,9 +1542,9 @@ array_seek(char *ptr, int eltsize, int nitems) static int array_read(char *destptr, int eltsize, int nitems, char *srcptr) { - int i, - inc, - tmp; + int i, + inc, + tmp; if (eltsize > 0) { @@ -1568,19 +1572,19 @@ _LOArrayRange(int st[], int isSrcLO, bool * isNull) { - int n, - *dim, - st_pos, - prod[MAXDIM]; - int span[MAXDIM], - dist[MAXDIM], - indx[MAXDIM]; - int i, - j, - inc, - tmp, - *lb, - offset; + int n, + *dim, + st_pos, + prod[MAXDIM]; + int span[MAXDIM], + dist[MAXDIM], + indx[MAXDIM]; + int i, + j, + inc, + tmp, + *lb, + offset; n = ARR_NDIM(array); dim = ARR_DIMS(array); @@ -1622,19 +1626,19 @@ _ReadArray(int st[], int isDestLO, bool * isNull) { - int n, - *dim, - st_pos, - prod[MAXDIM]; - int span[MAXDIM], - dist[MAXDIM], - indx[MAXDIM]; - int i, - j, - inc, - tmp, - *lb, - offset; + int n, + *dim, + st_pos, + prod[MAXDIM]; + int span[MAXDIM], + dist[MAXDIM], + indx[MAXDIM]; + int i, + j, + inc, + tmp, + *lb, + offset; n = ARR_NDIM(array); dim = ARR_DIMS(array); @@ -1677,9 +1681,9 @@ _LOtransfer(char **destfd, #define MAX_READ (512 * 1024) #define min(a, b) (a < b ? a : b) struct varlena *v = NULL; - int tmp, - inc, - resid; + int tmp, + inc, + resid; inc = nitems * size; if (isSrcLO && isDestLO && inc > 0) @@ -1719,11 +1723,11 @@ _LOtransfer(char **destfd, #undef MAX_READ } -char * +char * _array_newLO(int *fd, int flag) { - char *p; - char saveName[NAME_LEN]; + char *p; + char saveName[NAME_LEN]; p = (char *) palloc(NAME_LEN); sprintf(p, "/Arry.%d", newoid()); diff --git a/src/backend/utils/adt/arrayutils.c b/src/backend/utils/adt/arrayutils.c index 09a58d46e2c..898a6049629 100644 --- a/src/backend/utils/adt/arrayutils.c +++ b/src/backend/utils/adt/arrayutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayutils.c,v 1.4 1997/09/07 04:49:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayutils.c,v 1.5 1997/09/08 02:30:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,9 +21,9 @@ int GetOffset(int n, int dim[], int lb[], int indx[]) { - int i, - scale, - offset; + int i, + scale, + offset; for (i = n - 1, scale = 1, offset = 0; i >= 0; scale *= dim[i--]) offset += (indx[i] - lb[i]) * scale; @@ -33,8 +33,8 @@ GetOffset(int n, int dim[], int lb[], int indx[]) int getNitems(int n, int a[]) { - int i, - ret; + int i, + ret; for (i = 0, ret = 1; i < n; ret *= a[i++]); if (n == 0) @@ -45,8 +45,8 @@ getNitems(int n, int a[]) int compute_size(int st[], int endp[], int n, int base) { - int i, - ret; + int i, + ret; for (i = 0, ret = base; i < n; i++) ret *= (endp[i] - st[i] + 1); @@ -56,8 +56,8 @@ compute_size(int st[], int endp[], int n, int base) void mda_get_offset_values(int n, int dist[], int PC[], int span[]) { - int i, - j; + int i, + j; for (j = n - 2, dist[n - 1] = 0; j >= 0; j--) for (i = j + 1, dist[j] = PC[j] - 1; i < n; @@ -67,7 +67,7 @@ mda_get_offset_values(int n, int dist[], int PC[], int span[]) void mda_get_range(int n, int span[], int st[], int endp[]) { - int i; + int i; for (i = 0; i < n; i++) span[i] = endp[i] - st[i] + 1; @@ -76,7 +76,7 @@ mda_get_range(int n, int span[], int st[], int endp[]) void mda_get_prod(int n, int range[], int P[]) { - int i; + int i; for (i = n - 2, P[n - 1] = 1; i >= 0; i--) P[i] = P[i + 1] * range[i + 1]; @@ -85,8 +85,8 @@ mda_get_prod(int n, int range[], int P[]) int tuple2linear(int n, int tup[], int scale[]) { - int i, - lin; + int i, + lin; for (i = lin = 0; i < n; i++) lin += tup[i] * scale[i]; @@ -96,7 +96,7 @@ tuple2linear(int n, int tup[], int scale[]) void array2chunk_coord(int n, int C[], int a_coord[], int c_coord[]) { - int i; + int i; for (i = 0; i < n; i++) c_coord[i] = a_coord[i] / C[i]; @@ -112,7 +112,7 @@ array2chunk_coord(int n, int C[], int a_coord[], int c_coord[]) int next_tuple(int n, int curr[], int span[]) { - int i; + int i; if (!n) return (-1); diff --git a/src/backend/utils/adt/bool.c b/src/backend/utils/adt/bool.c index d02661efa67..82760cc8d74 100644 --- a/src/backend/utils/adt/bool.c +++ b/src/backend/utils/adt/bool.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.5 1997/09/07 04:49:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/bool.c,v 1.6 1997/09/08 02:30:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,10 +35,10 @@ boolin(char *b) /* * boolout - converts 1 or 0 to "t" or "f" */ -char * +char * boolout(long b) { - char *result = (char *) palloc(2); + char *result = (char *) palloc(2); *result = (b) ? 't' : 'f'; result[1] = '\0'; diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 763ac5856ce..a219ea3b832 100644 --- a/src/backend/utils/adt/cash.c +++ b/src/backend/utils/adt/cash.c @@ -9,7 +9,7 @@ * workings can be found in the book "Software Solutions in C" by * Dale Schumacher, Academic Press, ISBN: 0-12-632360-7. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.10 1997/09/07 04:49:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.11 1997/09/08 02:30:27 momjian Exp $ */ #include <stdio.h> @@ -47,22 +47,22 @@ static struct lconv *lconv = NULL; * monetary values returned by localeconv() can be multiple * bytes/characters. This code assumes one byte only. - tgl 97/04/14 */ -Cash * +Cash * cash_in(const char *str) { - Cash *result; - - Cash value = 0; - Cash dec = 0; - Cash sgn = 1; - int seen_dot = 0; - const char *s = str; - int fpoint; - char dsymbol, - ssymbol, - psymbol, - nsymbol, - csymbol; + Cash *result; + + Cash value = 0; + Cash dec = 0; + Cash sgn = 1; + int seen_dot = 0; + const char *s = str; + int fpoint; + char dsymbol, + ssymbol, + psymbol, + nsymbol, + csymbol; #ifdef USE_LOCALE if (lconv == NULL) @@ -164,22 +164,22 @@ cash_in(const char *str) * XXX HACK This code appears to assume US conventions for * positive-valued amounts. - tgl 97/04/14 */ -const char * +const char * cash_out(Cash * value) { - char *result; - char buf[CASH_BUFSZ]; - int minus = 0; - int count = LAST_DIGIT; - int point_pos; - int comma_position = 0; - char mon_group, - comma, - points; - char csymbol, - dsymbol, - *nsymbol; - char convention; + char *result; + char buf[CASH_BUFSZ]; + int minus = 0; + int count = LAST_DIGIT; + int point_pos; + int comma_position = 0; + char mon_group, + comma, + points; + char csymbol, + dsymbol, + *nsymbol; + char convention; #ifdef USE_LOCALE if (lconv == NULL) @@ -328,10 +328,10 @@ cash_ge(Cash * c1, Cash * c2) /* cash_pl() * Add two cash values. */ -Cash * +Cash * cash_pl(Cash * c1, Cash * c2) { - Cash *result; + Cash *result; if (!PointerIsValid(c1) || !PointerIsValid(c2)) return (NULL); @@ -348,10 +348,10 @@ cash_pl(Cash * c1, Cash * c2) /* cash_mi() * Subtract two cash values. */ -Cash * +Cash * cash_mi(Cash * c1, Cash * c2) { - Cash *result; + Cash *result; if (!PointerIsValid(c1) || !PointerIsValid(c2)) return (NULL); @@ -368,10 +368,10 @@ cash_mi(Cash * c1, Cash * c2) /* cash_mul() * Multiply cash by floating point number. */ -Cash * +Cash * cash_mul(Cash * c, float8 * f) { - Cash *result; + Cash *result; if (!PointerIsValid(f) || !PointerIsValid(c)) return (NULL); @@ -391,10 +391,10 @@ cash_mul(Cash * c, float8 * f) * XXX Don't know if rounding or truncating is correct behavior. * Round for now. - tgl 97/04/15 */ -Cash * +Cash * cash_div(Cash * c, float8 * f) { - Cash *result; + Cash *result; if (!PointerIsValid(f) || !PointerIsValid(c)) return (NULL); @@ -414,10 +414,10 @@ cash_div(Cash * c, float8 * f) /* cashlarger() * Return larger of two cash values. */ -Cash * +Cash * cashlarger(Cash * c1, Cash * c2) { - Cash *result; + Cash *result; if (!PointerIsValid(c1) || !PointerIsValid(c2)) return (NULL); @@ -434,10 +434,10 @@ cashlarger(Cash * c1, Cash * c2) /* cashsmaller() * Return smaller of two cash values. */ -Cash * +Cash * cashsmaller(Cash * c1, Cash * c2) { - Cash *result; + Cash *result; if (!PointerIsValid(c1) || !PointerIsValid(c2)) return (NULL); @@ -455,15 +455,15 @@ cashsmaller(Cash * c1, Cash * c2) * This converts a int4 as well but to a representation using words * Obviously way North American centric - sorry */ -const char * +const char * cash_words_out(Cash * value) { - static char buf[128]; - char *p = buf; - Cash m0; - Cash m1; - Cash m2; - Cash m3; + static char buf[128]; + char *p = buf; + Cash m0; + Cash m1; + Cash m2; + Cash m3; /* work with positive numbers */ if (*value < 0) @@ -515,15 +515,15 @@ cash_words_out(Cash * value) static const char * num_word(Cash value) { - static char buf[128]; + static char buf[128]; static const char *small[] = { "zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten", "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety" }; - const char **big = small + 18; - int tu = value % 100; + const char **big = small + 18; + int tu = value % 100; /* deal with the simple cases first */ if (value <= 20) diff --git a/src/backend/utils/adt/char.c b/src/backend/utils/adt/char.c index 24e30054b6b..db5a6827a90 100644 --- a/src/backend/utils/adt/char.c +++ b/src/backend/utils/adt/char.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.8 1997/09/07 04:50:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/char.c,v 1.9 1997/09/08 02:30:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,10 +40,10 @@ charin(char *ch) /* * charout - converts 'x' to "x" */ -char * +char * charout(int32 ch) { - char *result = (char *) palloc(2); + char *result = (char *) palloc(2); result[0] = (char) ch; result[1] = '\0'; @@ -59,7 +59,7 @@ charout(int32 ch) int32 cidin(char *s) { - CommandId c; + CommandId c; if (s == NULL) c = 0; @@ -75,11 +75,11 @@ cidin(char *s) * NOTE: we must no use 'charout' because cid might be a non * printable character... */ -char * +char * cidout(int32 c) { - char *result; - CommandId c2; + char *result; + CommandId c2; /* * cid is a number between 0 .. 2^16-1, therefore we need at most 6 @@ -98,10 +98,10 @@ cidout(int32 c) * Note: * Currently if strlen(s) < 14, the extra chars are nulls */ -char * +char * char16in(char *s) { - char *result; + char *result; if (s == NULL) return (NULL); @@ -113,10 +113,10 @@ char16in(char *s) /* * char16out - converts internal reprsentation to "..." */ -char * +char * char16out(char *s) { - char *result = (char *) palloc(17); + char *result = (char *) palloc(17); if (s == NULL) { @@ -133,48 +133,59 @@ char16out(char *s) * PUBLIC ROUTINES * *****************************************************************************/ -bool chareq(int8 arg1, int8 arg2) +bool +chareq(int8 arg1, int8 arg2) { return (arg1 == arg2); } -bool charne(int8 arg1, int8 arg2) +bool +charne(int8 arg1, int8 arg2) { return (arg1 != arg2); } -bool charlt(int8 arg1, int8 arg2) +bool +charlt(int8 arg1, int8 arg2) { return ((uint8) arg1 < (uint8) arg2); } -bool charle(int8 arg1, int8 arg2) +bool +charle(int8 arg1, int8 arg2) { return ((uint8) arg1 <= (uint8) arg2); } -bool chargt(int8 arg1, int8 arg2) +bool +chargt(int8 arg1, int8 arg2) { return ((uint8) arg1 > (uint8) arg2); } -bool charge(int8 arg1, int8 arg2) +bool +charge(int8 arg1, int8 arg2) { return ((uint8) arg1 >= (uint8) arg2); } -int8 charpl(int8 arg1, int8 arg2) +int8 +charpl(int8 arg1, int8 arg2) { return (arg1 + arg2); } -int8 charmi(int8 arg1, int8 arg2) +int8 +charmi(int8 arg1, int8 arg2) { return (arg1 - arg2); } -int8 charmul(int8 arg1, int8 arg2) +int8 +charmul(int8 arg1, int8 arg2) { return (arg1 * arg2); } -int8 chardiv(int8 arg1, int8 arg2) +int8 +chardiv(int8 arg1, int8 arg2) { return (arg1 / arg2); } -bool cideq(int8 arg1, int8 arg2) +bool +cideq(int8 arg1, int8 arg2) { return (arg1 == arg2); } @@ -248,7 +259,7 @@ char16ge(char *arg1, char *arg2) uint16 char2in(char *s) { - uint16 res; + uint16 res; if (s == NULL) return (0); @@ -257,10 +268,10 @@ char2in(char *s) return (res); } -char * +char * char2out(uint16 s) { - char *result = (char *) palloc(3); + char *result = (char *) palloc(3); strNcpy(result, (char *) &s, 2); @@ -313,7 +324,7 @@ char2cmp(uint16 a, uint16 b) uint32 char4in(char *s) { - uint32 res; + uint32 res; if (s == NULL) return (0); @@ -323,11 +334,11 @@ char4in(char *s) return (res); } -char * +char * char4out(s) -uint32 s; +uint32 s; { - char *result = (char *) palloc(5); + char *result = (char *) palloc(5); strNcpy(result, (char *) &s, 4); @@ -377,10 +388,10 @@ char4cmp(uint32 a, uint32 b) } /* ============================== char8 ============================== */ -char * +char * char8in(char *s) { - char *result; + char *result; if (s == NULL) return ((char *) NULL); @@ -390,10 +401,10 @@ char8in(char *s) return (result); } -char * +char * char8out(char *s) { - char *result = (char *) palloc(9); + char *result = (char *) palloc(9); if (s == NULL) { diff --git a/src/backend/utils/adt/chunk.c b/src/backend/utils/adt/chunk.c index fcfc8cdaeb5..021b7268676 100644 --- a/src/backend/utils/adt/chunk.c +++ b/src/backend/utils/adt/chunk.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.7 1997/09/07 04:50:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/chunk.c,v 1.8 1997/09/08 02:30:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -48,8 +48,8 @@ static CHUNK_INFO cInfo; static int _FindBestChunk(int size, int dmax[], int dbest[], int dim, int A[MAXPAT][MAXDIM + 1], int N); -static int get_next(int d[], int k, int C, int dmax[]); -static void initialize_info(CHUNK_INFO * A, int ndim, int dim[], int chunk[]); +static int get_next(int d[], int k, int C, int dmax[]); +static void initialize_info(CHUNK_INFO * A, int ndim, int dim[], int chunk[]); #ifdef LOARRAY static void @@ -58,8 +58,8 @@ _ConvertToChunkFile(int n, int baseSize, int dim[], int C[], static void read_chunk(int chunk_no[], int C[], char a_chunk[], int srcfd, int n, int baseSize, int PX[], int dist[]); -static int write_chunk(struct varlena * a_chunk, int ofile); -static int seek_and_read(int pos, int size, char buff[], int fp, int from); +static int write_chunk(struct varlena * a_chunk, int ofile); +static int seek_and_read(int pos, int size, char buff[], int fp, int from); #endif static int @@ -75,7 +75,7 @@ GetChunkSize(FILE * fd, int ndim, int dim[MAXDIM], int baseSize, * information about the chunked file *----------------------------------------------------------------------- */ -char * +char * _ChunkArray(int fd, FILE * afd, int ndim, @@ -85,12 +85,12 @@ _ChunkArray(int fd, char *chunkfile) { #ifdef LOARRAY - int cfd = 0; + int cfd = 0; #endif - int chunk[MAXDIM], - csize; - bool reorgFlag; + int chunk[MAXDIM], + csize; + bool reorgFlag; if (chunkfile == NULL) reorgFlag = true; @@ -136,12 +136,12 @@ GetChunkSize(FILE * fd, int baseSize, int d[MAXDIM]) { - int N, - i, - j, - csize; - int A[MAXPAT][MAXDIM + 1], - dmax[MAXDIM]; + int N, + i, + j, + csize; + int A[MAXPAT][MAXDIM + 1], + dmax[MAXDIM]; /* * ----------- read input ------------ @@ -183,9 +183,9 @@ _FindBestChunk(int size, int A[MAXPAT][MAXDIM + 1], int N) { - int d[MAXDIM]; - int tc, - mintc = INFTY; + int d[MAXDIM]; + int tc, + mintc = INFTY; d[0] = 0; mintc = INFTY; @@ -196,9 +196,9 @@ _FindBestChunk(int size, * compute the number of page fetches for a given chunk size (d[]) * and access pattern (A[][]) */ - register int i, - j, - nc; + register int i, + j, + nc; for (i = 0, tc = 0; i < N; i++) { @@ -229,9 +229,9 @@ _FindBestChunk(int size, static int get_next(int d[], int k, int C, int dmax[]) { - register int i, - j, - temp; + register int i, + j, + temp; if (!d[0]) { @@ -271,15 +271,14 @@ get_next(int d[], int k, int C, int dmax[]) } #ifdef LOARRAY -static char a_chunk[BLCKSZ + 4]; /* 4 since a_chunk is in varlena - * format */ +static char a_chunk[BLCKSZ + 4];/* 4 since a_chunk is in varlena format */ #endif static void initialize_info(CHUNK_INFO * A, int ndim, int dim[], int chunk[]) { - int i; + int i; for (i = 0; i < ndim; i++) A->C[i] = chunk[i]; @@ -305,13 +304,13 @@ _ConvertToChunkFile(int n, int srcfd, int destfd) { - int max_chunks[MAXDIM], - chunk_no[MAXDIM]; - int PX[MAXDIM], - dist[MAXDIM]; - int csize = 1, - i, - temp; + int max_chunks[MAXDIM], + chunk_no[MAXDIM]; + int PX[MAXDIM], + dist[MAXDIM]; + int csize = 1, + i, + temp; for (i = 0; i < n; chunk_no[i++] = 0) { @@ -349,14 +348,14 @@ read_chunk(int chunk_no[], int PX[], int dist[]) { - int i, - j, - cp, - unit_transfer; - int start_pos, - pos[MAXDIM]; - int indx[MAXDIM]; - int fpOff; + int i, + j, + cp, + unit_transfer; + int start_pos, + pos[MAXDIM]; + int indx[MAXDIM]; + int fpOff; for (i = start_pos = 0; i < n; i++) { @@ -392,7 +391,7 @@ read_chunk(int chunk_no[], static int write_chunk(struct varlena * a_chunk, int ofile) { - int got_n = 0; + int got_n = 0; #ifdef LOARRAY got_n = LOwrite(ofile, a_chunk); @@ -444,41 +443,41 @@ _ReadChunkArray(int st[], int isDestLO, bool * isNull) { - int i, - j, - jj; - int n, - temp, - words_read; - int chunk_span[MAXDIM], - chunk_off[MAXDIM]; - int chunk_st[MAXDIM], - chunk_end[MAXDIM]; - int block_seek; - - int bptr, - *C, - csize, - *dim, - *lb; - int range_st[MAXDIM], - range_end[MAXDIM], - range[MAXDIM], - array_span[MAXDIM]; - int PA[MAXDIM], - PCHUNK[MAXDIM], - PC[MAXDIM]; - int to_read; - int cdist[MAXDIM], - adist[MAXDIM]; - int dist[MAXDIM], - temp_seek; - - int srcOff; /* Needed since LO don't understand + int i, + j, + jj; + int n, + temp, + words_read; + int chunk_span[MAXDIM], + chunk_off[MAXDIM]; + int chunk_st[MAXDIM], + chunk_end[MAXDIM]; + int block_seek; + + int bptr, + *C, + csize, + *dim, + *lb; + int range_st[MAXDIM], + range_end[MAXDIM], + range[MAXDIM], + array_span[MAXDIM]; + int PA[MAXDIM], + PCHUNK[MAXDIM], + PC[MAXDIM]; + int to_read; + int cdist[MAXDIM], + adist[MAXDIM]; + int dist[MAXDIM], + temp_seek; + + int srcOff; /* Needed since LO don't understand * SEEK_CUR */ - char *baseDestFp = (char *) destfp; + char *baseDestFp = (char *) destfp; - CHUNK_INFO *A = (CHUNK_INFO *) ARR_DATA_PTR(array); + CHUNK_INFO *A = (CHUNK_INFO *) ARR_DATA_PTR(array); n = ARR_NDIM(array); dim = ARR_DIMS(array); @@ -584,7 +583,7 @@ _ReadChunkArray(int st[], * compute next tuple in range[] */ { - int x; + int x; if (!(i + 1)) j = -1; @@ -641,21 +640,21 @@ _ReadChunkArray1El(int st[], ArrayType * array, bool * isNull) { - int i, - j, - n, - temp, - srcOff; - int chunk_st[MAXDIM]; - - int *C, - csize, - *dim, - *lb; - int PCHUNK[MAXDIM], - PC[MAXDIM]; - - CHUNK_INFO *A = (CHUNK_INFO *) ARR_DATA_PTR(array); + int i, + j, + n, + temp, + srcOff; + int chunk_st[MAXDIM]; + + int *C, + csize, + *dim, + *lb; + int PCHUNK[MAXDIM], + PC[MAXDIM]; + + CHUNK_INFO *A = (CHUNK_INFO *) ARR_DATA_PTR(array); n = ARR_NDIM(array); lb = ARR_LBOUND(array); diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index 40369f9a84e..5a88e2bf324 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.15 1997/09/07 04:50:06 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.16 1997/09/08 02:30:32 momjian Exp $ * * NOTES * This code is actually (almost) unused. @@ -74,7 +74,7 @@ #define ABSTIMEMAX(t1, t2) abstimelt((t1),(t2)) ? (t2) : (t1) #if FALSE -static char *unit_tab[] = { +static char *unit_tab[] = { "second", "seconds", "minute", "minutes", "hour", "hours", "day", "days", "week", "weeks", "month", "months", "year", "years"}; @@ -83,7 +83,7 @@ static char *unit_tab[] = { #define NUNITS 14 /* number of different units */ /* table of seconds per unit (month = 30 days, year = 365 days) */ -static int sec_tab[] = { +static int sec_tab[] = { 1, 1, 60, 60, 3600, 3600, 86400, 86400, 604800, 604800, 2592000, 2592000, 31536000, 31536000}; @@ -94,11 +94,11 @@ static int sec_tab[] = { * Function prototypes -- internal to this file only */ -static void reltime2tm(int32 time, struct tm * tm); +static void reltime2tm(int32 time, struct tm * tm); #if FALSE -static int correct_unit(char unit[], int *unptr); -static int correct_dir(char direction[], int *signptr); +static int correct_unit(char unit[], int *unptr); +static int correct_dir(char direction[], int *signptr); #endif @@ -117,16 +117,16 @@ istinterval(char *i_string, RelativeTime reltimein(char *str) { - RelativeTime result; + RelativeTime result; - struct tm tt, - *tm = &tt; - double fsec; - int dtype; - char *field[MAXDATEFIELDS]; - int nf, - ftype[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; + struct tm tt, + *tm = &tt; + double fsec; + int dtype; + char *field[MAXDATEFIELDS]; + int nf, + ftype[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) elog(WARN, "Bad (null) date external representation", NULL); @@ -144,13 +144,13 @@ reltimein(char *str) switch (dtype) { - case DTK_DELTA: - result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec); - result += (((tm->tm_year * 365) + (tm->tm_mon * 30) + tm->tm_mday) * (24 * 60 * 60)); - return (result); + case DTK_DELTA: + result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec); + result += (((tm->tm_year * 365) + (tm->tm_mon * 30) + tm->tm_mday) * (24 * 60 * 60)); + return (result); - default: - return (INVALID_RELTIME); + default: + return (INVALID_RELTIME); } elog(WARN, "Bad reltime (internal coding error) '%s'", str); @@ -161,13 +161,13 @@ reltimein(char *str) /* * reltimeout - converts the internal format to a reltime string */ -char * +char * reltimeout(int32 time) { - char *result; - struct tm tt, - *tm = &tt; - char buf[MAXDATELEN + 1]; + char *result; + struct tm tt, + *tm = &tt; + char buf[MAXDATELEN + 1]; if (time == INVALID_RELTIME) { @@ -204,10 +204,10 @@ reltime2tm(int32 time, struct tm * tm) } /* reltime2tm() */ #if FALSE -char *timestring; -long quantity; -register int i; -int unitnr; +char *timestring; +long quantity; +register int i; +int unitnr; timestring = (char *) palloc(Max(strlen(INVALID_RELTIME_STR), UNITMAXLEN) + 1); @@ -245,12 +245,12 @@ return (timestring); TimeInterval tintervalin(char *intervalstr) { - int error; - AbsoluteTime i_start, - i_end, - t1, - t2; - TimeInterval interval; + int error; + AbsoluteTime i_start, + i_end, + t1, + t2; + TimeInterval interval; interval = (TimeInterval) palloc(sizeof(TimeIntervalData)); error = istinterval(intervalstr, &t1, &t2); @@ -274,11 +274,11 @@ tintervalin(char *intervalstr) * tintervalout - converts an internal interval format to a string * */ -char * +char * tintervalout(TimeInterval interval) { - char *i_str, - *p; + char *i_str, + *p; i_str = (char *) palloc(T_INTERVAL_LEN); /* ['...' '...'] */ strcpy(i_str, "[\""); @@ -306,10 +306,10 @@ tintervalout(TimeInterval interval) RelativeTime timespan_reltime(TimeSpan * timespan) { - RelativeTime time; - int year, - month; - double span; + RelativeTime time; + int year, + month; + double span; if (!PointerIsValid(timespan)) time = INVALID_RELTIME; @@ -353,28 +353,28 @@ timespan_reltime(TimeSpan * timespan) } /* timespan_reltime() */ -TimeSpan * +TimeSpan * reltime_timespan(RelativeTime reltime) { - TimeSpan *result; - int year, - month; + TimeSpan *result; + int year, + month; if (!PointerIsValid(result = PALLOCTYPE(TimeSpan))) elog(WARN, "Memory allocation failed, can't convert reltime to timespan", NULL); switch (reltime) { - case INVALID_RELTIME: - TIMESPAN_INVALID(*result); - break; + case INVALID_RELTIME: + TIMESPAN_INVALID(*result); + break; - default: - TMODULO(reltime, year, 31536000); - TMODULO(reltime, month, 2592000); + default: + TMODULO(reltime, year, 31536000); + TMODULO(reltime, month, 2592000); - result->time = reltime; - result->month = ((12 * year) + month); + result->time = reltime; + result->month = ((12 * year) + month); } return (result); @@ -387,9 +387,9 @@ reltime_timespan(RelativeTime reltime) TimeInterval mktinterval(AbsoluteTime t1, AbsoluteTime t2) { - AbsoluteTime tstart = ABSTIMEMIN(t1, t2), - tend = ABSTIMEMAX(t1, t2); - TimeInterval interval; + AbsoluteTime tstart = ABSTIMEMIN(t1, t2), + tend = ABSTIMEMAX(t1, t2); + TimeInterval interval; interval = (TimeInterval) palloc(sizeof(TimeIntervalData)); if (t1 == INVALID_ABSTIME || t2 == INVALID_ABSTIME) @@ -500,7 +500,7 @@ intervalrel(TimeInterval interval) AbsoluteTime timenow() { - time_t sec; + time_t sec; if (time(&sec) < 0) return (INVALID_ABSTIME); @@ -583,7 +583,7 @@ intervaleq(TimeInterval i1, TimeInterval i2) bool intervalleneq(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -598,7 +598,7 @@ intervalleneq(TimeInterval i, RelativeTime t) bool intervallenne(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -613,7 +613,7 @@ intervallenne(TimeInterval i, RelativeTime t) bool intervallenlt(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -628,7 +628,7 @@ intervallenlt(TimeInterval i, RelativeTime t) bool intervallengt(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -643,7 +643,7 @@ intervallengt(TimeInterval i, RelativeTime t) bool intervallenle(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -658,7 +658,7 @@ intervallenle(TimeInterval i, RelativeTime t) bool intervallenge(TimeInterval i, RelativeTime t) { - RelativeTime rt; + RelativeTime rt; if ((i->status == T_INTERVAL_INVAL) || (t == INVALID_RELTIME)) return (0); @@ -727,14 +727,14 @@ intervalend(TimeInterval i) int isreltime(char *str) { - struct tm tt, - *tm = &tt; - double fsec; - int dtype; - char *field[MAXDATEFIELDS]; - int nf, - ftype[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; + struct tm tt, + *tm = &tt; + double fsec; + int dtype; + char *field[MAXDATEFIELDS]; + int nf, + ftype[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) return 0; @@ -748,31 +748,31 @@ isreltime(char *str) switch (dtype) { - case (DTK_DELTA): - return ((abs(tm->tm_year) <= 68) ? 1 : 0); - break; + case (DTK_DELTA): + return ((abs(tm->tm_year) <= 68) ? 1 : 0); + break; - case (DTK_INVALID): - return 2; - break; + case (DTK_INVALID): + return 2; + break; - default: - return 0; - break; + default: + return 0; + break; } return 0; } /* isreltime() */ #if FALSE -register char *p; -register char c; -int i; -char unit[UNITMAXLEN]; -char direction[DIRMAXLEN]; -int localSign; -int localUnitNumber; -long localQuantity; +register char *p; +register char c; +int i; +char unit[UNITMAXLEN]; +char direction[DIRMAXLEN]; +int localSign; +int localUnitNumber; +long localQuantity; if (!PointerIsValid(sign)) { @@ -897,7 +897,7 @@ return (1); static int correct_unit(char unit[], int *unptr) { - int j = 0; + int j = 0; while (j < NUNITS) { @@ -955,9 +955,9 @@ istinterval(char *i_string, AbsoluteTime * i_start, AbsoluteTime * i_end) { - register char *p, - *p1; - register char c; + register char *p, + *p1; + register char c; p = i_string; /* skip leading blanks up to '[' */ @@ -1058,16 +1058,16 @@ istinterval(char *i_string, * the Wisconsin benchmark with Illustra whose TimeNow() shows current * time with precision up to microsecs.) - ay 3/95 */ -text * +text * timeofday(void) { - struct timeval tp; + struct timeval tp; struct timezone tpz; - char templ[500]; - char buf[500]; - text *tm; - int len = 0; + char templ[500]; + char buf[500]; + text *tm; + int len = 0; gettimeofday(&tp, &tpz); strftime(templ, sizeof(templ), "%a %b %d %H:%M:%S.%%d %Y %Z", diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index a88bea36e9c..0ab3b501022 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.14 1997/09/07 04:50:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.15 1997/09/08 02:30:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,10 +25,10 @@ #include "utils/datetime.h" #include "access/xact.h" -static int date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn); +static int date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn); -static int day_tab[2][12] = { +static int day_tab[2][12] = { {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}, {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}}; @@ -59,16 +59,16 @@ static int day_tab[2][12] = { DateADT date_in(char *str) { - DateADT date; - double fsec; - struct tm tt, - *tm = &tt; - int tzp; - int dtype; - int nf; - char *field[MAXDATEFIELDS]; - int ftype[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; + DateADT date; + double fsec; + struct tm tt, + *tm = &tt; + int tzp; + int dtype; + int nf; + char *field[MAXDATEFIELDS]; + int ftype[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) elog(WARN, "Bad (null) date external representation", NULL); @@ -82,21 +82,21 @@ date_in(char *str) switch (dtype) { - case DTK_DATE: - break; + case DTK_DATE: + break; - case DTK_CURRENT: - GetCurrentTime(tm); - break; + case DTK_CURRENT: + GetCurrentTime(tm); + break; - case DTK_EPOCH: - tm->tm_year = 1970; - tm->tm_mon = 1; - tm->tm_mday = 1; - break; + case DTK_EPOCH: + tm->tm_year = 1970; + tm->tm_mon = 1; + tm->tm_mday = 1; + break; - default: - elog(WARN, "Unrecognized date external representation %s", str); + default: + elog(WARN, "Unrecognized date external representation %s", str); } if (tm->tm_year < 0 || tm->tm_year > 32767) @@ -115,18 +115,18 @@ date_in(char *str) /* date_out() * Given internal format date, convert to text string. */ -char * +char * date_out(DateADT date) { - char *result; - struct tm tt, - *tm = &tt; - char buf[MAXDATELEN + 1]; + char *result; + struct tm tt, + *tm = &tt; + char buf[MAXDATELEN + 1]; #if FALSE - int year, - month, - day; + int year, + month, + day; #endif @@ -237,15 +237,15 @@ date_mii(DateADT dateVal, int4 days) /* date_datetime() * Convert date to datetime data type. */ -DateTime * +DateTime * date_datetime(DateADT dateVal) { - DateTime *result; - struct tm tt, - *tm = &tt; - int tz; - double fsec = 0; - char *tzn; + DateTime *result; + struct tm tt, + *tm = &tt; + int tz; + double fsec = 0; + char *tzn; result = PALLOCTYPE(DateTime); @@ -270,12 +270,12 @@ date_datetime(DateADT dateVal) DateADT datetime_date(DateTime * datetime) { - DateADT result; - struct tm tt, - *tm = &tt; - int tz; - double fsec; - char *tzn; + DateADT result; + struct tm tt, + *tm = &tt; + int tz; + double fsec; + char *tzn; if (!PointerIsValid(datetime)) elog(WARN, "Unable to convert null datetime to date", NULL); @@ -311,36 +311,36 @@ datetime_date(DateTime * datetime) DateADT abstime_date(AbsoluteTime abstime) { - DateADT result; - struct tm tt, - *tm = &tt; - int tz; + DateADT result; + struct tm tt, + *tm = &tt; + int tz; switch (abstime) { - case INVALID_ABSTIME: - case NOSTART_ABSTIME: - case NOEND_ABSTIME: - elog(WARN, "Unable to convert reserved abstime value to date", NULL); - - /* - * pretend to drop through to make compiler think that result will - * be set - */ - - case EPOCH_ABSTIME: - result = date2j(1970, 1, 1) - date2j(2000, 1, 1); - break; - - case CURRENT_ABSTIME: - GetCurrentTime(tm); - result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1); - break; - - default: - abstime2tm(abstime, &tz, tm, NULL); - result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1); - break; + case INVALID_ABSTIME: + case NOSTART_ABSTIME: + case NOEND_ABSTIME: + elog(WARN, "Unable to convert reserved abstime value to date", NULL); + + /* + * pretend to drop through to make compiler think that result + * will be set + */ + + case EPOCH_ABSTIME: + result = date2j(1970, 1, 1) - date2j(2000, 1, 1); + break; + + case CURRENT_ABSTIME: + GetCurrentTime(tm); + result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1); + break; + + default: + abstime2tm(abstime, &tz, tm, NULL); + result = date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - date2j(2000, 1, 1); + break; } return (result); @@ -356,8 +356,8 @@ abstime_date(AbsoluteTime abstime) static int date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn) { - struct tm *tx; - time_t utime; + struct tm *tx; + time_t utime; *fsec = 0; @@ -447,20 +447,20 @@ date2tm(DateADT dateVal, int *tzp, struct tm * tm, double *fsec, char **tzn) *****************************************************************************/ -TimeADT * +TimeADT * time_in(char *str) { - TimeADT *time; + TimeADT *time; - double fsec; - struct tm tt, - *tm = &tt; + double fsec; + struct tm tt, + *tm = &tt; - int nf; - char lowstr[MAXDATELEN + 1]; - char *field[MAXDATEFIELDS]; - int dtype; - int ftype[MAXDATEFIELDS]; + int nf; + char lowstr[MAXDATELEN + 1]; + char *field[MAXDATEFIELDS]; + int dtype; + int ftype[MAXDATEFIELDS]; if (!PointerIsValid(str)) elog(WARN, "Bad (null) time external representation", NULL); @@ -484,21 +484,21 @@ time_in(char *str) } /* time_in() */ -char * +char * time_out(TimeADT * time) { - char *result; - struct tm tt, - *tm = &tt; + char *result; + struct tm tt, + *tm = &tt; #if FALSE - int hour, - min, - sec; + int hour, + min, + sec; #endif - double fsec; - char buf[MAXDATELEN + 1]; + double fsec; + char buf[MAXDATELEN + 1]; if (!PointerIsValid(time)) return NULL; @@ -602,10 +602,10 @@ time_cmp(TimeADT * time1, TimeADT * time2) /* datetime_datetime() * Convert date and time to datetime data type. */ -DateTime * +DateTime * datetime_datetime(DateADT date, TimeADT * time) { - DateTime *result; + DateTime *result; if (!PointerIsValid(time)) { diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index eb314176bab..b1045765575 100644 --- a/src/backend/utils/adt/datum.c +++ b/src/backend/utils/adt/datum.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.6 1997/09/07 04:50:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.7 1997/09/08 02:30:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ datumGetSize(Datum value, Oid type, bool byVal, Size len) { struct varlena *s; - Size size = 0; + Size size = 0; if (byVal) { @@ -110,9 +110,9 @@ Datum datumCopy(Datum value, Oid type, bool byVal, Size len) { - Size realSize; - Datum res; - char *s; + Size realSize; + Datum res; + char *s; if (byVal) @@ -154,8 +154,8 @@ void datumFree(Datum value, Oid type, bool byVal, Size len) { - Size realSize; - Pointer s; + Size realSize; + Pointer s; realSize = datumGetSize(value, type, byVal, len); @@ -188,10 +188,10 @@ datumFree(Datum value, Oid type, bool byVal, Size len) bool datumIsEqual(Datum value1, Datum value2, Oid type, bool byVal, Size len) { - Size size1, - size2; - char *s1, - *s2; + Size size1, + size2; + char *s1, + *s2; if (byVal) { diff --git a/src/backend/utils/adt/dt.c b/src/backend/utils/adt/dt.c index b3eca30144c..e7968e9a40c 100644 --- a/src/backend/utils/adt/dt.c +++ b/src/backend/utils/adt/dt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.38 1997/09/07 04:50:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/dt.c,v 1.39 1997/09/08 02:30:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,38 +31,38 @@ #endif #include "utils/builtins.h" -static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); +static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm); static int DecodeNumber(int flen, char *field, int fmask, int *tmask, struct tm * tm, double *fsec); static int DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, double *fsec); -static int DecodeSpecial(int field, char *lowtoken, int *val); +static int DecodeSpecial(int field, char *lowtoken, int *val); static int DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec); -static int DecodeTimezone(char *str, int *tzp); -static int DecodeUnits(int field, char *lowtoken, int *val); -static int EncodeSpecialDateTime(DateTime dt, char *str); +static int DecodeTimezone(char *str, int *tzp); +static int DecodeUnits(int field, char *lowtoken, int *val); +static int EncodeSpecialDateTime(DateTime dt, char *str); static datetkn *datebsearch(char *key, datetkn * base, unsigned int nel); static DateTime dt2local(DateTime dt, int timezone); -static void dt2time(DateTime dt, int *hour, int *min, double *sec); -static int j2day(int jd); -static int timespan2tm(TimeSpan span, struct tm * tm, float8 * fsec); -static int tm2timespan(struct tm * tm, double fsec, TimeSpan * span); +static void dt2time(DateTime dt, int *hour, int *min, double *sec); +static int j2day(int jd); +static int timespan2tm(TimeSpan span, struct tm * tm, float8 * fsec); +static int tm2timespan(struct tm * tm, double fsec, TimeSpan * span); #define USE_DATE_CACHE 1 #define ROUND_ALL 0 #define isleap(y) (((y % 4) == 0) && (((y % 100) != 0) || ((y % 400) == 0))) -int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; +int mdays[] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}; -char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", +char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; -char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", +char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", NULL}; /* TMODULO() @@ -71,7 +71,7 @@ char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", #define TMODULO(t,q,u) {q = ((t < 0)? ceil(t / u): floor(t / u)); \ if (q != 0) t -= rint(q * u);} -static void GetEpochTime(struct tm * tm); +static void GetEpochTime(struct tm * tm); #define UTIME_MINYEAR (1901) #define UTIME_MINMONTH (12) @@ -95,20 +95,20 @@ static void GetEpochTime(struct tm * tm); /* datetime_in() * Convert a string to internal form. */ -DateTime * +DateTime * datetime_in(char *str) { - DateTime *result; - - double fsec; - struct tm tt, - *tm = &tt; - int tz; - int dtype; - int nf; - char *field[MAXDATEFIELDS]; - int ftype[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; + DateTime *result; + + double fsec; + struct tm tt, + *tm = &tt; + int tz; + int dtype; + int nf; + char *field[MAXDATEFIELDS]; + int ftype[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) elog(WARN, "Bad (null) datetime external representation", NULL); @@ -121,38 +121,38 @@ datetime_in(char *str) switch (dtype) { - case DTK_DATE: - if (tm2datetime(tm, fsec, &tz, result) != 0) - elog(WARN, "Datetime out of range %s", str); + case DTK_DATE: + if (tm2datetime(tm, fsec, &tz, result) != 0) + elog(WARN, "Datetime out of range %s", str); #ifdef DATEDEBUG - printf("datetime_in- date is %f\n", *result); + printf("datetime_in- date is %f\n", *result); #endif - break; + break; - case DTK_EPOCH: - DATETIME_EPOCH(*result); - break; + case DTK_EPOCH: + DATETIME_EPOCH(*result); + break; - case DTK_CURRENT: - DATETIME_CURRENT(*result); - break; + case DTK_CURRENT: + DATETIME_CURRENT(*result); + break; - case DTK_LATE: - DATETIME_NOEND(*result); - break; + case DTK_LATE: + DATETIME_NOEND(*result); + break; - case DTK_EARLY: - DATETIME_NOBEGIN(*result); - break; + case DTK_EARLY: + DATETIME_NOBEGIN(*result); + break; - case DTK_INVALID: - DATETIME_INVALID(*result); - break; + case DTK_INVALID: + DATETIME_INVALID(*result); + break; - default: - elog(WARN, "Internal coding error, can't input datetime '%s'", str); + default: + elog(WARN, "Internal coding error, can't input datetime '%s'", str); } return (result); @@ -161,16 +161,16 @@ datetime_in(char *str) /* datetime_out() * Convert a datetime to external form. */ -char * +char * datetime_out(DateTime * dt) { - char *result; - int tz; - struct tm tt, - *tm = &tt; - double fsec; - char *tzn; - char buf[MAXDATELEN + 1]; + char *result; + int tz; + struct tm tt, + *tm = &tt; + double fsec; + char *tzn; + char buf[MAXDATELEN + 1]; if (!PointerIsValid(dt)) return (NULL); @@ -204,19 +204,19 @@ datetime_out(DateTime * dt) * External format(s): * Uses the generic date/time parsing and decoding routines. */ -TimeSpan * +TimeSpan * timespan_in(char *str) { - TimeSpan *span; + TimeSpan *span; - double fsec; - struct tm tt, - *tm = &tt; - int dtype; - int nf; - char *field[MAXDATEFIELDS]; - int ftype[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; + double fsec; + struct tm tt, + *tm = &tt; + int dtype; + int nf; + char *field[MAXDATEFIELDS]; + int ftype[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; tm->tm_year = 0; tm->tm_mon = 0; @@ -237,18 +237,18 @@ timespan_in(char *str) switch (dtype) { - case DTK_DELTA: - if (tm2timespan(tm, fsec, span) != 0) - { + case DTK_DELTA: + if (tm2timespan(tm, fsec, span) != 0) + { #if FALSE - TIMESPAN_INVALID(span); + TIMESPAN_INVALID(span); #endif - elog(WARN, "Bad timespan external representation %s", str); - } - break; + elog(WARN, "Bad timespan external representation %s", str); + } + break; - default: - elog(WARN, "Internal coding error, can't input timespan '%s'", str); + default: + elog(WARN, "Internal coding error, can't input timespan '%s'", str); } return (span); @@ -257,15 +257,15 @@ timespan_in(char *str) /* timespan_out() * Convert a time span to external form. */ -char * +char * timespan_out(TimeSpan * span) { - char *result; + char *result; - struct tm tt, - *tm = &tt; - double fsec; - char buf[MAXDATELEN + 1]; + struct tm tt, + *tm = &tt; + double fsec; + char buf[MAXDATELEN + 1]; if (!PointerIsValid(span)) return (NULL); @@ -317,8 +317,8 @@ timespan_finite(TimeSpan * timespan) static void GetEpochTime(struct tm * tm) { - struct tm *t0; - time_t epoch = 0; + struct tm *t0; + time_t epoch = 0; t0 = gmtime(&epoch); @@ -344,7 +344,7 @@ GetEpochTime(struct tm * tm) DateTime SetDateTime(DateTime dt) { - struct tm tt; + struct tm tt; if (DATETIME_IS_CURRENT(dt)) { @@ -373,8 +373,8 @@ SetDateTime(DateTime dt) bool datetime_eq(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -396,8 +396,8 @@ datetime_eq(DateTime * datetime1, DateTime * datetime2) bool datetime_ne(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -419,8 +419,8 @@ datetime_ne(DateTime * datetime1, DateTime * datetime2) bool datetime_lt(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -442,8 +442,8 @@ datetime_lt(DateTime * datetime1, DateTime * datetime2) bool datetime_gt(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -468,8 +468,8 @@ datetime_gt(DateTime * datetime1, DateTime * datetime2) bool datetime_le(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -491,8 +491,8 @@ datetime_le(DateTime * datetime1, DateTime * datetime2) bool datetime_ge(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return FALSE; @@ -518,8 +518,8 @@ datetime_ge(DateTime * datetime1, DateTime * datetime2) int datetime_cmp(DateTime * datetime1, DateTime * datetime2) { - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return 0; @@ -580,8 +580,8 @@ timespan_ne(TimeSpan * timespan1, TimeSpan * timespan2) bool timespan_lt(TimeSpan * timespan1, TimeSpan * timespan2) { - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return FALSE; @@ -602,8 +602,8 @@ timespan_lt(TimeSpan * timespan1, TimeSpan * timespan2) bool timespan_gt(TimeSpan * timespan1, TimeSpan * timespan2) { - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return FALSE; @@ -624,8 +624,8 @@ timespan_gt(TimeSpan * timespan1, TimeSpan * timespan2) bool timespan_le(TimeSpan * timespan1, TimeSpan * timespan2) { - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return FALSE; @@ -646,8 +646,8 @@ timespan_le(TimeSpan * timespan1, TimeSpan * timespan2) bool timespan_ge(TimeSpan * timespan1, TimeSpan * timespan2) { - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return FALSE; @@ -671,8 +671,8 @@ timespan_ge(TimeSpan * timespan1, TimeSpan * timespan2) int timespan_cmp(TimeSpan * timespan1, TimeSpan * timespan2) { - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return 0; @@ -706,13 +706,13 @@ timespan_cmp(TimeSpan * timespan1, TimeSpan * timespan2) * actual value. *---------------------------------------------------------*/ -DateTime * +DateTime * datetime_smaller(DateTime * datetime1, DateTime * datetime2) { - DateTime *result; + DateTime *result; - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return NULL; @@ -743,13 +743,13 @@ datetime_smaller(DateTime * datetime1, DateTime * datetime2) return (result); } /* datetime_smaller() */ -DateTime * +DateTime * datetime_larger(DateTime * datetime1, DateTime * datetime2) { - DateTime *result; + DateTime *result; - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return NULL; @@ -781,13 +781,13 @@ datetime_larger(DateTime * datetime1, DateTime * datetime2) } /* datetime_larger() */ -TimeSpan * +TimeSpan * datetime_mi(DateTime * datetime1, DateTime * datetime2) { - TimeSpan *result; + TimeSpan *result; - DateTime dt1, - dt2; + DateTime dt1, + dt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return NULL; @@ -830,13 +830,13 @@ datetime_mi(DateTime * datetime1, DateTime * datetime2) * Then, if the next month has fewer days, set the day of month * to the last day of month. */ -DateTime * +DateTime * datetime_pl_span(DateTime * datetime, TimeSpan * span) { - DateTime *result; - DateTime dt; - int tz; - char *tzn; + DateTime *result; + DateTime dt; + int tz; + char *tzn; if ((!PointerIsValid(datetime)) || (!PointerIsValid(span))) return NULL; @@ -869,9 +869,9 @@ datetime_pl_span(DateTime * datetime, TimeSpan * span) if (span->month != 0) { - struct tm tt, - *tm = &tt; - double fsec; + struct tm tt, + *tm = &tt; + double fsec; if (datetime2tm(dt, &tz, tm, &fsec, &tzn) == 0) { @@ -924,11 +924,11 @@ datetime_pl_span(DateTime * datetime, TimeSpan * span) return (result); } /* datetime_pl_span() */ -DateTime * +DateTime * datetime_mi_span(DateTime * datetime, TimeSpan * span) { - DateTime *result; - TimeSpan tspan; + DateTime *result; + TimeSpan tspan; if (!PointerIsValid(datetime) || !PointerIsValid(span)) return NULL; @@ -942,10 +942,10 @@ datetime_mi_span(DateTime * datetime, TimeSpan * span) } /* datetime_mi_span() */ -TimeSpan * +TimeSpan * timespan_um(TimeSpan * timespan) { - TimeSpan *result; + TimeSpan *result; if (!PointerIsValid(timespan)) return NULL; @@ -959,13 +959,13 @@ timespan_um(TimeSpan * timespan) } /* timespan_um() */ -TimeSpan * +TimeSpan * timespan_smaller(TimeSpan * timespan1, TimeSpan * timespan2) { - TimeSpan *result; + TimeSpan *result; - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return NULL; @@ -1014,13 +1014,13 @@ timespan_smaller(TimeSpan * timespan1, TimeSpan * timespan2) return (result); } /* timespan_smaller() */ -TimeSpan * +TimeSpan * timespan_larger(TimeSpan * timespan1, TimeSpan * timespan2) { - TimeSpan *result; + TimeSpan *result; - double span1, - span2; + double span1, + span2; if (!PointerIsValid(timespan1) || !PointerIsValid(timespan2)) return NULL; @@ -1070,10 +1070,10 @@ timespan_larger(TimeSpan * timespan1, TimeSpan * timespan2) } /* timespan_larger() */ -TimeSpan * +TimeSpan * timespan_pl(TimeSpan * span1, TimeSpan * span2) { - TimeSpan *result; + TimeSpan *result; if ((!PointerIsValid(span1)) || (!PointerIsValid(span2))) return NULL; @@ -1086,10 +1086,10 @@ timespan_pl(TimeSpan * span1, TimeSpan * span2) return (result); } /* timespan_pl() */ -TimeSpan * +TimeSpan * timespan_mi(TimeSpan * span1, TimeSpan * span2) { - TimeSpan *result; + TimeSpan *result; if ((!PointerIsValid(span1)) || (!PointerIsValid(span2))) return NULL; @@ -1102,10 +1102,10 @@ timespan_mi(TimeSpan * span1, TimeSpan * span2) return (result); } /* timespan_mi() */ -TimeSpan * +TimeSpan * timespan_div(TimeSpan * span1, float8 * arg2) { - TimeSpan *result; + TimeSpan *result; if ((!PointerIsValid(span1)) || (!PointerIsValid(arg2))) return NULL; @@ -1128,22 +1128,22 @@ timespan_div(TimeSpan * span1, float8 * arg2) * since year and month are out of context once the arithmetic * is done. */ -TimeSpan * +TimeSpan * datetime_age(DateTime * datetime1, DateTime * datetime2) { - TimeSpan *result; - - DateTime dt1, - dt2; - double fsec, - fsec1, - fsec2; - struct tm tt, - *tm = &tt; - struct tm tt1, - *tm1 = &tt1; - struct tm tt2, - *tm2 = &tt2; + TimeSpan *result; + + DateTime dt1, + dt2; + double fsec, + fsec1, + fsec2; + struct tm tt, + *tm = &tt; + struct tm tt1, + *tm1 = &tt1; + struct tm tt2, + *tm2 = &tt2; if (!PointerIsValid(datetime1) || !PointerIsValid(datetime2)) return NULL; @@ -1275,12 +1275,12 @@ datetime_age(DateTime * datetime1, DateTime * datetime2) /* datetime_text() * Convert datetime to text data type. */ -text * +text * datetime_text(DateTime * datetime) { - text *result; - char *str; - int len; + text *result; + char *str; + int len; if (!PointerIsValid(datetime)) return NULL; @@ -1308,14 +1308,14 @@ datetime_text(DateTime * datetime) * Text type is not null terminated, so use temporary string * then call the standard input routine. */ -DateTime * +DateTime * text_datetime(text * str) { - DateTime *result; - int i; - char *sp, - *dp, - dstr[MAXDATELEN + 1]; + DateTime *result; + int i; + char *sp, + *dp, + dstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) return NULL; @@ -1335,12 +1335,12 @@ text_datetime(text * str) /* timespan_text() * Convert timespan to text data type. */ -text * +text * timespan_text(TimeSpan * timespan) { - text *result; - char *str; - int len; + text *result; + char *str; + int len; if (!PointerIsValid(timespan)) return NULL; @@ -1369,14 +1369,14 @@ timespan_text(TimeSpan * timespan) * then call the standard input routine. */ #ifdef NOT_USED -TimeSpan * +TimeSpan * text_timespan(text * str) { - TimeSpan *result; - int i; - char *sp, - *dp, - dstr[MAXDATELEN + 1]; + TimeSpan *result; + int i; + char *sp, + *dp, + dstr[MAXDATELEN + 1]; if (!PointerIsValid(str)) return NULL; @@ -1397,23 +1397,23 @@ text_timespan(text * str) /* datetime_trunc() * Extract specified field from datetime. */ -DateTime * +DateTime * datetime_trunc(text * units, DateTime * datetime) { - DateTime *result; - - DateTime dt; - int tz; - int type, - val; - int i; - char *up, - *lp, - lowunits[MAXDATELEN + 1]; - double fsec; - char *tzn; - struct tm tt, - *tm = &tt; + DateTime *result; + + DateTime dt; + int tz; + int type, + val; + int i; + char *up, + *lp, + lowunits[MAXDATELEN + 1]; + double fsec; + char *tzn; + struct tm tt, + *tm = &tt; if ((!PointerIsValid(units)) || (!PointerIsValid(datetime))) return NULL; @@ -1457,39 +1457,39 @@ datetime_trunc(text * units, DateTime * datetime) { switch (val) { - case DTK_MILLENIUM: - tm->tm_year = (tm->tm_year / 1000) * 1000; - case DTK_CENTURY: - tm->tm_year = (tm->tm_year / 100) * 100; - case DTK_DECADE: - tm->tm_year = (tm->tm_year / 10) * 10; - case DTK_YEAR: - tm->tm_mon = 1; - case DTK_QUARTER: - tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1; - case DTK_MONTH: - tm->tm_mday = 1; - case DTK_DAY: - tm->tm_hour = 0; - case DTK_HOUR: - tm->tm_min = 0; - case DTK_MINUTE: - tm->tm_sec = 0; - case DTK_SECOND: - fsec = 0; - break; + case DTK_MILLENIUM: + tm->tm_year = (tm->tm_year / 1000) * 1000; + case DTK_CENTURY: + tm->tm_year = (tm->tm_year / 100) * 100; + case DTK_DECADE: + tm->tm_year = (tm->tm_year / 10) * 10; + case DTK_YEAR: + tm->tm_mon = 1; + case DTK_QUARTER: + tm->tm_mon = (3 * (tm->tm_mon / 4)) + 1; + case DTK_MONTH: + tm->tm_mday = 1; + case DTK_DAY: + tm->tm_hour = 0; + case DTK_HOUR: + tm->tm_min = 0; + case DTK_MINUTE: + tm->tm_sec = 0; + case DTK_SECOND: + fsec = 0; + break; - case DTK_MILLISEC: - fsec = rint(fsec * 1000) / 1000; - break; + case DTK_MILLISEC: + fsec = rint(fsec * 1000) / 1000; + break; - case DTK_MICROSEC: - fsec = rint(fsec * 1000) / 1000; - break; + case DTK_MICROSEC: + fsec = rint(fsec * 1000) / 1000; + break; - default: - elog(WARN, "Datetime units %s not supported", lowunits); - result = NULL; + default: + elog(WARN, "Datetime units %s not supported", lowunits); + result = NULL; } if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday)) @@ -1545,20 +1545,20 @@ datetime_trunc(text * units, DateTime * datetime) /* timespan_trunc() * Extract specified field from timespan. */ -TimeSpan * +TimeSpan * timespan_trunc(text * units, TimeSpan * timespan) { - TimeSpan *result; - - int type, - val; - int i; - char *up, - *lp, - lowunits[MAXDATELEN + 1]; - double fsec; - struct tm tt, - *tm = &tt; + TimeSpan *result; + + int type, + val; + int i; + char *up, + *lp, + lowunits[MAXDATELEN + 1]; + double fsec; + struct tm tt, + *tm = &tt; if ((!PointerIsValid(units)) || (!PointerIsValid(timespan))) return NULL; @@ -1600,39 +1600,39 @@ timespan_trunc(text * units, TimeSpan * timespan) { switch (val) { - case DTK_MILLENIUM: - tm->tm_year = (tm->tm_year / 1000) * 1000; - case DTK_CENTURY: - tm->tm_year = (tm->tm_year / 100) * 100; - case DTK_DECADE: - tm->tm_year = (tm->tm_year / 10) * 10; - case DTK_YEAR: - tm->tm_mon = 0; - case DTK_QUARTER: - tm->tm_mon = (3 * (tm->tm_mon / 4)); - case DTK_MONTH: - tm->tm_mday = 0; - case DTK_DAY: - tm->tm_hour = 0; - case DTK_HOUR: - tm->tm_min = 0; - case DTK_MINUTE: - tm->tm_sec = 0; - case DTK_SECOND: - fsec = 0; - break; + case DTK_MILLENIUM: + tm->tm_year = (tm->tm_year / 1000) * 1000; + case DTK_CENTURY: + tm->tm_year = (tm->tm_year / 100) * 100; + case DTK_DECADE: + tm->tm_year = (tm->tm_year / 10) * 10; + case DTK_YEAR: + tm->tm_mon = 0; + case DTK_QUARTER: + tm->tm_mon = (3 * (tm->tm_mon / 4)); + case DTK_MONTH: + tm->tm_mday = 0; + case DTK_DAY: + tm->tm_hour = 0; + case DTK_HOUR: + tm->tm_min = 0; + case DTK_MINUTE: + tm->tm_sec = 0; + case DTK_SECOND: + fsec = 0; + break; - case DTK_MILLISEC: - fsec = rint(fsec * 1000) / 1000; - break; + case DTK_MILLISEC: + fsec = rint(fsec * 1000) / 1000; + break; - case DTK_MICROSEC: - fsec = rint(fsec * 1000) / 1000; - break; + case DTK_MICROSEC: + fsec = rint(fsec * 1000) / 1000; + break; - default: - elog(WARN, "Timespan units %s not supported", lowunits); - result = NULL; + default: + elog(WARN, "Timespan units %s not supported", lowunits); + result = NULL; } if (tm2timespan(tm, fsec, result) != 0) @@ -1674,20 +1674,20 @@ timespan_trunc(text * units, TimeSpan * timespan) float64 datetime_part(text * units, DateTime * datetime) { - float64 result; - - DateTime dt; - int tz; - int type, - val; - int i; - char *up, - *lp, - lowunits[MAXDATELEN + 1]; - double fsec; - char *tzn; - struct tm tt, - *tm = &tt; + float64 result; + + DateTime dt; + int tz; + int type, + val; + int i; + char *up, + *lp, + lowunits[MAXDATELEN + 1]; + double fsec; + char *tzn; + struct tm tt, + *tm = &tt; if ((!PointerIsValid(units)) || (!PointerIsValid(datetime))) return NULL; @@ -1729,61 +1729,61 @@ datetime_part(text * units, DateTime * datetime) { switch (val) { - case DTK_TZ: - *result = tz; - break; + case DTK_TZ: + *result = tz; + break; - case DTK_MICROSEC: - *result = (fsec * 1000000); - break; + case DTK_MICROSEC: + *result = (fsec * 1000000); + break; - case DTK_MILLISEC: - *result = (fsec * 1000); - break; + case DTK_MILLISEC: + *result = (fsec * 1000); + break; - case DTK_SECOND: - *result = (tm->tm_sec + fsec); - break; + case DTK_SECOND: + *result = (tm->tm_sec + fsec); + break; - case DTK_MINUTE: - *result = tm->tm_min; - break; + case DTK_MINUTE: + *result = tm->tm_min; + break; - case DTK_HOUR: - *result = tm->tm_hour; - break; + case DTK_HOUR: + *result = tm->tm_hour; + break; - case DTK_DAY: - *result = tm->tm_mday; - break; + case DTK_DAY: + *result = tm->tm_mday; + break; - case DTK_MONTH: - *result = tm->tm_mon; - break; + case DTK_MONTH: + *result = tm->tm_mon; + break; - case DTK_QUARTER: - *result = (tm->tm_mon / 4) + 1; - break; + case DTK_QUARTER: + *result = (tm->tm_mon / 4) + 1; + break; - case DTK_YEAR: - *result = tm->tm_year; - break; + case DTK_YEAR: + *result = tm->tm_year; + break; - case DTK_DECADE: - *result = (tm->tm_year / 10) + 1; - break; + case DTK_DECADE: + *result = (tm->tm_year / 10) + 1; + break; - case DTK_CENTURY: - *result = (tm->tm_year / 100) + 1; - break; + case DTK_CENTURY: + *result = (tm->tm_year / 100) + 1; + break; - case DTK_MILLENIUM: - *result = (tm->tm_year / 1000) + 1; - break; + case DTK_MILLENIUM: + *result = (tm->tm_year / 1000) + 1; + break; - default: - elog(WARN, "Datetime units %s not supported", lowunits); - *result = 0; + default: + elog(WARN, "Datetime units %s not supported", lowunits); + *result = 0; } } @@ -1791,21 +1791,21 @@ datetime_part(text * units, DateTime * datetime) { switch (val) { - case DTK_EPOCH: - DATETIME_EPOCH(*result); - *result = dt - SetDateTime(*result); - break; + case DTK_EPOCH: + DATETIME_EPOCH(*result); + *result = dt - SetDateTime(*result); + break; - case DTK_DOW: - if (datetime2tm(dt, &tz, tm, &fsec, &tzn) != 0) - elog(WARN, "Unable to encode datetime", NULL); + case DTK_DOW: + if (datetime2tm(dt, &tz, tm, &fsec, &tzn) != 0) + elog(WARN, "Unable to encode datetime", NULL); - *result = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); - break; + *result = j2day(date2j(tm->tm_year, tm->tm_mon, tm->tm_mday)); + break; - default: - elog(WARN, "Datetime units %s not supported", lowunits); - *result = 0; + default: + elog(WARN, "Datetime units %s not supported", lowunits); + *result = 0; } } @@ -1826,17 +1826,17 @@ datetime_part(text * units, DateTime * datetime) float64 timespan_part(text * units, TimeSpan * timespan) { - float64 result; - - int type, - val; - int i; - char *up, - *lp, - lowunits[MAXDATELEN + 1]; - double fsec; - struct tm tt, - *tm = &tt; + float64 result; + + int type, + val; + int i; + char *up, + *lp, + lowunits[MAXDATELEN + 1]; + double fsec; + struct tm tt, + *tm = &tt; if ((!PointerIsValid(units)) || (!PointerIsValid(timespan))) return NULL; @@ -1876,57 +1876,57 @@ timespan_part(text * units, TimeSpan * timespan) { switch (val) { - case DTK_MICROSEC: - *result = (fsec * 1000000); - break; + case DTK_MICROSEC: + *result = (fsec * 1000000); + break; - case DTK_MILLISEC: - *result = (fsec * 1000); - break; + case DTK_MILLISEC: + *result = (fsec * 1000); + break; - case DTK_SECOND: - *result = (tm->tm_sec + fsec); - break; + case DTK_SECOND: + *result = (tm->tm_sec + fsec); + break; - case DTK_MINUTE: - *result = tm->tm_min; - break; + case DTK_MINUTE: + *result = tm->tm_min; + break; - case DTK_HOUR: - *result = tm->tm_hour; - break; + case DTK_HOUR: + *result = tm->tm_hour; + break; - case DTK_DAY: - *result = tm->tm_mday; - break; + case DTK_DAY: + *result = tm->tm_mday; + break; - case DTK_MONTH: - *result = tm->tm_mon; - break; + case DTK_MONTH: + *result = tm->tm_mon; + break; - case DTK_QUARTER: - *result = (tm->tm_mon / 4) + 1; - break; + case DTK_QUARTER: + *result = (tm->tm_mon / 4) + 1; + break; - case DTK_YEAR: - *result = tm->tm_year; - break; + case DTK_YEAR: + *result = tm->tm_year; + break; - case DTK_DECADE: - *result = (tm->tm_year / 10) + 1; - break; + case DTK_DECADE: + *result = (tm->tm_year / 10) + 1; + break; - case DTK_CENTURY: - *result = (tm->tm_year / 100) + 1; - break; + case DTK_CENTURY: + *result = (tm->tm_year / 100) + 1; + break; - case DTK_MILLENIUM: - *result = (tm->tm_year / 1000) + 1; - break; + case DTK_MILLENIUM: + *result = (tm->tm_year / 1000) + 1; + break; - default: - elog(WARN, "Timespan units %s not yet supported", units); - result = NULL; + default: + elog(WARN, "Timespan units %s not yet supported", units); + result = NULL; } } @@ -1960,26 +1960,26 @@ timespan_part(text * units, TimeSpan * timespan) /* datetime_zone() * Encode datetime type with specified time zone. */ -text * +text * datetime_zone(text * zone, DateTime * datetime) { - text *result; - - DateTime dt; - int tz; - int type, - val; - int i; - char *up, - *lp, - lowzone[MAXDATELEN + 1]; - char *tzn, - upzone[MAXDATELEN + 1]; - double fsec; - struct tm tt, - *tm = &tt; - char buf[MAXDATELEN + 1]; - int len; + text *result; + + DateTime dt; + int tz; + int type, + val; + int i; + char *up, + *lp, + lowzone[MAXDATELEN + 1]; + char *tzn, + upzone[MAXDATELEN + 1]; + double fsec; + struct tm tt, + *tm = &tt; + char buf[MAXDATELEN + 1]; + int len; if ((!PointerIsValid(zone)) || (!PointerIsValid(datetime))) return NULL; @@ -2064,7 +2064,7 @@ datetime_zone(text * zone, DateTime * datetime) * entries by 10 and truncate the text field at MAXTOKLEN characters. * the text field is not guaranteed to be NULL-terminated. */ -static datetkn datetktbl[] = { +static datetkn datetktbl[] = { /* text token lexval */ {EARLY, RESERV, DTK_EARLY}, /* "-infinity" reserved for "early time" */ {"acsst", DTZ, 63}, /* Cent. Australia */ @@ -2218,7 +2218,7 @@ static datetkn datetktbl[] = { static unsigned int szdatetktbl = sizeof datetktbl / sizeof datetktbl[0]; -static datetkn deltatktbl[] = { +static datetkn deltatktbl[] = { /* text token lexval */ {"@", IGNORE, 0}, /* postgres relative time prefix */ {DAGO, AGO, 0}, /* "ago" indicates negative time offset */ @@ -2302,9 +2302,9 @@ static datetkn deltatktbl[] = { static unsigned int szdeltatktbl = sizeof deltatktbl / sizeof deltatktbl[0]; #if USE_DATE_CACHE -datetkn *datecache[MAXDATEFIELDS] = {NULL}; +datetkn *datecache[MAXDATEFIELDS] = {NULL}; -datetkn *deltacache[MAXDATEFIELDS] = {NULL}; +datetkn *deltacache[MAXDATEFIELDS] = {NULL}; #endif @@ -2341,7 +2341,7 @@ datetkn *deltacache[MAXDATEFIELDS] = {NULL}; int date2j(int y, int m, int d) { - int m12 = (m - 14) / 12; + int m12 = (m - 14) / 12; return ((1461 * (y + 4800 + m12)) / 4 + (367 * (m - 2 - 12 * (m12))) / 12 - (3 * ((y + 4900 + m12) / 100)) / 4 + d - 32075); @@ -2350,14 +2350,14 @@ date2j(int y, int m, int d) void j2date(int jd, int *year, int *month, int *day) { - int j, - y, - m, - d; + int j, + y, + m, + d; - int i, - l, - n; + int i, + l, + n; l = jd + 68569; n = (4 * l) / 146097; @@ -2379,7 +2379,7 @@ j2date(int jd, int *year, int *month, int *day) static int j2day(int date) { - int day; + int day; day = (date + 1) % 7; @@ -2401,14 +2401,14 @@ j2day(int date) int datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn) { - double date, - date0, - time, - sec; - time_t utime; + double date, + date0, + time, + sec; + time_t utime; #ifdef USE_POSIX_TIME - struct tm *tx; + struct tm *tx; #endif @@ -2556,8 +2556,8 @@ int tm2datetime(struct tm * tm, double fsec, int *tzp, DateTime * result) { - double date, - time; + double date, + time; /* Julian day routines are not correct for negative Julian days */ if (!IS_VALID_JULIAN(tm->tm_year, tm->tm_mon, tm->tm_mday)) @@ -2583,7 +2583,7 @@ tm2datetime(struct tm * tm, double fsec, int *tzp, DateTime * result) static int timespan2tm(TimeSpan span, struct tm * tm, float8 * fsec) { - double time; + double time; if (span.month != 0) { @@ -2633,7 +2633,7 @@ tm2timespan(struct tm * tm, double fsec, TimeSpan * span) } /* tm2timespan() */ -static DateTime +static DateTime dt2local(DateTime dt, int tz) { dt -= tz; @@ -2650,7 +2650,7 @@ time2t(const int hour, const int min, const double sec) static void dt2time(DateTime jd, int *hour, int *min, double *sec) { - double time; + double time; time = jd; @@ -2677,9 +2677,9 @@ int ParseDateTime(char *timestr, char *lowstr, char *field[], int ftype[], int maxfields, int *numfields) { - int nf = 0; - char *cp = timestr; - char *lp = lowstr; + int nf = 0; + char *cp = timestr; + char *lp = lowstr; #ifdef DATEDEBUG printf("ParseDateTime- input string is %s\n", timestr); @@ -2833,14 +2833,14 @@ int DecodeDateTime(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, double *fsec, int *tzp) { - int fmask = 0, - tmask, - type; - int i; - int flen, - val; - int mer = HR24; - int bc = FALSE; + int fmask = 0, + tmask, + type; + int i; + int flen, + val; + int mer = HR24; + int bc = FALSE; *dtype = DTK_DATE; tm->tm_hour = 0; @@ -2859,181 +2859,181 @@ DecodeDateTime(char *field[], int ftype[], int nf, #endif switch (ftype[i]) { - case DTK_DATE: - if (DecodeDate(field[i], fmask, &tmask, tm) != 0) - return -1; - break; - - case DTK_TIME: - if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) - return -1; - - /* - * check upper limit on hours; other limits checked in - * DecodeTime() - */ - if (tm->tm_hour > 23) - return -1; - break; - - case DTK_TZ: - if (tzp == NULL) - return -1; - if (DecodeTimezone(field[i], tzp) != 0) - return -1; - tmask = DTK_M(TZ); - break; - - case DTK_NUMBER: - flen = strlen(field[i]); - - if (flen > 4) - { - if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0) - return -1; - - } - else - { - if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec) != 0) + case DTK_DATE: + if (DecodeDate(field[i], fmask, &tmask, tm) != 0) return -1; - } - break; - - case DTK_STRING: - case DTK_SPECIAL: - type = DecodeSpecial(i, field[i], &val); -#ifdef DATEDEBUG - printf("DecodeDateTime- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); -#endif - if (type == IGNORE) - continue; - - tmask = DTK_M(type); - switch (type) - { - case RESERV: -#ifdef DATEDEBUG - printf("DecodeDateTime- RESERV field %s value is %d\n", field[i], val); -#endif - switch (val) - { - case DTK_NOW: - tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ)); - *dtype = DTK_DATE; - GetCurrentTime(tm); - if (tzp != NULL) - *tzp = CTimeZone; - break; - - case DTK_YESTERDAY: - tmask = DTK_DATE_M; - *dtype = DTK_DATE; - GetCurrentTime(tm); - j2date((date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - 1), - &tm->tm_year, &tm->tm_mon, &tm->tm_mday); - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - break; - - case DTK_TODAY: - tmask = DTK_DATE_M; - *dtype = DTK_DATE; - GetCurrentTime(tm); - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - break; - - case DTK_TOMORROW: - tmask = DTK_DATE_M; - *dtype = DTK_DATE; - GetCurrentTime(tm); - j2date((date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1), - &tm->tm_year, &tm->tm_mon, &tm->tm_mday); - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - break; - - case DTK_ZULU: - tmask = (DTK_TIME_M | DTK_M(TZ)); - *dtype = DTK_DATE; - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - if (tzp != NULL) - *tzp = 0; - break; - - default: - *dtype = val; - } - - break; - - case MONTH: -#ifdef DATEDEBUG - printf("DecodeDateTime- month field %s value is %d\n", field[i], val); -#endif - tm->tm_mon = val; break; - /* - * daylight savings time modifier (solves "MET DST" - * syntax) - */ - case DTZMOD: - tmask |= DTK_M(DTZ); - tm->tm_isdst = 1; - if (tzp == NULL) + case DTK_TIME: + if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) return -1; - *tzp += val * 60; - break; - - case DTZ: /* - * set mask for TZ here _or_ check for DTZ later when - * getting default timezone + * check upper limit on hours; other limits checked in + * DecodeTime() */ - tmask |= DTK_M(TZ); - tm->tm_isdst = 1; - if (tzp == NULL) + if (tm->tm_hour > 23) return -1; - *tzp = val * 60; break; - case TZ: - tm->tm_isdst = 0; + case DTK_TZ: if (tzp == NULL) return -1; - *tzp = val * 60; + if (DecodeTimezone(field[i], tzp) != 0) + return -1; + tmask = DTK_M(TZ); break; - case IGNORE: - break; + case DTK_NUMBER: + flen = strlen(field[i]); - case AMPM: - mer = val; - break; + if (flen > 4) + { + if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0) + return -1; - case ADBC: - bc = (val == BC); + } + else + { + if (DecodeNumber(flen, field[i], fmask, &tmask, tm, fsec) != 0) + return -1; + } break; - case DOW: - tm->tm_wday = val; + case DTK_STRING: + case DTK_SPECIAL: + type = DecodeSpecial(i, field[i], &val); +#ifdef DATEDEBUG + printf("DecodeDateTime- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); +#endif + if (type == IGNORE) + continue; + + tmask = DTK_M(type); + switch (type) + { + case RESERV: +#ifdef DATEDEBUG + printf("DecodeDateTime- RESERV field %s value is %d\n", field[i], val); +#endif + switch (val) + { + case DTK_NOW: + tmask = (DTK_DATE_M | DTK_TIME_M | DTK_M(TZ)); + *dtype = DTK_DATE; + GetCurrentTime(tm); + if (tzp != NULL) + *tzp = CTimeZone; + break; + + case DTK_YESTERDAY: + tmask = DTK_DATE_M; + *dtype = DTK_DATE; + GetCurrentTime(tm); + j2date((date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) - 1), + &tm->tm_year, &tm->tm_mon, &tm->tm_mday); + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + break; + + case DTK_TODAY: + tmask = DTK_DATE_M; + *dtype = DTK_DATE; + GetCurrentTime(tm); + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + break; + + case DTK_TOMORROW: + tmask = DTK_DATE_M; + *dtype = DTK_DATE; + GetCurrentTime(tm); + j2date((date2j(tm->tm_year, tm->tm_mon, tm->tm_mday) + 1), + &tm->tm_year, &tm->tm_mon, &tm->tm_mday); + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + break; + + case DTK_ZULU: + tmask = (DTK_TIME_M | DTK_M(TZ)); + *dtype = DTK_DATE; + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + if (tzp != NULL) + *tzp = 0; + break; + + default: + *dtype = val; + } + + break; + + case MONTH: +#ifdef DATEDEBUG + printf("DecodeDateTime- month field %s value is %d\n", field[i], val); +#endif + tm->tm_mon = val; + break; + + /* + * daylight savings time modifier (solves "MET + * DST" syntax) + */ + case DTZMOD: + tmask |= DTK_M(DTZ); + tm->tm_isdst = 1; + if (tzp == NULL) + return -1; + *tzp += val * 60; + break; + + case DTZ: + + /* + * set mask for TZ here _or_ check for DTZ later + * when getting default timezone + */ + tmask |= DTK_M(TZ); + tm->tm_isdst = 1; + if (tzp == NULL) + return -1; + *tzp = val * 60; + break; + + case TZ: + tm->tm_isdst = 0; + if (tzp == NULL) + return -1; + *tzp = val * 60; + break; + + case IGNORE: + break; + + case AMPM: + mer = val; + break; + + case ADBC: + bc = (val == BC); + break; + + case DOW: + tm->tm_wday = val; + break; + + default: + return -1; + } break; default: return -1; - } - break; - - default: - return -1; } #ifdef DATEDEBUG @@ -3114,13 +3114,13 @@ DecodeDateTime(char *field[], int ftype[], int nf, int DecodeTimeOnly(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, double *fsec) { - int fmask, - tmask, - type; - int i; - int flen, - val; - int mer = HR24; + int fmask, + tmask, + type; + int i; + int flen, + val; + int mer = HR24; *dtype = DTK_TIME; tm->tm_hour = 0; @@ -3138,71 +3138,71 @@ DecodeTimeOnly(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, d #endif switch (ftype[i]) { - case DTK_TIME: - if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) - return -1; - break; + case DTK_TIME: + if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) + return -1; + break; - case DTK_NUMBER: - flen = strlen(field[i]); + case DTK_NUMBER: + flen = strlen(field[i]); - if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0) - return -1; - break; + if (DecodeNumberField(flen, field[i], fmask, &tmask, tm, fsec) != 0) + return -1; + break; - case DTK_STRING: - case DTK_SPECIAL: - type = DecodeSpecial(i, field[i], &val); + case DTK_STRING: + case DTK_SPECIAL: + type = DecodeSpecial(i, field[i], &val); #ifdef DATEDEBUG - printf("DecodeTimeOnly- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); + printf("DecodeTimeOnly- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); #endif - if (type == IGNORE) - continue; + if (type == IGNORE) + continue; - tmask = DTK_M(type); - switch (type) - { - case RESERV: + tmask = DTK_M(type); + switch (type) + { + case RESERV: #ifdef DATEDEBUG - printf("DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val); + printf("DecodeTimeOnly- RESERV field %s value is %d\n", field[i], val); #endif - switch (val) - { - case DTK_NOW: - tmask = DTK_TIME_M; - *dtype = DTK_TIME; - GetCurrentTime(tm); - break; - - case DTK_ZULU: - tmask = (DTK_TIME_M | DTK_M(TZ)); - *dtype = DTK_TIME; - tm->tm_hour = 0; - tm->tm_min = 0; - tm->tm_sec = 0; - tm->tm_isdst = 0; - break; - - default: - return -1; + switch (val) + { + case DTK_NOW: + tmask = DTK_TIME_M; + *dtype = DTK_TIME; + GetCurrentTime(tm); + break; + + case DTK_ZULU: + tmask = (DTK_TIME_M | DTK_M(TZ)); + *dtype = DTK_TIME; + tm->tm_hour = 0; + tm->tm_min = 0; + tm->tm_sec = 0; + tm->tm_isdst = 0; + break; + + default: + return -1; + } + + break; + + case IGNORE: + break; + + case AMPM: + mer = val; + break; + + default: + return -1; } - - break; - - case IGNORE: - break; - - case AMPM: - mer = val; break; default: return -1; - } - break; - - default: - return -1; } if (tmask & fmask) @@ -3238,15 +3238,15 @@ DecodeTimeOnly(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, d static int DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) { - double fsec; + double fsec; - int nf = 0; - int i, - len; - int type, - val, - dmask = 0; - char *field[MAXDATEFIELDS]; + int nf = 0; + int i, + len; + int type, + val, + dmask = 0; + char *field[MAXDATEFIELDS]; /* parse this string... */ while ((*str != '\0') && (nf < MAXDATEFIELDS)) @@ -3290,18 +3290,18 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) dmask = DTK_M(type); switch (type) { - case MONTH: + case MONTH: #ifdef DATEDEBUG - printf("DecodeDate- month field %s value is %d\n", field[i], val); + printf("DecodeDate- month field %s value is %d\n", field[i], val); #endif - tm->tm_mon = val; - break; + tm->tm_mon = val; + break; - default: + default: #ifdef DATEDEBUG - printf("DecodeDate- illegal field %s value is %d\n", field[i], val); + printf("DecodeDate- illegal field %s value is %d\n", field[i], val); #endif - return -1; + return -1; } if (fmask & dmask) return -1; @@ -3345,7 +3345,7 @@ DecodeDate(char *str, int fmask, int *tmask, struct tm * tm) static int DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec) { - char *cp; + char *cp; *tmask = DTK_TIME_M; @@ -3402,8 +3402,8 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, double *fsec) static int DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double *fsec) { - int val; - char *cp; + int val; + char *cp; *tmask = 0; @@ -3531,7 +3531,7 @@ DecodeNumber(int flen, char *str, int fmask, int *tmask, struct tm * tm, double static int DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, double *fsec) { - char *cp; + char *cp; /* yyyymmdd? */ if (len == 8) @@ -3616,11 +3616,11 @@ DecodeNumberField(int len, char *str, int fmask, int *tmask, struct tm * tm, dou static int DecodeTimezone(char *str, int *tzp) { - int tz; - int hr, - min; - char *cp; - int len; + int tz; + int hr, + min; + char *cp; + int len; /* assume leading character is "+" or "-" */ hr = strtol((str + 1), &cp, 10); @@ -3661,8 +3661,8 @@ DecodeTimezone(char *str, int *tzp) static int DecodeSpecial(int field, char *lowtoken, int *val) { - int type; - datetkn *tp; + int type; + datetkn *tp; #if USE_DATE_CACHE if ((datecache[field] != NULL) @@ -3688,15 +3688,15 @@ DecodeSpecial(int field, char *lowtoken, int *val) type = tp->type; switch (type) { - case TZ: - case DTZ: - case DTZMOD: - *val = FROMVAL(tp); - break; + case TZ: + case DTZ: + case DTZMOD: + *val = FROMVAL(tp); + break; - default: - *val = tp->value; - break; + default: + *val = tp->value; + break; } } @@ -3715,22 +3715,22 @@ DecodeSpecial(int field, char *lowtoken, int *val) int DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, double *fsec) { - int is_before = FALSE; + int is_before = FALSE; #if READ_FORWARD - int is_neg = FALSE; + int is_neg = FALSE; #endif - int fmask = 0, - tmask, - type; - int i, - ii; - int flen, - val; - char *cp; - double sec; + int fmask = 0, + tmask, + type; + int i, + ii; + int flen, + val; + char *cp; + double sec; *dtype = DTK_DELTA; @@ -3773,137 +3773,137 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, #endif switch (ftype[i]) { - case DTK_TIME: - /* already read in forward-scan above so return error */ + case DTK_TIME: + /* already read in forward-scan above so return error */ #if FALSE - if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) - return -1; + if (DecodeTime(field[i], fmask, &tmask, tm, fsec) != 0) + return -1; #endif - return -1; - break; + return -1; + break; - case DTK_TZ: /* timezone is a token with a leading sign + case DTK_TZ: /* timezone is a token with a leading sign * character */ #if READ_FORWARD - is_neg = (*field[i] == '-'); + is_neg = (*field[i] == '-'); #endif - case DTK_NUMBER: - val = strtol(field[i], &cp, 10); + case DTK_NUMBER: + val = strtol(field[i], &cp, 10); #if READ_FORWARD - if (is_neg && (val > 0)) - val = -val; + if (is_neg && (val > 0)) + val = -val; #endif - if (*cp == '.') - { - *fsec = strtod(cp, NULL); - if (val < 0) - *fsec = -(*fsec); - } - flen = strlen(field[i]); - tmask = 0; /* DTK_M(type); */ - - switch (type) - { - case DTK_MICROSEC: - *fsec += (val * 1e-6); - break; - - case DTK_MILLISEC: - *fsec += (val * 1e-3); - break; - - case DTK_SECOND: - tm->tm_sec += val; - tmask = DTK_M(SECOND); - break; - - case DTK_MINUTE: - tm->tm_min += val; - tmask = DTK_M(MINUTE); - break; - - case DTK_HOUR: - tm->tm_hour += val; - tmask = DTK_M(HOUR); - break; - - case DTK_DAY: - tm->tm_mday += val; - tmask = ((fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY)); - break; - - case DTK_WEEK: - tm->tm_mday += val * 7; - tmask = ((fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY)); - break; - - case DTK_MONTH: - tm->tm_mon += val; - tmask = DTK_M(MONTH); - break; - - case DTK_YEAR: - tm->tm_year += val; - tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); - break; - - case DTK_DECADE: - tm->tm_year += val * 10; - tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); - break; - - case DTK_CENTURY: - tm->tm_year += val * 100; - tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); - break; + if (*cp == '.') + { + *fsec = strtod(cp, NULL); + if (val < 0) + *fsec = -(*fsec); + } + flen = strlen(field[i]); + tmask = 0; /* DTK_M(type); */ - case DTK_MILLENIUM: - tm->tm_year += val * 1000; - tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); + switch (type) + { + case DTK_MICROSEC: + *fsec += (val * 1e-6); + break; + + case DTK_MILLISEC: + *fsec += (val * 1e-3); + break; + + case DTK_SECOND: + tm->tm_sec += val; + tmask = DTK_M(SECOND); + break; + + case DTK_MINUTE: + tm->tm_min += val; + tmask = DTK_M(MINUTE); + break; + + case DTK_HOUR: + tm->tm_hour += val; + tmask = DTK_M(HOUR); + break; + + case DTK_DAY: + tm->tm_mday += val; + tmask = ((fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY)); + break; + + case DTK_WEEK: + tm->tm_mday += val * 7; + tmask = ((fmask & DTK_M(DAY)) ? 0 : DTK_M(DAY)); + break; + + case DTK_MONTH: + tm->tm_mon += val; + tmask = DTK_M(MONTH); + break; + + case DTK_YEAR: + tm->tm_year += val; + tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); + break; + + case DTK_DECADE: + tm->tm_year += val * 10; + tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); + break; + + case DTK_CENTURY: + tm->tm_year += val * 100; + tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); + break; + + case DTK_MILLENIUM: + tm->tm_year += val * 1000; + tmask = ((fmask & DTK_M(YEAR)) ? 0 : DTK_M(YEAR)); + break; + + default: + return -1; + } break; - default: - return -1; - } - break; - - case DTK_STRING: - case DTK_SPECIAL: - type = DecodeUnits(i, field[i], &val); + case DTK_STRING: + case DTK_SPECIAL: + type = DecodeUnits(i, field[i], &val); #ifdef DATEDEBUG - printf("DecodeDateDelta- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); + printf("DecodeDateDelta- special field[%d] %s type=%d value=%d\n", i, field[i], type, val); #endif - if (type == IGNORE) - continue; + if (type == IGNORE) + continue; - tmask = 0; /* DTK_M(type); */ - switch (type) - { - case UNITS: + tmask = 0; /* DTK_M(type); */ + switch (type) + { + case UNITS: #ifdef DATEDEBUG - printf("DecodeDateDelta- UNITS field %s value is %d\n", field[i], val); + printf("DecodeDateDelta- UNITS field %s value is %d\n", field[i], val); #endif - type = val; - break; + type = val; + break; - case AGO: - is_before = TRUE; - type = val; - break; + case AGO: + is_before = TRUE; + type = val; + break; + + case RESERV: + tmask = (DTK_DATE_M || DTK_TIME_M); + *dtype = val; + break; - case RESERV: - tmask = (DTK_DATE_M || DTK_TIME_M); - *dtype = val; + default: + return -1; + } break; default: return -1; - } - break; - - default: - return -1; } #ifdef DATEDEBUG @@ -3951,8 +3951,8 @@ DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, static int DecodeUnits(int field, char *lowtoken, int *val) { - int type; - datetkn *tp; + int type; + datetkn *tp; #if USE_DATE_CACHE if ((deltacache[field] != NULL) @@ -3998,8 +3998,8 @@ static datetkn * datebsearch(char *key, datetkn * base, unsigned int nel) { register datetkn *last = base + nel - 1, - *position; - register int result; + *position; + register int result; while (last >= base) { @@ -4074,7 +4074,7 @@ int EncodeDateOnly(struct tm * tm, int style, char *str) { #if FALSE - int day; + int day; #endif @@ -4186,7 +4186,7 @@ EncodeDateOnly(struct tm * tm, int style, char *str) int EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str) { - double sec; + double sec; if ((tm->tm_hour < 0) || (tm->tm_hour > 24)) return -1; @@ -4210,10 +4210,10 @@ EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str) int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str) { - int day, - hour, - min; - double sec; + int day, + hour, + min; + double sec; if ((tm->tm_mon < 1) || (tm->tm_mon > 12)) return -1; @@ -4372,9 +4372,9 @@ EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, cha int EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str) { - int is_before = FALSE; - int is_nonzero = FALSE; - char *cp; + int is_before = FALSE; + int is_nonzero = FALSE; + char *cp; strcpy(str, "@"); cp = str + strlen(str); @@ -4465,9 +4465,9 @@ datetime_is_epoch(double j) { static union { - double epoch; - unsigned char c[8]; - } u; + double epoch; + unsigned char c[8]; + } u; u.c[0] = 0x80; /* sign bit */ u.c[1] = 0x10; /* DBL_MIN */ @@ -4479,9 +4479,9 @@ datetime_is_current(double j) { static union { - double current; - unsigned char c[8]; - } u; + double current; + unsigned char c[8]; + } u; u.c[1] = 0x10; /* DBL_MIN */ diff --git a/src/backend/utils/adt/filename.c b/src/backend/utils/adt/filename.c index 445de98a77a..e8bfba41c96 100644 --- a/src/backend/utils/adt/filename.c +++ b/src/backend/utils/adt/filename.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.9 1997/09/07 04:50:14 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/filename.c,v 1.10 1997/09/08 02:30:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,11 +22,11 @@ #include <miscadmin.h> #include "utils/builtins.h" /* where function declarations go */ -char * +char * filename_in(char *file) { - char *str; - int ind = 0; + char *str; + int ind = 0; /* * XXX - HACK CITY --- REDO should let the shell do expansions @@ -41,8 +41,8 @@ filename_in(char *file) { /* Home directory */ - char *userName; - struct passwd *pw; + char *userName; + struct passwd *pw; userName = GetPgUserName(); @@ -59,10 +59,10 @@ filename_in(char *file) else { /* Someone else's directory */ - char name[16], - *p; - struct passwd *pw; - int len; + char name[16], + *p; + struct passwd *pw; + int len; if ((p = (char *) strchr(file, '/')) == NULL) { @@ -89,10 +89,10 @@ filename_in(char *file) } else if (file[0] == '$') { /* $POSTGRESHOME, etc. expand it. */ - char environment[80], - *envirp, - *p; - int len; + char environment[80], + *envirp, + *p; + int len; if ((p = (char *) strchr(file, '/')) == NULL) { @@ -123,10 +123,10 @@ filename_in(char *file) return (str); } -char * +char * filename_out(char *s) { - char *ret; + char *ret; if (!s) return ((char *) NULL); diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 32d78fb2ba7..03bd767dc65 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.18 1997/09/07 04:50:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.19 1997/09/08 02:30:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,36 +81,36 @@ /* NS3.3 has conflicting declarations of these in <math.h> */ #ifndef atof -extern double atof(const char *p); +extern double atof(const char *p); #endif #ifndef HAVE_CBRT #define cbrt my_cbrt -static double cbrt(double x); +static double cbrt(double x); #else #if !defined(nextstep) -extern double cbrt(double x); +extern double cbrt(double x); #endif #endif #ifndef HAVE_RINT #define rint my_rint -static double rint(double x); +static double rint(double x); #else -extern double rint(double x); +extern double rint(double x); #endif #ifndef HAVE_ISINF #define isinf my_isinf -static int isinf(double x); +static int isinf(double x); #else -extern int isinf(double x); +extern int isinf(double x); #endif @@ -203,9 +203,9 @@ CheckFloat8Val(double val) float32 float4in(char *num) { - float32 result = (float32) palloc(sizeof(float32data)); - double val; - char *endptr; + float32 result = (float32) palloc(sizeof(float32data)); + double val; + char *endptr; errno = 0; val = strtod(num, &endptr); @@ -227,10 +227,10 @@ float4in(char *num) * float4out - converts a float4 number to a string * using a standard output format */ -char * +char * float4out(float32 num) { - char *ascii = (char *) palloc(MAXFLOATWIDTH + 1); + char *ascii = (char *) palloc(MAXFLOATWIDTH + 1); if (!num) return strcpy(ascii, "(null)"); @@ -250,9 +250,9 @@ float4out(float32 num) float64 float8in(char *num) { - float64 result = (float64) palloc(sizeof(float64data)); - double val; - char *endptr; + float64 result = (float64) palloc(sizeof(float64data)); + double val; + char *endptr; errno = 0; val = strtod(num, &endptr); @@ -269,10 +269,10 @@ float8in(char *num) * float8out - converts float8 number to a string * using a standard output format */ -char * +char * float8out(float64 num) { - char *ascii = (char *) palloc(MAXDOUBLEWIDTH + 1); + char *ascii = (char *) palloc(MAXDOUBLEWIDTH + 1); if (!num) return strcpy(ascii, "(null)"); @@ -301,8 +301,8 @@ float8out(float64 num) float32 float4abs(float32 arg1) { - float32 result; - double val; + float32 result; + double val; if (!arg1) return (float32) NULL; @@ -322,8 +322,8 @@ float4abs(float32 arg1) float32 float4um(float32 arg1) { - float32 result; - double val; + float32 result; + double val; if (!arg1) return (float32) NULL; @@ -339,7 +339,7 @@ float4um(float32 arg1) float32 float4larger(float32 arg1, float32 arg2) { - float32 result; + float32 result; if (!arg1 || !arg2) return (float32) NULL; @@ -353,7 +353,7 @@ float4larger(float32 arg1, float32 arg2) float32 float4smaller(float32 arg1, float32 arg2) { - float32 result; + float32 result; if (!arg1 || !arg2) return (float32) NULL; @@ -376,8 +376,8 @@ float4smaller(float32 arg1, float32 arg2) float64 float8abs(float64 arg1) { - float64 result; - double val; + float64 result; + double val; if (!arg1) return (float64) NULL; @@ -397,8 +397,8 @@ float8abs(float64 arg1) float64 float8um(float64 arg1) { - float64 result; - double val; + float64 result; + double val; if (!arg1) return (float64) NULL; @@ -414,7 +414,7 @@ float8um(float64 arg1) float64 float8larger(float64 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -428,7 +428,7 @@ float8larger(float64 arg1, float64 arg2) float64 float8smaller(float64 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -456,8 +456,8 @@ float8smaller(float64 arg1, float64 arg2) float32 float4pl(float32 arg1, float32 arg2) { - float32 result; - double val; + float32 result; + double val; if (!arg1 || !arg2) return (float32) NULL; @@ -474,8 +474,8 @@ float4pl(float32 arg1, float32 arg2) float32 float4mi(float32 arg1, float32 arg2) { - float32 result; - double val; + float32 result; + double val; if (!arg1 || !arg2) return (float32) NULL; @@ -491,8 +491,8 @@ float4mi(float32 arg1, float32 arg2) float32 float4mul(float32 arg1, float32 arg2) { - float32 result; - double val; + float32 result; + double val; if (!arg1 || !arg2) return (float32) NULL; @@ -508,8 +508,8 @@ float4mul(float32 arg1, float32 arg2) float32 float4div(float32 arg1, float32 arg2) { - float32 result; - double val; + float32 result; + double val; if (!arg1 || !arg2) return (float32) NULL; @@ -528,7 +528,7 @@ float4div(float32 arg1, float32 arg2) float32 float4inc(float32 arg1) { - double val; + double val; if (!arg1) return (float32) NULL; @@ -549,8 +549,8 @@ float4inc(float32 arg1) float64 float8pl(float64 arg1, float64 arg2) { - float64 result; - double val; + float64 result; + double val; if (!arg1 || !arg2) return (float64) NULL; @@ -566,8 +566,8 @@ float8pl(float64 arg1, float64 arg2) float64 float8mi(float64 arg1, float64 arg2) { - float64 result; - double val; + float64 result; + double val; if (!arg1 || !arg2) return (float64) NULL; @@ -583,8 +583,8 @@ float8mi(float64 arg1, float64 arg2) float64 float8mul(float64 arg1, float64 arg2) { - float64 result; - double val; + float64 result; + double val; if (!arg1 || !arg2) return (float64) NULL; @@ -600,8 +600,8 @@ float8mul(float64 arg1, float64 arg2) float64 float8div(float64 arg1, float64 arg2) { - float64 result; - double val; + float64 result; + double val; if (!arg1 || !arg2) return (float64) NULL; @@ -620,7 +620,7 @@ float8div(float64 arg1, float64 arg2) float64 float8inc(float64 arg1) { - double val; + double val; if (!arg1) return (float64) NULL; @@ -765,7 +765,7 @@ float8ge(float64 arg1, float64 arg2) float64 ftod(float32 num) { - float64 result; + float64 result; if (!num) return (float64) NULL; @@ -783,7 +783,7 @@ ftod(float32 num) float32 dtof(float64 num) { - float32 result; + float32 result; if (!num) return (float32) NULL; @@ -803,7 +803,7 @@ dtof(float64 num) int32 dtoi4(float64 num) { - int32 result; + int32 result; if (!num) elog(WARN, "dtoi4: unable to convert null", NULL); @@ -822,7 +822,7 @@ dtoi4(float64 num) int16 dtoi2(float64 num) { - int16 result; + int16 result; if (!num) elog(WARN, "dtoi2: unable to convert null", NULL); @@ -841,7 +841,7 @@ dtoi2(float64 num) float64 i4tod(int32 num) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); @@ -856,7 +856,7 @@ i4tod(int32 num) float64 i2tod(int16 num) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); @@ -871,7 +871,7 @@ i2tod(int16 num) int32 ftoi4(float32 num) { - int32 result; + int32 result; if (!num) elog(WARN, "ftoi4: unable to convert null", NULL); @@ -890,7 +890,7 @@ ftoi4(float32 num) int16 ftoi2(float32 num) { - int16 result; + int16 result; if (!num) elog(WARN, "ftoi2: unable to convert null", NULL); @@ -909,7 +909,7 @@ ftoi2(float32 num) float32 i4tof(int32 num) { - float32 result; + float32 result; result = (float32) palloc(sizeof(float32data)); @@ -924,7 +924,7 @@ i4tof(int32 num) float32 i2tof(int16 num) { - float32 result; + float32 result; result = (float32) palloc(sizeof(float32data)); @@ -945,8 +945,8 @@ i2tof(int16 num) float64 dround(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -969,8 +969,8 @@ dround(float64 arg1) float64 dtrunc(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -992,8 +992,8 @@ dtrunc(float64 arg1) float64 dsqrt(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -1012,8 +1012,8 @@ dsqrt(float64 arg1) float64 dcbrt(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -1032,9 +1032,9 @@ dcbrt(float64 arg1) float64 dpow(float64 arg1, float64 arg2) { - float64 result; - double tmp1, - tmp2; + float64 result; + double tmp1, + tmp2; if (!arg1 || !arg2) return (float64) NULL; @@ -1065,8 +1065,8 @@ dpow(float64 arg1, float64 arg2) float64 dexp(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -1097,8 +1097,8 @@ dexp(float64 arg1) float64 dlog1(float64 arg1) { - float64 result; - double tmp; + float64 result; + double tmp; if (!arg1) return (float64) NULL; @@ -1132,7 +1132,7 @@ dlog1(float64 arg1) float64 float48pl(float32 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1147,7 +1147,7 @@ float48pl(float32 arg1, float64 arg2) float64 float48mi(float32 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1162,7 +1162,7 @@ float48mi(float32 arg1, float64 arg2) float64 float48mul(float32 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1177,7 +1177,7 @@ float48mul(float32 arg1, float64 arg2) float64 float48div(float32 arg1, float64 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1201,7 +1201,7 @@ float48div(float32 arg1, float64 arg2) float64 float84pl(float64 arg1, float32 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1216,7 +1216,7 @@ float84pl(float64 arg1, float32 arg2) float64 float84mi(float64 arg1, float32 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1232,7 +1232,7 @@ float64 float84mul(float64 arg1, float32 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1247,7 +1247,7 @@ float84mul(float64 arg1, float32 arg2) float64 float84div(float64 arg1, float32 arg2) { - float64 result; + float64 result; if (!arg1 || !arg2) return (float64) NULL; @@ -1415,8 +1415,8 @@ static const double #else static double #endif - one = 1.0, - TWO52[2] = { + one = 1.0, + TWO52[2] = { 4.50359962737049600000e+15, /* 0x43300000, 0x00000000 */ -4.50359962737049600000e+15,/* 0xC3300000, 0x00000000 */ }; @@ -1427,18 +1427,18 @@ rint(double x) #else static double rint(x) -double x; +double x; #endif { - int i0, - n0, - j0, - sx; - unsigned i, - i1; - double w, - t; + int i0, + n0, + j0, + sx; + unsigned i, + i1; + double w, + t; n0 = (*((int *) &one) >> 29) ^ 1; i0 = *(n0 + (int *) &x); @@ -1505,10 +1505,10 @@ double x; static double cbrt(x) -double x; +double x; { - int isneg = (x < 0.0); - double tmpres = pow(fabs(x), (double) 1.0 / (double) 3.0); + int isneg = (x < 0.0); + double tmpres = pow(fabs(x), (double) 1.0 / (double) 3.0); return (isneg ? -tmpres : tmpres); } @@ -1525,9 +1525,9 @@ double x; static int isinf(x) -double x; +double x; { - int fpclass = class(x); + int fpclass = class(x); if (fpclass == FP_PLUS_INF) return (1); @@ -1542,9 +1542,9 @@ double x; #include <fp_class.h> static int isinf(x) -double x; +double x; { - int fpclass = fp_class_d(x); + int fpclass = fp_class_d(x); if (fpclass == FP_POS_INF) return (1); @@ -1559,9 +1559,9 @@ double x; #include <fp_class.h> static int isinf(x) -double x; +double x; { - int fpclass = fp_class(x); + int fpclass = fp_class(x); if (fpclass == FP_POS_INF) return (1); @@ -1577,19 +1577,19 @@ double x; #include <ieeefp.h> static int isinf(d) -double d; +double d; { - fpclass_t type = fpclass(d); + fpclass_t type = fpclass(d); switch (type) { - case FP_SNAN: - case FP_QNAN: - case FP_NINF: - case FP_PINF: - return (1); - default: - break; + case FP_SNAN: + case FP_QNAN: + case FP_NINF: + case FP_PINF: + return (1); + default: + break; } return (0); @@ -1601,19 +1601,19 @@ double d; #include <ieeefp.h> static int isinf(d) -double d; +double d; { - fpclass_t type = fpclass(d); + fpclass_t type = fpclass(d); switch (type) { - case FP_SNAN: - case FP_QNAN: - case FP_NINF: - case FP_PINF: - return (1); - default: - break; + case FP_SNAN: + case FP_QNAN: + case FP_NINF: + case FP_PINF: + return (1); + default: + break; } return (0); diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index 71b478788ef..ac3bb853981 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.20 1997/09/07 04:50:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.21 1997/09/08 02:30:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,38 +28,38 @@ #define PI 3.1415926536 #endif -static int point_inside(Point * p, int npts, Point plist[]); -static int lseg_crossing(double x, double y, double px, double py); -static BOX *box_construct(double x1, double x2, double y1, double y2); -static BOX *box_copy(BOX * box); -static BOX *box_fill(BOX * result, double x1, double x2, double y1, double y2); -static double box_ht(BOX * box); -static double box_wd(BOX * box); -static double circle_ar(CIRCLE * circle); -static CIRCLE *circle_copy(CIRCLE * circle); -static LINE *line_construct_pm(Point * pt, double m); -static bool line_horizontal(LINE * line); -static Point *line_interpt(LINE * l1, LINE * l2); -static bool line_intersect(LINE * l1, LINE * l2); -static bool line_parallel(LINE * l1, LINE * l2); -static bool line_vertical(LINE * line); -static double lseg_dt(LSEG * l1, LSEG * l2); -static void make_bound_box(POLYGON * poly); -static PATH *path_copy(PATH * path); -static bool plist_same(int npts, Point p1[], Point p2[]); -static Point *point_construct(double x, double y); -static Point *point_copy(Point * pt); -static int single_decode(char *str, float8 * x, char **ss); -static int single_encode(float8 x, char *str); -static int pair_decode(char *str, float8 * x, float8 * y, char **s); -static int pair_encode(float8 x, float8 y, char *str); -static int pair_count(char *s, char delim); -static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point * p); -static char *path_encode(bool closed, int npts, Point * pt); -static void statlseg_construct(LSEG * lseg, Point * pt1, Point * pt2); -static double box_ar(BOX * box); -static Point *interpt_sl(LSEG * lseg, LINE * line); -static LINE *line_construct_pp(Point * pt1, Point * pt2); +static int point_inside(Point * p, int npts, Point plist[]); +static int lseg_crossing(double x, double y, double px, double py); +static BOX *box_construct(double x1, double x2, double y1, double y2); +static BOX *box_copy(BOX * box); +static BOX *box_fill(BOX * result, double x1, double x2, double y1, double y2); +static double box_ht(BOX * box); +static double box_wd(BOX * box); +static double circle_ar(CIRCLE * circle); +static CIRCLE *circle_copy(CIRCLE * circle); +static LINE *line_construct_pm(Point * pt, double m); +static bool line_horizontal(LINE * line); +static Point *line_interpt(LINE * l1, LINE * l2); +static bool line_intersect(LINE * l1, LINE * l2); +static bool line_parallel(LINE * l1, LINE * l2); +static bool line_vertical(LINE * line); +static double lseg_dt(LSEG * l1, LSEG * l2); +static void make_bound_box(POLYGON * poly); +static PATH *path_copy(PATH * path); +static bool plist_same(int npts, Point p1[], Point p2[]); +static Point *point_construct(double x, double y); +static Point *point_copy(Point * pt); +static int single_decode(char *str, float8 * x, char **ss); +static int single_encode(float8 x, char *str); +static int pair_decode(char *str, float8 * x, float8 * y, char **s); +static int pair_encode(float8 x, float8 y, char *str); +static int pair_count(char *s, char delim); +static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point * p); +static char *path_encode(bool closed, int npts, Point * pt); +static void statlseg_construct(LSEG * lseg, Point * pt1, Point * pt2); +static double box_ar(BOX * box); +static Point *interpt_sl(LSEG * lseg, LINE * line); +static LINE *line_construct_pp(Point * pt1, Point * pt2); /* @@ -80,7 +80,7 @@ static LINE *line_construct_pp(Point * pt1, Point * pt2); #define P_MAXDIG DBL_DIG #define P_MAXLEN (2*(P_MAXDIG+7)+1) -static int digits8 = P_MAXDIG; +static int digits8 = P_MAXDIG; /* @@ -111,7 +111,7 @@ static int digits8 = P_MAXDIG; static int single_decode(char *str, float8 * x, char **s) { - char *cp; + char *cp; if (!PointerIsValid(str)) return (FALSE); @@ -143,8 +143,8 @@ single_encode(float8 x, char *str) static int pair_decode(char *str, float8 * x, float8 * y, char **s) { - int has_delim; - char *cp; + int has_delim; + char *cp; if (!PointerIsValid(str)) return (FALSE); @@ -194,10 +194,10 @@ pair_encode(float8 x, float8 y, char *str) static int path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point * p) { - int depth = 0; - char *s, - *cp; - int i; + int depth = 0; + char *s, + *cp; + int i; s = str; while (isspace(*s)) @@ -263,25 +263,25 @@ path_decode(int opentype, int npts, char *str, int *isopen, char **ss, Point * p return (TRUE); } /* path_decode() */ -static char * +static char * path_encode(bool closed, int npts, Point * pt) { - char *result = PALLOC(npts * (P_MAXLEN + 3) + 2); + char *result = PALLOC(npts * (P_MAXLEN + 3) + 2); - char *cp; - int i; + char *cp; + int i; cp = result; switch (closed) { - case TRUE: - *cp++ = LDELIM; - break; - case FALSE: - *cp++ = LDELIM_EP; - break; - default: - break; + case TRUE: + *cp++ = LDELIM; + break; + case FALSE: + *cp++ = LDELIM_EP; + break; + default: + break; } for (i = 0; i < npts; i++) @@ -297,14 +297,14 @@ path_encode(bool closed, int npts, Point * pt) cp--; switch (closed) { - case TRUE: - *cp++ = RDELIM; - break; - case FALSE: - *cp++ = RDELIM_EP; - break; - default: - break; + case TRUE: + *cp++ = RDELIM; + break; + case FALSE: + *cp++ = RDELIM_EP; + break; + default: + break; } *cp = '\0'; @@ -321,7 +321,7 @@ path_encode(bool closed, int npts, Point * pt) static int pair_count(char *s, char delim) { - int ndelim = 0; + int ndelim = 0; while ((s = strchr(s, delim)) != NULL) { @@ -347,15 +347,15 @@ pair_count(char *s, char delim) * "(f8, f8), (f8, f8)" * also supports the older style "(f8, f8, f8, f8)" */ -BOX * +BOX * box_in(char *str) { - BOX *box = PALLOCTYPE(BOX); + BOX *box = PALLOCTYPE(BOX); - int isopen; - char *s; - double x, - y; + int isopen; + char *s; + double x, + y; if (!PointerIsValid(str)) elog(WARN, " Bad (null) box external representation", NULL); @@ -383,7 +383,7 @@ box_in(char *str) /* box_out - convert a box to external form. */ -char * +char * box_out(BOX * box) { if (!PointerIsValid(box)) @@ -395,10 +395,10 @@ box_out(BOX * box) /* box_construct - fill in a new box. */ -static BOX * +static BOX * box_construct(double x1, double x2, double y1, double y2) { - BOX *result = PALLOCTYPE(BOX); + BOX *result = PALLOCTYPE(BOX); return (box_fill(result, x1, x2, y1, y2)); } @@ -406,7 +406,7 @@ box_construct(double x1, double x2, double y1, double y2) /* box_fill - fill in a static box */ -static BOX * +static BOX * box_fill(BOX * result, double x1, double x2, double y1, double y2) { if (x1 > x2) @@ -436,10 +436,10 @@ box_fill(BOX * result, double x1, double x2, double y1, double y2) /* box_copy - copy a box */ -static BOX * +static BOX * box_copy(BOX * box) { - BOX *result = PALLOCTYPE(BOX); + BOX *result = PALLOCTYPE(BOX); memmove((char *) result, (char *) box, sizeof(BOX)); @@ -592,10 +592,10 @@ box_ge(BOX * box1, BOX * box2) /* box_area - returns the area of the box. */ -double * +double * box_area(BOX * box) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = box_wd(box) * box_ht(box); @@ -606,10 +606,10 @@ box_area(BOX * box) /* box_width - returns the width of the box * (horizontal magnitude). */ -double * +double * box_width(BOX * box) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = box->high.x - box->low.x; @@ -620,10 +620,10 @@ box_width(BOX * box) /* box_height - returns the height of the box * (vertical magnitude). */ -double * +double * box_height(BOX * box) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = box->high.y - box->low.y; @@ -634,12 +634,12 @@ box_height(BOX * box) /* box_distance - returns the distance between the * center points of two boxes. */ -double * +double * box_distance(BOX * box1, BOX * box2) { - double *result = PALLOCTYPE(double); - Point *a, - *b; + double *result = PALLOCTYPE(double); + Point *a, + *b; a = box_center(box1); b = box_center(box2); @@ -653,10 +653,10 @@ box_distance(BOX * box1, BOX * box2) /* box_center - returns the center point of the box. */ -Point * +Point * box_center(BOX * box) { - Point *result = PALLOCTYPE(Point); + Point *result = PALLOCTYPE(Point); result->x = (box->high.x + box->low.x) / 2.0; result->y = (box->high.y + box->low.y) / 2.0; @@ -701,9 +701,9 @@ box_ht(BOX * box) static double box_dt(BOX * box1, BOX * box2) { - double result; - Point *a, - *b; + double result; + Point *a, + *b; a = box_center(box1); b = box_center(box2); @@ -724,10 +724,10 @@ box_dt(BOX * box1, BOX * box2) * returns the overlapping portion of two boxes, * or NULL if they do not intersect. */ -BOX * +BOX * box_intersect(BOX * box1, BOX * box2) { - BOX *result; + BOX *result; if (!box_overlap(box1, box2)) return (NULL); @@ -748,11 +748,11 @@ box_intersect(BOX * box1, BOX * box2) * positive-slope diagonal of "box". * provided, of course, we have LSEGs. */ -LSEG * +LSEG * box_diagonal(BOX * box) { - Point p1, - p2; + Point p1, + p2; p1.x = box->high.x; p1.y = box->high.y; @@ -776,10 +776,10 @@ box_diagonal(BOX * box) * Internal form: Ax+By+C=0 *---------------------------------------------------------*/ -static LINE * /* point-slope */ +static LINE * /* point-slope */ line_construct_pm(Point * pt, double m) { - LINE *result = PALLOCTYPE(LINE); + LINE *result = PALLOCTYPE(LINE); /* use "mx - y + yinter = 0" */ result->A = m; @@ -792,10 +792,10 @@ line_construct_pm(Point * pt, double m) } /* line_construct_pm() */ -static LINE * /* two points */ +static LINE * /* two points */ line_construct_pp(Point * pt1, Point * pt2) { - LINE *result = PALLOCTYPE(LINE); + LINE *result = PALLOCTYPE(LINE); if (FPeq(pt1->x, pt2->x)) { /* vertical */ @@ -910,7 +910,7 @@ line_horizontal(LINE * line) bool line_eq(LINE * l1, LINE * l2) { - double k; + double k; if (!FPzero(l2->A)) k = l1->A / l2->A; @@ -932,11 +932,11 @@ line_eq(LINE * l1, LINE * l2) * Line arithmetic routines. *---------------------------------------------------------*/ -double * /* distance between l1, l2 */ +double * /* distance between l1, l2 */ line_distance(LINE * l1, LINE * l2) { - double *result = PALLOCTYPE(double); - Point *tmp; + double *result = PALLOCTYPE(double); + Point *tmp; if (line_intersect(l1, l2)) { @@ -957,12 +957,12 @@ line_distance(LINE * l1, LINE * l2) /* line_interpt() * Point where two lines l1, l2 intersect (if any) */ -static Point * +static Point * line_interpt(LINE * l1, LINE * l2) { - Point *result; - double x, - y; + Point *result; + double x, + y; if (line_parallel(l1, l2)) return (NULL); @@ -1040,16 +1040,16 @@ line_interpt(LINE * l1, LINE * l2) * "(closed, npts, xcoord, ycoord,... )" *---------------------------------------------------------*/ -PATH * +PATH * path_in(char *str) { - PATH *path; + PATH *path; - int isopen; - char *s; - int npts; - int size; - int depth = 0; + int isopen; + char *s; + int npts; + int size; + int depth = 0; if (!PointerIsValid(str)) elog(WARN, "Bad (null) path external representation"); @@ -1084,7 +1084,7 @@ path_in(char *str) } /* path_in() */ -char * +char * path_out(PATH * path) { if (!PointerIsValid(path)) @@ -1165,10 +1165,10 @@ path_npoints(PATH * path) return (path->npts); } /* path_npoints() */ -PATH * +PATH * path_close(PATH * path) { - PATH *result; + PATH *result; if (!PointerIsValid(path)) return (NULL); @@ -1180,10 +1180,10 @@ path_close(PATH * path) } /* path_close() */ -PATH * +PATH * path_open(PATH * path) { - PATH *result; + PATH *result; if (!PointerIsValid(path)) return (NULL); @@ -1195,11 +1195,11 @@ path_open(PATH * path) } /* path_open() */ -PATH * +PATH * path_copy(PATH * path) { - PATH *result; - int size; + PATH *result; + int size; size = offsetof(PATH, p[0]) + (sizeof(path->p[0]) * path->npts); result = PALLOC(size); @@ -1217,12 +1217,12 @@ path_copy(PATH * path) bool path_inter(PATH * p1, PATH * p2) { - BOX b1, - b2; - int i, - j; - LSEG seg1, - seg2; + BOX b1, + b2; + int i, + j; + LSEG seg1, + seg2; b1.high.x = b1.low.x = p1->p[0].x; b1.high.y = b1.low.y = p1->p[0].y; @@ -1263,15 +1263,15 @@ path_inter(PATH * p1, PATH * p2) /* this essentially does a cartesian product of the lsegs in the two paths, and finds the min distance between any two lsegs */ -double * +double * path_distance(PATH * p1, PATH * p2) { - double *min = NULL, - *tmp; - int i, - j; - LSEG seg1, - seg2; + double *min = NULL, + *tmp; + int i, + j; + LSEG seg1, + seg2; /* statlseg_construct(&seg1, &p1->p[0], &p1->p[1]); @@ -1306,11 +1306,11 @@ path_distance(PATH * p1, PATH * p2) * "Arithmetic" operations. *---------------------------------------------------------*/ -double * +double * path_length(PATH * path) { - double *result; - int i; + double *result; + int i; result = PALLOCTYPE(double); @@ -1326,8 +1326,8 @@ path_length(PATH * path) double path_ln(PATH * path) { - double result; - int i; + double result; + int i; result = 0; for (i = 0; i < (path->npts - 1); i++) @@ -1351,14 +1351,14 @@ path_ln(PATH * path) * "x,y" *---------------------------------------------------------*/ -Point * +Point * point_in(char *str) { - Point *point; + Point *point; - double x, - y; - char *s; + double x, + y; + char *s; if (!PointerIsValid(str)) elog(WARN, "Bad (null) point external representation"); @@ -1374,7 +1374,7 @@ point_in(char *str) return (point); } /* point_in() */ -char * +char * point_out(Point * pt) { if (!PointerIsValid(pt)) @@ -1384,10 +1384,10 @@ point_out(Point * pt) } /* point_out() */ -static Point * +static Point * point_construct(double x, double y) { - Point *result = PALLOCTYPE(Point); + Point *result = PALLOCTYPE(Point); result->x = x; result->y = y; @@ -1395,10 +1395,10 @@ point_construct(double x, double y) } -static Point * +static Point * point_copy(Point * pt) { - Point *result; + Point *result; if (!PointerIsValid(pt)) return (NULL); @@ -1469,16 +1469,16 @@ point_eq(Point * pt1, Point * pt2) int32 pointdist(Point * p1, Point * p2) { - int32 result; + int32 result; result = point_dt(p1, p2); return (result); } -double * +double * point_distance(Point * pt1, Point * pt2) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = HYPOT(pt1->x - pt2->x, pt1->y - pt2->y); return (result); @@ -1491,10 +1491,10 @@ point_dt(Point * pt1, Point * pt2) return (HYPOT(pt1->x - pt2->x, pt1->y - pt2->y)); } -double * +double * point_slope(Point * pt1, Point * pt2) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); if (point_vert(pt1, pt2)) *result = (double) DBL_MAX; @@ -1528,13 +1528,13 @@ point_sl(Point * pt1, Point * pt2) * (old form) "(x1, y1, x2, y2)" *---------------------------------------------------------*/ -LSEG * +LSEG * lseg_in(char *str) { - LSEG *lseg; + LSEG *lseg; - int isopen; - char *s; + int isopen; + char *s; if (!PointerIsValid(str)) elog(WARN, " Bad (null) lseg external representation", NULL); @@ -1551,7 +1551,7 @@ lseg_in(char *str) } /* lseg_in() */ -char * +char * lseg_out(LSEG * ls) { if (!PointerIsValid(ls)) @@ -1564,10 +1564,10 @@ lseg_out(LSEG * ls) /* lseg_construct - * form a LSEG from two Points. */ -LSEG * +LSEG * lseg_construct(Point * pt1, Point * pt2) { - LSEG *result = PALLOCTYPE(LSEG); + LSEG *result = PALLOCTYPE(LSEG); result->p[0].x = pt1->x; result->p[0].y = pt1->y; @@ -1602,9 +1602,9 @@ statlseg_construct(LSEG * lseg, Point * pt1, Point * pt2) bool lseg_intersect(LSEG * l1, LSEG * l2) { - LINE *ln; - Point *interpt; - bool retval; + LINE *ln; + Point *interpt; + bool retval; ln = line_construct_pp(&l2->p[0], &l2->p[1]); interpt = interpt_sl(l1, ln); @@ -1632,8 +1632,8 @@ lseg_parallel(LSEG * l1, LSEG * l2) bool lseg_perp(LSEG * l1, LSEG * l2) { - double m1, - m2; + double m1, + m2; m1 = point_sl(&(l1->p[0]), &(l1->p[1])); m2 = point_sl(&(l2->p[0]), &(l2->p[1])); @@ -1677,10 +1677,10 @@ lseg_eq(LSEG * l1, LSEG * l2) * point will be from one of the endpoints to the other * segment. */ -double * +double * lseg_distance(LSEG * l1, LSEG * l2) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = lseg_dt(l1, l2); @@ -1691,8 +1691,8 @@ lseg_distance(LSEG * l1, LSEG * l2) static double lseg_dt(LSEG * l1, LSEG * l2) { - double *d, - result; + double *d, + result; if (lseg_intersect(l1, l2)) return (0.0); @@ -1719,10 +1719,10 @@ lseg_dt(LSEG * l1, LSEG * l2) } /* lseg_dt() */ -Point * +Point * lseg_center(LSEG * lseg) { - Point *result; + Point *result; if (!PointerIsValid(lseg)) return (NULL); @@ -1745,12 +1745,12 @@ lseg_center(LSEG * lseg) * endpoints since there may be rounding effects with annoying * lsb residue. - tgl 1997-07-09 */ -Point * +Point * lseg_interpt(LSEG * l1, LSEG * l2) { - Point *result; - LINE *tmp1, - *tmp2; + Point *result; + LINE *tmp1, + *tmp2; if (!PointerIsValid(l1) || !PointerIsValid(l2)) return (NULL); @@ -1805,10 +1805,10 @@ lseg_interpt(LSEG * l1, LSEG * l2) * Minimum distance from one object to another. *-------------------------------------------------------------------*/ -double * +double * dist_pl(Point * pt, LINE * line) { - double *result = PALLOCTYPE(double); + double *result = PALLOCTYPE(double); *result = (line->A * pt->x + line->B * pt->y + line->C) / HYPOT(line->A, line->B); @@ -1816,14 +1816,14 @@ dist_pl(Point * pt, LINE * line) return (result); } -double * +double * dist_ps(Point * pt, LSEG * lseg) { - double m; /* slope of perp. */ - LINE *ln; - double *result, - *tmpdist; - Point *ip; + double m; /* slope of perp. */ + LINE *ln; + double *result, + *tmpdist; + Point *ip; /* * Construct a line perpendicular to the input segment @@ -1887,51 +1887,51 @@ dist_ps(Point * pt, LSEG * lseg) /* ** Distance from a point to a path */ -double * +double * dist_ppath(Point * pt, PATH * path) { - double *result; - double *tmp; - int i; - LSEG lseg; + double *result; + double *tmp; + int i; + LSEG lseg; switch (path->npts) { - /* no points in path? then result is undefined... */ - case 0: - result = NULL; - break; - /* one point in path? then get distance between two points... */ - case 1: - result = point_distance(pt, &path->p[0]); - break; - default: - /* make sure the path makes sense... */ - Assert(path->npts > 1); - - /* - * the distance from a point to a path is the smallest distance - * from the point to any of its constituent segments. - */ - result = PALLOCTYPE(double); - for (i = 0; i < path->npts - 1; i++) - { - statlseg_construct(&lseg, &path->p[i], &path->p[i + 1]); - tmp = dist_ps(pt, &lseg); - if (i == 0 || *tmp < *result) - *result = *tmp; - PFREE(tmp); - } - break; + /* no points in path? then result is undefined... */ + case 0: + result = NULL; + break; + /* one point in path? then get distance between two points... */ + case 1: + result = point_distance(pt, &path->p[0]); + break; + default: + /* make sure the path makes sense... */ + Assert(path->npts > 1); + + /* + * the distance from a point to a path is the smallest + * distance from the point to any of its constituent segments. + */ + result = PALLOCTYPE(double); + for (i = 0; i < path->npts - 1; i++) + { + statlseg_construct(&lseg, &path->p[i], &path->p[i + 1]); + tmp = dist_ps(pt, &lseg); + if (i == 0 || *tmp < *result) + *result = *tmp; + PFREE(tmp); + } + break; } return (result); } -double * +double * dist_pb(Point * pt, BOX * box) { - Point *tmp; - double *result; + Point *tmp; + double *result; tmp = close_pb(pt, box); result = point_distance(tmp, pt); @@ -1941,11 +1941,11 @@ dist_pb(Point * pt, BOX * box) } -double * +double * dist_sl(LSEG * lseg, LINE * line) { - double *result, - *d2; + double *result, + *d2; if (inter_sl(lseg, line)) { @@ -1972,11 +1972,11 @@ dist_sl(LSEG * lseg, LINE * line) } -double * +double * dist_sb(LSEG * lseg, BOX * box) { - Point *tmp; - double *result; + Point *tmp; + double *result; tmp = close_sb(lseg, box); if (tmp == NULL) @@ -1994,11 +1994,11 @@ dist_sb(LSEG * lseg, BOX * box) } -double * +double * dist_lb(LINE * line, BOX * box) { - Point *tmp; - double *result; + Point *tmp; + double *result; tmp = close_lb(line, box); if (tmp == NULL) @@ -2016,13 +2016,13 @@ dist_lb(LINE * line, BOX * box) } -double * +double * dist_cpoly(CIRCLE * circle, POLYGON * poly) { - double *result; - int i; - double *d; - LSEG seg; + double *result; + int i; + double *d; + LSEG seg; if (!PointerIsValid(circle) || !PointerIsValid(poly)) elog(WARN, "Invalid (null) input for distance", NULL); @@ -2079,11 +2079,11 @@ dist_cpoly(CIRCLE * circle, POLYGON * poly) * lines and boxes, since there are typically two. *-------------------------------------------------------------------*/ -static Point * +static Point * interpt_sl(LSEG * lseg, LINE * line) { - LINE *tmp; - Point *p; + LINE *tmp; + Point *p; tmp = line_construct_pp(&lseg->p[0], &lseg->p[1]); p = line_interpt(tmp, line); @@ -2126,12 +2126,12 @@ interpt_sl(LSEG * lseg, LINE * line) * The intersection point of a perpendicular of the line * through the point. */ -Point * +Point * close_pl(Point * pt, LINE * line) { - Point *result; - LINE *tmp; - double invm; + Point *result; + LINE *tmp; + double invm; result = PALLOCTYPE(Point); #if FALSE @@ -2174,14 +2174,14 @@ close_pl(Point * pt, LINE * line) * above, or below the segment, otherwise find the intersection * point of the segment and its perpendicular through the point. */ -Point * +Point * close_ps(Point * pt, LSEG * lseg) { - Point *result; - LINE *tmp; - double invm; - int xh, - yh; + Point *result; + LINE *tmp; + double invm; + int xh, + yh; result = NULL; xh = lseg->p[0].x < lseg->p[1].x; @@ -2226,7 +2226,7 @@ close_ps(Point * pt, LSEG * lseg) return (result); } /* close_ps() */ -Point * +Point * close_pb(Point * pt, BOX * box) { /* think about this one for a while */ @@ -2235,12 +2235,12 @@ close_pb(Point * pt, BOX * box) return (NULL); } -Point * +Point * close_sl(LSEG * lseg, LINE * line) { - Point *result; - double *d1, - *d2; + Point *result; + double *d1, + *d2; result = interpt_sl(lseg, line); if (result) @@ -2257,7 +2257,7 @@ close_sl(LSEG * lseg, LINE * line) return (result); } -Point * +Point * close_sb(LSEG * lseg, BOX * box) { /* think about this one for a while */ @@ -2266,7 +2266,7 @@ close_sb(LSEG * lseg, BOX * box) return (NULL); } -Point * +Point * close_lb(LINE * line, BOX * box) { /* think about this one for a while */ @@ -2334,21 +2334,21 @@ bool on_ppath(Point * pt, PATH * path) { #if FALSE - int above, - next, /* is the seg above the ray? */ - inter, /* # of times path crosses ray */ - hi; /* index inc of higher seg (0,1) */ - double x, - yh, - yl, - xh, - xl; + int above, + next, /* is the seg above the ray? */ + inter, /* # of times path crosses ray */ + hi; /* index inc of higher seg (0,1) */ + double x, + yh, + yl, + xh, + xl; #endif - int i, - n; - double a, - b; + int i, + n; + double a, + b; if (!PointerIsValid(pt) || !PointerIsValid(path)) return (FALSE); @@ -2449,7 +2449,7 @@ on_sb(LSEG * lseg, BOX * box) bool inter_sl(LSEG * lseg, LINE * line) { - Point *tmp; + Point *tmp; if (!PointerIsValid(lseg) || !PointerIsValid(line)) return (FALSE); @@ -2493,11 +2493,11 @@ inter_lb(LINE * line, BOX * box) static void make_bound_box(POLYGON * poly) { - int i; - double x1, - y1, - x2, - y2; + int i; + double x1, + y1, + x2, + y2; if (poly->npts > 0) { @@ -2531,14 +2531,14 @@ make_bound_box(POLYGON * poly) * "x0,y0,...,xn,yn" * also supports the older style "(x1,...,xn,y1,...yn)" *------------------------------------------------------------------*/ -POLYGON * +POLYGON * poly_in(char *str) { - POLYGON *poly; - int npts; - int size; - int isopen; - char *s; + POLYGON *poly; + int npts; + int size; + int isopen; + char *s; if (!PointerIsValid(str)) elog(WARN, " Bad (null) polygon external representation"); @@ -2567,7 +2567,7 @@ poly_in(char *str) * character string format "((f8,f8),...,(f8,f8))" * also support old format "(f8,f8,...,f8,f8)" *---------------------------------------------------------------*/ -char * +char * poly_out(POLYGON * poly) { if (!PointerIsValid(poly)) @@ -2677,7 +2677,7 @@ poly_contain(POLYGON * polya, POLYGON * polyb) bool poly_contain(POLYGON * polya, POLYGON * polyb) { - int i; + int i; if (!PointerIsValid(polya) || !PointerIsValid(polyb)) return (FALSE); @@ -2764,10 +2764,10 @@ pt_contained_poly(Point * p, POLYGON * poly) } /* pt_contained_poly() */ -double * +double * poly_distance(POLYGON * polya, POLYGON * polyb) { - double *result; + double *result; if (!PointerIsValid(polya) || !PointerIsValid(polyb)) return (NULL); @@ -2786,7 +2786,7 @@ poly_distance(POLYGON * polya, POLYGON * polyb) ** ***********************************************************************/ -Point * +Point * point(float8 * x, float8 * y) { if (!(PointerIsValid(x) && PointerIsValid(y))) @@ -2796,10 +2796,10 @@ point(float8 * x, float8 * y) } /* point() */ -Point * +Point * point_add(Point * p1, Point * p2) { - Point *result; + Point *result; if (!(PointerIsValid(p1) && PointerIsValid(p2))) return (NULL); @@ -2812,10 +2812,10 @@ point_add(Point * p1, Point * p2) return (result); } /* point_add() */ -Point * +Point * point_sub(Point * p1, Point * p2) { - Point *result; + Point *result; if (!(PointerIsValid(p1) && PointerIsValid(p2))) return (NULL); @@ -2828,10 +2828,10 @@ point_sub(Point * p1, Point * p2) return (result); } /* point_sub() */ -Point * +Point * point_mul(Point * p1, Point * p2) { - Point *result; + Point *result; if (!(PointerIsValid(p1) && PointerIsValid(p2))) return (NULL); @@ -2844,11 +2844,11 @@ point_mul(Point * p1, Point * p2) return (result); } /* point_mul() */ -Point * +Point * point_div(Point * p1, Point * p2) { - Point *result; - double div; + Point *result; + double div; if (!(PointerIsValid(p1) && PointerIsValid(p2))) return (NULL); @@ -2873,10 +2873,10 @@ point_div(Point * p1, Point * p2) ** ***********************************************************************/ -BOX * +BOX * box(Point * p1, Point * p2) { - BOX *result; + BOX *result; if (!(PointerIsValid(p1) && PointerIsValid(p2))) return (NULL); @@ -2886,10 +2886,10 @@ box(Point * p1, Point * p2) return (result); } /* box() */ -BOX * +BOX * box_add(BOX * box, Point * p) { - BOX *result; + BOX *result; if (!(PointerIsValid(box) && PointerIsValid(p))) return (NULL); @@ -2900,10 +2900,10 @@ box_add(BOX * box, Point * p) return (result); } /* box_add() */ -BOX * +BOX * box_sub(BOX * box, Point * p) { - BOX *result; + BOX *result; if (!(PointerIsValid(box) && PointerIsValid(p))) return (NULL); @@ -2914,12 +2914,12 @@ box_sub(BOX * box, Point * p) return (result); } /* box_sub() */ -BOX * +BOX * box_mul(BOX * box, Point * p) { - BOX *result; - Point *high, - *low; + BOX *result; + Point *high, + *low; if (!(PointerIsValid(box) && PointerIsValid(p))) return (NULL); @@ -2934,12 +2934,12 @@ box_mul(BOX * box, Point * p) return (result); } /* box_mul() */ -BOX * +BOX * box_div(BOX * box, Point * p) { - BOX *result; - Point *high, - *low; + BOX *result; + Point *high, + *low; if (!(PointerIsValid(box) && PointerIsValid(p))) return (NULL); @@ -2974,12 +2974,12 @@ box_div(BOX * box, Point * p) /* path_add() * Concatenate two paths (only if they are both open). */ -PATH * +PATH * path_add(PATH * p1, PATH * p2) { - PATH *result; - int size; - int i; + PATH *result; + int size; + int i; if (!(PointerIsValid(p1) && PointerIsValid(p2)) || p1->closed || p2->closed) @@ -3009,11 +3009,11 @@ path_add(PATH * p1, PATH * p2) /* path_add_pt() * Translation operator. */ -PATH * +PATH * path_add_pt(PATH * path, Point * point) { - PATH *result; - int i; + PATH *result; + int i; if ((!PointerIsValid(path)) || (!PointerIsValid(point))) return (NULL); @@ -3029,11 +3029,11 @@ path_add_pt(PATH * path, Point * point) return (result); } /* path_add_pt() */ -PATH * +PATH * path_sub_pt(PATH * path, Point * point) { - PATH *result; - int i; + PATH *result; + int i; if ((!PointerIsValid(path)) || (!PointerIsValid(point))) return (NULL); @@ -3053,12 +3053,12 @@ path_sub_pt(PATH * path, Point * point) /* path_mul_pt() * Rotation and scaling operators. */ -PATH * +PATH * path_mul_pt(PATH * path, Point * point) { - PATH *result; - Point *p; - int i; + PATH *result; + Point *p; + int i; if ((!PointerIsValid(path)) || (!PointerIsValid(point))) return (NULL); @@ -3076,12 +3076,12 @@ path_mul_pt(PATH * path, Point * point) return (result); } /* path_mul_pt() */ -PATH * +PATH * path_div_pt(PATH * path, Point * point) { - PATH *result; - Point *p; - int i; + PATH *result; + Point *p; + int i; if ((!PointerIsValid(path)) || (!PointerIsValid(point))) return (NULL); @@ -3119,10 +3119,10 @@ pt_contained_path(Point * p, PATH * path) } /* pt_contained_path() */ -Point * +Point * path_center(PATH * path) { - Point *result; + Point *result; if (!PointerIsValid(path)) return (NULL); @@ -3135,12 +3135,12 @@ path_center(PATH * path) return (result); } /* path_center() */ -POLYGON * +POLYGON * path_poly(PATH * path) { - POLYGON *poly; - int size; - int i; + POLYGON *poly; + int size; + int i; if (!PointerIsValid(path)) return (NULL); @@ -3176,10 +3176,10 @@ path_poly(PATH * path) PATH * upgradepath(PATH * path) { - PATH *result; - int size, - npts; - int i; + PATH *result; + int size, + npts; + int i; if (!PointerIsValid(path) || (path->npts < 2)) return (NULL); @@ -3231,11 +3231,11 @@ poly_npoints(POLYGON * poly) } /* poly_npoints() */ -Point * +Point * poly_center(POLYGON * poly) { - Point *result; - CIRCLE *circle; + Point *result; + CIRCLE *circle; if (!PointerIsValid(poly)) return (NULL); @@ -3255,10 +3255,10 @@ poly_center(POLYGON * poly) } /* poly_center() */ -BOX * +BOX * poly_box(POLYGON * poly) { - BOX *box; + BOX *box; if (!PointerIsValid(poly) || (poly->npts < 1)) return (NULL); @@ -3272,11 +3272,11 @@ poly_box(POLYGON * poly) /* box_poly() * Convert a box to a polygon. */ -POLYGON * +POLYGON * box_poly(BOX * box) { - POLYGON *poly; - int size; + POLYGON *poly; + int size; if (!PointerIsValid(box)) return (NULL); @@ -3303,12 +3303,12 @@ box_poly(BOX * box) } /* box_poly() */ -PATH * +PATH * poly_path(POLYGON * poly) { - PATH *path; - int size; - int i; + PATH *path; + int size; + int i; if (!PointerIsValid(poly) || (poly->npts < 0)) return (NULL); @@ -3338,11 +3338,11 @@ poly_path(POLYGON * poly) POLYGON * upgradepoly(POLYGON * poly) { - POLYGON *result; - int size; - int n2, - i, - ii; + POLYGON *result; + int size; + int n2, + i, + ii; if (!PointerIsValid(poly) || (poly->npts < 1)) return (NULL); @@ -3384,11 +3384,11 @@ POLYGON POLYGON * revertpoly(POLYGON * poly) { - POLYGON *result; - int size; - int n2, - i, - ii; + POLYGON *result; + int size; + int n2, + i, + ii; if (!PointerIsValid(poly) || (poly->npts < 1)) return (NULL); @@ -3441,14 +3441,14 @@ POLYGON * "((f8,f8)<f8>)" * also supports quick entry style "(f8,f8,f8)" */ -CIRCLE * +CIRCLE * circle_in(char *str) { - CIRCLE *circle; + CIRCLE *circle; - char *s, - *cp; - int depth = 0; + char *s, + *cp; + int depth = 0; if (!PointerIsValid(str)) elog(WARN, " Bad (null) circle external representation", NULL); @@ -3505,11 +3505,11 @@ circle_in(char *str) /* circle_out - convert a circle to external form. */ -char * +char * circle_out(CIRCLE * circle) { - char *result; - char *cp; + char *result; + char *cp; if (!PointerIsValid(circle)) return (NULL); @@ -3674,10 +3674,10 @@ circle_ge(CIRCLE * circle1, CIRCLE * circle2) * actual value. *---------------------------------------------------------*/ -static CIRCLE * +static CIRCLE * circle_copy(CIRCLE * circle) { - CIRCLE *result; + CIRCLE *result; if (!PointerIsValid(circle)) return NULL; @@ -3692,10 +3692,10 @@ circle_copy(CIRCLE * circle) /* circle_add_pt() * Translation operator. */ -CIRCLE * +CIRCLE * circle_add_pt(CIRCLE * circle, Point * point) { - CIRCLE *result; + CIRCLE *result; if (!PointerIsValid(circle) || !PointerIsValid(point)) return (NULL); @@ -3708,10 +3708,10 @@ circle_add_pt(CIRCLE * circle, Point * point) return (result); } /* circle_add_pt() */ -CIRCLE * +CIRCLE * circle_sub_pt(CIRCLE * circle, Point * point) { - CIRCLE *result; + CIRCLE *result; if (!PointerIsValid(circle) || !PointerIsValid(point)) return (NULL); @@ -3728,11 +3728,11 @@ circle_sub_pt(CIRCLE * circle, Point * point) /* circle_mul_pt() * Rotation and scaling operators. */ -CIRCLE * +CIRCLE * circle_mul_pt(CIRCLE * circle, Point * point) { - CIRCLE *result; - Point *p; + CIRCLE *result; + Point *p; if (!PointerIsValid(circle) || !PointerIsValid(point)) return (NULL); @@ -3748,11 +3748,11 @@ circle_mul_pt(CIRCLE * circle, Point * point) return (result); } /* circle_mul_pt() */ -CIRCLE * +CIRCLE * circle_div_pt(CIRCLE * circle, Point * point) { - CIRCLE *result; - Point *p; + CIRCLE *result; + Point *p; if (!PointerIsValid(circle) || !PointerIsValid(point)) return (NULL); @@ -3771,10 +3771,10 @@ circle_div_pt(CIRCLE * circle, Point * point) /* circle_area - returns the area of the circle. */ -double * +double * circle_area(CIRCLE * circle) { - double *result; + double *result; result = PALLOCTYPE(double); *result = circle_ar(circle); @@ -3785,10 +3785,10 @@ circle_area(CIRCLE * circle) /* circle_diameter - returns the diameter of the circle. */ -double * +double * circle_diameter(CIRCLE * circle) { - double *result; + double *result; result = PALLOCTYPE(double); *result = (2 * circle->radius); @@ -3799,10 +3799,10 @@ circle_diameter(CIRCLE * circle) /* circle_radius - returns the radius of the circle. */ -double * +double * circle_radius(CIRCLE * circle) { - double *result; + double *result; result = PALLOCTYPE(double); *result = circle->radius; @@ -3814,10 +3814,10 @@ circle_radius(CIRCLE * circle) /* circle_distance - returns the distance between * two circles. */ -double * +double * circle_distance(CIRCLE * circle1, CIRCLE * circle2) { - double *result; + double *result; result = PALLOCTYPE(double); *result = (point_dt(&circle1->center, &circle2->center) @@ -3832,8 +3832,8 @@ circle_distance(CIRCLE * circle1, CIRCLE * circle2) bool circle_contain_pt(CIRCLE * circle, Point * point) { - bool within; - double *d; + bool within; + double *d; if (!PointerIsValid(circle) || !PointerIsValid(point)) return (FALSE); @@ -3856,10 +3856,10 @@ pt_contained_circle(Point * point, CIRCLE * circle) /* dist_pc - returns the distance between * a point and a circle. */ -double * +double * dist_pc(Point * point, CIRCLE * circle) { - double *result; + double *result; result = PALLOCTYPE(double); @@ -3873,10 +3873,10 @@ dist_pc(Point * point, CIRCLE * circle) /* circle_center - returns the center point of the circle. */ -Point * +Point * circle_center(CIRCLE * circle) { - Point *result; + Point *result; result = PALLOCTYPE(Point); result->x = circle->center.x; @@ -3902,7 +3902,7 @@ circle_ar(CIRCLE * circle) double circle_dt(CIRCLE * circle1, CIRCLE * circle2) { - double result; + double result; result = point_dt(&circle1->center, &circle2->center); @@ -3915,10 +3915,10 @@ circle_dt(CIRCLE * circle1, CIRCLE * circle2) * Conversion operators. *---------------------------------------------------------*/ -CIRCLE * +CIRCLE * circle(Point * center, float8 * radius) { - CIRCLE *result; + CIRCLE *result; if (!(PointerIsValid(center) && PointerIsValid(radius))) return (NULL); @@ -3933,11 +3933,11 @@ circle(Point * center, float8 * radius) } -BOX * +BOX * circle_box(CIRCLE * circle) { - BOX *box; - double delta; + BOX *box; + double delta; if (!PointerIsValid(circle)) return (NULL); @@ -3957,10 +3957,10 @@ circle_box(CIRCLE * circle) /* box_circle() * Convert a box to a circle. */ -CIRCLE * +CIRCLE * box_circle(BOX * box) { - CIRCLE *circle; + CIRCLE *circle; if (!PointerIsValid(box)) return (NULL); @@ -3976,13 +3976,13 @@ box_circle(BOX * box) } /* box_circle() */ -POLYGON * +POLYGON * circle_poly(int npts, CIRCLE * circle) { - POLYGON *poly; - int size; - int i; - double angle; + POLYGON *poly; + int size; + int i; + double angle; if (!PointerIsValid(circle)) return (NULL); @@ -4014,11 +4014,11 @@ circle_poly(int npts, CIRCLE * circle) * XXX This algorithm should use weighted means of line segments * rather than straight average values of points - tgl 97/01/21. */ -CIRCLE * +CIRCLE * poly_circle(POLYGON * poly) { - CIRCLE *circle; - int i; + CIRCLE *circle; + int i; if (!PointerIsValid(poly)) return (NULL); @@ -4064,16 +4064,16 @@ poly_circle(POLYGON * poly) static int point_inside(Point * p, int npts, Point plist[]) { - double x0, - y0; - double px, - py; + double x0, + y0; + double px, + py; - int i; - double x, - y; - int cross, - crossnum; + int i; + double x, + y; + int cross, + crossnum; /* * We calculate crossnum, which is twice the crossing number of a @@ -4132,8 +4132,8 @@ point_inside(Point * p, int npts, Point plist[]) static int lseg_crossing(double x, double y, double px, double py) { - double z; - int sgn; + double z; + int sgn; /* If (px,py) = (0,0) and not first call we have already sent HIT_IT */ @@ -4184,12 +4184,12 @@ lseg_crossing(double x, double y, double px, double py) } /* lseg_crossing() */ -static bool +static bool plist_same(int npts, Point p1[], Point p2[]) { - int i, - ii, - j; + int i, + ii, + j; /* find match for first point */ for (i = 0; i < npts; i++) diff --git a/src/backend/utils/adt/geo_selfuncs.c b/src/backend/utils/adt/geo_selfuncs.c index 240639d6eda..d07230e41f7 100644 --- a/src/backend/utils/adt/geo_selfuncs.c +++ b/src/backend/utils/adt/geo_selfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.4 1997/09/07 04:50:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_selfuncs.c,v 1.5 1997/09/08 02:30:44 momjian Exp $ * * XXX These are totally bogus. * @@ -28,7 +28,7 @@ areasel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 4.0; @@ -42,7 +42,7 @@ areajoinsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 4.0; @@ -73,7 +73,7 @@ leftsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 6.0; @@ -90,7 +90,7 @@ leftjoinsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 6.0; @@ -110,7 +110,7 @@ contsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 10.0; @@ -127,7 +127,7 @@ contjoinsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 10.0; diff --git a/src/backend/utils/adt/int.c b/src/backend/utils/adt/int.c index c7ea5f71fcc..b1945196175 100644 --- a/src/backend/utils/adt/int.c +++ b/src/backend/utils/adt/int.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.5 1997/09/07 04:50:21 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int.c,v 1.6 1997/09/08 02:30:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,10 +50,10 @@ int2in(char *num) /* * int2out - converts short to "num" */ -char * +char * int2out(int16 sh) { - char *result; + char *result; result = (char *) palloc(7);/* assumes sign, 5 digits, '\0' */ itoa((int) sh, result); @@ -66,11 +66,11 @@ int2out(int16 sh) * Note: * Fills any nonexistent digits with NULLs. */ -int16 * +int16 * int28in(char *shs) { - register int16(*result)[]; - int nums; + register int16(*result)[]; + int nums; if (shs == NULL) return (NULL); @@ -95,13 +95,13 @@ int28in(char *shs) /* * int28out - converts internal form to "num num ..." */ -char * +char * int28out(int16(*shs)[]) { - register int num; + register int num; register int16 *sp; - register char *rp; - char *result; + register char *rp; + char *result; if (shs == NULL) { @@ -130,11 +130,11 @@ int28out(int16(*shs)[]) * Note: * Fills any nonexistent digits with NULLs. */ -int32 * +int32 * int44in(char *input_string) { - int32 *foo = (int32 *) palloc(4 * sizeof(int32)); - register int i = 0; + int32 *foo = (int32 *) palloc(4 * sizeof(int32)); + register int i = 0; i = sscanf(input_string, "%d, %d, %d, %d", @@ -151,16 +151,16 @@ int44in(char *input_string) /* * int28out - converts internal form to "num num ..." */ -char * +char * int44out(int32 an_array[]) { - int temp = 4; - char *output_string = NULL; - int i; + int temp = 4; + char *output_string = NULL; + int i; if (temp > 0) { - char *walk; + char *walk; output_string = (char *) palloc(16 * temp); /* assume 15 digits + * sign */ @@ -194,10 +194,10 @@ int4in(char *num) /* * int4out - converts int4 to "num" */ -char * +char * int4out(int32 l) { - char *result; + char *result; result = (char *) palloc(12); /* assumes sign, 10 digits, '\0' */ ltoa(l, result); @@ -243,108 +243,133 @@ i4toi2(int32 arg1) * intgt - returns 1 iff arg1 > arg2 * intge - returns 1 iff arg1 >= arg2 */ -bool int4eq(int32 arg1, int32 arg2) +bool +int4eq(int32 arg1, int32 arg2) { return (arg1 == arg2); } -bool int4ne(int32 arg1, int32 arg2) +bool +int4ne(int32 arg1, int32 arg2) { return (arg1 != arg2); } -bool int4lt(int32 arg1, int32 arg2) +bool +int4lt(int32 arg1, int32 arg2) { return (arg1 < arg2); } -bool int4le(int32 arg1, int32 arg2) +bool +int4le(int32 arg1, int32 arg2) { return (arg1 <= arg2); } -bool int4gt(int32 arg1, int32 arg2) +bool +int4gt(int32 arg1, int32 arg2) { return (arg1 > arg2); } -bool int4ge(int32 arg1, int32 arg2) +bool +int4ge(int32 arg1, int32 arg2) { return (arg1 >= arg2); } -bool int2eq(int16 arg1, int16 arg2) +bool +int2eq(int16 arg1, int16 arg2) { return (arg1 == arg2); } -bool int2ne(int16 arg1, int16 arg2) +bool +int2ne(int16 arg1, int16 arg2) { return (arg1 != arg2); } -bool int2lt(int16 arg1, int16 arg2) +bool +int2lt(int16 arg1, int16 arg2) { return (arg1 < arg2); } -bool int2le(int16 arg1, int16 arg2) +bool +int2le(int16 arg1, int16 arg2) { return (arg1 <= arg2); } -bool int2gt(int16 arg1, int16 arg2) +bool +int2gt(int16 arg1, int16 arg2) { return (arg1 > arg2); } -bool int2ge(int16 arg1, int16 arg2) +bool +int2ge(int16 arg1, int16 arg2) { return (arg1 >= arg2); } -bool int24eq(int32 arg1, int32 arg2) +bool +int24eq(int32 arg1, int32 arg2) { return (arg1 == arg2); } -bool int24ne(int32 arg1, int32 arg2) +bool +int24ne(int32 arg1, int32 arg2) { return (arg1 != arg2); } -bool int24lt(int32 arg1, int32 arg2) +bool +int24lt(int32 arg1, int32 arg2) { return (arg1 < arg2); } -bool int24le(int32 arg1, int32 arg2) +bool +int24le(int32 arg1, int32 arg2) { return (arg1 <= arg2); } -bool int24gt(int32 arg1, int32 arg2) +bool +int24gt(int32 arg1, int32 arg2) { return (arg1 > arg2); } -bool int24ge(int32 arg1, int32 arg2) +bool +int24ge(int32 arg1, int32 arg2) { return (arg1 >= arg2); } -bool int42eq(int32 arg1, int32 arg2) +bool +int42eq(int32 arg1, int32 arg2) { return (arg1 == arg2); } -bool int42ne(int32 arg1, int32 arg2) +bool +int42ne(int32 arg1, int32 arg2) { return (arg1 != arg2); } -bool int42lt(int32 arg1, int32 arg2) +bool +int42lt(int32 arg1, int32 arg2) { return (arg1 < arg2); } -bool int42le(int32 arg1, int32 arg2) +bool +int42le(int32 arg1, int32 arg2) { return (arg1 <= arg2); } -bool int42gt(int32 arg1, int32 arg2) +bool +int42gt(int32 arg1, int32 arg2) { return (arg1 > arg2); } -bool int42ge(int32 arg1, int32 arg2) +bool +int42ge(int32 arg1, int32 arg2) { return (arg1 >= arg2); } -bool keyfirsteq(int16 * arg1, int16 arg2) +bool +keyfirsteq(int16 * arg1, int16 arg2) { return (*arg1 == arg2); } @@ -355,86 +380,106 @@ bool keyfirsteq(int16 * arg1, int16 arg2) * int[24]mul - returns arg1 * arg2 * int[24]div - returns arg1 / arg2 */ -int32 int4um(int32 arg) +int32 +int4um(int32 arg) { return (-arg); } -int32 int4pl(int32 arg1, int32 arg2) +int32 +int4pl(int32 arg1, int32 arg2) { return (arg1 + arg2); } -int32 int4mi(int32 arg1, int32 arg2) +int32 +int4mi(int32 arg1, int32 arg2) { return (arg1 - arg2); } -int32 int4mul(int32 arg1, int32 arg2) +int32 +int4mul(int32 arg1, int32 arg2) { return (arg1 * arg2); } -int32 int4div(int32 arg1, int32 arg2) +int32 +int4div(int32 arg1, int32 arg2) { return (arg1 / arg2); } -int32 int4inc(int32 arg) +int32 +int4inc(int32 arg) { return (arg + (int32) 1); } -int16 int2um(int16 arg) +int16 +int2um(int16 arg) { return (-arg); } -int16 int2pl(int16 arg1, int16 arg2) +int16 +int2pl(int16 arg1, int16 arg2) { return (arg1 + arg2); } -int16 int2mi(int16 arg1, int16 arg2) +int16 +int2mi(int16 arg1, int16 arg2) { return (arg1 - arg2); } -int16 int2mul(int16 arg1, int16 arg2) +int16 +int2mul(int16 arg1, int16 arg2) { return (arg1 * arg2); } -int16 int2div(int16 arg1, int16 arg2) +int16 +int2div(int16 arg1, int16 arg2) { return (arg1 / arg2); } -int16 int2inc(int16 arg) +int16 +int2inc(int16 arg) { return (arg + (int16) 1); } -int32 int24pl(int32 arg1, int32 arg2) +int32 +int24pl(int32 arg1, int32 arg2) { return (arg1 + arg2); } -int32 int24mi(int32 arg1, int32 arg2) +int32 +int24mi(int32 arg1, int32 arg2) { return (arg1 - arg2); } -int32 int24mul(int32 arg1, int32 arg2) +int32 +int24mul(int32 arg1, int32 arg2) { return (arg1 * arg2); } -int32 int24div(int32 arg1, int32 arg2) +int32 +int24div(int32 arg1, int32 arg2) { return (arg1 / arg2); } -int32 int42pl(int32 arg1, int32 arg2) +int32 +int42pl(int32 arg1, int32 arg2) { return (arg1 + arg2); } -int32 int42mi(int32 arg1, int32 arg2) +int32 +int42mi(int32 arg1, int32 arg2) { return (arg1 - arg2); } -int32 int42mul(int32 arg1, int32 arg2) +int32 +int42mul(int32 arg1, int32 arg2) { return (arg1 * arg2); } -int32 int42div(int32 arg1, int32 arg2) +int32 +int42div(int32 arg1, int32 arg2) { return (arg1 / arg2); } @@ -442,19 +487,23 @@ int32 int42div(int32 arg1, int32 arg2) /* * int[24]mod - returns arg1 mod arg2 */ -int32 int4mod(int32 arg1, int32 arg2) +int32 +int4mod(int32 arg1, int32 arg2) { return (arg1 % arg2); } -int32 int2mod(int16 arg1, int16 arg2) +int32 +int2mod(int16 arg1, int16 arg2) { return (arg1 % arg2); } -int32 int24mod(int32 arg1, int32 arg2) +int32 +int24mod(int32 arg1, int32 arg2) { return (arg1 % arg2); } -int32 int42mod(int32 arg1, int32 arg2) +int32 +int42mod(int32 arg1, int32 arg2) { return (arg1 % arg2); } @@ -465,7 +514,7 @@ int32 int42mod(int32 arg1, int32 arg2) int32 int4fac(int32 arg1) { - int32 result; + int32 result; if (arg1 < 1) result = 0; @@ -478,7 +527,7 @@ int4fac(int32 arg1) int32 int2fac(int16 arg1) { - int16 result; + int16 result; if (arg1 < 1) result = 0; diff --git a/src/backend/utils/adt/like.c b/src/backend/utils/adt/like.c index a3fdbce8855..5e9c0e7ebbe 100644 --- a/src/backend/utils/adt/like.c +++ b/src/backend/utils/adt/like.c @@ -22,7 +22,7 @@ #include "utils/palloc.h" #include "utils/builtins.h" /* where the function declarations go */ -static int like(char *text, char *p); +static int like(char *text, char *p); /* * interface routines called by the function manager @@ -36,12 +36,12 @@ static int like(char *text, char *p); p - the pattern charlen - the length of the string */ -static bool +static bool fixedlen_like(char *s, struct varlena * p, int charlen) { - char *sterm, - *pterm; - int result; + char *sterm, + *pterm; + int result; if (!s || !p) return FALSE; @@ -72,7 +72,7 @@ fixedlen_like(char *s, struct varlena * p, int charlen) bool char2like(uint16 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_like(s, p, 2)); } @@ -86,7 +86,7 @@ char2nlike(uint16 arg1, struct varlena * p) bool char4like(uint32 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_like(s, p, 4)); } @@ -150,7 +150,7 @@ textnlike(struct varlena * s, struct varlena * p) } -/* $Revision: 1.7 $ +/* $Revision: 1.8 $ ** "like.c" A first attempt at a LIKE operator for Postgres95. ** ** Originally written by Rich $alz, mirror!rs, Wed Nov 26 19:03:17 EST 1986. @@ -187,7 +187,7 @@ textnlike(struct varlena * s, struct varlena * p) static int DoMatch(register char *text, register char *p) { - register int matched; + register int matched; for (; *p; text++, p++) { @@ -195,28 +195,28 @@ DoMatch(register char *text, register char *p) return LIKE_ABORT; switch (*p) { - case '\\': - /* Literal match with following character. */ - p++; - /* FALLTHROUGH */ - default: - if (*text != *p) - return LIKE_FALSE; - continue; - case '_': - /* Match anything. */ - continue; - case '%': - while (*++p == '%') - /* Consecutive percents act just like one. */ + case '\\': + /* Literal match with following character. */ + p++; + /* FALLTHROUGH */ + default: + if (*text != *p) + return LIKE_FALSE; continue; - if (*p == '\0') - /* Trailing percent matches everything. */ - return LIKE_TRUE; - while (*text) - if ((matched = DoMatch(text++, p)) != LIKE_FALSE) - return matched; - return LIKE_ABORT; + case '_': + /* Match anything. */ + continue; + case '%': + while (*++p == '%') + /* Consecutive percents act just like one. */ + continue; + if (*p == '\0') + /* Trailing percent matches everything. */ + return LIKE_TRUE; + while (*text) + if ((matched = DoMatch(text++, p)) != LIKE_FALSE) + return matched; + return LIKE_ABORT; } } diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index f04152cf6d2..90d9c0289e3 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.8 1997/09/07 04:50:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.9 1997/09/08 02:30:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ nonnullvalue(Datum value, bool * isNull) bool oidrand(Oid o, int32 X) { - bool result; + bool result; if (X == 0) return true; diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index 9eb5ed36281..9e929c579c5 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.32 1997/09/07 04:50:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.33 1997/09/08 02:30:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,14 +45,14 @@ static AbsoluteTime tm2abstime(struct tm * tm, int tz); AbsoluteTime GetCurrentAbsoluteTime(void) { - time_t now; + time_t now; #ifdef USE_POSIX_TIME - struct tm *tm; + struct tm *tm; now = time(NULL); #else /* ! USE_POSIX_TIME */ - struct timeb tb; /* the old V7-ism */ + struct timeb tb; /* the old V7-ism */ ftime(&tb); now = tb.time; @@ -109,7 +109,7 @@ GetCurrentAbsoluteTime(void) void GetCurrentTime(struct tm * tm) { - int tz; + int tz; abstime2tm(GetCurrentTransactionStartTime(), &tz, tm, NULL); @@ -121,10 +121,10 @@ void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn) { #ifdef USE_POSIX_TIME - struct tm *tx; + struct tm *tx; #else /* ! USE_POSIX_TIME */ - struct timeb tb; /* the old V7-ism */ + struct timeb tb; /* the old V7-ism */ ftime(&tb); #endif @@ -198,11 +198,11 @@ abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn) * Convert a tm structure to abstime. * Note that tm has full year (not 1900-based) and 1-based month. */ -static AbsoluteTime +static AbsoluteTime tm2abstime(struct tm * tm, int tz) { - int day, - sec; + int day, + sec; /* validate, before going out of range on some members */ if (tm->tm_year < 1901 || tm->tm_year > 2038 @@ -241,18 +241,18 @@ tm2abstime(struct tm * tm, int tz) AbsoluteTime nabstimein(char *str) { - AbsoluteTime result; + AbsoluteTime result; - double fsec; - int tz = 0; - struct tm date, - *tm = &date; + double fsec; + int tz = 0; + struct tm date, + *tm = &date; - char *field[MAXDATEFIELDS]; - char lowstr[MAXDATELEN + 1]; - int dtype; - int nf, - ftype[MAXDATEFIELDS]; + char *field[MAXDATEFIELDS]; + char lowstr[MAXDATELEN + 1]; + int dtype; + int nf, + ftype[MAXDATEFIELDS]; if (!PointerIsValid(str)) elog(WARN, "Bad (null) abstime external representation", NULL); @@ -270,34 +270,34 @@ nabstimein(char *str) switch (dtype) { - case DTK_DATE: - result = tm2abstime(tm, tz); - break; + case DTK_DATE: + result = tm2abstime(tm, tz); + break; - case DTK_EPOCH: - result = EPOCH_ABSTIME; - break; + case DTK_EPOCH: + result = EPOCH_ABSTIME; + break; - case DTK_CURRENT: - result = CURRENT_ABSTIME; - break; + case DTK_CURRENT: + result = CURRENT_ABSTIME; + break; - case DTK_LATE: - result = NOEND_ABSTIME; - break; + case DTK_LATE: + result = NOEND_ABSTIME; + break; - case DTK_EARLY: - result = NOSTART_ABSTIME; - break; + case DTK_EARLY: + result = NOSTART_ABSTIME; + break; - case DTK_INVALID: - result = INVALID_ABSTIME; - break; + case DTK_INVALID: + result = INVALID_ABSTIME; + break; - default: - elog(WARN, "Bad abstime (internal coding error) '%s'", str); - result = INVALID_ABSTIME; - break; + default: + elog(WARN, "Bad abstime (internal coding error) '%s'", str); + result = INVALID_ABSTIME; + break; }; return result; @@ -307,41 +307,41 @@ nabstimein(char *str) /* nabstimeout() * Given an AbsoluteTime return the English text version of the date */ -char * +char * nabstimeout(AbsoluteTime time) { - char *result; - int tz; - double fsec = 0; - struct tm tt, - *tm = &tt; - char buf[MAXDATELEN + 1]; - char zone[MAXDATELEN + 1], - *tzn = zone; + char *result; + int tz; + double fsec = 0; + struct tm tt, + *tm = &tt; + char buf[MAXDATELEN + 1]; + char zone[MAXDATELEN + 1], + *tzn = zone; switch (time) { - case EPOCH_ABSTIME: - strcpy(buf, EPOCH); - break; - case INVALID_ABSTIME: - strcpy(buf, INVALID); - break; - case CURRENT_ABSTIME: - strcpy(buf, DCURRENT); - break; - case NOEND_ABSTIME: - strcpy(buf, LATE); - break; - case NOSTART_ABSTIME: - strcpy(buf, EARLY); - break; - default: - abstime2tm(time, &tz, tm, tzn); + case EPOCH_ABSTIME: + strcpy(buf, EPOCH); + break; + case INVALID_ABSTIME: + strcpy(buf, INVALID); + break; + case CURRENT_ABSTIME: + strcpy(buf, DCURRENT); + break; + case NOEND_ABSTIME: + strcpy(buf, LATE); + break; + case NOSTART_ABSTIME: + strcpy(buf, EARLY); + break; + default: + abstime2tm(time, &tz, tm, tzn); #if DATEDEBUG #endif - EncodeDateTime(tm, fsec, &tz, &tzn, DateStyle, buf); - break; + EncodeDateTime(tm, fsec, &tz, &tzn, DateStyle, buf); + break; } result = PALLOC(strlen(buf) + 1); @@ -489,11 +489,11 @@ abstimege(AbsoluteTime t1, AbsoluteTime t2) AbsoluteTime datetime_abstime(DateTime * datetime) { - AbsoluteTime result; + AbsoluteTime result; - double fsec; - struct tm tt, - *tm = &tt; + double fsec; + struct tm tt, + *tm = &tt; if (!PointerIsValid(datetime)) { @@ -540,39 +540,39 @@ datetime_abstime(DateTime * datetime) /* abstime_datetime() * Convert datetime to abstime. */ -DateTime * +DateTime * abstime_datetime(AbsoluteTime abstime) { - DateTime *result; + DateTime *result; if (!PointerIsValid(result = PALLOCTYPE(DateTime))) elog(WARN, "Unable to allocate space to convert abstime to datetime", NULL); switch (abstime) { - case INVALID_ABSTIME: - DATETIME_INVALID(*result); - break; + case INVALID_ABSTIME: + DATETIME_INVALID(*result); + break; - case NOSTART_ABSTIME: - DATETIME_NOBEGIN(*result); - break; + case NOSTART_ABSTIME: + DATETIME_NOBEGIN(*result); + break; - case NOEND_ABSTIME: - DATETIME_NOEND(*result); - break; + case NOEND_ABSTIME: + DATETIME_NOEND(*result); + break; - case EPOCH_ABSTIME: - DATETIME_EPOCH(*result); - break; + case EPOCH_ABSTIME: + DATETIME_EPOCH(*result); + break; - case CURRENT_ABSTIME: - DATETIME_CURRENT(*result); - break; + case CURRENT_ABSTIME: + DATETIME_CURRENT(*result); + break; - default: - *result = abstime + ((date2j(1970, 1, 1) - date2j(2000, 1, 1)) * 86400); - break; + default: + *result = abstime + ((date2j(1970, 1, 1) - date2j(2000, 1, 1)) * 86400); + break; }; return (result); diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index b0de03ff602..1c8f4563f7b 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.7 1997/09/07 04:50:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.8 1997/09/08 02:30:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,10 +32,10 @@ * [Old] Currently if strlen(s) < NAMEDATALEN, the extra chars are nulls * Now, always NULL terminated */ -NameData * +NameData * namein(char *s) { - NameData *result; + NameData *result; if (s == NULL) return (NULL); @@ -48,7 +48,7 @@ namein(char *s) /* * nameout - converts internal reprsentation to "..." */ -char * +char * nameout(NameData * s) { if (s == NULL) @@ -167,9 +167,9 @@ namestrcpy(Name name, char *str) int namestrcat(Name name, char *str) { - int i; - char *p, - *q; + int i; + char *p, + *q; if (!name || !str) return (-1); @@ -206,8 +206,8 @@ namestrcmp(Name name, char *str) uint32 NameComputeLength(Name name) { - char *charP; - int length; + char *charP; + int length; for (length = 0, charP = name->data; length < NAMEDATALEN && *charP != '\0'; diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c index 0bc51eb6f19..eb8f6533277 100644 --- a/src/backend/utils/adt/not_in.c +++ b/src/backend/utils/adt/not_in.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.4 1997/09/07 04:50:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.5 1997/09/08 02:30:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,7 +29,7 @@ #include "access/relscan.h" #include "utils/builtins.h" /* where function decls go */ -static int my_varattno(Relation rd, char *a); +static int my_varattno(Relation rd, char *a); /* ---------------------------------------------------------------- * @@ -38,20 +38,20 @@ static int my_varattno(Relation rd, char *a); bool int4notin(int16 not_in_arg, char *relation_and_attr) { - Relation relation_to_scan; - int left_side_argument, - integer_value; - HeapTuple current_tuple; - HeapScanDesc scan_descriptor; - bool dummy, - retval; - int attrid; - char *relation, - *attribute; - char my_copy[32]; - Datum value; - NameData relNameData; - ScanKeyData skeyData; + Relation relation_to_scan; + int left_side_argument, + integer_value; + HeapTuple current_tuple; + HeapScanDesc scan_descriptor; + bool dummy, + retval; + int attrid; + char *relation, + *attribute; + char my_copy[32]; + Datum value; + NameData relNameData; + ScanKeyData skeyData; strcpy(my_copy, relation_and_attr); @@ -116,7 +116,7 @@ oidnotin(Oid the_oid, char *compare) static int my_varattno(Relation rd, char *a) { - int i; + int i; for (i = 0; i < rd->rd_rel->relnatts; i++) { diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index 3fd4ae382be..3c698c93c4b 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.14 1997/09/07 04:50:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.15 1997/09/08 02:30:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ int32 pg_atoi(char *s, int size, int c) { - long l; - char *badp = (char *) NULL; + long l; + char *badp = (char *) NULL; Assert(s); @@ -43,47 +43,47 @@ pg_atoi(char *s, int size, int c) switch (size) { - case sizeof(int32): + case sizeof(int32): #ifdef HAS_LONG_LONG - /* won't get ERANGE on these with 64-bit longs... */ - if (l < -0x80000000L) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } - if (l > 0x7fffffffL) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } + /* won't get ERANGE on these with 64-bit longs... */ + if (l < -0x80000000L) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } + if (l > 0x7fffffffL) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } #endif /* HAS_LONG_LONG */ - break; - case sizeof(int16): - if (l < -0x8000) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } - if (l > 0x7fff) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } - break; - case sizeof(int8): - if (l < -0x80) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } - if (l > 0x7f) - { - errno = ERANGE; - elog(WARN, "pg_atoi: error reading \"%s\": %m", s); - } - break; - default: - elog(WARN, "pg_atoi: invalid result size: %d", size); + break; + case sizeof(int16): + if (l < -0x8000) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } + if (l > 0x7fff) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } + break; + case sizeof(int8): + if (l < -0x80) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } + if (l > 0x7f) + { + errno = ERANGE; + elog(WARN, "pg_atoi: error reading \"%s\": %m", s); + } + break; + default: + elog(WARN, "pg_atoi: invalid result size: %d", size); } return ((int32) l); } @@ -146,9 +146,9 @@ int ftoa(double value, char *ascii, int width, int prec1, char format) { #ifndef HAVE_FCVT - char out[256]; - char fmt[256]; - int ret; + char out[256]; + char fmt[256]; + int ret; sprintf(fmt, "%%%d.%d%c", width, prec1, format); sprintf(out, fmt, value); @@ -161,14 +161,14 @@ ftoa(double value, char *ascii, int width, int prec1, char format) strcpy(ascii, out); return (ret); #else - auto int expon; - auto int sign; - register int avail = 0; - register char *a = NULL; - register char *p = NULL; - char mode; - int lowercase; - int prec; + auto int expon; + auto int sign; + register int avail = 0; + register char *a = NULL; + register char *p = NULL; + char mode; + int lowercase; + int prec; /* extern char *ecvt(), *fcvt();*/ @@ -349,13 +349,13 @@ frac_out: int atof1(char *str, double *val) { - register char *p; - double v; - double fact; - int minus; - register char c; - int expon; - register int gotmant; + register char *p; + double v; + double fact; + int minus; + register char c; + int expon; + register int gotmant; v = 0.0; p = str; @@ -372,11 +372,11 @@ atof1(char *str, double *val) /* handle possible sign */ switch (c) { - case '-': - minus++; + case '-': + minus++; - case '+': - p++; + case '+': + p++; } /* skip blanks after sign */ diff --git a/src/backend/utils/adt/oid.c b/src/backend/utils/adt/oid.c index 864c272c793..0e064b44a38 100644 --- a/src/backend/utils/adt/oid.c +++ b/src/backend/utils/adt/oid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.9 1997/09/07 04:50:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oid.c,v 1.10 1997/09/08 02:30:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,11 +28,11 @@ * Note: * Fills any nonexistent digits with NULL oids. */ -Oid * +Oid * oid8in(char *oidString) { - register Oid(*result)[]; - int nums; + register Oid(*result)[]; + int nums; if (oidString == NULL) return (NULL); @@ -57,13 +57,13 @@ oid8in(char *oidString) /* * oid8out - converts internal form to "num num ..." */ -char * +char * oid8out(Oid(*oidArray)[]) { - register int num; - register Oid *sp; - register char *rp; - char *result; + register int num; + register Oid *sp; + register char *rp; + char *result; if (oidArray == NULL) { @@ -93,7 +93,7 @@ oidin(char *s) return (int4in(s)); } -char * +char * oidout(Oid o) { return (int4out(o)); diff --git a/src/backend/utils/adt/oidint2.c b/src/backend/utils/adt/oidint2.c index 009ab233f78..d40dae7a6cc 100644 --- a/src/backend/utils/adt/oidint2.c +++ b/src/backend/utils/adt/oidint2.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.2 1997/09/07 04:50:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint2.c,v 1.3 1997/09/08 02:30:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,8 +21,8 @@ OidInt2 oidint2in(char *o) { - OidInt2 oi; - char *p; + OidInt2 oi; + char *p; oi = (OidInt2) palloc(sizeof(OidInt2Data)); @@ -42,10 +42,10 @@ oidint2in(char *o) return (oi); } -char * +char * oidint2out(OidInt2 o) { - char *r; + char *r; /* * -2147483647/-32767 0 1 1234567890123456789 @@ -111,7 +111,7 @@ oidint2cmp(OidInt2 o1, OidInt2 o2) OidInt2 mkoidint2(Oid v_oid, uint16 v_int2) { - OidInt2 o; + OidInt2 o; o = (OidInt2) palloc(sizeof(OidInt2Data)); o->oi_oid = v_oid; diff --git a/src/backend/utils/adt/oidint4.c b/src/backend/utils/adt/oidint4.c index c4da5141acf..18931efc69a 100644 --- a/src/backend/utils/adt/oidint4.c +++ b/src/backend/utils/adt/oidint4.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.2 1997/09/07 04:50:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidint4.c,v 1.3 1997/09/08 02:30:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,8 +20,8 @@ OidInt4 oidint4in(char *o) { - OidInt4 oi; - char *p; + OidInt4 oi; + char *p; oi = (OidInt4) palloc(sizeof(OidInt4Data)); @@ -41,10 +41,10 @@ oidint4in(char *o) return (oi); } -char * +char * oidint4out(OidInt4 o) { - char *r; + char *r; /* * -2147483647/-2147483647 0 1 2 @@ -60,8 +60,8 @@ bool oidint4lt(OidInt4 o1, OidInt4 o2) { return - ((bool) (o1->oi_oid < o2->oi_oid || - (o1->oi_oid == o2->oi_oid && o1->oi_int4 < o2->oi_int4))); + ((bool) (o1->oi_oid < o2->oi_oid || + (o1->oi_oid == o2->oi_oid && o1->oi_int4 < o2->oi_int4))); } bool @@ -111,7 +111,7 @@ oidint4cmp(OidInt4 o1, OidInt4 o2) OidInt4 mkoidint4(Oid v_oid, uint32 v_int4) { - OidInt4 o; + OidInt4 o; o = (OidInt4) palloc(sizeof(OidInt4Data)); o->oi_oid = v_oid; diff --git a/src/backend/utils/adt/oidname.c b/src/backend/utils/adt/oidname.c index 30a081f2531..915b953ae49 100644 --- a/src/backend/utils/adt/oidname.c +++ b/src/backend/utils/adt/oidname.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.5 1997/09/07 04:50:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/oidname.c,v 1.6 1997/09/08 02:30:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,8 +23,8 @@ OidName oidnamein(char *inStr) { - OidName oc; - char *inptr; + OidName oc; + char *inptr; oc = (OidName) palloc(sizeof(OidNameData)); @@ -45,12 +45,12 @@ oidnamein(char *inStr) return oc; } -char * +char * oidnameout(OidName oidname) { - char buf[30 + NAMEDATALEN]; /* oidname length + oid - * length + some safety */ - char *res; + char buf[30 + NAMEDATALEN]; /* oidname length + oid length + + * some safety */ + char *res; sprintf(buf, "%d,%s", oidname->id, oidname->name.data); res = pstrdup(buf); @@ -115,7 +115,7 @@ oidnamecmp(OidName o1, OidName o2) OidName mkoidname(Oid id, char *name) { - OidName oidname; + OidName oidname; oidname = (OidName) palloc(sizeof(Oid) + NAMEDATALEN); diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index 99acb57b58f..fb8a512ed79 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -1,7 +1,7 @@ /* * Edmund Mergl <E.Mergl@bawue.de> * - * $Id: oracle_compat.c,v 1.8 1997/09/07 04:50:38 momjian Exp $ + * $Id: oracle_compat.c,v 1.9 1997/09/08 02:30:57 momjian Exp $ * */ @@ -10,16 +10,16 @@ #include "postgres.h" -text *lower(text * string); -text *upper(text * string); -text *initcap(text * string); -text *lpad(text * string1, int4 len, text * string2); -text *rpad(text * string1, int4 len, text * string2); -text *btrim(text * string, text * set); -text *ltrim(text * string, text * set); -text *rtrim(text * string, text * set); -text *substr(text * string, int4 m, int4 n); -text *translate(text * string, char from, char to); +text *lower(text * string); +text *upper(text * string); +text *initcap(text * string); +text *lpad(text * string1, int4 len, text * string2); +text *rpad(text * string1, int4 len, text * string2); +text *btrim(text * string, text * set); +text *ltrim(text * string, text * set); +text *rtrim(text * string, text * set); +text *substr(text * string, int4 m, int4 n); +text *translate(text * string, char from, char to); /******************************************************************** @@ -36,13 +36,13 @@ text *translate(text * string, char from, char to); * ********************************************************************/ -text * +text * lower(text * string) { - text *ret; - char *ptr, - *ptr_ret; - int m; + text *ret; + char *ptr, + *ptr_ret; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0)) return string; @@ -76,13 +76,13 @@ lower(text * string) * ********************************************************************/ -text * +text * upper(text * string) { - text *ret; - char *ptr, - *ptr_ret; - int m; + text *ret; + char *ptr, + *ptr_ret; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0)) return string; @@ -118,13 +118,13 @@ upper(text * string) * ********************************************************************/ -text * +text * initcap(text * string) { - text *ret; - char *ptr, - *ptr_ret; - int m; + text *ret; + char *ptr, + *ptr_ret; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0)) return string; @@ -169,15 +169,15 @@ initcap(text * string) * ********************************************************************/ -text * +text * lpad(text * string1, int4 len, text * string2) { - text *ret; - char *ptr1, - *ptr2, - *ptr_ret; - int m, - n; + text *ret; + char *ptr1, + *ptr2, + *ptr_ret; + int m, + n; if ((string1 == (text *) NULL) || (len <= (VARSIZE(string1) - VARHDRSZ)) || @@ -225,15 +225,15 @@ lpad(text * string1, int4 len, text * string2) * ********************************************************************/ -text * +text * rpad(text * string1, int4 len, text * string2) { - text *ret; - char *ptr1, - *ptr2, - *ptr_ret; - int m, - n; + text *ret; + char *ptr1, + *ptr2, + *ptr_ret; + int m, + n; if ((string1 == (text *) NULL) || (len <= (VARSIZE(string1) - VARHDRSZ)) || @@ -281,15 +281,15 @@ rpad(text * string1, int4 len, text * string2) * ********************************************************************/ -text * +text * btrim(text * string, text * set) { - text *ret; - char *ptr, - *end, - *ptr2, - *end2; - int m; + text *ret; + char *ptr, + *end, + *ptr2, + *end2; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0) || @@ -367,14 +367,14 @@ btrim(text * string, text * set) * ********************************************************************/ -text * +text * ltrim(text * string, text * set) { - text *ret; - char *ptr, - *ptr2, - *end2; - int m; + text *ret; + char *ptr, + *ptr2, + *end2; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0) || @@ -430,15 +430,15 @@ ltrim(text * string, text * set) * ********************************************************************/ -text * +text * rtrim(text * string, text * set) { - text *ret; - char *ptr, - *ptr2, - *end2, - *ptr_ret; - int m; + text *ret; + char *ptr, + *ptr2, + *end2, + *ptr_ret; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0) || @@ -502,13 +502,13 @@ rtrim(text * string, text * set) * ********************************************************************/ -text * +text * substr(text * string, int4 m, int4 n) { - text *ret; - char *ptr, - *ptr_ret; - int len; + text *ret; + char *ptr, + *ptr_ret; + int len; if ((string == (text *) NULL) || (m <= 0) || (n <= 0) || @@ -548,13 +548,13 @@ substr(text * string, int4 m, int4 n) * ********************************************************************/ -text * +text * translate(text * string, char from, char to) { - text *ret; - char *ptr, - *ptr_ret; - int m; + text *ret; + char *ptr, + *ptr_ret; + int m; if ((string == (text *) NULL) || ((m = VARSIZE(string) - VARHDRSZ) <= 0)) diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index e7d982785ba..5c94ca8bb8d 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.8 1997/09/07 04:50:39 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.9 1997/09/08 02:30:58 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -47,13 +47,13 @@ struct cached_re_str { struct varlena *cre_text; /* pattern as a text* */ - char *cre_s; /* pattern as null-terminated string */ - int cre_type; /* compiled-type: extended,icase etc */ - regex_t cre_re; /* the compiled regular expression */ - unsigned long cre_lru; /* lru tag */ + char *cre_s; /* pattern as null-terminated string */ + int cre_type; /* compiled-type: extended,icase etc */ + regex_t cre_re; /* the compiled regular expression */ + unsigned long cre_lru; /* lru tag */ }; -static int rec = 0; /* # of cached re's */ +static int rec = 0; /* # of cached re's */ static struct cached_re_str rev[MAX_CACHED_RES]; /* cached re's */ static unsigned long lru; /* system lru tag */ @@ -62,11 +62,11 @@ static unsigned long lru; /* system lru tag */ static int RE_compile_and_execute(struct varlena * text_re, char *text, int cflags) { - int oldest; - int n; - int i; - char *re; - int regcomp_result; + int oldest; + int n; + int i; + char *re; + int regcomp_result; re = textout(text_re); /* find a previously compiled regular expression */ @@ -151,7 +151,7 @@ RE_compile_and_execute(struct varlena * text_re, char *text, int cflags) } else { - char errMsg[1000]; + char errMsg[1000]; /* re didn't compile */ rev[oldest].cre_s = (char *) NULL; @@ -178,11 +178,11 @@ RE_compile_and_execute(struct varlena * text_re, char *text, int cflags) p - the pattern charlen - the length of the string */ -static bool +static bool fixedlen_regexeq(char *s, struct varlena * p, int charlen, int cflags) { - char *sterm; - int result; + char *sterm; + int result; if (!s || !p) return FALSE; @@ -206,7 +206,7 @@ fixedlen_regexeq(char *s, struct varlena * p, int charlen, int cflags) bool char2regexeq(uint16 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_regexeq(s, p, 2, REG_EXTENDED)); } @@ -220,7 +220,7 @@ char2regexne(uint16 arg1, struct varlena * p) bool char4regexeq(uint32 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_regexeq(s, p, 4, REG_EXTENDED)); } @@ -291,7 +291,7 @@ textregexne(struct varlena * s, struct varlena * p) bool char2icregexeq(uint16 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_regexeq(s, p, 2, REG_ICASE | REG_EXTENDED)); } @@ -306,7 +306,7 @@ char2icregexne(uint16 arg1, struct varlena * p) bool char4icregexeq(uint32 arg1, struct varlena * p) { - char *s = (char *) &arg1; + char *s = (char *) &arg1; return (fixedlen_regexeq(s, p, 4, REG_ICASE | REG_EXTENDED)); } diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index 6a4e8b01e50..ea3a66fe05e 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.6 1997/09/07 04:50:41 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.7 1997/09/08 02:30:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,12 +33,12 @@ int32 regprocin(char *proname) { - Relation proc; - HeapScanDesc procscan; - HeapTuple proctup; - ScanKeyData key; - RegProcedure result = (Oid) 0; - bool isnull; + Relation proc; + HeapScanDesc procscan; + HeapTuple proctup; + ScanKeyData key; + RegProcedure result = (Oid) 0; + bool isnull; if (proname == NULL) return (0); @@ -66,21 +66,21 @@ regprocin(char *proname) proctup = heap_getnext(procscan, 0, (Buffer *) NULL); switch (HeapTupleIsValid(proctup)) { - case 1: - result = (RegProcedure) heap_getattr(proctup, - InvalidBuffer, - ObjectIdAttributeNumber, + case 1: + result = (RegProcedure) heap_getattr(proctup, + InvalidBuffer, + ObjectIdAttributeNumber, RelationGetTupleDescriptor(proc), - &isnull); - if (isnull) - { - elog(FATAL, "regprocin: null procedure %s", proname); - } - break; - case 0: - result = (RegProcedure) 0; + &isnull); + if (isnull) + { + elog(FATAL, "regprocin: null procedure %s", proname); + } + break; + case 0: + result = (RegProcedure) 0; #ifdef EBUG - elog(DEBUG, "regprocin: no such procedure %s", proname); + elog(DEBUG, "regprocin: no such procedure %s", proname); #endif /* defined(EBUG) */ } heap_endscan(procscan); @@ -91,14 +91,14 @@ regprocin(char *proname) /* * regprocout - converts proid to "proname" */ -char * +char * regprocout(RegProcedure proid) { - Relation proc; - HeapScanDesc procscan; - HeapTuple proctup; - char *result; - ScanKeyData key; + Relation proc; + HeapScanDesc procscan; + HeapTuple proctup; + char *result; + ScanKeyData key; result = (char *) palloc(NAMEDATALEN); proc = heap_openr(ProcedureRelationName); @@ -125,24 +125,24 @@ regprocout(RegProcedure proid) proctup = heap_getnext(procscan, 0, (Buffer *) NULL); switch (HeapTupleIsValid(proctup)) { - char *s; - bool isnull; + char *s; + bool isnull; - case 1: - s = (char *) heap_getattr(proctup, InvalidBuffer, 1, + case 1: + s = (char *) heap_getattr(proctup, InvalidBuffer, 1, RelationGetTupleDescriptor(proc), &isnull); - if (!isnull) - { - strNcpy(result, s, 16); - break; - } - elog(FATAL, "regprocout: null procedure %d", proid); - /* FALLTHROUGH */ - case 0: - result[0] = '-'; - result[1] = '\0'; + if (!isnull) + { + strNcpy(result, s, 16); + break; + } + elog(FATAL, "regprocout: null procedure %d", proid); + /* FALLTHROUGH */ + case 0: + result[0] = '-'; + result[1] = '\0'; #ifdef EBUG - elog(DEBUG, "regprocout: no such procedure %d", proid); + elog(DEBUG, "regprocout: no such procedure %d", proid); #endif /* defined(EBUG) */ } heap_endscan(procscan); diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 3f8c225ca9e..e58bdf11b8f 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.9 1997/09/07 04:50:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.10 1997/09/08 02:31:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -57,7 +57,7 @@ eqsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); if (NONVALUE(attno) || NONVALUE(relid)) @@ -77,7 +77,7 @@ neqsel(Oid opid, char *value, int32 flag) { - float64 result; + float64 result; result = eqsel(opid, relid, attno, value, flag); *result = 1.0 - *result; @@ -95,14 +95,14 @@ intltsel(Oid opid, int32 value, int32 flag) { - float64 result; - char *highchar, - *lowchar; - long val, - high, - low, - top, - bottom; + float64 result; + char *highchar, + *lowchar; + long val, + high, + low, + top, + bottom; result = (float64) palloc(sizeof(float64data)); if (NONVALUE(attno) || NONVALUE(relid)) @@ -122,7 +122,7 @@ intltsel(Oid opid, if ((flag & SEL_RIGHT && val < low) || (!(flag & SEL_RIGHT) && val > high)) { - float32data nvals; + float32data nvals; nvals = getattdisbursion(relid, (int) attno); if (nvals == 0) @@ -167,8 +167,8 @@ intgtsel(Oid opid, int32 value, int32 flag) { - float64 result; - int notflag; + float64 result; + int notflag; if (flag & 0) notflag = flag & ~SEL_RIGHT; @@ -188,10 +188,10 @@ eqjoinsel(Oid opid, Oid relid2, AttrNumber attno2) { - float64 result; - float32data num1, - num2, - max; + float64 result; + float32data num1, + num2, + max; result = (float64) palloc(sizeof(float64data)); if (NONVALUE(attno1) || NONVALUE(relid1) || @@ -220,7 +220,7 @@ neqjoinsel(Oid opid, Oid relid2, AttrNumber attno2) { - float64 result; + float64 result; result = eqjoinsel(opid, relid1, attno1, relid2, attno2); *result = 1.0 - *result; @@ -237,7 +237,7 @@ intltjoinsel(Oid opid, Oid relid2, AttrNumber attno2) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 3.0; @@ -254,7 +254,7 @@ intgtjoinsel(Oid opid, Oid relid2, AttrNumber attno2) { - float64 result; + float64 result; result = (float64) palloc(sizeof(float64data)); *result = 1.0 / 3.0; @@ -275,12 +275,12 @@ intgtjoinsel(Oid opid, * more efficient. However, the cast will not work * for gethilokey which accesses stahikey in struct statistic. */ -static float32data +static float32data getattdisbursion(Oid relid, AttrNumber attnum) { - HeapTuple atp; - float32data nvals; - int32 ntuples; + HeapTuple atp; + float32data nvals; + int32 ntuples; atp = SearchSysCacheTuple(ATTNUM, ObjectIdGetDatum(relid), @@ -342,8 +342,8 @@ gethilokey(Oid relid, {0, Anum_pg_statistic_staattnum, F_INT2EQ}, {0, Anum_pg_statistic_staop, F_OIDEQ} }; - bool isnull; - HeapTuple tuple; + bool isnull; + HeapTuple tuple; rdesc = heap_openr(StatisticRelationName); @@ -392,8 +392,8 @@ btreesel(Oid operatorObjectId, int32 nIndexKeys, Oid indexrelid) { - float64 result; - float64data resultData; + float64 result; + float64data resultData; if (FunctionalSelectivity(nIndexKeys, attributeNumber)) { @@ -434,11 +434,11 @@ btreenpage(Oid operatorObjectId, int32 nIndexKeys, Oid indexrelid) { - float64 temp, - result; - float64data tempData; - HeapTuple atp; - int npage; + float64 temp, + result; + float64data tempData; + HeapTuple atp; + int npage; if (FunctionalSelectivity(nIndexKeys, attributeNumber)) { @@ -486,10 +486,10 @@ hashsel(Oid operatorObjectId, Oid indexrelid) { - float64 result; - float64data resultData; - HeapTuple atp; - int ntuples; + float64 result; + float64data resultData; + HeapTuple atp; + int ntuples; if (FunctionalSelectivity(nIndexKeys, attributeNumber)) { @@ -549,12 +549,12 @@ hashnpage(Oid operatorObjectId, int32 nIndexKeys, Oid indexrelid) { - float64 temp, - result; - float64data tempData; - HeapTuple atp; - int npage; - int ntuples; + float64 temp, + result; + float64data tempData; + HeapTuple atp; + int npage; + int ntuples; atp = SearchSysCacheTuple(RELOID, ObjectIdGetDatum(indexrelid), 0, 0, 0); diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 72f0a615a66..70bfecc9774 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.6 1997/09/07 04:50:43 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.7 1997/09/08 02:31:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,20 +42,20 @@ extern CommandDest whereToSendOutput; /* defined in tcop/postgres.c */ Oid SetDefine(char *querystr, char *typename) { - Oid setoid; - char *procname = GENERICSETNAME; - char *fileName = "-"; - char realprocname[16]; - HeapTuple tup, - newtup = NULL; - Form_pg_proc proc; - Relation procrel; - int i; - Datum replValue[Natts_pg_proc]; - char replNull[Natts_pg_proc]; - char repl[Natts_pg_proc]; - HeapScanDesc pg_proc_scan; - Buffer buffer; + Oid setoid; + char *procname = GENERICSETNAME; + char *fileName = "-"; + char realprocname[16]; + HeapTuple tup, + newtup = NULL; + Form_pg_proc proc; + Relation procrel; + int i; + Datum replValue[Natts_pg_proc]; + char replNull[Natts_pg_proc]; + char repl[Natts_pg_proc]; + HeapScanDesc pg_proc_scan; + Buffer buffer; ItemPointerData ipdata; static ScanKeyData oidKey[1] = { @@ -149,7 +149,7 @@ SetDefine(char *querystr, char *typename) if (RelationGetRelationTupleForm(procrel)->relhasindex) { - Relation idescs[Num_pg_proc_indices]; + Relation idescs[Num_pg_proc_indices]; CatalogOpenIndices(Num_pg_proc_indices, Name_pg_proc_indices, idescs); CatalogIndexInsert(idescs, Num_pg_proc_indices, procrel, newtup); diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index fe10f2b58e3..f394f081622 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.3 1997/09/07 04:50:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.4 1997/09/08 02:31:03 momjian Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -35,13 +35,13 @@ ItemPointer tidin(char *str) { - char *p, - *coord[NTIDARGS]; - int i; - ItemPointer result; + char *p, + *coord[NTIDARGS]; + int i; + ItemPointer result; - BlockNumber blockNumber; - OffsetNumber offsetNumber; + BlockNumber blockNumber; + OffsetNumber offsetNumber; if (str == NULL) return NULL; @@ -67,14 +67,14 @@ tidin(char *str) * tidout * ---------------------------------------------------------------- */ -char * +char * tidout(ItemPointer itemPtr) { - BlockNumber blockNumber; - OffsetNumber offsetNumber; - BlockId blockId; - char buf[32]; - char *str; + BlockNumber blockNumber; + OffsetNumber offsetNumber; + BlockId blockId; + char buf[32]; + char *str; blockId = &(itemPtr->ip_blkid); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index d9ed6d299c5..09fabfe72a0 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -16,7 +16,7 @@ static const char * cpstr(const char *s, char *buf) { - char in = 0; + char in = 0; while (isspace(*s)) s++; @@ -43,12 +43,12 @@ cpstr(const char *s, char *buf) time_t timestamp_in(const char *timestamp_str) { - int4 result; + int4 result; #if FALSE - struct tm input_time; - char buf[18]; - const char *p; + struct tm input_time; + char buf[18]; + const char *p; static const char *mstr[] = { "january", "february", "march", "april", "may", "june", "july", "august", "september", "october", "november", "december" @@ -72,7 +72,7 @@ timestamp_in(const char *timestamp_str) } else { - int i; + int i; for (i = 0; i < 12; i++) if (strncmp(mstr[i], buf, strlen(buf)) == 0) @@ -86,7 +86,7 @@ timestamp_in(const char *timestamp_str) else /* must be month/dd/yyyy */ { - int i; + int i; for (i = 0; i < 12; i++) if (strncmp(mstr[i], buf, strlen(buf)) == 0) @@ -126,17 +126,17 @@ timestamp_in(const char *timestamp_str) return result; } -char * +char * timestamp_out(time_t timestamp) { - char *result; - int tz; - double fsec = 0; - struct tm tt, - *tm = &tt; - char buf[MAXDATELEN + 1]; - char zone[MAXDATELEN + 1], - *tzn = zone; + char *result; + int tz; + double fsec = 0; + struct tm tt, + *tm = &tt; + char buf[MAXDATELEN + 1]; + char zone[MAXDATELEN + 1], + *tzn = zone; #if FALSE time = localtime(×tamp); @@ -156,7 +156,7 @@ timestamp_out(time_t timestamp) time_t now(void) { - time_t sec; + time_t sec; time(&sec); return (sec); @@ -198,13 +198,13 @@ timestampge(time_t t1, time_t t2) return difftime(t1, t2) <= 0; } -DateTime * +DateTime * timestamp_datetime(time_t timestamp) { - DateTime *result; + DateTime *result; - double fsec = 0; - struct tm *tm; + double fsec = 0; + struct tm *tm; if (!PointerIsValid(result = PALLOCTYPE(DateTime))) elog(WARN, "Memory allocation failed, can't convert timestamp to datetime", NULL); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 106ff5dad26..a9977fa6414 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.9 1997/09/07 04:52:53 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.10 1997/09/08 02:31:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,13 +49,13 @@ * len is the length specified in () plus 4 bytes. (XXX dummy is here * because we pass typelem as the second argument for array_in.) */ -char * +char * bpcharin(char *s, int dummy, int typlen) { - char *result, - *r; - int len = typlen - 4; - int i; + char *result, + *r; + int len = typlen - 4; + int i; if (s == NULL) return ((char *) NULL); @@ -90,11 +90,11 @@ bpcharin(char *s, int dummy, int typlen) return (result); } -char * +char * bpcharout(char *s) { - char *result; - int len; + char *result; + int len; if (s == NULL) { @@ -121,11 +121,11 @@ bpcharout(char *s) * len is the length specified in () plus 4 bytes. (XXX dummy is here * because we pass typelem as the second argument for array_in.) */ -char * +char * varcharin(char *s, int dummy, int typlen) { - char *result; - int len = typlen - 4; + char *result; + int len = typlen - 4; if (s == NULL) return ((char *) NULL); @@ -150,11 +150,11 @@ varcharin(char *s, int dummy, int typlen) return (result); } -char * +char * varcharout(char *s) { - char *result; - int len; + char *result; + int len; if (s == NULL) { @@ -178,9 +178,9 @@ varcharout(char *s) static int bcTruelen(char *arg) { - char *s = arg + 4; - int i; - int len; + char *s = arg + 4; + int i; + int len; len = *(int32 *) arg - 4; for (i = len - 1; i >= 0; i--) @@ -194,8 +194,8 @@ bcTruelen(char *arg) bool bpchareq(char *arg1, char *arg2) { - int len1, - len2; + int len1, + len2; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -211,8 +211,8 @@ bpchareq(char *arg1, char *arg2) bool bpcharne(char *arg1, char *arg2) { - int len1, - len2; + int len1, + len2; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -228,9 +228,9 @@ bpcharne(char *arg1, char *arg2) bool bpcharlt(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -247,9 +247,9 @@ bpcharlt(char *arg1, char *arg2) bool bpcharle(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -266,9 +266,9 @@ bpcharle(char *arg1, char *arg2) bool bpchargt(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -285,9 +285,9 @@ bpchargt(char *arg1, char *arg2) bool bpcharge(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -304,9 +304,9 @@ bpcharge(char *arg1, char *arg2) int32 bpcharcmp(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; len1 = bcTruelen(arg1); len2 = bcTruelen(arg2); @@ -325,9 +325,9 @@ bpcharcmp(char *arg1, char *arg2) static int vcTruelen(char *arg) { - char *s = arg + 4; - int i; - int len; + char *s = arg + 4; + int i; + int len; len = *(int32 *) arg - 4; for (i = 0; i < len; i++) @@ -341,8 +341,8 @@ vcTruelen(char *arg) bool varchareq(char *arg1, char *arg2) { - int len1, - len2; + int len1, + len2; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -358,8 +358,8 @@ varchareq(char *arg1, char *arg2) bool varcharne(char *arg1, char *arg2) { - int len1, - len2; + int len1, + len2; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -375,9 +375,9 @@ varcharne(char *arg1, char *arg2) bool varcharlt(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -394,9 +394,9 @@ varcharlt(char *arg1, char *arg2) bool varcharle(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -413,9 +413,9 @@ varcharle(char *arg1, char *arg2) bool varchargt(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -432,9 +432,9 @@ varchargt(char *arg1, char *arg2) bool varcharge(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -452,9 +452,9 @@ varcharge(char *arg1, char *arg2) int32 varcharcmp(char *arg1, char *arg2) { - int len1, - len2; - int cmp; + int len1, + len2; + int cmp; len1 = vcTruelen(arg1); len2 = vcTruelen(arg2); @@ -472,10 +472,10 @@ varcharcmp(char *arg1, char *arg2) uint32 hashbpchar(struct varlena * key) { - int keylen; - char *keydata; - uint32 n; - int loop; + int keylen; + char *keydata; + uint32 n; + int loop; keydata = VARDATA(key); keylen = bcTruelen((char *) key); @@ -489,25 +489,25 @@ hashbpchar(struct varlena * key) switch (keylen & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASHC; + case 7: + HASHC; + case 6: + HASHC; + case 5: + HASHC; + case 4: + HASHC; + case 3: + HASHC; + case 2: + HASHC; + case 1: + HASHC; + } while (--loop); } } return (n); @@ -516,10 +516,10 @@ hashbpchar(struct varlena * key) uint32 hashvarchar(struct varlena * key) { - int keylen; - char *keydata; - uint32 n; - int loop; + int keylen; + char *keydata; + uint32 n; + int loop; keydata = VARDATA(key); keylen = vcTruelen((char *) key); @@ -533,25 +533,25 @@ hashvarchar(struct varlena * key) switch (keylen & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASHC; + case 7: + HASHC; + case 6: + HASHC; + case 5: + HASHC; + case 4: + HASHC; + case 3: + HASHC; + case 2: + HASHC; + case 1: + HASHC; + } while (--loop); } } return (n); diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 273fae92e9e..ccd4b9c0acd 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.19 1997/09/07 04:52:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.20 1997/09/08 02:31:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,9 +40,9 @@ struct varlena * byteain(char *inputText) { - register char *tp; - register char *rp; - register int byte; + register char *tp; + register char *rp; + register int byte; struct varlena *result; if (inputText == NULL) @@ -107,15 +107,15 @@ shove_bytes(unsigned char *stuff, int len) * * NULL vlena should be an error--returning string with NULL for now. */ -char * +char * byteaout(struct varlena * vlena) { - register char *vp; - register char *rp; - register int val; /* holds unprintable chars */ - int i; - int len; - static char *result; + register char *vp; + register char *rp; + register int val; /* holds unprintable chars */ + int i; + int len; + static char *result; if (vlena == NULL) { @@ -168,7 +168,7 @@ struct varlena * textin(char *inputText) { struct varlena *result; - int len; + int len; if (inputText == NULL) return (NULL); @@ -182,11 +182,11 @@ textin(char *inputText) /* * textout - converts internal representation to "..." */ -char * +char * textout(struct varlena * vlena) { - int len; - char *result; + int len; + char *result; if (vlena == NULL) { @@ -214,9 +214,9 @@ textout(struct varlena * vlena) int textlen(text * t) { - int i = 0; - int max = VARSIZE(t) - VARHDRSZ; - char *ptr = VARDATA(t); + int i = 0; + int max = VARSIZE(t) - VARHDRSZ; + char *ptr = VARDATA(t); while (i < max && *ptr++) i++; @@ -238,14 +238,14 @@ textlen(text * t) * Is this OK? */ -text * +text * textcat(text * t1, text * t2) { - int len1, - len2, - len; - char *ptr; - text *result; + int len1, + len2, + len; + char *ptr; + text *result; if (!PointerIsValid(t1) && !PointerIsValid(t2)) return (NULL); @@ -283,13 +283,13 @@ textcat(text * t1, text * t2) int32 textpos(text * t1, text * t2) { - int pos; - int px, - p; - int len1, - len2; - char *p1, - *p2; + int pos; + int px, + p; + int len1, + len2; + char *p1, + *p2; if (!PointerIsValid(t1) || !PointerIsValid(t2)) return (0); @@ -322,9 +322,9 @@ textpos(text * t1, text * t2) bool texteq(struct varlena * arg1, struct varlena * arg2) { - register int len; - register char *a1p, - *a2p; + register int len; + register char *a1p, + *a2p; if (arg1 == NULL || arg2 == NULL) return ((bool) NULL); @@ -361,15 +361,15 @@ textne(struct varlena * arg1, struct varlena * arg2) bool text_lt(struct varlena * arg1, struct varlena * arg2) { - bool result; + bool result; #ifdef USE_LOCALE - int cval; + int cval; #endif - int len; - unsigned char *a1p, - *a2p; + int len; + unsigned char *a1p, + *a2p; if (arg1 == NULL || arg2 == NULL) return ((bool) FALSE); @@ -417,15 +417,15 @@ text_lt(struct varlena * arg1, struct varlena * arg2) bool text_le(struct varlena * arg1, struct varlena * arg2) { - bool result; + bool result; #ifdef USE_LOCALE - int cval; + int cval; #endif - int len; - unsigned char *a1p, - *a2p; + int len; + unsigned char *a1p, + *a2p; if (arg1 == NULL || arg2 == NULL) return ((bool) 0); @@ -484,7 +484,7 @@ text_ge(struct varlena * arg1, struct varlena * arg2) int32 byteaGetSize(struct varlena * v) { - register int len; + register int len; len = v->vl_len - sizeof(v->vl_len); @@ -502,8 +502,8 @@ byteaGetSize(struct varlena * v) int32 byteaGetByte(struct varlena * v, int32 n) { - int len; - int byte; + int len; + int byte; len = byteaGetSize(v); @@ -530,9 +530,9 @@ byteaGetByte(struct varlena * v, int32 n) int32 byteaGetBit(struct varlena * v, int32 n) { - int byteNo, - bitNo; - int byte; + int byteNo, + bitNo; + int byte; byteNo = n / 8; bitNo = n % 8; @@ -560,7 +560,7 @@ byteaGetBit(struct varlena * v, int32 n) struct varlena * byteaSetByte(struct varlena * v, int32 n, int32 newByte) { - int len; + int len; struct varlena *res; len = byteaGetSize(v); @@ -603,10 +603,10 @@ struct varlena * byteaSetBit(struct varlena * v, int32 n, int32 newBit) { struct varlena *res; - int oldByte, - newByte; - int byteNo, - bitNo; + int oldByte, + newByte; + int byteNo, + bitNo; /* * sanity check! diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 3edddd3c1aa..c1510f0ecc4 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.11 1997/09/07 04:52:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.12 1997/09/08 02:31:09 momjian Exp $ * * Notes: * XXX This needs to use exception.h to handle recovery when @@ -34,15 +34,15 @@ #include "catalog/pg_type.h" /* for OID of int28 type */ #include "lib/dllist.h" -static void CatCacheRemoveCTup(CatCache * cache, Dlelem * e); -static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP); +static void CatCacheRemoveCTup(CatCache * cache, Dlelem * e); +static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP); static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP, Relation relation, HeapTuple tuple); static void CatalogCacheInitializeCache(struct catcache * cache, Relation relation); -static long comphash(long l, char *v); +static long comphash(long l, char *v); /* ---------------- * variables, macros and other stuff @@ -68,17 +68,17 @@ static long comphash(long l, char *v); #define CACHE6_elog(a,b,c,d,e,f,g) #endif -CatCache *Caches = NULL; -GlobalMemory CacheCxt; +CatCache *Caches = NULL; +GlobalMemory CacheCxt; -static int DisableCache; +static int DisableCache; /* ---------------- * EQPROC is used in CatalogCacheInitializeCache * XXX this should be replaced by catalog lookups soon * ---------------- */ -static long eqproc[] = { +static long eqproc[] = { F_BOOLEQ, 0l, F_CHAREQ, F_CHAR16EQ, 0l, F_INT2EQ, F_KEYFIRSTEQ, F_INT4EQ, 0l, F_TEXTEQ, F_OIDEQ, 0l, 0l, 0l, F_OID8EQ @@ -120,10 +120,10 @@ static void CatalogCacheInitializeCache(struct catcache * cache, Relation relation) { - MemoryContext oldcxt; - short didopen = 0; - short i; - TupleDesc tupdesc; + MemoryContext oldcxt; + short didopen = 0; + short i; + TupleDesc tupdesc; CatalogCacheInitializeCache_DEBUG1; @@ -289,17 +289,17 @@ CatalogCacheSetId(CatCache * cacheInOutP, int id) static long comphash(long l, register char *v) { - long i; - NameData n; + long i; + NameData n; CACHE3_elog(DEBUG, "comphash (%d,%x)", l, v); switch (l) { - case 1: - case 2: - case 4: - return ((long) v); + case 1: + case 2: + case 4: + return ((long) v); } if (l == NAMEDATALEN) @@ -329,10 +329,10 @@ comphash(long l, register char *v) * CatalogCacheComputeHashIndex * -------------------------------- */ -static Index +static Index CatalogCacheComputeHashIndex(struct catcache * cacheInP) { - Index hashIndex; + Index hashIndex; hashIndex = 0x0; CACHE6_elog(DEBUG, "CatalogCacheComputeHashIndex %s %d %d %d %x", @@ -344,25 +344,25 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP) switch (cacheInP->cc_nkeys) { - case 4: - hashIndex ^= comphash(cacheInP->cc_klen[3], + case 4: + hashIndex ^= comphash(cacheInP->cc_klen[3], (char *) cacheInP->cc_skey[3].sk_argument) << 9; - /* FALLTHROUGH */ - case 3: - hashIndex ^= comphash(cacheInP->cc_klen[2], + /* FALLTHROUGH */ + case 3: + hashIndex ^= comphash(cacheInP->cc_klen[2], (char *) cacheInP->cc_skey[2].sk_argument) << 6; - /* FALLTHROUGH */ - case 2: - hashIndex ^= comphash(cacheInP->cc_klen[1], + /* FALLTHROUGH */ + case 2: + hashIndex ^= comphash(cacheInP->cc_klen[1], (char *) cacheInP->cc_skey[1].sk_argument) << 3; - /* FALLTHROUGH */ - case 1: - hashIndex ^= comphash(cacheInP->cc_klen[0], + /* FALLTHROUGH */ + case 1: + hashIndex ^= comphash(cacheInP->cc_klen[0], (char *) cacheInP->cc_skey[0].sk_argument); - break; - default: - elog(FATAL, "CCComputeHashIndex: %d cc_nkeys", cacheInP->cc_nkeys); - break; + break; + default: + elog(FATAL, "CCComputeHashIndex: %d cc_nkeys", cacheInP->cc_nkeys); + break; } hashIndex %= cacheInP->cc_size; return (hashIndex); @@ -372,62 +372,62 @@ CatalogCacheComputeHashIndex(struct catcache * cacheInP) * CatalogCacheComputeTupleHashIndex * -------------------------------- */ -static Index +static Index CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP, Relation relation, HeapTuple tuple) { - bool isNull = '\0'; + bool isNull = '\0'; if (cacheInOutP->relationId == InvalidOid) CatalogCacheInitializeCache(cacheInOutP, relation); switch (cacheInOutP->cc_nkeys) { - case 4: - cacheInOutP->cc_skey[3].sk_argument = - (cacheInOutP->cc_key[3] == ObjectIdAttributeNumber) - ? (Datum) tuple->t_oid - : (Datum) fastgetattr(tuple, - cacheInOutP->cc_key[3], - RelationGetTupleDescriptor(relation), - &isNull); - Assert(!isNull); - /* FALLTHROUGH */ - case 3: - cacheInOutP->cc_skey[2].sk_argument = - (cacheInOutP->cc_key[2] == ObjectIdAttributeNumber) - ? (Datum) tuple->t_oid - : (Datum) fastgetattr(tuple, - cacheInOutP->cc_key[2], - RelationGetTupleDescriptor(relation), - &isNull); - Assert(!isNull); - /* FALLTHROUGH */ - case 2: - cacheInOutP->cc_skey[1].sk_argument = - (cacheInOutP->cc_key[1] == ObjectIdAttributeNumber) - ? (Datum) tuple->t_oid - : (Datum) fastgetattr(tuple, - cacheInOutP->cc_key[1], - RelationGetTupleDescriptor(relation), - &isNull); - Assert(!isNull); - /* FALLTHROUGH */ - case 1: - cacheInOutP->cc_skey[0].sk_argument = - (cacheInOutP->cc_key[0] == ObjectIdAttributeNumber) - ? (Datum) tuple->t_oid - : (Datum) fastgetattr(tuple, - cacheInOutP->cc_key[0], - RelationGetTupleDescriptor(relation), - &isNull); - Assert(!isNull); - break; - default: - elog(FATAL, "CCComputeTupleHashIndex: %d cc_nkeys", - cacheInOutP->cc_nkeys - ); - break; + case 4: + cacheInOutP->cc_skey[3].sk_argument = + (cacheInOutP->cc_key[3] == ObjectIdAttributeNumber) + ? (Datum) tuple->t_oid + : (Datum) fastgetattr(tuple, + cacheInOutP->cc_key[3], + RelationGetTupleDescriptor(relation), + &isNull); + Assert(!isNull); + /* FALLTHROUGH */ + case 3: + cacheInOutP->cc_skey[2].sk_argument = + (cacheInOutP->cc_key[2] == ObjectIdAttributeNumber) + ? (Datum) tuple->t_oid + : (Datum) fastgetattr(tuple, + cacheInOutP->cc_key[2], + RelationGetTupleDescriptor(relation), + &isNull); + Assert(!isNull); + /* FALLTHROUGH */ + case 2: + cacheInOutP->cc_skey[1].sk_argument = + (cacheInOutP->cc_key[1] == ObjectIdAttributeNumber) + ? (Datum) tuple->t_oid + : (Datum) fastgetattr(tuple, + cacheInOutP->cc_key[1], + RelationGetTupleDescriptor(relation), + &isNull); + Assert(!isNull); + /* FALLTHROUGH */ + case 1: + cacheInOutP->cc_skey[0].sk_argument = + (cacheInOutP->cc_key[0] == ObjectIdAttributeNumber) + ? (Datum) tuple->t_oid + : (Datum) fastgetattr(tuple, + cacheInOutP->cc_key[0], + RelationGetTupleDescriptor(relation), + &isNull); + Assert(!isNull); + break; + default: + elog(FATAL, "CCComputeTupleHashIndex: %d cc_nkeys", + cacheInOutP->cc_nkeys + ); + break; } return @@ -441,9 +441,9 @@ CatalogCacheComputeTupleHashIndex(struct catcache * cacheInOutP, static void CatCacheRemoveCTup(CatCache * cache, Dlelem * elt) { - CatCTup *ct; - CatCTup *other_ct; - Dlelem *other_elt; + CatCTup *ct; + CatCTup *other_ct; + Dlelem *other_elt; if (elt) ct = (CatCTup *) DLE_VAL(elt); @@ -475,10 +475,10 @@ CatalogCacheIdInvalidate(int cacheId, /* XXX */ Index hashIndex, ItemPointer pointer) { - CatCache *ccp; - CatCTup *ct; - Dlelem *elt; - MemoryContext oldcxt; + CatCache *ccp; + CatCTup *ct; + Dlelem *elt; + MemoryContext oldcxt; /* ---------------- * sanity checks @@ -558,7 +558,7 @@ CatalogCacheIdInvalidate(int cacheId, /* XXX */ void ResetSystemCache() { - MemoryContext oldcxt; + MemoryContext oldcxt; struct catcache *cache; /* ---------------- @@ -593,12 +593,12 @@ ResetSystemCache() */ for (cache = Caches; PointerIsValid(cache); cache = cache->cc_next) { - int hash; + int hash; for (hash = 0; hash < NCCBUCK; hash += 1) { - Dlelem *elt, - *nextelt; + Dlelem *elt, + *nextelt; for (elt = DLGetHead(cache->cc_cache[hash]); elt; elt = nextelt) { @@ -645,7 +645,7 @@ elog(DEBUG, "InitSysCache: rid=%d id=%d nkeys=%d size=%d\n", \ #define InitSysCache_DEBUG1 #endif -CatCache * +CatCache * InitSysCache(char *relname, char *iname, int id, @@ -653,11 +653,11 @@ InitSysCache(char *relname, int key[], HeapTuple(*iScanfuncP) ()) { - CatCache *cp; - register int i; - MemoryContext oldcxt; + CatCache *cp; + register int i; + MemoryContext oldcxt; - char *indname; + char *indname; indname = (iname) ? iname : NULL; @@ -691,7 +691,7 @@ InitSysCache(char *relname, * We could move this to dllist.c, but the way we do this is not * dynamic/portabl, so why allow other routines to use it. */ - Dllist *cache_begin = malloc((NCCBUCK + 1) * sizeof(Dllist)); + Dllist *cache_begin = malloc((NCCBUCK + 1) * sizeof(Dllist)); for (i = 0; i <= NCCBUCK; ++i) { @@ -798,16 +798,16 @@ SearchSysCache(struct catcache * cache, Datum v3, Datum v4) { - unsigned hash; - CatCTup *ct = NULL; - CatCTup *nct; - CatCTup *nct2; - Dlelem *elt; - HeapTuple ntp = 0; - Buffer buffer; + unsigned hash; + CatCTup *ct = NULL; + CatCTup *nct; + CatCTup *nct2; + Dlelem *elt; + HeapTuple ntp = 0; + Buffer buffer; - Relation relation; - MemoryContext oldcxt; + Relation relation; + MemoryContext oldcxt; /* ---------------- * sanity checks @@ -859,7 +859,7 @@ SearchSysCache(struct catcache * cache, */ if (elt) { - Dlelem *old_lru_elt; + Dlelem *old_lru_elt; old_lru_elt = ((CatCTup *) DLE_VAL(elt))->ct_node; DLRemove(old_lru_elt); @@ -932,18 +932,18 @@ SearchSysCache(struct catcache * cache, Assert(cache->cc_iscanfunc); switch (cache->cc_nkeys) { - case 4: - ntp = cache->cc_iscanfunc(relation, v1, v2, v3, v4); - break; - case 3: - ntp = cache->cc_iscanfunc(relation, v1, v2, v3); - break; - case 2: - ntp = cache->cc_iscanfunc(relation, v1, v2); - break; - case 1: - ntp = cache->cc_iscanfunc(relation, v1); - break; + case 4: + ntp = cache->cc_iscanfunc(relation, v1, v2, v3, v4); + break; + case 3: + ntp = cache->cc_iscanfunc(relation, v1, v2, v3); + break; + case 2: + ntp = cache->cc_iscanfunc(relation, v1, v2); + break; + case 1: + ntp = cache->cc_iscanfunc(relation, v1); + break; } /* ---------- * Back to Cache context. If we got a tuple copy it @@ -959,7 +959,7 @@ SearchSysCache(struct catcache * cache, } else { - HeapScanDesc sd; + HeapScanDesc sd; /* ---------- * As above do the lookup in the callers memory @@ -1004,7 +1004,7 @@ SearchSysCache(struct catcache * cache, * to the heap tuple there and initialize the list pointers. * ---------------- */ - Dlelem *lru_elt; + Dlelem *lru_elt; /* * this is a little cumbersome here because we want the Dlelem's @@ -1030,7 +1030,7 @@ SearchSysCache(struct catcache * cache, */ if (++cache->cc_ntup > cache->cc_maxtup) { - CatCTup *ct; + CatCTup *ct; elt = DLGetTail(cache->cc_lrulist); ct = (CatCTup *) DLE_VAL(elt); @@ -1078,8 +1078,8 @@ RelationInvalidateCatalogCacheTuple(Relation relation, void (*function) (int, Index, ItemPointer)) { struct catcache *ccp; - MemoryContext oldcxt; - Oid relationId; + MemoryContext oldcxt; + Oid relationId; /* ---------------- * sanity checks diff --git a/src/backend/utils/cache/fcache.c b/src/backend/utils/cache/fcache.c index ad174c6fdf5..96c0102c1cf 100644 --- a/src/backend/utils/cache/fcache.c +++ b/src/backend/utils/cache/fcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.5 1997/09/07 04:52:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/Attic/fcache.c,v 1.6 1997/09/08 02:31:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ #include <string.h> #endif -static Oid GetDynamicFuncArgType(Var * arg, ExprContext * econtext); +static Oid GetDynamicFuncArgType(Var * arg, ExprContext * econtext); static FunctionCachePtr init_fcache(Oid foid, bool use_syscache, @@ -55,12 +55,12 @@ init_fcache(Oid foid, #define FuncArgTypeIsDynamic(arg) \ (IsA(arg,Var) && ((Var*)arg)->varattno == InvalidAttrNumber) -static Oid +static Oid GetDynamicFuncArgType(Var * arg, ExprContext * econtext) { - char *relname; - int rtid; - HeapTuple tup; + char *relname; + int rtid; + HeapTuple tup; Assert(IsA(arg, Var)); @@ -77,19 +77,19 @@ GetDynamicFuncArgType(Var * arg, ExprContext * econtext) return tup->t_oid; } -static FunctionCachePtr +static FunctionCachePtr init_fcache(Oid foid, bool use_syscache, List * argList, ExprContext * econtext) { - HeapTuple procedureTuple; - HeapTuple typeTuple; - Form_pg_proc procedureStruct; - TypeTupleForm typeStruct; + HeapTuple procedureTuple; + HeapTuple typeTuple; + Form_pg_proc procedureStruct; + TypeTupleForm typeStruct; FunctionCachePtr retval; - text *tmp; - int nargs; + text *tmp; + int nargs; /* ---------------- * get the procedure tuple corresponding to the given @@ -173,9 +173,9 @@ init_fcache(Oid foid, (retval->oneResult) && !(retval->typbyval)) { - Form_pg_class relationStruct; - HeapTuple relationTuple; - TupleDesc td; + Form_pg_class relationStruct; + HeapTuple relationTuple; + TupleDesc td; TupleTableSlot *slot; slot = makeNode(TupleTableSlot); @@ -209,14 +209,14 @@ init_fcache(Oid foid, if (nargs > 0) { - Oid *argTypes; + Oid *argTypes; retval->nullVect = (bool *) palloc((retval->nargs) * sizeof(bool)); if (retval->language == SQLlanguageId) { - int i; - List *oneArg; + int i; + List *oneArg; retval->argOidVect = (Oid *) palloc(retval->nargs * sizeof(Oid)); @@ -293,8 +293,8 @@ init_fcache(Oid foid, void setFcache(Node * node, Oid foid, List * argList, ExprContext * econtext) { - Func *fnode; - Oper *onode; + Func *fnode; + Oper *onode; FunctionCachePtr fcache; fcache = init_fcache(foid, true, argList, econtext); diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index 4fb8a5eb6ed..cc343f4d3e1 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.5 1997/09/07 04:53:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.6 1997/09/08 02:31:12 momjian Exp $ * * Note - this code is real crufty... * @@ -32,11 +32,11 @@ #include "utils/syscache.h" /* XXX to support the hacks below */ static InvalidationEntry InvalidationEntryAllocate(uint16 size); -static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ()); +static void LocalInvalidInvalidate(LocalInvalid invalid, void (*function) ()); static LocalInvalid LocalInvalidRegister(LocalInvalid invalid, InvalidationEntry entry); -static void getmyrelids(void); +static void getmyrelids(void); /* ---------------- @@ -45,28 +45,28 @@ static void getmyrelids(void); */ typedef struct CatalogInvalidationData { - Index cacheId; - Index hashIndex; + Index cacheId; + Index hashIndex; ItemPointerData pointerData; -} CatalogInvalidationData; +} CatalogInvalidationData; typedef struct RelationInvalidationData { - Oid relationId; - Oid objectId; -} RelationInvalidationData; + Oid relationId; + Oid objectId; +} RelationInvalidationData; typedef union AnyInvalidation { CatalogInvalidationData catalog; RelationInvalidationData relation; -} AnyInvalidation; +} AnyInvalidation; typedef struct InvalidationMessageData { - char kind; + char kind; AnyInvalidation any; -} InvalidationMessageData; +} InvalidationMessageData; typedef InvalidationMessageData *InvalidationMessage; @@ -75,12 +75,12 @@ typedef InvalidationMessageData *InvalidationMessage; * ---------------- */ static LocalInvalid Invalid = EmptyLocalInvalid; /* XXX global */ -static bool RefreshWhenInvalidate = false; +static bool RefreshWhenInvalidate = false; -Oid MyRelationRelationId = InvalidOid; -Oid MyAttributeRelationId = InvalidOid; -Oid MyAMRelationId = InvalidOid; -Oid MyAMOPRelationId = InvalidOid; +Oid MyRelationRelationId = InvalidOid; +Oid MyAttributeRelationId = InvalidOid; +Oid MyAMRelationId = InvalidOid; +Oid MyAMOPRelationId = InvalidOid; #define ValidateHacks() \ if (!OidIsValid(MyRelationRelationId)) getmyrelids() @@ -95,7 +95,7 @@ Oid MyAMOPRelationId = InvalidOid; * Allocates an invalidation entry. * -------------------------------- */ -static InvalidationEntry +static InvalidationEntry InvalidationEntryAllocate(uint16 size) { InvalidationEntryData *entryDataP; @@ -111,7 +111,7 @@ InvalidationEntryAllocate(uint16 size) * Returns a new local cache invalidation state containing a new entry. * -------------------------------- */ -static LocalInvalid +static LocalInvalid LocalInvalidRegister(LocalInvalid invalid, InvalidationEntry entry) { @@ -248,7 +248,7 @@ RelationIdRegisterLocalInvalid(Oid relationId, Oid objectId) static void getmyrelids() { - HeapTuple tuple; + HeapTuple tuple; tuple = SearchSysCacheTuple(RELNAME, PointerGetDatum(RelationRelationName), @@ -391,26 +391,26 @@ InvalidationMessageRegisterSharedInvalid(InvalidationMessage message) switch (message->kind) { - case 'c': /* cached system catalog tuple */ - InvalidationMessageRegisterSharedInvalid_DEBUG1; - - RegisterSharedInvalid(message->any.catalog.cacheId, - message->any.catalog.hashIndex, - &message->any.catalog.pointerData); - break; - - case 'r': /* cached relation descriptor */ - InvalidationMessageRegisterSharedInvalid_DEBUG2; - - RegisterSharedInvalid(message->any.relation.relationId, - message->any.relation.objectId, - (ItemPointer) NULL); - break; - - default: - elog(FATAL, - "InvalidationMessageRegisterSharedInvalid: `%c' kind", - message->kind); + case 'c': /* cached system catalog tuple */ + InvalidationMessageRegisterSharedInvalid_DEBUG1; + + RegisterSharedInvalid(message->any.catalog.cacheId, + message->any.catalog.hashIndex, + &message->any.catalog.pointerData); + break; + + case 'r': /* cached relation descriptor */ + InvalidationMessageRegisterSharedInvalid_DEBUG2; + + RegisterSharedInvalid(message->any.relation.relationId, + message->any.relation.objectId, + (ItemPointer) NULL); + break; + + default: + elog(FATAL, + "InvalidationMessageRegisterSharedInvalid: `%c' kind", + message->kind); } } @@ -441,23 +441,23 @@ InvalidationMessageCacheInvalidate(InvalidationMessage message) switch (message->kind) { - case 'c': /* cached system catalog tuple */ - InvalidationMessageCacheInvalidate_DEBUG1; + case 'c': /* cached system catalog tuple */ + InvalidationMessageCacheInvalidate_DEBUG1; - CatalogCacheIdInvalidate(message->any.catalog.cacheId, - message->any.catalog.hashIndex, - &message->any.catalog.pointerData); - break; + CatalogCacheIdInvalidate(message->any.catalog.cacheId, + message->any.catalog.hashIndex, + &message->any.catalog.pointerData); + break; - case 'r': /* cached relation descriptor */ - InvalidationMessageCacheInvalidate_DEBUG2; + case 'r': /* cached relation descriptor */ + InvalidationMessageCacheInvalidate_DEBUG2; - /* XXX ignore this--is this correct ??? */ - break; + /* XXX ignore this--is this correct ??? */ + break; - default: - elog(FATAL, "InvalidationMessageCacheInvalidate: `%c' kind", - message->kind); + default: + elog(FATAL, "InvalidationMessageCacheInvalidate: `%c' kind", + message->kind); } } @@ -470,8 +470,8 @@ RelationInvalidateRelationCache(Relation relation, HeapTuple tuple, void (*function) ()) { - Oid relationId; - Oid objectId = (Oid) 0; + Oid relationId; + Oid objectId = (Oid) 0; /* ---------------- * get the relation object id diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 37280036970..123e7c1462c 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.4 1997/09/07 04:53:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.5 1997/09/08 02:31:14 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -67,11 +67,11 @@ op_class(Oid opno, int32 opclass, Oid amopid) * return the "attname" field from the attribute relation. * */ -char * +char * get_attname(Oid relid, AttrNumber attnum) { FormData_pg_attribute att_tup; - char *retval; + char *retval; if (SearchSysCacheStruct(ATTNUM, (char *) &att_tup, @@ -137,8 +137,8 @@ get_atttype(Oid relid, AttrNumber attnum) bool get_attisset(Oid relid, char *attname) { - HeapTuple htup; - AttrNumber attno; + HeapTuple htup; + AttrNumber attno; AttributeTupleForm att_tup; attno = get_attnum(relid, attname); @@ -192,7 +192,7 @@ get_opcode(Oid opno) * * Note: return the struct so that it gets copied. */ -char * +char * get_opname(Oid opno) { FormData_pg_operator optup; @@ -284,7 +284,7 @@ get_commutator(Oid opno) HeapTuple get_operator_tuple(Oid opno) { - HeapTuple optup; + HeapTuple optup; if ((optup = SearchSysCacheTuple(OPROID, ObjectIdGetDatum(opno), @@ -378,7 +378,7 @@ get_relnatts(Oid relid) * Returns the name of a given relation. * */ -char * +char * get_rel_name(Oid relid) { FormData_pg_class reltup; diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 704d673279b..4b1f5e251c6 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.21 1997/09/07 04:53:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.22 1997/09/08 02:31:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,8 +91,8 @@ static void RelationFlushRelation(Relation * relationPtr, bool onlyFlushReferenceCountZero); static Relation RelationNameCacheGetRelation(char *relationName); -static void init_irels(void); -static void write_irels(void); +static void init_irels(void); +static void write_irels(void); /* ---------------- * defines @@ -105,7 +105,7 @@ static void write_irels(void); * externs * ---------------- */ -extern bool AMI_OVERRIDE; /* XXX style */ +extern bool AMI_OVERRIDE; /* XXX style */ extern GlobalMemory CacheCxt; /* from utils/cache/catcache.c */ /* ---------------- @@ -127,8 +127,8 @@ FormData_pg_attribute Desc_pg_time[Natts_pg_time] = {Schema_pg_time}; * thus there are two hash tables for referencing them. * ---------------- */ -HTAB *RelationNameCache; -HTAB *RelationIdCache; +HTAB *RelationNameCache; +HTAB *RelationIdCache; /* ---------------- * RelationBuildDescInfo exists so code can be shared @@ -137,27 +137,27 @@ HTAB *RelationIdCache; */ typedef struct RelationBuildDescInfo { - int infotype; /* lookup by id or by name */ + int infotype; /* lookup by id or by name */ #define INFO_RELID 1 #define INFO_RELNAME 2 union { - Oid info_id;/* relation object id */ - char *info_name; /* relation name */ - } i; -} RelationBuildDescInfo; + Oid info_id; /* relation object id */ + char *info_name; /* relation name */ + } i; +} RelationBuildDescInfo; typedef struct relidcacheent { - Oid reloid; - Relation reldesc; -} RelIdCacheEnt; + Oid reloid; + Relation reldesc; +} RelIdCacheEnt; typedef struct relnamecacheent { - NameData relname; - Relation reldesc; -} RelNameCacheEnt; + NameData relname; + Relation reldesc; +} RelNameCacheEnt; /* ----------------- * macros to manipulate name cache and id cache @@ -251,7 +251,7 @@ formrdesc(char *relationName, u_int natts, FormData_pg_attribute att[]); #if 0 /* See comments at line 1304 */ -static void RelationFlushIndexes(Relation * r, Oid accessMethodId); +static void RelationFlushIndexes(Relation * r, Oid accessMethodId); #endif @@ -269,19 +269,19 @@ static void build_tupdesc_ind(RelationBuildDescInfo buildinfo, Relation relation, u_int natts); static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo); -static void IndexedAccessMethodInitialize(Relation relation); -static void AttrDefaultFetch(Relation relation); -static void RelCheckFetch(Relation relation); +static void IndexedAccessMethodInitialize(Relation relation); +static void AttrDefaultFetch(Relation relation); +static void RelCheckFetch(Relation relation); -extern void RelationBuildTriggers(Relation relation); -extern void FreeTriggerDesc(Relation relation); +extern void RelationBuildTriggers(Relation relation); +extern void FreeTriggerDesc(Relation relation); /* * newlyCreatedRelns - * relations created during this transaction. We need to keep track of * these. */ -static List *newlyCreatedRelns = NULL; +static List *newlyCreatedRelns = NULL; /* ---------------------------------------------------------------- * RelationIdGetRelation() and RelationNameGetRelation() @@ -297,20 +297,20 @@ static List *newlyCreatedRelns = NULL; * the buildinfo passed to it * -------------------------------- */ -static char * +static char * BuildDescInfoError(RelationBuildDescInfo buildinfo) { - static char errBuf[64]; + static char errBuf[64]; memset(errBuf, 0, (int) sizeof(errBuf)); switch (buildinfo.infotype) { - case INFO_RELID: - sprintf(errBuf, "(relation id %d)", buildinfo.i.info_id); - break; - case INFO_RELNAME: - sprintf(errBuf, "(relation name %s)", buildinfo.i.info_name); - break; + case INFO_RELID: + sprintf(errBuf, "(relation id %d)", buildinfo.i.info_id); + break; + case INFO_RELNAME: + sprintf(errBuf, "(relation name %s)", buildinfo.i.info_name); + break; } return errBuf; @@ -326,7 +326,7 @@ BuildDescInfoError(RelationBuildDescInfo buildinfo) * as specified in buildinfo. * -------------------------------- */ -static HeapTuple +static HeapTuple ScanPgRelation(RelationBuildDescInfo buildinfo) { @@ -342,15 +342,15 @@ ScanPgRelation(RelationBuildDescInfo buildinfo) return (scan_pg_rel_ind(buildinfo)); } -static HeapTuple +static HeapTuple scan_pg_rel_seq(RelationBuildDescInfo buildinfo) { - HeapTuple pg_class_tuple; - HeapTuple return_tuple; - Relation pg_class_desc; - HeapScanDesc pg_class_scan; - ScanKeyData key; - Buffer buf; + HeapTuple pg_class_tuple; + HeapTuple return_tuple; + Relation pg_class_desc; + HeapScanDesc pg_class_scan; + ScanKeyData key; + Buffer buf; /* ---------------- * form a scan key @@ -358,23 +358,23 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo) */ switch (buildinfo.infotype) { - case INFO_RELID: - ScanKeyEntryInitialize(&key, 0, - ObjectIdAttributeNumber, - ObjectIdEqualRegProcedure, - ObjectIdGetDatum(buildinfo.i.info_id)); - break; - - case INFO_RELNAME: - ScanKeyEntryInitialize(&key, 0, - Anum_pg_class_relname, - Character16EqualRegProcedure, - NameGetDatum(buildinfo.i.info_name)); - break; - - default: - elog(WARN, "ScanPgRelation: bad buildinfo"); - return NULL; + case INFO_RELID: + ScanKeyEntryInitialize(&key, 0, + ObjectIdAttributeNumber, + ObjectIdEqualRegProcedure, + ObjectIdGetDatum(buildinfo.i.info_id)); + break; + + case INFO_RELNAME: + ScanKeyEntryInitialize(&key, 0, + Anum_pg_class_relname, + Character16EqualRegProcedure, + NameGetDatum(buildinfo.i.info_name)); + break; + + default: + elog(WARN, "ScanPgRelation: bad buildinfo"); + return NULL; } /* ---------------- @@ -421,11 +421,11 @@ scan_pg_rel_seq(RelationBuildDescInfo buildinfo) return return_tuple; } -static HeapTuple +static HeapTuple scan_pg_rel_ind(RelationBuildDescInfo buildinfo) { - Relation pg_class_desc; - HeapTuple return_tuple; + Relation pg_class_desc; + HeapTuple return_tuple; pg_class_desc = heap_openr(RelationRelationName); if (!IsInitProcessingMode()) @@ -433,23 +433,23 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) switch (buildinfo.infotype) { - case INFO_RELID: - return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id); - break; + case INFO_RELID: + return_tuple = ClassOidIndexScan(pg_class_desc, buildinfo.i.info_id); + break; - case INFO_RELNAME: - return_tuple = ClassNameIndexScan(pg_class_desc, - buildinfo.i.info_name); - break; + case INFO_RELNAME: + return_tuple = ClassNameIndexScan(pg_class_desc, + buildinfo.i.info_name); + break; - default: - elog(WARN, "ScanPgRelation: bad buildinfo"); + default: + elog(WARN, "ScanPgRelation: bad buildinfo"); - /* - * XXX I hope this is right. It seems better than returning an - * uninitialized value - */ - return_tuple = NULL; + /* + * XXX I hope this is right. It seems better than returning + * an uninitialized value + */ + return_tuple = NULL; } /* all done */ @@ -467,12 +467,12 @@ scan_pg_rel_ind(RelationBuildDescInfo buildinfo) * and initialize the rd_rel field. * ---------------- */ -static Relation +static Relation AllocateRelationDesc(u_int natts, Form_pg_class relp) { - Relation relation; - Size len; - Form_pg_class relationTupleForm; + Relation relation; + Size len; + Form_pg_class relationTupleForm; /* ---------------- * allocate space for the relation tuple form @@ -535,12 +535,12 @@ build_tupdesc_seq(RelationBuildDescInfo buildinfo, Relation relation, u_int natts) { - HeapTuple pg_attribute_tuple; - Relation pg_attribute_desc; - HeapScanDesc pg_attribute_scan; + HeapTuple pg_attribute_tuple; + Relation pg_attribute_desc; + HeapScanDesc pg_attribute_scan; AttributeTupleForm attp; - ScanKeyData key; - int need; + ScanKeyData key; + int need; /* ---------------- * form a scan key @@ -601,13 +601,13 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo, Relation relation, u_int natts) { - Relation attrel; - HeapTuple atttup; + Relation attrel; + HeapTuple atttup; AttributeTupleForm attp; - TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); - AttrDefault *attrdef = NULL; - int ndef = 0; - int i; + TupleConstr *constr = (TupleConstr *) palloc(sizeof(TupleConstr)); + AttrDefault *attrdef = NULL; + int ndef = 0; + int i; constr->has_not_null = false; @@ -694,15 +694,15 @@ build_tupdesc_ind(RelationBuildDescInfo buildinfo, static void RelationBuildRuleLock(Relation relation) { - HeapTuple pg_rewrite_tuple; - Relation pg_rewrite_desc; - TupleDesc pg_rewrite_tupdesc; - HeapScanDesc pg_rewrite_scan; - ScanKeyData key; - RuleLock *rulelock; - int numlocks; - RewriteRule **rules; - int maxlocks; + HeapTuple pg_rewrite_tuple; + Relation pg_rewrite_desc; + TupleDesc pg_rewrite_tupdesc; + HeapScanDesc pg_rewrite_scan; + ScanKeyData key; + RuleLock *rulelock; + int numlocks; + RewriteRule **rules; + int maxlocks; /* ---------------- * form an array to hold the rewrite rules (the array is extended if @@ -739,10 +739,10 @@ RelationBuildRuleLock(Relation relation) while ((pg_rewrite_tuple = heap_getnext(pg_rewrite_scan, 0, (Buffer *) NULL)) != NULL) { - bool isnull; - char *ruleaction = NULL; - char *rule_evqual_string; - RewriteRule *rule; + bool isnull; + char *ruleaction = NULL; + char *rule_evqual_string; + RewriteRule *rule; rule = (RewriteRule *) palloc(sizeof(RewriteRule)); @@ -828,19 +828,19 @@ RelationBuildRuleLock(Relation relation) * -cim 2/4/91 * -------------------------------- */ -static Relation +static Relation RelationBuildDesc(RelationBuildDescInfo buildinfo) { - File fd; - Relation relation; - u_int natts; - Oid relid; - Oid relam; - Form_pg_class relp; + File fd; + Relation relation; + u_int natts; + Oid relid; + Oid relam; + Form_pg_class relp; - MemoryContext oldcxt; + MemoryContext oldcxt; - HeapTuple pg_class_tuple; + HeapTuple pg_class_tuple; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); @@ -986,13 +986,13 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo) static void IndexedAccessMethodInitialize(Relation relation) { - IndexStrategy strategy; - RegProcedure *support; - int natts; - Size stratSize; - Size supportSize; - uint16 relamstrategies; - uint16 relamsupport; + IndexStrategy strategy; + RegProcedure *support; + int natts; + Size stratSize; + Size supportSize; + uint16 relamstrategies; + uint16 relamsupport; natts = relation->rd_rel->relnatts; relamstrategies = relation->rd_am->amstrategies; @@ -1033,9 +1033,9 @@ formrdesc(char *relationName, u_int natts, FormData_pg_attribute att[]) { - Relation relation; - Size len; - int i; + Relation relation; + Size len; + int i; /* ---------------- * allocate new relation desc @@ -1151,7 +1151,7 @@ formrdesc(char *relationName, Relation RelationIdCacheGetRelation(Oid relationId) { - Relation rd; + Relation rd; RelationIdCacheLookup(relationId, rd); @@ -1175,11 +1175,11 @@ RelationIdCacheGetRelation(Oid relationId) * RelationNameCacheGetRelation * -------------------------------- */ -static Relation +static Relation RelationNameCacheGetRelation(char *relationName) { - Relation rd; - NameData name; + Relation rd; + NameData name; /* * make sure that the name key used for hash lookup is properly @@ -1214,7 +1214,7 @@ RelationNameCacheGetRelation(char *relationName) Relation RelationIdGetRelation(Oid relationId) { - Relation rd; + Relation rd; RelationBuildDescInfo buildinfo; /* ---------------- @@ -1255,7 +1255,7 @@ RelationIdGetRelation(Oid relationId) Relation RelationNameGetRelation(char *relationName) { - Relation rd; + Relation rd; RelationBuildDescInfo buildinfo; /* ---------------- @@ -1332,8 +1332,8 @@ static void RelationFlushRelation(Relation * relationPtr, bool onlyFlushReferenceCountZero) { - MemoryContext oldcxt; - Relation relation = *relationPtr; + MemoryContext oldcxt; + Relation relation = *relationPtr; if (relation->rd_isnailed) { @@ -1356,7 +1356,7 @@ RelationFlushRelation(Relation * relationPtr, #if 0 if (relation->rd_rules) { - int j; + int j; for (j = 0; j < relation->rd_rules->numLocks; j++) { @@ -1384,22 +1384,22 @@ RelationFlushRelation(Relation * relationPtr, void RelationForgetRelation(Oid rid) { - Relation relation; + Relation relation; RelationIdCacheLookup(rid, relation); Assert(PointerIsValid(relation)); if (relation->rd_islocal) { - MemoryContext oldcxt; - List *curr; - List *prev = NIL; + MemoryContext oldcxt; + List *curr; + List *prev = NIL; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); foreach(curr, newlyCreatedRelns) { - Relation reln = lfirst(curr); + Relation reln = lfirst(curr); Assert(reln != NULL && reln->rd_islocal); if (reln->rd_id == rid) @@ -1427,7 +1427,7 @@ RelationForgetRelation(Oid rid) void RelationIdInvalidateRelationCacheByRelationId(Oid relationId) { - Relation relation; + Relation relation; RelationIdCacheLookup(relationId, relation); @@ -1462,7 +1462,7 @@ static void RelationFlushIndexes(Relation * r, Oid accessMethodId) { - Relation relation = *r; + Relation relation = *r; if (!RelationIsValid(relation)) { @@ -1536,7 +1536,7 @@ RelationCacheInvalidate(bool onlyFlushReferenceCountZero) void RelationRegisterRelation(Relation relation) { - MemoryContext oldcxt; + MemoryContext oldcxt; oldcxt = MemoryContextSwitchTo((MemoryContext) CacheCxt); @@ -1571,7 +1571,7 @@ RelationRegisterRelation(Relation relation) void RelationPurgeLocalRelation(bool xactCommitted) { - MemoryContext oldcxt; + MemoryContext oldcxt; if (newlyCreatedRelns == NULL) return; @@ -1580,8 +1580,8 @@ RelationPurgeLocalRelation(bool xactCommitted) while (newlyCreatedRelns) { - List *l = newlyCreatedRelns; - Relation reln = lfirst(l); + List *l = newlyCreatedRelns; + Relation reln = lfirst(l); Assert(reln != NULL && reln->rd_islocal); @@ -1641,8 +1641,8 @@ RelationPurgeLocalRelation(bool xactCommitted) void RelationInitialize(void) { - MemoryContext oldcxt; - HASHCTL ctl; + MemoryContext oldcxt; + HASHCTL ctl; /* ---------------- * switch to cache memory context @@ -1697,21 +1697,21 @@ RelationInitialize(void) static void AttrDefaultFetch(Relation relation) { - AttrDefault *attrdef = relation->rd_att->constr->defval; - int ndef = relation->rd_att->constr->num_defval; - Relation adrel; - Relation irel; - ScanKeyData skey; - HeapTuple tuple; + AttrDefault *attrdef = relation->rd_att->constr->defval; + int ndef = relation->rd_att->constr->num_defval; + Relation adrel; + Relation irel; + ScanKeyData skey; + HeapTuple tuple; Form_pg_attrdef adform; - IndexScanDesc sd; + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - ItemPointer iptr; + Buffer buffer; + ItemPointer iptr; struct varlena *val; - bool isnull; - int found; - int i; + bool isnull; + int found; + int i; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -1787,20 +1787,20 @@ AttrDefaultFetch(Relation relation) static void RelCheckFetch(Relation relation) { - ConstrCheck *check = relation->rd_att->constr->check; - int ncheck = relation->rd_att->constr->num_check; - Relation rcrel; - Relation irel; - ScanKeyData skey; - HeapTuple tuple; - IndexScanDesc sd; + ConstrCheck *check = relation->rd_att->constr->check; + int ncheck = relation->rd_att->constr->num_check; + Relation rcrel; + Relation irel; + ScanKeyData skey; + HeapTuple tuple; + IndexScanDesc sd; RetrieveIndexResult indexRes; - Buffer buffer; - ItemPointer iptr; - Name rcname; + Buffer buffer; + ItemPointer iptr; + Name rcname; struct varlena *val; - bool isnull; - int found; + bool isnull; + int found; ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -1902,17 +1902,17 @@ RelCheckFetch(Relation relation) static void init_irels(void) { - Size len; - int nread; - File fd; - Relation irel[Num_indices_bootstrap]; - Relation ird; - Form_pg_am am; - Form_pg_class relform; - IndexStrategy strat; - RegProcedure *support; - int i; - int relno; + Size len; + int nread; + File fd; + Relation irel[Num_indices_bootstrap]; + Relation ird; + Form_pg_am am; + Form_pg_class relform; + IndexStrategy strat; + RegProcedure *support; + int i; + int relno; if ((fd = FileNameOpenFile(INIT_FILENAME, O_RDONLY, 0600)) < 0) { @@ -2057,18 +2057,18 @@ init_irels(void) static void write_irels(void) { - int len; - int nwritten; - File fd; - Relation irel[Num_indices_bootstrap]; - Relation ird; - Form_pg_am am; - Form_pg_class relform; - IndexStrategy strat; - RegProcedure *support; - ProcessingMode oldmode; - int i; - int relno; + int len; + int nwritten; + File fd; + Relation irel[Num_indices_bootstrap]; + Relation ird; + Form_pg_am am; + Form_pg_class relform; + IndexStrategy strat; + RegProcedure *support; + ProcessingMode oldmode; + int i; + int relno; RelationBuildDescInfo bi; fd = FileNameOpenFile(INIT_FILENAME, O_WRONLY | O_CREAT | O_TRUNC, 0600); diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 5f6c22b95fc..75bd7bfcb43 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.5 1997/09/07 04:53:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.6 1997/09/08 02:31:21 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -52,12 +52,12 @@ #include "storage/large_object.h" #include "catalog/pg_listener.h" -extern bool AMI_OVERRIDE; /* XXX style */ +extern bool AMI_OVERRIDE; /* XXX style */ #include "utils/syscache.h" #include "catalog/indexing.h" -typedef HeapTuple(*ScanFunc) (); +typedef HeapTuple(*ScanFunc) (); /* ---------------- * Warning: cacheinfo[] below is changed, then be sure and @@ -321,7 +321,7 @@ static struct cachedesc cacheinfo[] = { static struct catcache *SysCache[ lengthof(cacheinfo)]; -static int32 SysCacheSize = lengthof(cacheinfo); +static int32 SysCacheSize = lengthof(cacheinfo); /* @@ -344,7 +344,7 @@ zerocaches() void InitCatalogCache() { - int cacheId; /* XXX type */ + int cacheId; /* XXX type */ if (!AMI_OVERRIDE) { @@ -456,7 +456,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */ Datum key3, Datum key4) { - HeapTuple tp; + HeapTuple tp; if (!PointerIsValid(returnStruct)) { @@ -480,7 +480,7 @@ SearchSysCacheStruct(int cacheId, /* cache selection code */ * * [callers all assume this returns a (struct varlena *). -ay 10/94] */ -void * +void * SearchSysCacheGetAttribute(int cacheId, AttrNumber attributeNumber, Datum key1, @@ -488,14 +488,14 @@ SearchSysCacheGetAttribute(int cacheId, Datum key3, Datum key4) { - HeapTuple tp; - char *cacheName; - Relation relation; - int32 attributeLength, - attributeByValue; - bool isNull; - char *attributeValue; - void *returnValue; + HeapTuple tp; + char *cacheName; + Relation relation; + int32 attributeLength, + attributeByValue; + bool isNull; + char *attributeValue; + void *returnValue; tp = SearchSysCacheTuple(cacheId, key1, key2, key3, key4); cacheName = cacheinfo[cacheId].name; @@ -556,8 +556,8 @@ SearchSysCacheGetAttribute(int cacheId, } else { - char *tmp; - int size = (attributeLength < 0) + char *tmp; + int size = (attributeLength < 0) ? VARSIZE((struct varlena *) attributeValue) /* variable length */ : attributeLength; /* fixed length */ @@ -583,16 +583,16 @@ SearchSysCacheGetAttribute(int cacheId, * [identical to get_typdefault, expecting a (struct varlena *) as ret val. * some day, either of the functions should be removed -ay 10/94] */ -void * +void * TypeDefaultRetrieve(Oid typId) { - HeapTuple typeTuple; - TypeTupleForm type; - int32 typByVal, - typLen; + HeapTuple typeTuple; + TypeTupleForm type; + int32 typByVal, + typLen; struct varlena *typDefault; - int32 dataSize; - void *returnValue; + int32 dataSize; + void *returnValue; typeTuple = SearchSysCacheTuple(TYPOID, ObjectIdGetDatum(typId), @@ -631,25 +631,25 @@ TypeDefaultRetrieve(Oid typId) if (typByVal) { - int8 i8; - int16 i16; - int32 i32; + int8 i8; + int16 i16; + int32 i32; if (dataSize == typLen) { switch (typLen) { - case sizeof(int8): - memmove((char *) &i8, VARDATA(typDefault), sizeof(int8)); - i32 = i8; - break; - case sizeof(int16): - memmove((char *) &i16, VARDATA(typDefault), sizeof(int16)); - i32 = i16; - break; - case sizeof(int32): - memmove((char *) &i32, VARDATA(typDefault), sizeof(int32)); - break; + case sizeof(int8): + memmove((char *) &i8, VARDATA(typDefault), sizeof(int8)); + i32 = i8; + break; + case sizeof(int16): + memmove((char *) &i16, VARDATA(typDefault), sizeof(int16)); + i32 = i16; + break; + case sizeof(int32): + memmove((char *) &i32, VARDATA(typDefault), sizeof(int32)); + break; } returnValue = (void *) i32; } diff --git a/src/backend/utils/error/assert.c b/src/backend/utils/error/assert.c index 2c46dde02b8..1e3276fe5cf 100644 --- a/src/backend/utils/error/assert.c +++ b/src/backend/utils/error/assert.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.5 1997/09/07 04:53:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.6 1997/09/08 02:31:25 momjian Exp $ * * NOTE * This should eventually work with elog(), dlog(), etc. @@ -28,8 +28,8 @@ ExceptionalCondition(char *conditionName, char *fileName, int lineNumber) { - extern char *ExcFileName;/* XXX */ - extern Index ExcLineNumber; /* XXX */ + extern char *ExcFileName; /* XXX */ + extern Index ExcLineNumber; /* XXX */ ExcFileName = fileName; ExcLineNumber = lineNumber; diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index e4cdc6d595b..5acc371f01c 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.18 1997/09/07 04:53:15 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.19 1997/09/08 02:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,11 +29,11 @@ #include "libpq/libpq.h" #include "storage/proc.h" -static int Debugfile = -1; -static int Err_file = -1; -static int ElogDebugIndentLevel = 0; +static int Debugfile = -1; +static int Err_file = -1; +static int ElogDebugIndentLevel = 0; -extern char OutputFileName[]; +extern char OutputFileName[]; /* * elog -- @@ -42,24 +42,24 @@ extern char OutputFileName[]; void elog(int lev, const char *fmt,...) { - va_list ap; - char buf[ELOG_MAXLEN], - line[ELOG_MAXLEN]; - register char *bp; + va_list ap; + char buf[ELOG_MAXLEN], + line[ELOG_MAXLEN]; + register char *bp; register const char *cp; - extern int errno, - sys_nerr; + extern int errno, + sys_nerr; #ifndef PG_STANDALONE - extern FILE *Pfout; + extern FILE *Pfout; #endif /* !PG_STANDALONE */ #ifdef ELOG_TIMESTAMPS - time_t tim; + time_t tim; #endif - int len; - int i = 0; + int len; + int i = 0; va_start(ap, fmt); if (lev == DEBUG && Debugfile < 0) @@ -68,31 +68,31 @@ elog(int lev, const char *fmt,...) } switch (lev) { - case NOIND: - i = ElogDebugIndentLevel - 1; - if (i < 0) - i = 0; - if (i > 30) - i = i % 30; - cp = "DEBUG:"; - break; - case DEBUG: - i = ElogDebugIndentLevel; - if (i < 0) - i = 0; - if (i > 30) - i = i % 30; - cp = "DEBUG:"; - break; - case NOTICE: - cp = "NOTICE:"; - break; - case WARN: - cp = "WARN:"; - break; - default: - sprintf(line, "FATAL %d:", lev); - cp = line; + case NOIND: + i = ElogDebugIndentLevel - 1; + if (i < 0) + i = 0; + if (i > 30) + i = i % 30; + cp = "DEBUG:"; + break; + case DEBUG: + i = ElogDebugIndentLevel; + if (i < 0) + i = 0; + if (i > 30) + i = i % 30; + cp = "DEBUG:"; + break; + case NOTICE: + cp = "NOTICE:"; + break; + case WARN: + cp = "WARN:"; + break; + default: + sprintf(line, "FATAL %d:", lev); + cp = line; } #ifdef ELOG_TIMESTAMPS time(&tim); @@ -166,7 +166,7 @@ elog(int lev, const char *fmt,...) if (lev == WARN) { - extern int InWarn; + extern int InWarn; ProcReleaseSpins(NULL); /* get rid of spinlocks we hold */ if (!InWarn) @@ -209,8 +209,8 @@ elog(int lev, const char *fmt,...) int DebugFileOpen(void) { - int fd, - istty; + int fd, + istty; Err_file = Debugfile = -1; ElogDebugIndentLevel = 0; diff --git a/src/backend/utils/error/exc.c b/src/backend/utils/error/exc.c index fd169b94a18..cfa0176440d 100644 --- a/src/backend/utils/error/exc.c +++ b/src/backend/utils/error/exc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.16 1997/09/07 04:53:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/exc.c,v 1.17 1997/09/08 02:31:29 momjian Exp $ * * NOTE * XXX this code needs improvement--check for state violations and @@ -34,16 +34,16 @@ ExcPrint(Exception * excP, ExcDetail detail, ExcData data, /* * Global Variables */ -static bool ExceptionHandlingEnabled = false; +static bool ExceptionHandlingEnabled = false; -char *ExcFileName = NULL; -Index ExcLineNumber = 0; +char *ExcFileName = NULL; +Index ExcLineNumber = 0; -ExcFrame *ExcCurFrameP = NULL; +ExcFrame *ExcCurFrameP = NULL; static ExcProc *ExcUnCaughtP = NULL; -extern char *ProgramName; +extern char *ProgramName; /* * Exported Functions @@ -103,8 +103,8 @@ ExcPrint(Exception * excP, ExcData data, ExcMessage message) { - extern int errno; - extern int sys_nerr; + extern int errno; + extern int sys_nerr; #ifdef lint data = data; @@ -141,7 +141,7 @@ ExcPrint(Exception * excP, } #ifdef NOT_USED -ExcProc * +ExcProc * ExcGetUnCaught(void) { return (ExcUnCaughtP); @@ -150,10 +150,10 @@ ExcGetUnCaught(void) #endif #ifdef NOT_USED -ExcProc * +ExcProc * ExcSetUnCaught(ExcProc * newP) { - ExcProc *oldP = ExcUnCaughtP; + ExcProc *oldP = ExcUnCaughtP; ExcUnCaughtP = newP; diff --git a/src/backend/utils/error/excid.c b/src/backend/utils/error/excid.c index ada9dabed70..b75a6f46b02 100644 --- a/src/backend/utils/error/excid.c +++ b/src/backend/utils/error/excid.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.3 1997/09/07 04:53:19 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/excid.c,v 1.4 1997/09/08 02:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,19 +25,19 @@ * FailedAssertion -- * Indicates an Assert(...) failed. */ -Exception FailedAssertion = {"Failed Assertion"}; +Exception FailedAssertion = {"Failed Assertion"}; /* * BadState -- * Indicates a function call request is inconsistent with module state. */ -Exception BadState = {"Bad State for Function Call"}; +Exception BadState = {"Bad State for Function Call"}; /* * BadArg -- * Indicates a function call argument or arguments is out-of-bounds. */ -Exception BadArg = {"Bad Argument to Function Call"}; +Exception BadArg = {"Bad Argument to Function Call"}; /***************************************************************************** * Specific Recoverable Exceptions * @@ -47,21 +47,21 @@ Exception BadArg = {"Bad Argument to Function Call"}; * BadAllocSize -- * Indicates that an allocation request is of unreasonable size. */ -Exception BadAllocSize = {"Too Large Allocation Request"}; +Exception BadAllocSize = {"Too Large Allocation Request"}; /* * ExhaustedMemory -- * Indicates an dynamic memory allocation failed. */ -Exception ExhaustedMemory = {"Memory Allocation Failed"}; +Exception ExhaustedMemory = {"Memory Allocation Failed"}; /* * Unimplemented -- * Indicates a function call request requires unimplemented code. */ -Exception Unimplemented = {"Unimplemented Functionality"}; +Exception Unimplemented = {"Unimplemented Functionality"}; -Exception CatalogFailure = {"Catalog failure"}; /* XXX inconsistent */ -Exception InternalError = {"Internal Error"}; /* XXX inconsistent */ -Exception SemanticError = {"Semantic Error"}; /* XXX inconsistent */ -Exception SystemError = {"System Error"}; /* XXX inconsistent */ +Exception CatalogFailure = {"Catalog failure"}; /* XXX inconsistent */ +Exception InternalError = {"Internal Error"}; /* XXX inconsistent */ +Exception SemanticError = {"Semantic Error"}; /* XXX inconsistent */ +Exception SystemError = {"System Error"}; /* XXX inconsistent */ diff --git a/src/backend/utils/error/format.c b/src/backend/utils/error/format.c index f996dbb8eb7..384da49a6f5 100644 --- a/src/backend/utils/error/format.c +++ b/src/backend/utils/error/format.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.4 1997/09/07 04:53:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/Attic/format.c,v 1.5 1997/09/08 02:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,17 +18,17 @@ #define FormMaxSize 1024 #define FormMinSize (FormMaxSize / 8) -static char FormBuf[FormMaxSize]; +static char FormBuf[FormMaxSize]; /* ---------------- * form * ---------------- */ -char * +char * form(const char *fmt,...) { - va_list args; + va_list args; va_start(args, fmt); diff --git a/src/backend/utils/fmgr/dfmgr.c b/src/backend/utils/fmgr/dfmgr.c index 0be7524290f..2fc776945f3 100644 --- a/src/backend/utils/fmgr/dfmgr.c +++ b/src/backend/utils/fmgr/dfmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.10 1997/09/07 04:53:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/dfmgr.c,v 1.11 1997/09/08 02:31:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,24 +41,24 @@ static DynamicFileList *file_tail = (DynamicFileList *) NULL; #define NOT_EQUAL(A, B) (((A).st_ino != (B).inode) \ || ((A).st_dev != (B).device)) -static Oid procedureId_save = -1; -static int pronargs_save; +static Oid procedureId_save = -1; +static int pronargs_save; static func_ptr user_fn_save = (func_ptr) NULL; static func_ptr handle_load(char *filename, char *funcname); -func_ptr trigger_dynamic(char *filename, char *funcname); +func_ptr trigger_dynamic(char *filename, char *funcname); func_ptr fmgr_dynamic(Oid procedureId, int *pronargs) { - HeapTuple procedureTuple; - Form_pg_proc procedureStruct; - char *proname; - char *probinattr, - *probinstring; - func_ptr user_fn; - Relation rdesc; - bool isnull; + HeapTuple procedureTuple; + Form_pg_proc procedureStruct; + char *proname; + char *probinattr, + *probinstring; + func_ptr user_fn; + Relation rdesc; + bool isnull; if (procedureId == procedureId_save) { @@ -118,13 +118,13 @@ fmgr_dynamic(Oid procedureId, int *pronargs) return (user_fn); } -static func_ptr +static func_ptr handle_load(char *filename, char *funcname) { DynamicFileList *file_scanner = (DynamicFileList *) NULL; - func_ptr retval = (func_ptr) NULL; - char *load_error; - struct stat stat_buf; + func_ptr retval = (func_ptr) NULL; + char *load_error; + struct stat stat_buf; /* * Do this because loading files may screw up the dynamic function @@ -247,10 +247,10 @@ void load_file(char *filename) { DynamicFileList *file_scanner, - *p; - struct stat stat_buf; + *p; + struct stat stat_buf; - int done = 0; + int done = 0; if (stat(filename, &stat_buf) == -1) { @@ -298,7 +298,7 @@ load_file(char *filename) func_ptr trigger_dynamic(char *filename, char *funcname) { - func_ptr trigger_fn; + func_ptr trigger_fn; trigger_fn = handle_load(filename, funcname); diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index f7d7b29d0a6..73238f0e15a 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.4 1997/09/07 04:53:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.5 1997/09/08 02:31:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,14 +29,14 @@ #include "utils/elog.h" -char * +char * fmgr_c(func_ptr user_fn, Oid func_id, int n_arguments, FmgrValues * values, bool * isNull) { - char *returnValue = (char *) NULL; + char *returnValue = (char *) NULL; if (user_fn == (func_ptr) NULL) @@ -52,63 +52,64 @@ fmgr_c(func_ptr user_fn, switch (n_arguments) { - case 0: - returnValue = (*user_fn) (); - break; - case 1: - /* NullValue() uses isNull to check if args[0] is NULL */ - returnValue = (*user_fn) (values->data[0], isNull); - break; - case 2: - returnValue = (*user_fn) (values->data[0], values->data[1]); - break; - case 3: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2]); - break; - case 4: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3]); - break; - case 5: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3], - values->data[4]); - break; - case 6: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3], - values->data[4], values->data[5]); - break; - case 7: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3], - values->data[4], values->data[5], - values->data[6]); - break; - case 8: - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3], - values->data[4], values->data[5], - values->data[6], values->data[7]); - break; - case 9: + case 0: + returnValue = (*user_fn) (); + break; + case 1: + /* NullValue() uses isNull to check if args[0] is NULL */ + returnValue = (*user_fn) (values->data[0], isNull); + break; + case 2: + returnValue = (*user_fn) (values->data[0], values->data[1]); + break; + case 3: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2]); + break; + case 4: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3]); + break; + case 5: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3], + values->data[4]); + break; + case 6: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3], + values->data[4], values->data[5]); + break; + case 7: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3], + values->data[4], values->data[5], + values->data[6]); + break; + case 8: + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3], + values->data[4], values->data[5], + values->data[6], values->data[7]); + break; + case 9: - /* - * XXX Note that functions with >8 arguments can only be called - * from inside the system, not from the user level, since the - * catalogs only store 8 argument types for user type-checking! - */ - returnValue = (*user_fn) (values->data[0], values->data[1], - values->data[2], values->data[3], - values->data[4], values->data[5], - values->data[6], values->data[7], - values->data[8]); - break; - default: - elog(WARN, "fmgr_c: function %d: too many arguments (%d > %d)", - func_id, n_arguments, MAXFMGRARGS); - break; + /* + * XXX Note that functions with >8 arguments can only be + * called from inside the system, not from the user level, + * since the catalogs only store 8 argument types for user + * type-checking! + */ + returnValue = (*user_fn) (values->data[0], values->data[1], + values->data[2], values->data[3], + values->data[4], values->data[5], + values->data[6], values->data[7], + values->data[8]); + break; + default: + elog(WARN, "fmgr_c: function %d: too many arguments (%d > %d)", + func_id, n_arguments, MAXFMGRARGS); + break; } return (returnValue); } @@ -116,11 +117,11 @@ fmgr_c(func_ptr user_fn, void fmgr_info(Oid procedureId, func_ptr * function, int *nargs) { - func_ptr user_fn = NULL; - FmgrCall *fcp; - HeapTuple procedureTuple; + func_ptr user_fn = NULL; + FmgrCall *fcp; + HeapTuple procedureTuple; FormData_pg_proc *procedureStruct; - Oid language; + Oid language; if (!(fcp = fmgr_isbuiltin(procedureId))) { @@ -143,22 +144,22 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs) language = procedureStruct->prolang; switch (language) { - case INTERNALlanguageId: - user_fn = fmgr_lookupByName(procedureStruct->proname.data); - if (!user_fn) - elog(WARN, "fmgr_info: function %s: not in internal table", - procedureStruct->proname.data); - break; - case ClanguageId: - user_fn = fmgr_dynamic(procedureId, nargs); - break; - case SQLlanguageId: - user_fn = (func_ptr) NULL; - *nargs = procedureStruct->pronargs; - break; - default: - elog(WARN, "fmgr_info: function %d: unknown language %d", - procedureId, language); + case INTERNALlanguageId: + user_fn = fmgr_lookupByName(procedureStruct->proname.data); + if (!user_fn) + elog(WARN, "fmgr_info: function %s: not in internal table", + procedureStruct->proname.data); + break; + case ClanguageId: + user_fn = fmgr_dynamic(procedureId, nargs); + break; + case SQLlanguageId: + user_fn = (func_ptr) NULL; + *nargs = procedureStruct->pronargs; + break; + default: + elog(WARN, "fmgr_info: function %d: unknown language %d", + procedureId, language); } } else @@ -180,15 +181,15 @@ fmgr_info(Oid procedureId, func_ptr * function, int *nargs) * Returns the return value of the invoked function if succesful, * 0 if unsuccessful. */ -char * +char * fmgr(Oid procedureId,...) { - va_list pvar; - register i; - int pronargs; - FmgrValues values; - func_ptr user_fn; - bool isNull = false; + va_list pvar; + register i; + int pronargs; + FmgrValues values; + func_ptr user_fn; + bool isNull = false; va_start(pvar, procedureId); @@ -218,14 +219,14 @@ fmgr(Oid procedureId,...) * func_ptr, func_id, n_arguments, args... */ #ifdef NOT_USED -char * +char * fmgr_ptr(func_ptr user_fn, Oid func_id,...) { - va_list pvar; - register i; - int n_arguments; - FmgrValues values; - bool isNull = false; + va_list pvar; + register i; + int n_arguments; + FmgrValues values; + bool isNull = false; va_start(pvar, func_id); n_arguments = va_arg(pvar, int); @@ -250,11 +251,11 @@ fmgr_ptr(func_ptr user_fn, Oid func_id,...) * function pointer field to FuncIndexInfo, it will be replace by calls * to fmgr_c(). */ -char * +char * fmgr_array_args(Oid procedureId, int nargs, char *args[], bool * isNull) { - func_ptr user_fn; - int true_arguments; + func_ptr user_fn; + int true_arguments; fmgr_info(procedureId, &user_fn, &true_arguments); diff --git a/src/backend/utils/hash/dynahash.c b/src/backend/utils/hash/dynahash.c index 736ca39d09f..8f306ff9a80 100644 --- a/src/backend/utils/hash/dynahash.c +++ b/src/backend/utils/hash/dynahash.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.8 1997/09/07 04:53:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/dynahash.c,v 1.9 1997/09/08 02:31:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,14 +64,14 @@ /* * Private function prototypes */ -static long *DynaHashAlloc(unsigned int size); -static void DynaHashFree(Pointer ptr); -static uint32 call_hash(HTAB * hashp, char *k, int len); +static long *DynaHashAlloc(unsigned int size); +static void DynaHashFree(Pointer ptr); +static uint32 call_hash(HTAB * hashp, char *k, int len); static SEG_OFFSET seg_alloc(HTAB * hashp); -static int bucket_alloc(HTAB * hashp); -static int dir_realloc(HTAB * hashp); +static int bucket_alloc(HTAB * hashp); +static int dir_realloc(HTAB * hashp); -typedef long *((*dhalloc_ptr) ()); +typedef long *((*dhalloc_ptr) ()); #ifndef FRONTEND /* ---------------- @@ -89,9 +89,9 @@ typedef long *((*dhalloc_ptr) ()); * do the latter -cim 1/19/91 * ---------------- */ -GlobalMemory DynaHashCxt = (GlobalMemory) NULL; +GlobalMemory DynaHashCxt = (GlobalMemory) NULL; -static long * +static long * DynaHashAlloc(unsigned int size) { if (!DynaHashCxt) @@ -122,9 +122,9 @@ DynaHashFree(Pointer ptr) * ---------------- */ -static int expand_table(HTAB * hashp); -static int hdefault(HTAB * hashp); -static int init_htab(HTAB * hashp, int nelem); +static int expand_table(HTAB * hashp); +static int hdefault(HTAB * hashp); +static int init_htab(HTAB * hashp, int nelem); /* @@ -146,19 +146,19 @@ static int init_htab(HTAB * hashp, int nelem); ( ((unsigned long) ptr) - ((unsigned long) (hp)->segbase) ) #if HASH_STATISTICS -static long hash_accesses, - hash_collisions, - hash_expansions; +static long hash_accesses, + hash_collisions, + hash_expansions; #endif /************************** CREATE ROUTINES **********************/ -HTAB * +HTAB * hash_create(int nelem, HASHCTL * info, int flags) { - register HHDR *hctl; - HTAB *hashp; + register HHDR *hctl; + HTAB *hashp; hashp = (HTAB *) MEM_ALLOC((unsigned long) sizeof(HTAB)); @@ -269,7 +269,7 @@ hash_create(int nelem, HASHCTL * info, int flags) static int hdefault(HTAB * hashp) { - HHDR *hctl; + HHDR *hctl; memset(hashp->hctl, 0, sizeof(HHDR)); @@ -303,10 +303,10 @@ static int init_htab(HTAB * hashp, int nelem) { register SEG_OFFSET *segp; - register int nbuckets; - register int nsegs; - int l2; - HHDR *hctl; + register int nbuckets; + register int nsegs; + int l2; + HHDR *hctl; hctl = hashp->hctl; @@ -388,13 +388,13 @@ hash_destroy(HTAB * hashp) if (hashp != NULL) { register SEG_OFFSET segNum; - SEGMENT segp; - int nsegs = hashp->hctl->nsegs; - int j; - BUCKET_INDEX *elp, - p, - q; - ELEMENT *curr; + SEGMENT segp; + int nsegs = hashp->hctl->nsegs; + int j; + BUCKET_INDEX *elp, + p, + q; + ELEMENT *curr; for (segNum = 0; nsegs > 0; nsegs--, segNum++) { @@ -440,12 +440,12 @@ hash_stats(char *where, HTAB * hashp) /*******************************SEARCH ROUTINES *****************************/ -static uint32 +static uint32 call_hash(HTAB * hashp, char *k, int len) { - long hash_val, - bucket; - HHDR *hctl; + long hash_val, + bucket; + HHDR *hctl; hctl = hashp->hctl; hash_val = hashp->hash(k, len); @@ -469,28 +469,28 @@ call_hash(HTAB * hashp, char *k, int len) * foundPtr is TRUE if we found an element in the table * (FALSE if we entered one). */ -long * +long * hash_search(HTAB * hashp, char *keyPtr, HASHACTION action, /* HASH_FIND / HASH_ENTER / HASH_REMOVE * HASH_FIND_SAVE / HASH_REMOVE_SAVED */ bool * foundPtr) { - uint32 bucket; - long segment_num; - long segment_ndx; - SEGMENT segp; + uint32 bucket; + long segment_num; + long segment_ndx; + SEGMENT segp; register ELEMENT *curr; - HHDR *hctl; - BUCKET_INDEX currIndex; - BUCKET_INDEX *prevIndexPtr; - char *destAddr; + HHDR *hctl; + BUCKET_INDEX currIndex; + BUCKET_INDEX *prevIndexPtr; + char *destAddr; static struct State { - ELEMENT *currElem; - BUCKET_INDEX currIndex; - BUCKET_INDEX *prevIndex; - } saveState; + ELEMENT *currElem; + BUCKET_INDEX currIndex; + BUCKET_INDEX *prevIndex; + } saveState; Assert((hashp && keyPtr)); Assert((action == HASH_FIND) || (action == HASH_REMOVE) || (action == HASH_ENTER) || (action == HASH_FIND_SAVE) || (action == HASH_REMOVE_SAVED)); @@ -553,46 +553,46 @@ hash_search(HTAB * hashp, *foundPtr = (bool) (currIndex != INVALID_INDEX); switch (action) { - case HASH_ENTER: - if (currIndex != INVALID_INDEX) - return (&(curr->key)); - break; - case HASH_REMOVE: - case HASH_REMOVE_SAVED: - if (currIndex != INVALID_INDEX) - { - Assert(hctl->nkeys > 0); - hctl->nkeys--; - - /* add the bucket to the freelist for this table. */ - *prevIndexPtr = curr->next; - curr->next = hctl->freeBucketIndex; - hctl->freeBucketIndex = currIndex; - - /* - * better hope the caller is synchronizing access to this - * element, because someone else is going to reuse it the next - * time something is added to the table - */ - return (&(curr->key)); - } - return ((long *) TRUE); - case HASH_FIND: - if (currIndex != INVALID_INDEX) - return (&(curr->key)); - return ((long *) TRUE); - case HASH_FIND_SAVE: - if (currIndex != INVALID_INDEX) - { - saveState.currElem = curr; - saveState.prevIndex = prevIndexPtr; - saveState.currIndex = currIndex; - return (&(curr->key)); - } - return ((long *) TRUE); - default: - /* can't get here */ - return (NULL); + case HASH_ENTER: + if (currIndex != INVALID_INDEX) + return (&(curr->key)); + break; + case HASH_REMOVE: + case HASH_REMOVE_SAVED: + if (currIndex != INVALID_INDEX) + { + Assert(hctl->nkeys > 0); + hctl->nkeys--; + + /* add the bucket to the freelist for this table. */ + *prevIndexPtr = curr->next; + curr->next = hctl->freeBucketIndex; + hctl->freeBucketIndex = currIndex; + + /* + * better hope the caller is synchronizing access to this + * element, because someone else is going to reuse it the + * next time something is added to the table + */ + return (&(curr->key)); + } + return ((long *) TRUE); + case HASH_FIND: + if (currIndex != INVALID_INDEX) + return (&(curr->key)); + return ((long *) TRUE); + case HASH_FIND_SAVE: + if (currIndex != INVALID_INDEX) + { + saveState.currElem = curr; + saveState.prevIndex = prevIndexPtr; + saveState.currIndex = currIndex; + return (&(curr->key)); + } + return ((long *) TRUE); + default: + /* can't get here */ + return (NULL); } /* @@ -653,16 +653,16 @@ hash_search(HTAB * hashp, * return TRUE in the end. * */ -long * +long * hash_seq(HTAB * hashp) { - static uint32 curBucket = 0; + static uint32 curBucket = 0; static BUCKET_INDEX curIndex; - ELEMENT *curElem; - long segment_num; - long segment_ndx; - SEGMENT segp; - HHDR *hctl; + ELEMENT *curElem; + long segment_num; + long segment_ndx; + SEGMENT segp; + HHDR *hctl; if (hashp == NULL) { @@ -723,20 +723,20 @@ hash_seq(HTAB * hashp) static int expand_table(HTAB * hashp) { - HHDR *hctl; - SEGMENT old_seg, - new_seg; - long old_bucket, - new_bucket; - long new_segnum, - new_segndx; - long old_segnum, - old_segndx; - ELEMENT *chain; - BUCKET_INDEX *old, - *newbi; + HHDR *hctl; + SEGMENT old_seg, + new_seg; + long old_bucket, + new_bucket; + long new_segnum, + new_segndx; + long old_segnum, + old_segndx; + ELEMENT *chain; + BUCKET_INDEX *old, + *newbi; register BUCKET_INDEX chainIndex, - nextIndex; + nextIndex; #ifdef HASH_STATISTICS hash_expansions++; @@ -811,10 +811,10 @@ expand_table(HTAB * hashp) static int dir_realloc(HTAB * hashp) { - register char *p; - char **p_ptr; - long old_dirsize; - long new_dirsize; + register char *p; + char **p_ptr; + long old_dirsize; + long new_dirsize; if (hashp->hctl->max_dsize != NO_MAX_DSIZE) @@ -840,11 +840,11 @@ dir_realloc(HTAB * hashp) } -static SEG_OFFSET +static SEG_OFFSET seg_alloc(HTAB * hashp) { - SEGMENT segp; - SEG_OFFSET segOffset; + SEGMENT segp; + SEG_OFFSET segOffset; segp = (SEGMENT) hashp->alloc((unsigned long) @@ -868,11 +868,11 @@ seg_alloc(HTAB * hashp) static int bucket_alloc(HTAB * hashp) { - int i; - ELEMENT *tmpBucket; - long bucketSize; - BUCKET_INDEX tmpIndex, - lastIndex; + int i; + ELEMENT *tmpBucket; + long bucketSize; + BUCKET_INDEX tmpIndex, + lastIndex; bucketSize = sizeof(BUCKET_INDEX) + hashp->hctl->keysize + hashp->hctl->datasize; @@ -918,8 +918,8 @@ bucket_alloc(HTAB * hashp) int my_log2(long num) { - int i = 1; - int limit; + int i = 1; + int limit; for (i = 0, limit = 1; limit < num; limit = 2 * limit, i++); return (i); diff --git a/src/backend/utils/hash/hashfn.c b/src/backend/utils/hash/hashfn.c index f7b8f3fde6e..a0439fb0baa 100644 --- a/src/backend/utils/hash/hashfn.c +++ b/src/backend/utils/hash/hashfn.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.4 1997/09/07 04:53:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/hash/hashfn.c,v 1.5 1997/09/08 02:31:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,7 +24,7 @@ long string_hash(char *key, int keysize) { - int h; + int h; register unsigned char *k = (unsigned char *) key; h = 0; @@ -43,7 +43,7 @@ string_hash(char *key, int keysize) long tag_hash(int *key, int keysize) { - register long h = 0; + register long h = 0; /* * Convert tag to integer; Use four byte chunks in a "jump table" to @@ -53,64 +53,64 @@ tag_hash(int *key, int keysize) */ switch (keysize) { - case 6 * sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - /* fall through */ - - case 5 * sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - /* fall through */ - - case 4 * sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - /* fall through */ - - case 3 * sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - /* fall through */ - - case 2 * sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - /* fall through */ - - case sizeof(int): - h = h * PRIME1 ^ (*key); - key++; - break; - - default: - for (; keysize > (sizeof(int) - 1); keysize -= sizeof(int), key++) + case 6 * sizeof(int): h = h * PRIME1 ^ (*key); + key++; + /* fall through */ - /* - * now let's grab the last few bytes of the tag if the tag has - * (size % 4) != 0 (which it sometimes will on a sun3). - */ - if (keysize) - { - char *keytmp = (char *) key; + case 5 * sizeof(int): + h = h * PRIME1 ^ (*key); + key++; + /* fall through */ + + case 4 * sizeof(int): + h = h * PRIME1 ^ (*key); + key++; + /* fall through */ + + case 3 * sizeof(int): + h = h * PRIME1 ^ (*key); + key++; + /* fall through */ + + case 2 * sizeof(int): + h = h * PRIME1 ^ (*key); + key++; + /* fall through */ - switch (keysize) + case sizeof(int): + h = h * PRIME1 ^ (*key); + key++; + break; + + default: + for (; keysize > (sizeof(int) - 1); keysize -= sizeof(int), key++) + h = h * PRIME1 ^ (*key); + + /* + * now let's grab the last few bytes of the tag if the tag has + * (size % 4) != 0 (which it sometimes will on a sun3). + */ + if (keysize) { - case 3: - h = h * PRIME1 ^ (*keytmp); - keytmp++; - /* fall through */ - case 2: - h = h * PRIME1 ^ (*keytmp); - keytmp++; - /* fall through */ - case 1: - h = h * PRIME1 ^ (*keytmp); - break; + char *keytmp = (char *) key; + + switch (keysize) + { + case 3: + h = h * PRIME1 ^ (*keytmp); + keytmp++; + /* fall through */ + case 2: + h = h * PRIME1 ^ (*keytmp); + keytmp++; + /* fall through */ + case 1: + h = h * PRIME1 ^ (*keytmp); + break; + } } - } - break; + break; } h %= PRIME2; @@ -130,10 +130,10 @@ tag_hash(int *key, int keysize) long disk_hash(char *key) { - register int n = 0; - register char *str = key; - register int len = strlen(key); - register int loop; + register int n = 0; + register char *str = key; + register int len = strlen(key); + register int loop; #define HASHC n = *str++ + 65599 * n @@ -143,25 +143,25 @@ disk_hash(char *key) switch (len & (8 - 1)) { - case 0: - do - { /* All fall throughs */ - HASHC; - case 7: - HASHC; - case 6: - HASHC; - case 5: - HASHC; - case 4: - HASHC; - case 3: - HASHC; - case 2: - HASHC; - case 1: - HASHC; - } while (--loop); + case 0: + do + { /* All fall throughs */ + HASHC; + case 7: + HASHC; + case 6: + HASHC; + case 5: + HASHC; + case 4: + HASHC; + case 3: + HASHC; + case 2: + HASHC; + case 1: + HASHC; + } while (--loop); } } diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index 5e6aa7412a6..e2cc9219a74 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -6,7 +6,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.6 1997/09/07 04:53:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.7 1997/09/08 02:31:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,14 +43,14 @@ int ValidateBackend(char *path) { - struct stat buf; - uid_t euid; - struct group *gp; - struct passwd *pwp; - int i; - int is_r = 0; - int is_x = 0; - int in_grp = 0; + struct stat buf; + uid_t euid; + struct group *gp; + struct passwd *pwp; + int i; + int is_r = 0; + int is_x = 0; + int in_grp = 0; /* * Ensure that the file exists and is a regular file. @@ -153,12 +153,12 @@ ValidateBackend(char *path) int FindBackend(char *backend, char *argv0) { - char buf[MAXPGPATH + 2]; - char *p; - char *path, - *startp, - *endp; - int pathlen; + char buf[MAXPGPATH + 2]; + char *p; + char *path, + *startp, + *endp; + int pathlen; /* * for the postmaster: First try: use the backend that's located in @@ -222,20 +222,20 @@ FindBackend(char *backend, char *argv0) strcat(buf, "/postgres"); switch (ValidateBackend(buf)) { - case 0: /* found ok */ - strncpy(backend, buf, MAXPGPATH); - if (DebugLvl) - fprintf(stderr, "FindBackend: found \"%s\" using PATH\n", - backend); - free(path); - return (0); - case -1: /* wasn't even a candidate, keep looking */ - break; - case -2: /* found but disqualified */ - fprintf(stderr, "FindBackend: could not read backend \"%s\"\n", - buf); - free(path); - return (-1); + case 0: /* found ok */ + strncpy(backend, buf, MAXPGPATH); + if (DebugLvl) + fprintf(stderr, "FindBackend: found \"%s\" using PATH\n", + backend); + free(path); + return (0); + case -1: /* wasn't even a candidate, keep looking */ + break; + case -2: /* found but disqualified */ + fprintf(stderr, "FindBackend: could not read backend \"%s\"\n", + buf); + free(path); + return (-1); } if (!endp) /* last one */ break; diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 2ed0c83e0b2..131e352ddfb 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.11 1997/09/07 04:53:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.12 1997/09/08 02:31:56 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -36,52 +36,52 @@ #include "catalog/catname.h" -int Portfd = -1; -int Noversion = 0; -int Quiet = 1; +int Portfd = -1; +int Noversion = 0; +int Quiet = 1; -int MasterPid; -char *DataDir; +int MasterPid; +char *DataDir; /* * The PGDATA directory user says to use, or defaults to via environment * variable. NULL if no option given and no environment variable set */ -Relation reldesc; /* current relation descriptor */ +Relation reldesc; /* current relation descriptor */ -char OutputFileName[MAXPGPATH] = ""; +char OutputFileName[MAXPGPATH] = ""; -BackendId MyBackendId; -BackendTag MyBackendTag; +BackendId MyBackendId; +BackendTag MyBackendTag; -char *UserName = NULL; -char *DatabaseName = NULL; -char *DatabasePath = NULL; +char *UserName = NULL; +char *DatabaseName = NULL; +char *DatabasePath = NULL; -bool MyDatabaseIdIsInitialized = false; -Oid MyDatabaseId = InvalidOid; -bool TransactionInitWasProcessed = false; +bool MyDatabaseIdIsInitialized = false; +Oid MyDatabaseId = InvalidOid; +bool TransactionInitWasProcessed = false; -bool IsUnderPostmaster = false; -bool IsPostmaster = false; +bool IsUnderPostmaster = false; +bool IsPostmaster = false; -short DebugLvl = 0; +short DebugLvl = 0; -int DateStyle = USE_POSTGRES_DATES; -bool EuroDates = false; -bool HasCTZSet = false; -bool CDayLight = false; -int CTimeZone = 0; -char CTZName[MAXTZLEN + 1] = ""; +int DateStyle = USE_POSTGRES_DATES; +bool EuroDates = false; +bool HasCTZSet = false; +bool CDayLight = false; +int CTimeZone = 0; +char CTZName[MAXTZLEN + 1] = ""; -char DateFormat[20] = "%d-%m-%Y"; /* mjl: sizes! or better +char DateFormat[20] = "%d-%m-%Y"; /* mjl: sizes! or better * malloc? XXX */ -char FloatFormat[20] = "%f"; +char FloatFormat[20] = "%f"; -int fsyncOff = 0; -int SortMem = 512; +int fsyncOff = 0; +int SortMem = 512; -char *IndexedCatalogNames[] = { +char *IndexedCatalogNames[] = { AttributeRelationName, ProcedureRelationName, TypeRelationName, @@ -105,7 +105,7 @@ char *IndexedCatalogNames[] = { * XXX this is a serious hack which should be fixed -cim 1/26/90 * ---------------- */ -char *SharedSystemRelationNames[] = { +char *SharedSystemRelationNames[] = { DatabaseRelationName, DefaultsRelationName, DemonRelationName, diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index 71efb80d120..e608bb484f8 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.7 1997/09/07 04:53:49 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.8 1997/09/08 02:31:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,12 +44,12 @@ */ #define EnableAbortEnvVarName "POSTGRESABORT" -extern char *getenv(const char *name); /* XXX STDLIB */ +extern char *getenv(const char *name); /* XXX STDLIB */ /* from globals.c */ -extern char *DatabaseName; -extern char *UserName; -extern char *DatabasePath; +extern char *DatabaseName; +extern char *UserName; +extern char *DatabasePath; /* @@ -105,7 +105,7 @@ ExitPostgres(ExitStatus status) void AbortPostgres() { - char *abortValue = getenv(EnableAbortEnvVarName); + char *abortValue = getenv(EnableAbortEnvVarName); #ifdef __SABER__ saber_stop(); @@ -223,7 +223,7 @@ GetProcessingMode() * Returns path to database. * */ -char * +char * GetDatabasePath() { return DatabasePath; @@ -233,7 +233,7 @@ GetDatabasePath() * GetDatabaseName -- * Returns name of database. */ -char * +char * GetDatabaseName() { return DatabaseName; @@ -269,7 +269,7 @@ SetDatabaseName(char *name) * in pg_proc.h). Define GetPgUserName() as a macro - tgl 97/04/26 * ---------------- */ -char * +char * getpgusername() { return UserName; @@ -279,8 +279,8 @@ void SetPgUserName() { #ifndef NO_SECURITY - char *p; - struct passwd *pw; + char *p; + struct passwd *pw; if (IsUnderPostmaster) { @@ -306,7 +306,7 @@ SetPgUserName() * GetUserId and SetUserId * ---------------------------------------------------------------- */ -static Oid UserId = InvalidOid; +static Oid UserId = InvalidOid; Oid GetUserId() @@ -318,8 +318,8 @@ GetUserId() void SetUserId() { - HeapTuple userTup; - char *userName; + HeapTuple userTup; + char *userName; Assert(!OidIsValid(UserId));/* only once */ diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 5a8a1a83d4d..47e7842d451 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.13 1997/09/07 04:53:50 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.14 1997/09/08 02:31:58 momjian Exp $ * * NOTES * InitPostgres() is the function called from PostgresMain @@ -70,13 +70,13 @@ #include "port-protos.h" #include "libpq/libpq-be.h" -static void InitCommunication(void); -static void InitMyDatabaseId(void); -static void InitStdio(void); -static void InitUserid(void); +static void InitCommunication(void); +static void InitMyDatabaseId(void); +static void InitStdio(void); +static void InitUserid(void); -static IPCKey PostgresIpcKey; +static IPCKey PostgresIpcKey; /* ---------------------------------------------------------------- * InitPostgres support @@ -106,15 +106,15 @@ static IPCKey PostgresIpcKey; static void InitMyDatabaseId() { - int dbfd; - int fileflags; - int nbytes; - int max, - i; - HeapTuple tup; - Page pg; - PageHeader ph; - char *dbfname; + int dbfd; + int fileflags; + int nbytes; + int max, + i; + HeapTuple tup; + Page pg; + PageHeader ph; + char *dbfname; Form_pg_database tup_db; /* @@ -165,7 +165,7 @@ InitMyDatabaseId() /* look at each tuple on the page */ for (i = 0; i <= max; i++) { - int offset; + int offset; /* if it's a freed tuple, ignore it */ if (!(ph->pd_linp[i].lp_flags & LP_USED)) @@ -253,11 +253,11 @@ done: static void DoChdirAndInitDatabaseNameAndPath(char *name) { - char *reason; + char *reason; /* Failure reason returned by some function. NULL if no failure */ - int fd; - char errormsg[1000]; + int fd; + char errormsg[1000]; if ((fd = open(DataDir, O_RDONLY, 0)) == -1) sprintf(errormsg, "Database system does not exist. " @@ -266,8 +266,7 @@ DoChdirAndInitDatabaseNameAndPath(char *name) DataDir); else { - char myPath[MAXPGPATH]; /* DatabasePath points - * here! */ + char myPath[MAXPGPATH]; /* DatabasePath points here! */ close(fd); if (strlen(DataDir) + strlen(name) + 10 > sizeof(myPath)) @@ -317,8 +316,8 @@ DoChdirAndInitDatabaseNameAndPath(char *name) * The directories and PG_VERSION files are in * order. */ - int rc; /* return code from some - * function we call */ + int rc; /* return code from some function + * we call */ SetDatabasePath(myPath); SetDatabaseName(name); @@ -368,9 +367,9 @@ InitUserid() static void InitCommunication() { - char *postid; - char *postport; - IPCKey key = 0; + char *postid; + char *postport; + IPCKey key = 0; /* ---------------- * try and get the backend tag from POSTID @@ -495,8 +494,8 @@ InitStdio() * Be very careful with the order of calls in the InitPostgres function. * -------------------------------- */ -bool PostgresIsInitialized = false; -extern int NBuffers; +bool PostgresIsInitialized = false; +extern int NBuffers; /* * this global is used by wei for testing his code, but must be declared @@ -505,14 +504,14 @@ extern int NBuffers; */ /*int testFlag = 0;*/ -int lockingOff = 0; +int lockingOff = 0; /* */ void InitPostgres(char *name) /* database name */ { - bool bootstrap; /* true if BootstrapProcessing */ + bool bootstrap; /* true if BootstrapProcessing */ /* ---------------- * see if we're running in BootstrapProcessing mode diff --git a/src/backend/utils/misc/superuser.c b/src/backend/utils/misc/superuser.c index 57a9950dea3..bfc6efdeae6 100644 --- a/src/backend/utils/misc/superuser.c +++ b/src/backend/utils/misc/superuser.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.3 1997/09/07 04:53:52 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/superuser.c,v 1.4 1997/09/08 02:32:00 momjian Exp $ * * DESCRIPTION * See superuser(). @@ -26,9 +26,9 @@ superuser(void) The Postgres user running this command has Postgres superuser privileges. --------------------------------------------------------------------------*/ - extern char *UserName; /* defined in global.c */ + extern char *UserName; /* defined in global.c */ - HeapTuple utup; + HeapTuple utup; utup = SearchSysCacheTuple(USENAME, PointerGetDatum(UserName), 0, 0, 0); diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index c07fb1bd587..f78d8b5f320 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.6 1997/09/07 04:54:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.7 1997/09/08 02:32:05 momjian Exp $ * * NOTE * XXX This is a preliminary implementation which lacks fail-fast @@ -25,7 +25,7 @@ #include <string.h> #endif -static void AllocPointerDump(AllocPointer pointer); +static void AllocPointerDump(AllocPointer pointer); static int AllocSetIterate(AllocSet set, void (*function) (AllocPointer pointer)); @@ -45,8 +45,8 @@ AllocSetIterate(AllocSet set, typedef struct AllocElemData { OrderedElemData elemData; /* elem in AllocSet */ - Size size; -} AllocElemData; + Size size; +} AllocElemData; typedef AllocElemData *AllocElem; @@ -125,7 +125,7 @@ AllocSetInit(AllocSet set, AllocMode mode, Size limit) void AllocSetReset(AllocSet set) { - AllocPointer pointer; + AllocPointer pointer; AssertArg(AllocSetIsValid(set)); @@ -139,7 +139,7 @@ AllocSetReset(AllocSet set) void AllocSetReset_debug(char *file, int line, AllocSet set) { - AllocPointer pointer; + AllocPointer pointer; AssertArg(AllocSetIsValid(set)); @@ -181,7 +181,7 @@ AllocSetContains(AllocSet set, AllocPointer pointer) AllocPointer AllocSetAlloc(AllocSet set, Size size) { - AllocElem alloc; + AllocElem alloc; AssertArg(AllocSetIsValid(set)); @@ -214,7 +214,7 @@ AllocSetAlloc(AllocSet set, Size size) void AllocSetFree(AllocSet set, AllocPointer pointer) { - AllocElem alloc; + AllocElem alloc; /* AssertArg(AllocSetIsValid(set)); */ /* AssertArg(AllocPointerIsValid(pointer)); */ @@ -244,8 +244,8 @@ AllocSetFree(AllocSet set, AllocPointer pointer) AllocPointer AllocSetRealloc(AllocSet set, AllocPointer pointer, Size size) { - AllocPointer newPointer; - AllocElem alloc; + AllocPointer newPointer; + AllocElem alloc; /* AssertArg(AllocSetIsValid(set)); */ /* AssertArg(AllocPointerIsValid(pointer)); */ @@ -287,8 +287,8 @@ static int AllocSetIterate(AllocSet set, void (*function) (AllocPointer pointer)) { - int count = 0; - AllocPointer pointer; + int count = 0; + AllocPointer pointer; AssertArg(AllocSetIsValid(set)); @@ -311,8 +311,8 @@ AllocSetIterate(AllocSet set, int AllocSetCount(AllocSet set) { - int count = 0; - AllocPointer pointer; + int count = 0; + AllocPointer pointer; AssertArg(AllocSetIsValid(set)); @@ -338,10 +338,10 @@ AllocSetCount(AllocSet set) * Note: * Assumes set is valid. */ -static AllocPointer +static AllocPointer AllocSetGetFirst(AllocSet set) { - AllocElem alloc; + AllocElem alloc; alloc = (AllocElem) OrderedSetGetHead(&set->setData); @@ -360,10 +360,10 @@ AllocSetGetFirst(AllocSet set) * Note: * Assumes pointer is valid. */ -static AllocPointer +static AllocPointer AllocPointerGetNext(AllocPointer pointer) { - AllocElem alloc; + AllocElem alloc; alloc = (AllocElem) OrderedElemGetSuccessor(&AllocPointerGetAllocElem(pointer)->elemData); @@ -398,7 +398,7 @@ AllocPointerDump(AllocPointer pointer) void AllocSetDump(AllocSet set) { - int count; + int count; count = AllocSetIterate(set, AllocPointerDump); printf("\ttotal %d allocations\n", count); diff --git a/src/backend/utils/mmgr/mcxt.c b/src/backend/utils/mmgr/mcxt.c index dbd1b6e19f6..61cf729fa8b 100644 --- a/src/backend/utils/mmgr/mcxt.c +++ b/src/backend/utils/mmgr/mcxt.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.4 1997/09/07 04:54:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/mcxt.c,v 1.5 1997/09/08 02:32:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,7 +35,7 @@ /* * Global State */ -static int MemoryContextEnableCount = 0; +static int MemoryContextEnableCount = 0; #define MemoryContextEnabled (MemoryContextEnableCount > 0) @@ -67,22 +67,22 @@ static OrderedSetData ActiveGlobalMemorySetData; /* uninitialized */ * CurrentMemoryContext -- * Memory context for general global allocations. */ -MemoryContext CurrentMemoryContext = NULL; +MemoryContext CurrentMemoryContext = NULL; /***************************************************************************** * PRIVATE DEFINITIONS * *****************************************************************************/ -static Pointer GlobalMemoryAlloc(GlobalMemory this, Size size); -static void GlobalMemoryFree(GlobalMemory this, Pointer pointer); +static Pointer GlobalMemoryAlloc(GlobalMemory this, Size size); +static void GlobalMemoryFree(GlobalMemory this, Pointer pointer); static Pointer GlobalMemoryRealloc(GlobalMemory this, Pointer pointer, Size size); -static char *GlobalMemoryGetName(GlobalMemory this); -static void GlobalMemoryDump(GlobalMemory this); +static char *GlobalMemoryGetName(GlobalMemory this); +static void GlobalMemoryDump(GlobalMemory this); #ifdef NOT_USED -static void DumpGlobalMemories(void); +static void DumpGlobalMemories(void); #endif @@ -121,7 +121,7 @@ static struct GlobalMemory TopGlobalMemoryData = { * allocate something here, you are expected to clean it up when * appropriate. */ -MemoryContext TopMemoryContext = (MemoryContext) & TopGlobalMemoryData; +MemoryContext TopMemoryContext = (MemoryContext) & TopGlobalMemoryData; @@ -145,7 +145,7 @@ MemoryContext TopMemoryContext = (MemoryContext) & TopGlobalMemoryData; void EnableMemoryContext(bool on) { - static bool processing = false; + static bool processing = false; AssertState(!processing); AssertArg(BoolIsValid(on)); @@ -175,7 +175,7 @@ EnableMemoryContext(bool on) } else { /* cleanup */ - GlobalMemory context; + GlobalMemory context; /* walk the list of allocations */ while (PointerIsValid(context = (GlobalMemory) @@ -293,7 +293,7 @@ MemoryContextRealloc(MemoryContext context, * BadArgumentsErr if firstTime is true for subsequent calls. */ #ifdef NOT_USED -char * +char * MemoryContextGetName(MemoryContext context) { AssertState(MemoryContextEnabled); @@ -341,7 +341,7 @@ PointerGetAllocSize(Pointer pointer) MemoryContext MemoryContextSwitchTo(MemoryContext context) { - MemoryContext old; + MemoryContext old; AssertState(MemoryContextEnabled); AssertArg(MemoryContextIsValid(context)); @@ -369,8 +369,8 @@ MemoryContextSwitchTo(MemoryContext context) GlobalMemory CreateGlobalMemory(char *name) /* XXX MemoryContextName */ { - GlobalMemory context; - MemoryContext savecxt; + GlobalMemory context; + MemoryContext savecxt; AssertState(MemoryContextEnabled); @@ -423,7 +423,7 @@ GlobalMemoryDestroy(GlobalMemory context) * Exceptions: * ExhaustedMemory if allocation fails. */ -static Pointer +static Pointer GlobalMemoryAlloc(GlobalMemory this, Size size) { return (AllocSetAlloc(&this->setData, size)); @@ -456,7 +456,7 @@ GlobalMemoryFree(GlobalMemory this, * BadArgumentsErr if pointer is invalid. * NoMoreMemoryErr if allocation fails. */ -static Pointer +static Pointer GlobalMemoryRealloc(GlobalMemory this, Pointer pointer, Size size) @@ -471,7 +471,7 @@ GlobalMemoryRealloc(GlobalMemory this, * Exceptions: * ??? */ -static char * +static char * GlobalMemoryGetName(GlobalMemory this) { return (this->name); @@ -487,7 +487,7 @@ GlobalMemoryGetName(GlobalMemory this) static void GlobalMemoryDump(GlobalMemory this) { - GlobalMemory context; + GlobalMemory context; printf("--\n%s:\n", GlobalMemoryGetName(this)); @@ -517,7 +517,7 @@ GlobalMemoryDump(GlobalMemory this) static void DumpGlobalMemories() { - GlobalMemory context; + GlobalMemory context; context = (GlobalMemory) OrderedSetGetHead(&ActiveGlobalMemorySetData); diff --git a/src/backend/utils/mmgr/oset.c b/src/backend/utils/mmgr/oset.c index 758b701ff55..7def05f5656 100644 --- a/src/backend/utils/mmgr/oset.c +++ b/src/backend/utils/mmgr/oset.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.4 1997/09/07 04:54:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/oset.c,v 1.5 1997/09/08 02:32:14 momjian Exp $ * * NOTE * XXX This is a preliminary implementation which lacks fail-fast @@ -19,15 +19,15 @@ #include "utils/memutils.h" /* where declarations of this file goes */ -static Pointer OrderedElemGetBase(OrderedElem elem); -static void OrderedElemPush(OrderedElem elem); -static void OrderedElemPushHead(OrderedElem elem); +static Pointer OrderedElemGetBase(OrderedElem elem); +static void OrderedElemPush(OrderedElem elem); +static void OrderedElemPushHead(OrderedElem elem); /* * OrderedElemGetBase -- * Returns base of enclosing structure. */ -static Pointer +static Pointer OrderedElemGetBase(OrderedElem elem) { if (elem == (OrderedElem) NULL) diff --git a/src/backend/utils/mmgr/palloc.c b/src/backend/utils/mmgr/palloc.c index f644706c911..bd680464b93 100644 --- a/src/backend/utils/mmgr/palloc.c +++ b/src/backend/utils/mmgr/palloc.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.4 1997/09/07 04:54:12 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/Attic/palloc.c,v 1.5 1997/09/08 02:32:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ * NonallocatedPointer if pointer was not returned by palloc or repalloc * or may have been subsequently freed. */ -void * +void * palloc(Size size) { #ifdef PALLOC_IS_MALLOC @@ -94,7 +94,7 @@ pfree(void *pointer) * NonallocatedPointer if pointer was not returned by palloc or repalloc * or may have been freed already. */ -void * +void * repalloc(void *pointer, Size size) { #ifdef PALLOC_IS_MALLOC @@ -107,10 +107,10 @@ repalloc(void *pointer, Size size) /* pstrdup allocates space for and copies a string just like strdup except it uses palloc instead of malloc */ -char * +char * pstrdup(char *string) { - char *nstr; + char *nstr; nstr = (char *) palloc(strlen(string) + 1); strcpy(nstr, string); diff --git a/src/backend/utils/mmgr/portalmem.c b/src/backend/utils/mmgr/portalmem.c index 595153b0ce6..0cdd54d35bc 100644 --- a/src/backend/utils/mmgr/portalmem.c +++ b/src/backend/utils/mmgr/portalmem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.6 1997/09/07 04:54:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/portalmem.c,v 1.7 1997/09/08 02:32:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,11 +91,11 @@ #include "utils/portal.h" -static void CollectNamedPortals(Portal * portalP, int destroy); -static Portal PortalHeapMemoryGetPortal(PortalHeapMemory context); +static void CollectNamedPortals(Portal * portalP, int destroy); +static Portal PortalHeapMemoryGetPortal(PortalHeapMemory context); static PortalVariableMemory PortalHeapMemoryGetVariableMemory(PortalHeapMemory context); -static void PortalResetHeapMemory(Portal portal); -static Portal PortalVariableMemoryGetPortal(PortalVariableMemory context); +static void PortalResetHeapMemory(Portal portal); +static Portal PortalVariableMemoryGetPortal(PortalVariableMemory context); /* ---------------- * ALLOCFREE_ERROR_ABORT @@ -110,19 +110,19 @@ static Portal PortalVariableMemoryGetPortal(PortalVariableMemory context); * ---------------- */ -static int PortalManagerEnableCount = 0; +static int PortalManagerEnableCount = 0; #define MAX_PORTALNAME_LEN 64 /* XXX LONGALIGNable value */ typedef struct portalhashent { - char portalname[MAX_PORTALNAME_LEN]; - Portal portal; -} PortalHashEnt; + char portalname[MAX_PORTALNAME_LEN]; + Portal portal; +} PortalHashEnt; #define PortalManagerEnabled (PortalManagerEnableCount >= 1) -static HTAB *PortalHashTable = NULL; +static HTAB *PortalHashTable = NULL; #define PortalHashTableLookup(NAME, PORTAL) \ { PortalHashEnt *hentry; bool found; char key[MAX_PORTALNAME_LEN]; \ @@ -162,9 +162,9 @@ static HTAB *PortalHashTable = NULL; } static GlobalMemory PortalMemory = NULL; -static char PortalMemoryName[] = "Portal"; +static char PortalMemoryName[] = "Portal"; -static Portal BlankPortal = NULL; +static Portal BlankPortal = NULL; /* ---------------- * Internal class definitions @@ -172,9 +172,9 @@ static Portal BlankPortal = NULL; */ typedef struct HeapMemoryBlockData { - AllocSetData setData; - FixedItemData itemData; -} HeapMemoryBlockData; + AllocSetData setData; + FixedItemData itemData; +} HeapMemoryBlockData; typedef HeapMemoryBlockData *HeapMemoryBlock; @@ -189,7 +189,7 @@ typedef HeapMemoryBlockData *HeapMemoryBlock; * PortalVariableMemoryAlloc * ---------------- */ -static Pointer +static Pointer PortalVariableMemoryAlloc(PortalVariableMemory this, Size size) { @@ -211,7 +211,7 @@ PortalVariableMemoryFree(PortalVariableMemory this, * PortalVariableMemoryRealloc * ---------------- */ -static Pointer +static Pointer PortalVariableMemoryRealloc(PortalVariableMemory this, Pointer pointer, Size size) @@ -223,7 +223,7 @@ PortalVariableMemoryRealloc(PortalVariableMemory this, * PortalVariableMemoryGetName * ---------------- */ -static char * +static char * PortalVariableMemoryGetName(PortalVariableMemory this) { return (form("%s-var", PortalVariableMemoryGetPortal(this)->name)); @@ -245,7 +245,7 @@ PortalVariableMemoryDump(PortalVariableMemory this) * PortalHeapMemoryAlloc * ---------------- */ -static Pointer +static Pointer PortalHeapMemoryAlloc(PortalHeapMemory this, Size size) { @@ -285,7 +285,7 @@ PortalHeapMemoryFree(PortalHeapMemory this, * PortalHeapMemoryRealloc * ---------------- */ -static Pointer +static Pointer PortalHeapMemoryRealloc(PortalHeapMemory this, Pointer pointer, Size size) @@ -301,7 +301,7 @@ PortalHeapMemoryRealloc(PortalHeapMemory this, * PortalHeapMemoryGetName * ---------------- */ -static char * +static char * PortalHeapMemoryGetName(PortalHeapMemory this) { return (form("%s-heap", PortalHeapMemoryGetPortal(this)->name)); @@ -366,7 +366,7 @@ static struct MemoryContextMethodsData PortalHeapContextMethodsData = { static void CreateNewBlankPortal() { - Portal portal; + Portal portal; AssertState(!PortalIsValid(BlankPortal)); @@ -428,16 +428,16 @@ PortalNameIsSpecial(char *pname) static void CollectNamedPortals(Portal * portalP, int destroy) { - static Portal *portalList = (Portal *) NULL; - static int listIndex = 0; - static int maxIndex = 9; + static Portal *portalList = (Portal *) NULL; + static int listIndex = 0; + static int maxIndex = 9; if (portalList == (Portal *) NULL) portalList = (Portal *) malloc(10 * sizeof(Portal)); if (destroy != 0) { - int i; + int i; for (i = 0; i < listIndex; i++) PortalDestroy(&portalList[i]); @@ -515,8 +515,8 @@ DumpPortals() void EnablePortalManager(bool on) { - static bool processing = false; - HASHCTL ctl; + static bool processing = false; + HASHCTL ctl; AssertState(!processing); AssertArg(BoolIsValid(on)); @@ -581,7 +581,7 @@ EnablePortalManager(bool on) Portal GetPortalByName(char *name) { - Portal portal; + Portal portal; AssertState(PortalManagerEnabled); @@ -615,8 +615,8 @@ GetPortalByName(char *name) Portal BlankPortalAssignName(char *name) /* XXX PortalName */ { - Portal portal; - uint16 length; + Portal portal; + uint16 length; AssertState(PortalManagerEnabled); AssertState(PortalIsValid(BlankPortal)); @@ -687,7 +687,7 @@ PortalSetQuery(Portal portal, * BadState if called when disabled. * BadArg if portal is invalid. */ -QueryDesc * +QueryDesc * PortalGetQueryDesc(Portal portal) { AssertState(PortalManagerEnabled); @@ -704,7 +704,7 @@ PortalGetQueryDesc(Portal portal) * BadState if called when disabled. * BadArg if portal is invalid. */ -EState * +EState * PortalGetState(Portal portal) { AssertState(PortalManagerEnabled); @@ -729,8 +729,8 @@ PortalGetState(Portal portal) Portal CreatePortal(char *name) /* XXX PortalName */ { - Portal portal; - uint16 length; + Portal portal; + uint16 length; AssertState(PortalManagerEnabled); AssertArg(PointerIsValid(name)); /* XXX PortalName */ @@ -788,7 +788,7 @@ CreatePortal(char *name) /* XXX PortalName */ void PortalDestroy(Portal * portalP) { - Portal portal = *portalP; + Portal portal = *portalP; AssertState(PortalManagerEnabled); AssertArg(PortalIsValid(portal)); @@ -828,7 +828,7 @@ static void PortalResetHeapMemory(Portal portal) { PortalHeapMemory context; - MemoryContext currentContext; + MemoryContext currentContext; context = PortalGetHeapMemory(portal); @@ -955,7 +955,7 @@ PortalGetHeapMemory(Portal portal) * BadState if called when disabled. * BadArg if context is invalid. */ -static Portal +static Portal PortalVariableMemoryGetPortal(PortalVariableMemory context) { return ((Portal) ((char *) context - offsetof(PortalD, variable))); @@ -969,7 +969,7 @@ PortalVariableMemoryGetPortal(PortalVariableMemory context) * BadState if called when disabled. * BadArg if context is invalid. */ -static Portal +static Portal PortalHeapMemoryGetPortal(PortalHeapMemory context) { return ((Portal) ((char *) context - offsetof(PortalD, heap))); @@ -1002,7 +1002,7 @@ PortalVariableMemoryGetHeapMemory(PortalVariableMemory context) * BadState if called when disabled. * BadArg if context is invalid. */ -static PortalVariableMemory +static PortalVariableMemory PortalHeapMemoryGetVariableMemory(PortalHeapMemory context) { return ((PortalVariableMemory) ((char *) context diff --git a/src/backend/utils/sort/lselect.c b/src/backend/utils/sort/lselect.c index bc6948292b3..e4dab6583aa 100644 --- a/src/backend/utils/sort/lselect.c +++ b/src/backend/utils/sort/lselect.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.6 1997/09/07 04:54:16 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/lselect.c,v 1.7 1997/09/08 02:32:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,9 +47,9 @@ struct leftist * lmerge(struct leftist * pt, struct leftist * qt, LeftistContext context) { register struct leftist *root, - *majorLeftist, - *minorLeftist; - int dist; + *majorLeftist, + *minorLeftist; + int dist; if (tuplecmp(pt->lt_tuple, qt->lt_tuple, context)) { @@ -86,7 +86,7 @@ static struct leftist * linsert(struct leftist * root, struct leftist * new1, LeftistContext context) { register struct leftist *left, - *right; + *right; if (!tuplecmp(root->lt_tuple, new1->lt_tuple, context)) { @@ -139,7 +139,7 @@ gettuple(struct leftist ** treep, LeftistContext context) { register struct leftist *tp; - HeapTuple tup; + HeapTuple tup; tp = *treep; tup = tp->lt_tuple; @@ -197,11 +197,11 @@ puttuple(struct leftist ** treep, int tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context) { - register char *lattr, - *rattr; - int nkey = 0; - int result = 0; - bool isnull; + register char *lattr, + *rattr; + int nkey = 0; + int result = 0; + bool isnull; if (ltup == (HeapTuple) NULL) return (0); @@ -240,8 +240,8 @@ tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context) void checktree(struct leftist * tree, LeftistContext context) { - int lnodes; - int rnodes; + int lnodes; + int rnodes; if (tree == NULL) { @@ -292,9 +292,9 @@ checktree(struct leftist * tree, LeftistContext context) int checktreer(struct leftist * tree, int level, LeftistContext context) { - int lnodes, - rnodes; - int error = 0; + int lnodes, + rnodes; + int error = 0; if (tree == NULL) return (0); diff --git a/src/backend/utils/sort/psort.c b/src/backend/utils/sort/psort.c index 00cbfbacba5..a84dabd1c76 100644 --- a/src/backend/utils/sort/psort.c +++ b/src/backend/utils/sort/psort.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.19 1997/09/07 04:54:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/Attic/psort.c,v 1.20 1997/09/08 02:32:29 momjian Exp $ * * NOTES * Sorts the first relation into the second relation. @@ -64,21 +64,21 @@ #include "miscadmin.h" #include "storage/fd.h" -static bool createrun(Sort * node, FILE * file, bool * empty); -static void destroytape(FILE * file); -static void dumptuples(FILE * file, Sort * node); -static FILE *gettape(void); -static void initialrun(Sort * node, bool * empty); -static void inittapes(Sort * node); -static void merge(Sort * node, struct tape * dest); -static FILE *mergeruns(Sort * node); +static bool createrun(Sort * node, FILE * file, bool * empty); +static void destroytape(FILE * file); +static void dumptuples(FILE * file, Sort * node); +static FILE *gettape(void); +static void initialrun(Sort * node, bool * empty); +static void inittapes(Sort * node); +static void merge(Sort * node, struct tape * dest); +static FILE *mergeruns(Sort * node); static HeapTuple tuplecopy(HeapTuple tup); #define TEMPDIR "./" -static long shortzero = 0; /* used to delimit runs */ +static long shortzero = 0; /* used to delimit runs */ /* * old psort global variables @@ -125,7 +125,7 @@ static long shortzero = 0; /* used to delimit runs */ bool psort_begin(Sort * node, int nkeys, ScanKey key) { - bool empty; /* to answer: is child node empty? */ + bool empty; /* to answer: is child node empty? */ node->psortstate = (struct Psortstate *) palloc(sizeof(struct Psortstate)); if (node->psortstate == NULL) @@ -172,7 +172,7 @@ psort_begin(Sort * node, int nkeys, ScanKey key) static void inittapes(Sort * node) { - register int i; + register int i; register struct tape *tp; Assert(node != (Sort *) NULL); @@ -272,8 +272,8 @@ initialrun(Sort * node, bool * empty) { /* register struct tuple *tup; */ register struct tape *tp; - int baseruns; /* D:(a) */ - int extrapasses;/* EOF */ + int baseruns; /* D:(a) */ + int extrapasses; /* EOF */ Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -349,17 +349,16 @@ initialrun(Sort * node, bool * empty) * FALSE iff process through end of relation * Tuples contains the tuples for the following run upon exit */ -static bool +static bool createrun(Sort * node, FILE * file, bool * empty) { register HeapTuple lasttuple; register HeapTuple tup; struct leftist *nextrun; - bool foundeor; - short junk; + bool foundeor; + short junk; - int cr_tuples = 0; /* Count tuples grabbed from - * plannode */ + int cr_tuples = 0; /* Count tuples grabbed from plannode */ TupleTableSlot *cr_slot; Assert(node != (Sort *) NULL); @@ -447,10 +446,10 @@ createrun(Sort * node, FILE * file, bool * empty) * This should eventually go there under that name? And this will * then use palloc directly (see version -r1.2). */ -static HeapTuple +static HeapTuple tuplecopy(HeapTuple tup) { - HeapTuple rettup; + HeapTuple rettup; if (!HeapTupleIsValid(tup)) { @@ -468,7 +467,7 @@ tuplecopy(HeapTuple tup) * Returns: * file of tuples in order */ -static FILE * +static FILE * mergeruns(Sort * node) { register struct tape *tp; @@ -502,11 +501,11 @@ merge(Sort * node, struct tape * dest) register struct tape *lasttp; /* (TAPE[P]) */ register struct tape *tp; struct leftist *tuples; - FILE *destfile; - int times; /* runs left to merge */ - int outdummy; /* complete dummy runs */ - short fromtape; - long tuplen; + FILE *destfile; + int times; /* runs left to merge */ + int outdummy; /* complete dummy runs */ + short fromtape; + long tuplen; Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -608,9 +607,9 @@ dumptuples(FILE * file, Sort * node) register struct leftist *tp; register struct leftist *newp; struct leftist **treep = &PS(node)->Tuples; - LeftistContext context = &PS(node)->treeContext; - HeapTuple tup; - int memtupindex = 0; + LeftistContext context = &PS(node)->treeContext; + HeapTuple tup; + int memtupindex = 0; if (!PS(node)->using_tape_files && PS(node)->tupcount) { @@ -652,7 +651,7 @@ HeapTuple psort_grabtuple(Sort * node) { register HeapTuple tup; - long tuplen; + long tuplen; Assert(node != (Sort *) NULL); Assert(PS(node) != (Psortstate *) NULL); @@ -763,8 +762,8 @@ psort_end(Sort * node) struct tapelst { - char *tl_name; - int tl_fd; + char *tl_name; + int tl_fd; struct tapelst *tl_next; }; @@ -777,16 +776,16 @@ static struct tapelst *Tapes = NULL; * Open stream for writing/reading. * NULL if unable to open temporary file. */ -static FILE * +static FILE * gettape() { register struct tapelst *tp; - FILE *file; - static int tapeinit = 0; - char *mktemp(); + FILE *file; + static int tapeinit = 0; + char *mktemp(); static unsigned int uniqueFileId = 0; - extern int errno; - char uniqueName[MAXPGPATH]; + extern int errno; + char uniqueName[MAXPGPATH]; tp = (struct tapelst *) palloc((unsigned) sizeof(struct tapelst)); @@ -823,7 +822,7 @@ static void resettape(FILE * file) { register struct tapelst *tp; - register int fd; + register int fd; Assert(PointerIsValid(file)); @@ -855,8 +854,8 @@ static void destroytape(FILE * file) { register struct tapelst *tp, - *tq; - register int fd; + *tq; + register int fd; if ((tp = Tapes) == NULL) elog(FATAL, "destroytape: tape not found"); diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 2a85ecd712b..e291e9c3441 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.5 1997/09/07 04:54:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.6 1997/09/08 02:32:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,18 +29,18 @@ static AbsoluteTime TimeQualGetEndTime(TimeQual qual); static AbsoluteTime TimeQualGetSnapshotTime(TimeQual qual); static AbsoluteTime TimeQualGetStartTime(TimeQual qual); -static bool TimeQualIncludesNow(TimeQual qual); -static bool TimeQualIndicatesDisableValidityChecking(TimeQual qual); -static bool TimeQualIsLegal(TimeQual qual); -static bool TimeQualIsRanged(TimeQual qual); -static bool TimeQualIsSnapshot(TimeQual qual); -static bool TimeQualIsValid(TimeQual qual); +static bool TimeQualIncludesNow(TimeQual qual); +static bool TimeQualIndicatesDisableValidityChecking(TimeQual qual); +static bool TimeQualIsLegal(TimeQual qual); +static bool TimeQualIsRanged(TimeQual qual); +static bool TimeQualIsSnapshot(TimeQual qual); +static bool TimeQualIsValid(TimeQual qual); /* * TimeQualMode -- * Mode indicator for treatment of time qualifications. */ -typedef uint16 TimeQualMode; +typedef uint16 TimeQualMode; #define TimeQualAt 0x1 #define TimeQualNewer 0x2 @@ -55,17 +55,17 @@ typedef uint16 TimeQualMode; typedef struct TimeQualData { - AbsoluteTime start; - AbsoluteTime end; - TimeQualMode mode; -} TimeQualData; + AbsoluteTime start; + AbsoluteTime end; + TimeQualMode mode; +} TimeQualData; typedef TimeQualData *InternalTimeQual; static TimeQualData SelfTimeQualData; -TimeQual SelfTimeQual = (Pointer) & SelfTimeQualData; +TimeQual SelfTimeQual = (Pointer) & SelfTimeQualData; -extern bool PostgresIsInitialized; +extern bool PostgresIsInitialized; /* * XXX Transaction system override hacks start here @@ -115,8 +115,8 @@ heapisoverride() * XXX Transaction system override hacks end here */ -static bool HeapTupleSatisfiesItself(HeapTuple tuple); -static bool HeapTupleSatisfiesNow(HeapTuple tuple); +static bool HeapTupleSatisfiesItself(HeapTuple tuple); +static bool HeapTupleSatisfiesNow(HeapTuple tuple); static bool HeapTupleSatisfiesSnapshotInternalTimeQual(HeapTuple tuple, InternalTimeQual qual); @@ -133,10 +133,10 @@ HeapTupleSatisfiesUpperUnboundedInternalTimeQual(HeapTuple tuple, * TimeQualIsValid -- * True iff time qualification is valid. */ -static bool +static bool TimeQualIsValid(TimeQual qual) { - bool hasStartTime; + bool hasStartTime; if (!PointerIsValid(qual) || qual == SelfTimeQual) { @@ -189,7 +189,7 @@ TimeQualIsValid(TimeQual qual) * Note: * Assumes time qualification is valid. */ -static bool +static bool TimeQualIsLegal(TimeQual qual) { Assert(TimeQualIsValid(qual)); @@ -202,8 +202,8 @@ TimeQualIsLegal(TimeQual qual) /* TimeQualAt */ if (((InternalTimeQual) qual)->mode & TimeQualAt) { - AbsoluteTime a, - b; + AbsoluteTime a, + b; a = ((InternalTimeQual) qual)->start; b = GetCurrentTransactionStartTime(); @@ -217,8 +217,8 @@ TimeQualIsLegal(TimeQual qual) /* TimeQualOlder or TimeQualRange */ if (((InternalTimeQual) qual)->mode & TimeQualOlder) { - AbsoluteTime a, - b; + AbsoluteTime a, + b; a = ((InternalTimeQual) qual)->end; b = GetCurrentTransactionStartTime(); @@ -232,8 +232,8 @@ TimeQualIsLegal(TimeQual qual) /* TimeQualNewer */ if (((InternalTimeQual) qual)->mode & TimeQualNewer) { - AbsoluteTime a, - b; + AbsoluteTime a, + b; a = ((InternalTimeQual) qual)->start; b = GetCurrentTransactionStartTime(); @@ -255,7 +255,7 @@ TimeQualIsLegal(TimeQual qual) * Note: * Assumes time qualification is valid. */ -static bool +static bool TimeQualIncludesNow(TimeQual qual) { Assert(TimeQualIsValid(qual)); @@ -312,7 +312,7 @@ TimeQualIncludesPast(TimeQual qual) * Note: * Assumes time qualification is valid. */ -static bool +static bool TimeQualIsSnapshot(TimeQual qual) { Assert(TimeQualIsValid(qual)); @@ -332,7 +332,7 @@ TimeQualIsSnapshot(TimeQual qual) * Note: * Assumes time qualification is valid. */ -static bool +static bool TimeQualIsRanged(TimeQual qual) { Assert(TimeQualIsValid(qual)); @@ -353,7 +353,7 @@ TimeQualIsRanged(TimeQual qual) * Note: * XXX This should not be implemented since this does not make sense. */ -static bool +static bool TimeQualIndicatesDisableValidityChecking(TimeQual qual) { Assert(TimeQualIsValid(qual)); @@ -377,7 +377,7 @@ TimeQualIndicatesDisableValidityChecking(TimeQual qual) * Note: * Assumes time qual is valid snapshot time qual. */ -static AbsoluteTime +static AbsoluteTime TimeQualGetSnapshotTime(TimeQual qual) { Assert(TimeQualIsSnapshot(qual)); @@ -392,7 +392,7 @@ TimeQualGetSnapshotTime(TimeQual qual) * Note: * Assumes time qual is valid ranged time qual. */ -static AbsoluteTime +static AbsoluteTime TimeQualGetStartTime(TimeQual qual) { Assert(TimeQualIsRanged(qual)); @@ -407,7 +407,7 @@ TimeQualGetStartTime(TimeQual qual) * Note: * Assumes time qual is valid ranged time qual. */ -static AbsoluteTime +static AbsoluteTime TimeQualGetEndTime(TimeQual qual) { Assert(TimeQualIsRanged(qual)); @@ -550,7 +550,7 @@ HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual) * (Xmax != my-transaction && the row was deleted by another transaction * Xmax is not committed))) that has not been committed */ -static bool +static bool HeapTupleSatisfiesItself(HeapTuple tuple) { @@ -647,7 +647,7 @@ HeapTupleSatisfiesItself(HeapTuple tuple) * the serializability guarantees we provide don't extend to xacts * that do catalog accesses. this is unfortunate, but not critical. */ -static bool +static bool HeapTupleSatisfiesNow(HeapTuple tuple) { if (AMI_OVERRIDE) @@ -755,7 +755,7 @@ HeapTupleSatisfiesNow(HeapTuple tuple) * (Xmax is null || (Xmax is not committed && Xmax != my-transaction) || * Tmax >= T)) */ -static bool +static bool HeapTupleSatisfiesSnapshotInternalTimeQual(HeapTuple tuple, InternalTimeQual qual) { @@ -816,7 +816,7 @@ HeapTupleSatisfiesSnapshotInternalTimeQual(HeapTuple tuple, * (Xmax is null || (Xmax is not committed && Xmax != my-transaction) || * T1 is null || Tmax >= T1)) */ -static bool +static bool HeapTupleSatisfiesUpperBoundedInternalTimeQual(HeapTuple tuple, InternalTimeQual qual) { @@ -886,7 +886,7 @@ HeapTupleSatisfiesUpperBoundedInternalTimeQual(HeapTuple tuple, * (Xmax is not committed && Xmax != my-transaction) || * T1 is null || Tmax >= T1))) */ -static bool +static bool HeapTupleSatisfiesUpperUnboundedInternalTimeQual(HeapTuple tuple, InternalTimeQual qual) { diff --git a/src/bin/pg_dump/common.c b/src/bin/pg_dump/common.c index c8d3c755b6f..61d0879e315 100644 --- a/src/bin/pg_dump/common.c +++ b/src/bin/pg_dump/common.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.14 1997/09/07 04:54:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/common.c,v 1.15 1997/09/08 02:32:37 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -35,16 +35,16 @@ #include "pg_dump.h" -static char ** +static char ** findParentsByOid(TableInfo * tbinfo, int numTables, InhInfo * inhinfo, int numInherits, const char *oid, int *numParents); -static int findTableByOid(TableInfo * tbinfo, int numTables, const char *oid); +static int findTableByOid(TableInfo * tbinfo, int numTables, const char *oid); static void flagInhAttrs(TableInfo * tbinfo, int numTables, InhInfo * inhinfo, int numInherits); -static int strInArray(const char *pattern, char **arr, int arr_size); +static int strInArray(const char *pattern, char **arr, int arr_size); /* * findTypeByOid @@ -55,10 +55,10 @@ static int strInArray(const char *pattern, char **arr, int arr_size); * NOTE: should hash this, but just do linear search for now */ -char * +char * findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid) { - int i; + int i; if (strcmp(oid, "0") == 0) return g_opaque_type; @@ -83,10 +83,10 @@ findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid) * NOTE: should hash this, but just do linear search for now * */ -char * +char * findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid) { - int i; + int i; for (i = 0; i < numOprs; i++) { @@ -110,16 +110,16 @@ findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid) * returns NULL if none */ -static char ** +static char ** findParentsByOid(TableInfo * tblinfo, int numTables, InhInfo * inhinfo, int numInherits, const char *oid, int *numParentsPtr) { - int i, - j; - int parentInd; - char **result; - int numParents; + int i, + j; + int parentInd; + char **result; + int numParents; numParents = 0; for (i = 0; i < numInherits; i++) @@ -160,10 +160,10 @@ findParentsByOid(TableInfo * tblinfo, int numTables, void parseArgTypes(char **argtypes, const char *str) { - int j, - argNum; - char temp[100]; - char s; + int j, + argNum; + char temp[100]; + char s; argNum = 0; j = 0; @@ -203,7 +203,7 @@ parseArgTypes(char **argtypes, const char *str) static int strInArray(const char *pattern, char **arr, int arr_size) { - int i; + int i; for (i = 0; i < arr_size; i++) { @@ -220,24 +220,24 @@ strInArray(const char *pattern, char **arr, int arr_size) * */ -TableInfo * +TableInfo * dumpSchema(FILE * fout, int *numTablesPtr, const char *tablename, const bool acls) { - int numTypes; - int numFuncs; - int numTables; - int numInherits; - int numAggregates; - int numOperators; - TypeInfo *tinfo = NULL; - FuncInfo *finfo = NULL; - AggInfo *agginfo = NULL; - TableInfo *tblinfo = NULL; - InhInfo *inhinfo = NULL; - OprInfo *oprinfo = NULL; + int numTypes; + int numFuncs; + int numTables; + int numInherits; + int numAggregates; + int numOperators; + TypeInfo *tinfo = NULL; + FuncInfo *finfo = NULL; + AggInfo *agginfo = NULL; + TableInfo *tblinfo = NULL; + InhInfo *inhinfo = NULL; + OprInfo *oprinfo = NULL; if (g_verbose) fprintf(stderr, "%s reading user-defined types %s\n", @@ -339,8 +339,8 @@ extern void dumpSchemaIdx(FILE * fout, int *numTablesPtr, const char *tablename, TableInfo * tblinfo, int numTables) { - int numIndices; - IndInfo *indinfo; + int numIndices; + IndInfo *indinfo; if (g_verbose) fprintf(stderr, "%s reading indices information %s\n", @@ -370,10 +370,10 @@ static void flagInhAttrs(TableInfo * tblinfo, int numTables, InhInfo * inhinfo, int numInherits) { - int i, - j, - k; - int parentInd; + int i, + j, + k; + int parentInd; /* * we go backwards because the tables in tblinfo are in OID order, @@ -415,7 +415,7 @@ flagInhAttrs(TableInfo * tblinfo, int numTables, int findTableByName(TableInfo * tblinfo, int numTables, const char *relname) { - int i; + int i; for (i = 0; i < numTables; i++) { @@ -436,7 +436,7 @@ findTableByName(TableInfo * tblinfo, int numTables, const char *relname) static int findTableByOid(TableInfo * tblinfo, int numTables, const char *oid) { - int i; + int i; for (i = 0; i < numTables; i++) { @@ -458,7 +458,7 @@ findTableByOid(TableInfo * tblinfo, int numTables, const char *oid) int findFuncByName(FuncInfo * finfo, int numFuncs, const char *name) { - int i; + int i; for (i = 0; i < numFuncs; i++) { diff --git a/src/bin/pg_dump/pg_dump.c b/src/bin/pg_dump/pg_dump.c index 8192d5c30b6..7409b62873d 100644 --- a/src/bin/pg_dump/pg_dump.c +++ b/src/bin/pg_dump/pg_dump.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.41 1997/09/07 04:54:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_dump/pg_dump.c,v 1.42 1997/09/08 02:32:45 momjian Exp $ * * Modifications - 6/10/96 - dave@bensoft.com - version 1.13.dhb * @@ -67,36 +67,36 @@ #include "pg_dump.h" -static void dumpSequence(FILE * fout, TableInfo tbinfo); -static char *checkForQuote(const char *s); -static void clearTableInfo(TableInfo *, int); +static void dumpSequence(FILE * fout, TableInfo tbinfo); +static char *checkForQuote(const char *s); +static void clearTableInfo(TableInfo *, int); static void dumpOneFunc(FILE * fout, FuncInfo * finfo, int i, TypeInfo * tinfo, int numTypes); -static int findLastBuiltinOid(void); -static bool isViewRule(char *relname); -static void setMaxOid(FILE * fout); +static int findLastBuiltinOid(void); +static bool isViewRule(char *relname); +static void setMaxOid(FILE * fout); -extern char *optarg; -extern int optind, - opterr; +extern char *optarg; +extern int optind, + opterr; /* global decls */ -bool g_verbose; /* User wants verbose narration of our +bool g_verbose; /* User wants verbose narration of our * activities. */ -int g_last_builtin_oid; /* value of the last builtin oid */ -FILE *g_fout; /* the script file */ -PGconn *g_conn; /* the database connection */ -int dumpData; /* dump data using proper insert strings */ -int attrNames; /* put attr names into insert strings */ -int schemaOnly; -int dataOnly; +int g_last_builtin_oid; /* value of the last builtin oid */ +FILE *g_fout; /* the script file */ +PGconn *g_conn; /* the database connection */ +int dumpData; /* dump data using proper insert strings */ +int attrNames; /* put attr names into insert strings */ +int schemaOnly; +int dataOnly; -char g_opaque_type[10]; /* name for the opaque type */ +char g_opaque_type[10]; /* name for the opaque type */ /* placeholders for the delimiters for comments */ -char g_comment_start[10]; -char g_comment_end[10]; +char g_comment_start[10]; +char g_comment_end[10]; static void @@ -149,12 +149,12 @@ exit_nicely(PGconn * conn) * Determine if the relation is a VIEW * */ -static bool +static bool isViewRule(char *relname) { - PGresult *res; - int ntups; - char query[MAXQUERYLEN]; + PGresult *res; + int ntups; + char query[MAXQUERYLEN]; res = PQexec(g_conn, "begin"); if (!res || @@ -192,11 +192,11 @@ static void dumpClasses_nodumpData(FILE * fout, const char *classname, const bool oids) { - PGresult *res; - char query[255]; - int ret; - bool copydone; - char copybuf[COPYBUFSIZ]; + PGresult *res; + char query[255]; + int ret; + bool copydone; + char copybuf[COPYBUFSIZ]; if (oids) { @@ -248,14 +248,14 @@ dumpClasses_nodumpData(FILE * fout, const char *classname, const bool oids) fputs(copybuf, fout); switch (ret) { - case EOF: - copydone = true; - /* FALLTHROUGH */ - case 0: - fputc('\n', fout); - break; - case 1: - break; + case EOF: + copydone = true; + /* FALLTHROUGH */ + case 0: + fputc('\n', fout); + break; + case 1: + break; } } } @@ -286,13 +286,13 @@ dumpClasses_dumpData(FILE * fout, const char *classname, const TableInfo tblinfo, bool oids) { - PGresult *res; - char query[255]; - int actual_atts;/* number of attrs in this a table */ - char expandbuf[COPYBUFSIZ]; - char q[MAXQUERYLEN]; - int tuple; - int field; + PGresult *res; + char query[255]; + int actual_atts; /* number of attrs in this a table */ + char expandbuf[COPYBUFSIZ]; + char q[MAXQUERYLEN]; + int tuple; + int field; sprintf(query, "select * from %s", classname); res = PQexec(g_conn, query); @@ -308,7 +308,7 @@ dumpClasses_dumpData(FILE * fout, const char *classname, fprintf(fout, "insert into %s ", classname); if (attrNames) { - int j; + int j; actual_atts = 0; sprintf(q, "("); @@ -338,38 +338,38 @@ dumpClasses_dumpData(FILE * fout, const char *classname, { switch (PQftype(res, field)) { - case INT2OID: - case INT4OID: - case OIDOID: /* int types */ - case FLOAT4OID: - case FLOAT8OID:/* float types */ - fprintf(fout, "%s", - PQgetvalue(res, tuple, field)); - break; - default: - { - char *expsrc, + case INT2OID: + case INT4OID: + case OIDOID: /* int types */ + case FLOAT4OID: + case FLOAT8OID: /* float types */ + fprintf(fout, "%s", + PQgetvalue(res, tuple, field)); + break; + default: + { + char *expsrc, *expdest; - /* - * Before outputting string value, expand all - * single quotes to twin single quotes - dhb - - * 6/11/96 - */ - expsrc = PQgetvalue(res, tuple, field); - expdest = expandbuf; - while (*expsrc) - { - *expdest++ = *expsrc; - if (*expsrc == (char) 0x27) /* single quote */ + /* + * Before outputting string value, expand all + * single quotes to twin single quotes - dhb - + * 6/11/96 + */ + expsrc = PQgetvalue(res, tuple, field); + expdest = expandbuf; + while (*expsrc) + { *expdest++ = *expsrc; - expsrc++; - } - *expdest = *expsrc; /* null term. */ + if (*expsrc == (char) 0x27) /* single quote */ + *expdest++ = *expsrc; + expsrc++; + } + *expdest = *expsrc; /* null term. */ - fprintf(fout, "'%s'", expandbuf); - } - break; + fprintf(fout, "'%s'", expandbuf); + } + break; } } field++; @@ -393,8 +393,8 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout, const char *onlytable, const bool oids) { - int i; - char *all_only; + int i; + char *all_only; if (onlytable == NULL) all_only = "all"; @@ -407,7 +407,7 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout, for (i = 0; i < numTables; i++) { - const char *classname = tblinfo[i].relname; + const char *classname = tblinfo[i].relname; /* Skip VIEW relations */ if (isViewRule(tblinfo[i].relname)) @@ -451,17 +451,17 @@ dumpClasses(const TableInfo tblinfo[], const int numTables, FILE * fout, int main(int argc, char **argv) { - int c; - const char *progname; - const char *filename = NULL; - const char *dbname = NULL; - const char *pghost = NULL; - const char *pgport = NULL; - const char *tablename = NULL; - int oids = 0, - acls = 0; - TableInfo *tblinfo; - int numTables; + int c; + const char *progname; + const char *filename = NULL; + const char *dbname = NULL; + const char *pghost = NULL; + const char *pgport = NULL; + const char *tablename = NULL; + int oids = 0, + acls = 0; + TableInfo *tblinfo; + int numTables; g_verbose = false; @@ -477,44 +477,44 @@ main(int argc, char **argv) { switch (c) { - case 'f': /* output file name */ - filename = optarg; - break; - case 'H': /* server host */ - pghost = optarg; - break; - case 'p': /* server port */ - pgport = optarg; - break; - case 'v': /* verbose */ - g_verbose = true; - break; - case 'S': /* dump schema only */ - schemaOnly = 1; - break; - case 'd': /* dump data as proper insert strings */ - dumpData = 1; - break; - case 'D': /* dump data as proper insert strings with + case 'f': /* output file name */ + filename = optarg; + break; + case 'H': /* server host */ + pghost = optarg; + break; + case 'p': /* server port */ + pgport = optarg; + break; + case 'v': /* verbose */ + g_verbose = true; + break; + case 'S': /* dump schema only */ + schemaOnly = 1; + break; + case 'd': /* dump data as proper insert strings */ + dumpData = 1; + break; + case 'D': /* dump data as proper insert strings with * attr names */ - dumpData = 1; - attrNames = 1; - break; - case 't': /* Dump data for this table only */ - tablename = optarg; - break; - case 'a': /* Dump data only */ - dataOnly = 1; - break; - case 'o': /* Dump oids */ - oids = 1; - break; - case 'z': /* Dump oids */ - acls = 1; - break; - default: - usage(progname); - break; + dumpData = 1; + attrNames = 1; + break; + case 't': /* Dump data for this table only */ + tablename = optarg; + break; + case 'a': /* Dump data only */ + dataOnly = 1; + break; + case 'o': /* Dump oids */ + oids = 1; + break; + case 'z': /* Dump oids */ + acls = 1; + break; + default: + usage(progname); + break; } } @@ -589,30 +589,30 @@ main(int argc, char **argv) * numTypes is set to the number of types read in * */ -TypeInfo * +TypeInfo * getTypes(int *numTypes) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - TypeInfo *tinfo; - - int i_oid; - int i_typowner; - int i_typname; - int i_typlen; - int i_typprtlen; - int i_typinput; - int i_typoutput; - int i_typreceive; - int i_typsend; - int i_typelem; - int i_typdelim; - int i_typdefault; - int i_typrelid; - int i_typbyval; - int i_usename; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + TypeInfo *tinfo; + + int i_oid; + int i_typowner; + int i_typname; + int i_typlen; + int i_typprtlen; + int i_typinput; + int i_typoutput; + int i_typreceive; + int i_typsend; + int i_typelem; + int i_typdelim; + int i_typdefault; + int i_typrelid; + int i_typbyval; + int i_usename; res = PQexec(g_conn, "begin"); if (!res || @@ -718,30 +718,30 @@ getTypes(int *numTypes) * * */ -OprInfo * +OprInfo * getOperators(int *numOprs) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - - OprInfo *oprinfo; - - int i_oid; - int i_oprname; - int i_oprkind; - int i_oprcode; - int i_oprleft; - int i_oprright; - int i_oprcom; - int i_oprnegate; - int i_oprrest; - int i_oprjoin; - int i_oprcanhash; - int i_oprlsortop; - int i_oprrsortop; - int i_usename; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + + OprInfo *oprinfo; + + int i_oid; + int i_oprname; + int i_oprkind; + int i_oprcode; + int i_oprleft; + int i_oprright; + int i_oprcom; + int i_oprnegate; + int i_oprrest; + int i_oprjoin; + int i_oprcanhash; + int i_oprlsortop; + int i_oprrsortop; + int i_usename; /* * find all operators, including builtin operators, filter out @@ -818,7 +818,7 @@ getOperators(int *numOprs) void clearTypeInfo(TypeInfo * tp, int numTypes) { - int i; + int i; for (i = 0; i < numTypes; ++i) { @@ -857,8 +857,8 @@ clearTypeInfo(TypeInfo * tp, int numTypes) void clearFuncInfo(FuncInfo * fun, int numFuncs) { - int i, - a; + int i, + a; if (!fun) return; @@ -886,8 +886,8 @@ clearFuncInfo(FuncInfo * fun, int numFuncs) static void clearTableInfo(TableInfo * tblinfo, int numTables) { - int i, - j; + int i, + j; for (i = 0; i < numTables; ++i) { @@ -940,7 +940,7 @@ clearTableInfo(TableInfo * tblinfo, int numTables) void clearInhInfo(InhInfo * inh, int numInherits) { - int i; + int i; if (!inh) return; @@ -957,7 +957,7 @@ clearInhInfo(InhInfo * inh, int numInherits) void clearOprInfo(OprInfo * opr, int numOprs) { - int i; + int i; if (!opr) return; @@ -998,8 +998,8 @@ clearOprInfo(OprInfo * opr, int numOprs) void clearIndInfo(IndInfo * ind, int numIndices) { - int i, - a; + int i, + a; if (!ind) return; @@ -1029,7 +1029,7 @@ clearIndInfo(IndInfo * ind, int numIndices) void clearAggInfo(AggInfo * agginfo, int numArgs) { - int i; + int i; if (!agginfo) return; @@ -1070,26 +1070,26 @@ clearAggInfo(AggInfo * agginfo, int numArgs) * * */ -AggInfo * +AggInfo * getAggregates(int *numAggs) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - AggInfo *agginfo; - - int i_oid; - int i_aggname; - int i_aggtransfn1; - int i_aggtransfn2; - int i_aggfinalfn; - int i_aggtranstype1; - int i_aggbasetype; - int i_aggtranstype2; - int i_agginitval1; - int i_agginitval2; - int i_usename; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + AggInfo *agginfo; + + int i_oid; + int i_aggname; + int i_aggtransfn1; + int i_aggtransfn2; + int i_aggfinalfn; + int i_aggtranstype1; + int i_aggbasetype; + int i_aggtranstype2; + int i_agginitval1; + int i_agginitval2; + int i_usename; /* find all user-defined aggregates */ @@ -1164,25 +1164,25 @@ getAggregates(int *numAggs) * * */ -FuncInfo * +FuncInfo * getFuncs(int *numFuncs) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - FuncInfo *finfo; - - int i_oid; - int i_proname; - int i_prolang; - int i_pronargs; - int i_proargtypes; - int i_prorettype; - int i_proretset; - int i_prosrc; - int i_probin; - int i_usename; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + FuncInfo *finfo; + + int i_oid; + int i_proname; + int i_prolang; + int i_pronargs; + int i_proargtypes; + int i_prorettype; + int i_proretset; + int i_prosrc; + int i_probin; + int i_usename; /* find all user-defined funcs */ @@ -1264,21 +1264,21 @@ getFuncs(int *numFuncs) * * */ -TableInfo * +TableInfo * getTables(int *numTables) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - TableInfo *tblinfo; - - int i_oid; - int i_relname; - int i_relarch; - int i_relkind; - int i_relacl; - int i_usename; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + TableInfo *tblinfo; + + int i_oid; + int i_relname; + int i_relarch; + int i_relkind; + int i_relacl; + int i_usename; /* * find all the user-defined tables (no indices and no catalogs), @@ -1352,17 +1352,17 @@ getTables(int *numTables) * * */ -InhInfo * +InhInfo * getInherits(int *numInherits) { - PGresult *res; - int ntups; - int i; - char query[MAXQUERYLEN]; - InhInfo *inhinfo; + PGresult *res; + int ntups; + int i; + char query[MAXQUERYLEN]; + InhInfo *inhinfo; - int i_inhrel; - int i_inhparent; + int i_inhrel; + int i_inhparent; /* find all the inheritance information */ res = PQexec(g_conn, "begin"); @@ -1418,15 +1418,15 @@ getInherits(int *numInherits) void getTableAttrs(TableInfo * tblinfo, int numTables) { - int i, - j; - char q[MAXQUERYLEN]; - int i_attname; - int i_typname; - int i_attlen; - int i_attnotnull; - PGresult *res; - int ntups; + int i, + j; + char q[MAXQUERYLEN]; + int i_attname; + int i_typname; + int i_attlen; + int i_attnotnull; + PGresult *res; + int ntups; for (i = 0; i < numTables; i++) { @@ -1504,22 +1504,22 @@ getTableAttrs(TableInfo * tblinfo, int numTables) * * */ -IndInfo * +IndInfo * getIndices(int *numIndices) { - int i; - char query[MAXQUERYLEN]; - PGresult *res; - int ntups; - IndInfo *indinfo; - - int i_indexrelname; - int i_indrelname; - int i_indamname; - int i_indproc; - int i_indkey; - int i_indclass; - int i_indisunique; + int i; + char query[MAXQUERYLEN]; + PGresult *res; + int ntups; + IndInfo *indinfo; + + int i_indexrelname; + int i_indrelname; + int i_indamname; + int i_indproc; + int i_indkey; + int i_indclass; + int i_indisunique; /* * find all the user-defined indices. We do not handle partial @@ -1599,9 +1599,9 @@ void dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs, TypeInfo * tinfo, int numTypes) { - int i; - char q[MAXQUERYLEN]; - int funcInd; + int i; + char q[MAXQUERYLEN]; + int funcInd; for (i = 0; i < numTypes; i++) { @@ -1648,7 +1648,7 @@ dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs, if (tinfo[i].isArray) { - char *elemType; + char *elemType; elemType = findTypeByOid(tinfo, numTypes, tinfo[i].typelem); @@ -1673,7 +1673,7 @@ void dumpFuncs(FILE * fout, FuncInfo * finfo, int numFuncs, TypeInfo * tinfo, int numTypes) { - int i; + int i; for (i = 0; i < numFuncs; i++) { @@ -1692,8 +1692,8 @@ static void dumpOneFunc(FILE * fout, FuncInfo * finfo, int i, TypeInfo * tinfo, int numTypes) { - char q[MAXQUERYLEN]; - int j; + char q[MAXQUERYLEN]; + int j; if (finfo[i].dumped) return; @@ -1705,7 +1705,7 @@ dumpOneFunc(FILE * fout, FuncInfo * finfo, int i, sprintf(q, "CREATE FUNCTION %s (", finfo[i].proname); for (j = 0; j < finfo[i].nargs; j++) { - char *typname; + char *typname; typname = findTypeByOid(tinfo, numTypes, finfo[i].argtypes[j]); sprintf(q, "%s%s%s", @@ -1733,15 +1733,15 @@ void dumpOprs(FILE * fout, OprInfo * oprinfo, int numOperators, TypeInfo * tinfo, int numTypes) { - int i; - char q[MAXQUERYLEN]; - char leftarg[MAXQUERYLEN]; - char rightarg[MAXQUERYLEN]; - char commutator[MAXQUERYLEN]; - char negator[MAXQUERYLEN]; - char restrict[MAXQUERYLEN]; - char join[MAXQUERYLEN]; - char sortop[MAXQUERYLEN]; + int i; + char q[MAXQUERYLEN]; + char leftarg[MAXQUERYLEN]; + char rightarg[MAXQUERYLEN]; + char commutator[MAXQUERYLEN]; + char negator[MAXQUERYLEN]; + char restrict[MAXQUERYLEN]; + char join[MAXQUERYLEN]; + char sortop[MAXQUERYLEN]; for (i = 0; i < numOperators; i++) { @@ -1840,13 +1840,13 @@ void dumpAggs(FILE * fout, AggInfo * agginfo, int numAggs, TypeInfo * tinfo, int numTypes) { - int i; - char q[MAXQUERYLEN]; - char sfunc1[MAXQUERYLEN]; - char sfunc2[MAXQUERYLEN]; - char finalfunc[MAXQUERYLEN]; - char comma1[2], - comma2[2]; + int i; + char q[MAXQUERYLEN]; + char sfunc1[MAXQUERYLEN]; + char sfunc2[MAXQUERYLEN]; + char finalfunc[MAXQUERYLEN]; + char comma1[2], + comma2[2]; for (i = 0; i < numAggs; i++) { @@ -1929,14 +1929,14 @@ dumpTables(FILE * fout, TableInfo * tblinfo, int numTables, TypeInfo * tinfo, int numTypes, const char *tablename, const bool acls) { - int i, - j, - k; - char q[MAXQUERYLEN]; - char **parentRels; /* list of names of parent relations */ - int numParents; - int actual_atts;/* number of attrs in this CREATE statment */ - const char *archiveMode; + int i, + j, + k; + char q[MAXQUERYLEN]; + char **parentRels; /* list of names of parent relations */ + int numParents; + int actual_atts; /* number of attrs in this CREATE statment */ + const char *archiveMode; for (i = 0; i < numTables; i++) { @@ -2031,19 +2031,19 @@ dumpTables(FILE * fout, TableInfo * tblinfo, int numTables, switch (tblinfo[i].relarch[0]) { - case 'n': - archiveMode = "none"; - break; - case 'h': - archiveMode = "heavy"; - break; - case 'l': - archiveMode = "light"; - break; - default: - fprintf(stderr, "unknown archive mode\n"); - archiveMode = "none"; - break; + case 'n': + archiveMode = "none"; + break; + case 'h': + archiveMode = "heavy"; + break; + case 'l': + archiveMode = "light"; + break; + default: + fprintf(stderr, "unknown archive mode\n"); + archiveMode = "none"; + break; } sprintf(q, "%s archive = %s;\n", @@ -2067,19 +2067,19 @@ void dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices, TableInfo * tblinfo, int numTables, const char *tablename) { - int i, - k; - int tableInd; - char attlist[1000]; - char *classname[INDEX_MAX_KEYS]; - char *funcname; /* the name of the function to comput the + int i, + k; + int tableInd; + char attlist[1000]; + char *classname[INDEX_MAX_KEYS]; + char *funcname; /* the name of the function to comput the * index key from */ - int indkey, - indclass; - int nclass; + int indkey, + indclass; + int nclass; - char q[MAXQUERYLEN]; - PGresult *res; + char q[MAXQUERYLEN]; + PGresult *res; for (i = 0; i < numIndices; i++) { @@ -2145,7 +2145,7 @@ dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices, /* convert attribute numbers into attribute list */ for (k = 0, attlist[0] = 0; k < INDEX_MAX_KEYS; k++) { - char *attname; + char *attname; indkey = atoi(indinfo[i].indkey[k]); if (indkey == 0) @@ -2214,11 +2214,11 @@ dumpIndices(FILE * fout, IndInfo * indinfo, int numIndices, void dumpTuples(PGresult * res, FILE * fout, int *attrmap) { - int j, - k; - int m, - n; - char **outVals = NULL; /* values to copy out */ + int j, + k; + int m, + n; + char **outVals = NULL; /* values to copy out */ n = PQntuples(res); m = PQnfields(res); @@ -2240,7 +2240,7 @@ dumpTuples(PGresult * res, FILE * fout, int *attrmap) } for (k = 0; k < m; k++) { - char *pval = outVals[k]; + char *pval = outVals[k]; if (k != 0) fputc('\t', fout); /* delimiter for attribute */ @@ -2273,8 +2273,8 @@ dumpTuples(PGresult * res, FILE * fout, int *attrmap) static void setMaxOid(FILE * fout) { - PGresult *res; - Oid max_oid; + PGresult *res; + Oid max_oid; res = PQexec(g_conn, "CREATE TABLE pgdump_oid (dummy int4)"); if (!res || @@ -2326,9 +2326,9 @@ setMaxOid(FILE * fout) static int findLastBuiltinOid(void) { - PGresult *res; - int ntups; - int last_oid; + PGresult *res; + int ntups; + int last_oid; res = PQexec(g_conn, "SELECT oid from pg_database where datname = 'template1'"); @@ -2355,14 +2355,14 @@ findLastBuiltinOid(void) * checkForQuote: * checks a string for quote characters and quotes them */ -static char * +static char * checkForQuote(const char *s) { - char *r; - char c; - char *result; + char *r; + char c; + char *result; - int j = 0; + int j = 0; r = malloc(strlen(s) * 3 + 1); /* definitely long enough */ @@ -2389,16 +2389,16 @@ checkForQuote(const char *s) static void dumpSequence(FILE * fout, TableInfo tbinfo) { - PGresult *res; - int4 last, - incby, - maxv, - minv, - cache; - char cycled, - called, - *t; - char query[MAXQUERYLEN]; + PGresult *res; + int4 last, + incby, + maxv, + minv, + cache; + char cycled, + called, + *t; + char query[MAXQUERYLEN]; sprintf(query, "SELECT sequence_name, last_value, increment_by, max_value, " diff --git a/src/bin/pg_dump/pg_dump.h b/src/bin/pg_dump/pg_dump.h index b59e4d82997..cf50bee06e0 100644 --- a/src/bin/pg_dump/pg_dump.h +++ b/src/bin/pg_dump/pg_dump.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_dump.h,v 1.20 1997/09/07 04:54:42 momjian Exp $ + * $Id: pg_dump.h,v 1.21 1997/09/08 02:32:50 momjian Exp $ * * Modifications - 6/12/96 - dave@bensoft.com - version 1.13.dhb.2 * @@ -26,142 +26,139 @@ typedef struct _typeInfo { - char *oid; - char *typowner; - char *typname; - char *typlen; - char *typprtlen; - char *typinput; - char *typoutput; - char *typreceive; - char *typsend; - char *typelem; - char *typdelim; - char *typdefault; - char *typrelid; - char *usename; - int passedbyvalue; - int isArray; -} TypeInfo; + char *oid; + char *typowner; + char *typname; + char *typlen; + char *typprtlen; + char *typinput; + char *typoutput; + char *typreceive; + char *typsend; + char *typelem; + char *typdelim; + char *typdefault; + char *typrelid; + char *usename; + int passedbyvalue; + int isArray; +} TypeInfo; typedef struct _funcInfo { - char *oid; - char *proname; - char *proowner; - int lang; /* 1 if C, else SQL */ - int nargs; - char *argtypes[8];/* should be derived from obj/fmgr.h + char *oid; + char *proname; + char *proowner; + int lang; /* 1 if C, else SQL */ + int nargs; + char *argtypes[8]; /* should be derived from obj/fmgr.h * instead of hardwired */ - char *prorettype; - int retset; /* 1 if the function returns a set, 0 + char *prorettype; + int retset; /* 1 if the function returns a set, 0 * otherwise */ - char *prosrc; - char *probin; - char *usename; - int dumped; /* 1 if already dumped */ -} FuncInfo; + char *prosrc; + char *probin; + char *usename; + int dumped; /* 1 if already dumped */ +} FuncInfo; typedef struct _tableInfo { - char *oid; - char *relname; - char *relarch; - char *relacl; - bool sequence; - int numatts; /* number of attributes */ - int *inhAttrs; /* an array of flags, one for each + char *oid; + char *relname; + char *relarch; + char *relacl; + bool sequence; + int numatts; /* number of attributes */ + int *inhAttrs; /* an array of flags, one for each * attribute if the value is 1, then this * attribute is an inherited attribute */ - char **attnames; /* the attribute names */ - char **typnames; /* fill out attributes */ - bool *notnull; /* Not null constraints of an attribute */ - int numParents; /* number of (immediate) parent + char **attnames; /* the attribute names */ + char **typnames; /* fill out attributes */ + bool *notnull; /* Not null constraints of an attribute */ + int numParents; /* number of (immediate) parent * supertables */ - char **parentRels; /* names of parent relations, NULL if + char **parentRels; /* names of parent relations, NULL if * numParents == 0 */ - char **out_attnames; /* the attribute names, in the - * order they would be in, when - * the table is created in the - * target query language. this is - * needed because the SQL tables - * will not have the same order of - * attributes as the POSTQUEL - * tables */ - int *attlen; /* attribute lengths */ - char *usename; - -} TableInfo; + char **out_attnames; /* the attribute names, in the order they + * would be in, when the table is created + * in the target query language. this is + * needed because the SQL tables will not + * have the same order of attributes as + * the POSTQUEL tables */ + int *attlen; /* attribute lengths */ + char *usename; + +} TableInfo; typedef struct _inhInfo { - char *inhrel; - char *inhparent; -} InhInfo; + char *inhrel; + char *inhparent; +} InhInfo; typedef struct _indInfo { - char *indexrelname; /* name of the secondary index - * class */ - char *indrelname; /* name of the indexed heap class */ - char *indamname; /* name of the access method (e.g. btree, + char *indexrelname; /* name of the secondary index class */ + char *indrelname; /* name of the indexed heap class */ + char *indamname; /* name of the access method (e.g. btree, * rtree, etc.) */ - char *indproc; /* oid of the function to compute the + char *indproc; /* oid of the function to compute the * index, 0 if none */ - char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of - * the key attributes */ - char *indclass[INDEX_MAX_KEYS]; /* opclass of the keys */ - char *indisunique;/* is this index unique? */ -} IndInfo; + char *indkey[INDEX_MAX_KEYS]; /* attribute numbers of the key + * attributes */ + char *indclass[INDEX_MAX_KEYS]; /* opclass of the keys */ + char *indisunique; /* is this index unique? */ +} IndInfo; typedef struct _aggInfo { - char *oid; - char *aggname; - char *aggtransfn1; - char *aggtransfn2; - char *aggfinalfn; - char *aggtranstype1; - char *aggbasetype; - char *aggtranstype2; - char *agginitval1; - char *agginitval2; - char *usename; -} AggInfo; + char *oid; + char *aggname; + char *aggtransfn1; + char *aggtransfn2; + char *aggfinalfn; + char *aggtranstype1; + char *aggbasetype; + char *aggtranstype2; + char *agginitval1; + char *agginitval2; + char *usename; +} AggInfo; typedef struct _oprInfo { - char *oid; - char *oprname; - char *oprkind; /* "b" = binary, "l" = left unary, "r" = + char *oid; + char *oprname; + char *oprkind; /* "b" = binary, "l" = left unary, "r" = * right unary */ - char *oprcode; /* operator function name */ - char *oprleft; /* left operand type */ - char *oprright; /* right operand type */ - char *oprcom; /* oid of the commutator operator */ - char *oprnegate; /* oid of the negator operator */ - char *oprrest; /* name of the function to calculate + char *oprcode; /* operator function name */ + char *oprleft; /* left operand type */ + char *oprright; /* right operand type */ + char *oprcom; /* oid of the commutator operator */ + char *oprnegate; /* oid of the negator operator */ + char *oprrest; /* name of the function to calculate * operator restriction selectivity */ - char *oprjoin; /* name of the function to calculate + char *oprjoin; /* name of the function to calculate * operator join selectivity */ - char *oprcanhash; /* can we use hash join strategy ? */ - char *oprlsortop; /* oid's of the left and right sort + char *oprcanhash; /* can we use hash join strategy ? */ + char *oprlsortop; /* oid's of the left and right sort * operators */ - char *oprrsortop; - char *usename; -} OprInfo; + char *oprrsortop; + char *usename; +} OprInfo; /* global decls */ -extern bool g_verbose; /* verbose flag */ -extern int g_last_builtin_oid; /* value of the last builtin oid */ -extern FILE *g_fout; /* the script file */ +extern bool g_verbose; /* verbose flag */ +extern int g_last_builtin_oid; /* value of the last builtin oid */ +extern FILE *g_fout; /* the script file */ /* placeholders for comment starting and ending delimiters */ -extern char g_comment_start[10]; -extern char g_comment_end[10]; +extern char g_comment_start[10]; +extern char g_comment_end[10]; -extern char g_opaque_type[10]; /* name for the opaque type */ +extern char g_opaque_type[10]; /* name for the opaque type */ /* pg_dump is really two programs in one one version works with postgres v4r2 @@ -184,14 +181,14 @@ dumpSchemaIdx(FILE * fout, TableInfo * tblinfo, int numTables); -extern char *findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid); -extern char *findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid); -extern int findFuncByName(FuncInfo * finfo, int numFuncs, const char *name); -extern int findTableByName(TableInfo * tbinfo, int numTables, const char *relname); +extern char *findTypeByOid(TypeInfo * tinfo, int numTypes, const char *oid); +extern char *findOprByOid(OprInfo * oprinfo, int numOprs, const char *oid); +extern int findFuncByName(FuncInfo * finfo, int numFuncs, const char *name); +extern int findTableByName(TableInfo * tbinfo, int numTables, const char *relname); -extern void check_conn_and_db(void); -extern void parseArgTypes(char **argtypes, const char *str); -extern int isArchiveName(const char *); +extern void check_conn_and_db(void); +extern void parseArgTypes(char **argtypes, const char *str); +extern int isArchiveName(const char *); /* * version specific routines @@ -200,17 +197,17 @@ extern TypeInfo *getTypes(int *numTypes); extern FuncInfo *getFuncs(int *numFuncs); extern AggInfo *getAggregates(int *numAggregates); -extern void clearAggInfo(AggInfo *, int); -extern void clearFuncInfo(FuncInfo *, int); -extern void clearInhInfo(InhInfo *, int); -extern void clearIndInfo(IndInfo *, int); -extern void clearOprInfo(OprInfo *, int); -extern void clearTypeInfo(TypeInfo *, int); +extern void clearAggInfo(AggInfo *, int); +extern void clearFuncInfo(FuncInfo *, int); +extern void clearInhInfo(InhInfo *, int); +extern void clearIndInfo(IndInfo *, int); +extern void clearOprInfo(OprInfo *, int); +extern void clearTypeInfo(TypeInfo *, int); extern OprInfo *getOperators(int *numOperators); extern TableInfo *getTables(int *numTables); extern InhInfo *getInherits(int *numInherits); -extern void getTableAttrs(TableInfo * tbinfo, int numTables); +extern void getTableAttrs(TableInfo * tbinfo, int numTables); extern IndInfo *getIndices(int *numIndices); extern void dumpTypes(FILE * fout, FuncInfo * finfo, int numFuncs, diff --git a/src/bin/pg_id/pg_id.c b/src/bin/pg_id/pg_id.c index b782b091a3e..b246131b84a 100644 --- a/src/bin/pg_id/pg_id.c +++ b/src/bin/pg_id/pg_id.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.4 1997/09/07 04:54:46 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_id/Attic/pg_id.c,v 1.5 1997/09/08 02:32:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,17 +23,17 @@ int main(int argc, char **argv) { - struct passwd *pw; - int ch; - extern int optind; + struct passwd *pw; + int ch; + extern int optind; while ((ch = getopt(argc, argv, "")) != EOF) switch (ch) { - case '?': - default: - fprintf(stderr, "usage: pg_id [login]\n"); - exit(1); + case '?': + default: + fprintf(stderr, "usage: pg_id [login]\n"); + exit(1); } argc -= optind; argv += optind; diff --git a/src/bin/pg_passwd/pg_passwd.c b/src/bin/pg_passwd/pg_passwd.c index 9a99b45b69e..4394f83e7cc 100644 --- a/src/bin/pg_passwd/pg_passwd.c +++ b/src/bin/pg_passwd/pg_passwd.c @@ -19,18 +19,18 @@ #ifdef HAVE_CRYPT_H #include <crypt.h> #else -extern char *crypt(const char *, const char *); +extern char *crypt(const char *, const char *); #endif -char *comname; -void usage(FILE * stream); -void read_pwd_file(char *filename); -void write_pwd_file(char *filename, char *bkname); -void encrypt_pwd(char key[9], char salt[3], char passwd[14]); -int check_pwd(char key[9], char passwd[14]); -void prompt_for_username(char *username); -void prompt_for_password(char *prompt, char *password); +char *comname; +void usage(FILE * stream); +void read_pwd_file(char *filename); +void write_pwd_file(char *filename, char *bkname); +void encrypt_pwd(char key[9], char salt[3], char passwd[14]); +int check_pwd(char key[9], char passwd[14]); +void prompt_for_username(char *username); +void prompt_for_password(char *prompt, char *password); void usage(FILE * stream) @@ -40,24 +40,24 @@ usage(FILE * stream) typedef struct { - char *uname; - char *pwd; - char *rest; -} pg_pwd; + char *uname; + char *pwd; + char *rest; +} pg_pwd; #define MAXPWDS 1024 -pg_pwd pwds[MAXPWDS]; -int npwds = 0; +pg_pwd pwds[MAXPWDS]; +int npwds = 0; void read_pwd_file(char *filename) { - FILE *fp; - static char line[512]; - static char ans[128]; - int i; + FILE *fp; + static char line[512]; + static char ans[128]; + int i; try_again: fp = fopen(filename, "r"); @@ -70,19 +70,19 @@ try_again: fgets(ans, 128, stdin); switch (ans[0]) { - case 'y': - case 'Y': - fp = fopen(filename, "w"); - if (fp == NULL) - { - perror(filename); + case 'y': + case 'Y': + fp = fopen(filename, "w"); + if (fp == NULL) + { + perror(filename); + exit(1); + } + fclose(fp); + goto try_again; + default: + /* cannot continue */ exit(1); - } - fclose(fp); - goto try_again; - default: - /* cannot continue */ - exit(1); } } else @@ -95,9 +95,9 @@ try_again: /* read all the entries */ for (npwds = 0; npwds < MAXPWDS && fgets(line, 512, fp) != NULL; ++npwds) { - int l; - char *p, - *q; + int l; + char *p, + *q; l = strlen(line); if (line[l - 1] == '\n') @@ -168,8 +168,8 @@ try_again: void write_pwd_file(char *filename, char *bkname) { - FILE *fp; - int i; + FILE *fp; + int i; /* make the backup file */ link_again: @@ -210,12 +210,12 @@ link_again: void encrypt_pwd(char key[9], char salt[3], char passwd[14]) { - int n; + int n; /* get encrypted password */ if (salt[0] == '\0') { - struct timeval tm; + struct timeval tm; gettimeofday(&tm, NULL); srand(tm.tv_sec ? tm.tv_sec : 1); @@ -244,8 +244,8 @@ encrypt_pwd(char key[9], char salt[3], char passwd[14]) int check_pwd(char key[9], char passwd[14]) { - char shouldbe[14]; - char salt[3]; + char shouldbe[14]; + char salt[3]; salt[0] = passwd[0]; salt[1] = passwd[1]; @@ -258,7 +258,7 @@ check_pwd(char key[9], char passwd[14]) void prompt_for_username(char *username) { - int length; + int length; printf("Username: "); fgets(username, 9, stdin); @@ -267,7 +267,7 @@ prompt_for_username(char *username) /* skip rest of the line */ if (length > 0 && username[length - 1] != '\n') { - static char buf[512]; + static char buf[512]; do { @@ -281,11 +281,11 @@ prompt_for_username(char *username) void prompt_for_password(char *prompt, char *password) { - int length; + int length; #ifdef HAVE_TERMIOS_H - struct termios t_orig, - t; + struct termios t_orig, + t; #endif @@ -305,7 +305,7 @@ prompt_for_password(char *prompt, char *password) /* skip rest of the line */ if (length > 0 && password[length - 1] != '\n') { - static char buf[512]; + static char buf[512]; do { @@ -321,13 +321,13 @@ prompt_for_password(char *prompt, char *password) int main(int argc, char *argv[]) { - static char bkname[512]; - char username[9]; - char salt[3]; - char key[9], - key2[9]; - char e_passwd[14]; - int i; + static char bkname[512]; + char username[9]; + char salt[3]; + char key[9], + key2[9]; + char e_passwd[14]; + int i; comname = argv[0]; if (argc != 2) diff --git a/src/bin/pg_version/pg_version.c b/src/bin/pg_version/pg_version.c index 314ddddeb2d..3c7de9387f0 100644 --- a/src/bin/pg_version/pg_version.c +++ b/src/bin/pg_version/pg_version.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.7 1997/09/07 04:54:56 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/pg_version/Attic/pg_version.c,v 1.8 1997/09/08 02:33:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,8 +21,8 @@ int main(int argc, char **argv) { - int retcode; /* our eventual return code */ - char *reason; /* Reason that SetPgVersion failed, NULL + int retcode; /* our eventual return code */ + char *reason; /* Reason that SetPgVersion failed, NULL * if it didn't. */ if (argc < 2) diff --git a/src/bin/pgtclsh/pgtclAppInit.c b/src/bin/pgtclsh/pgtclAppInit.c index 1c9040fbd53..f344dd403ef 100644 --- a/src/bin/pgtclsh/pgtclAppInit.c +++ b/src/bin/pgtclsh/pgtclAppInit.c @@ -21,8 +21,8 @@ */ #ifdef NEED_MATHERR -extern int matherr(); -int *tclDummyMathPtr = (int *) matherr; +extern int matherr(); +int *tclDummyMathPtr = (int *) matherr; #endif diff --git a/src/bin/pgtclsh/pgtkAppInit.c b/src/bin/pgtclsh/pgtkAppInit.c index fbca4cca2e5..bdb569cb3c9 100644 --- a/src/bin/pgtclsh/pgtkAppInit.c +++ b/src/bin/pgtclsh/pgtkAppInit.c @@ -20,8 +20,8 @@ */ #ifdef NEED_MATHERR -extern int matherr(); -int *tclDummyMathPtr = (int *) matherr; +extern int matherr(); +int *tclDummyMathPtr = (int *) matherr; #endif diff --git a/src/bin/psql/psql.c b/src/bin/psql/psql.c index 3a58f8ad321..fa6bd9608e6 100644 --- a/src/bin/psql/psql.c +++ b/src/bin/psql/psql.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.91 1997/09/07 04:55:20 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/Attic/psql.c,v 1.92 1997/09/08 02:33:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,41 +80,41 @@ typedef struct _psqlSettings { - PGconn *db; /* connection to backend */ - FILE *queryFout; /* where to send the query results */ - PQprintOpt opt; /* options to be passed to PQprint */ - char *prompt; /* prompt to display */ - char *gfname; /* one-shot file output argument for \g */ - bool notty; /* input or output is not a tty */ - bool pipe; /* queryFout is from a popen() */ - bool echoQuery; /* echo the query before sending it */ - bool quiet; /* run quietly, no messages, no promt */ - bool singleStep; /* prompt before for each query */ - bool singleLineMode; /* query terminated by newline */ - bool useReadline;/* use libreadline routines */ - bool getPassword;/* prompt the user for a username and + PGconn *db; /* connection to backend */ + FILE *queryFout; /* where to send the query results */ + PQprintOpt opt; /* options to be passed to PQprint */ + char *prompt; /* prompt to display */ + char *gfname; /* one-shot file output argument for \g */ + bool notty; /* input or output is not a tty */ + bool pipe; /* queryFout is from a popen() */ + bool echoQuery; /* echo the query before sending it */ + bool quiet; /* run quietly, no messages, no promt */ + bool singleStep; /* prompt before for each query */ + bool singleLineMode; /* query terminated by newline */ + bool useReadline; /* use libreadline routines */ + bool getPassword; /* prompt the user for a username and * password */ -} PsqlSettings; +} PsqlSettings; /* declarations for functions in this file */ -static void usage(char *progname); -static void slashUsage(); -static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream); +static void usage(char *progname); +static void slashUsage(); +static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream); static void handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream); -static int tableList(PsqlSettings * ps, bool deep_tablelist, char info_type); -static int tableDesc(PsqlSettings * ps, char *table); -static int rightsList(PsqlSettings * ps); -static void prompt_for_password(char *username, char *password); -static char * +static int tableList(PsqlSettings * ps, bool deep_tablelist, char info_type); +static int tableDesc(PsqlSettings * ps, char *table); +static int rightsList(PsqlSettings * ps); +static void prompt_for_password(char *username, char *password); +static char * make_connect_string(char *host, char *port, char *dbname, char *username, char *password); -static char *gets_noreadline(char *prompt, FILE * source); -static char *gets_readline(char *prompt, FILE * source); -static char *gets_fromFile(char *prompt, FILE * source); -static int listAllDbs(PsqlSettings * settings); +static char *gets_noreadline(char *prompt, FILE * source); +static char *gets_readline(char *prompt, FILE * source); +static char *gets_fromFile(char *prompt, FILE * source); +static int listAllDbs(PsqlSettings * settings); static void SendQuery(bool * success_p, PsqlSettings * settings, const char *query, const bool copy_in, const bool copy_out, FILE * copystream); @@ -122,7 +122,7 @@ static int HandleSlashCmds(PsqlSettings * settings, char *line, char *query); -static int MainLoop(PsqlSettings * settings, FILE * source); +static int MainLoop(PsqlSettings * settings, FILE * source); /* probably should move this into libpq */ void @@ -131,7 +131,7 @@ PQprint(FILE * fp, PQprintOpt * po ); -static FILE *setFout(PsqlSettings * ps, char *fname); +static FILE *setFout(PsqlSettings * ps, char *fname); /* * usage print out usage for command line arguments @@ -168,7 +168,7 @@ usage(char *progname) * slashUsage print out usage for the backslash commands */ -static char * +static char * on(bool f) { return f ? "on" : "off"; @@ -177,9 +177,9 @@ on(bool f) static void slashUsage(PsqlSettings * ps) { - int usePipe = 0; - char *pagerenv; - FILE *fout; + int usePipe = 0; + char *pagerenv; + FILE *fout; if (ps->notty == 0 && (pagerenv = getenv("PAGER")) && @@ -230,7 +230,7 @@ slashUsage(PsqlSettings * ps) static PGresult * PSQLexec(PsqlSettings * ps, char *query) { - PGresult *res; + PGresult *res; res = PQexec(ps->db, query); if (!res) @@ -258,8 +258,8 @@ PSQLexec(PsqlSettings * ps, char *query) static int listAllDbs(PsqlSettings * ps) { - PGresult *results; - char *query = "select * from pg_database;"; + PGresult *results; + char *query = "select * from pg_database;"; if (!(results = PSQLexec(ps, query))) return 1; @@ -280,32 +280,32 @@ listAllDbs(PsqlSettings * ps) int tableList(PsqlSettings * ps, bool deep_tablelist, char info_type) { - char listbuf[256]; - int nColumns; - int i; - char *rk; - char *rr; + char listbuf[256]; + int nColumns; + int i; + char *rk; + char *rr; - PGresult *res; + PGresult *res; listbuf[0] = '\0'; strcat(listbuf, "SELECT usename, relname, relkind, relhasrules"); strcat(listbuf, " FROM pg_class, pg_user "); switch (info_type) { - case 't': - strcat(listbuf, "WHERE ( relkind = 'r') "); - break; - case 'i': - strcat(listbuf, "WHERE ( relkind = 'i') "); - break; - case 'S': - strcat(listbuf, "WHERE ( relkind = 'S') "); - break; - case 'b': - default: - strcat(listbuf, "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') "); - break; + case 't': + strcat(listbuf, "WHERE ( relkind = 'r') "); + break; + case 'i': + strcat(listbuf, "WHERE ( relkind = 'i') "); + break; + case 'S': + strcat(listbuf, "WHERE ( relkind = 'S') "); + break; + case 'b': + default: + strcat(listbuf, "WHERE ( relkind = 'r' OR relkind = 'i' OR relkind = 'S') "); + break; } strcat(listbuf, " and relname !~ '^pg_'"); strcat(listbuf, " and relname !~ '^xin[vx][0-9]+'"); @@ -325,7 +325,7 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type) if (deep_tablelist) { /* describe everything here */ - char **table; + char **table; table = (char **) malloc(nColumns * sizeof(char *)); if (table == NULL) @@ -382,19 +382,19 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type) PQclear(res); /* PURIFY */ switch (info_type) { - case 't': - fprintf(stderr, "Couldn't find any tables!\n"); - break; - case 'i': - fprintf(stderr, "Couldn't find any indices!\n"); - break; - case 'S': - fprintf(stderr, "Couldn't find any sequences!\n"); - break; - case 'b': - default: - fprintf(stderr, "Couldn't find any tables, sequences or indices!\n"); - break; + case 't': + fprintf(stderr, "Couldn't find any tables!\n"); + break; + case 'i': + fprintf(stderr, "Couldn't find any indices!\n"); + break; + case 'S': + fprintf(stderr, "Couldn't find any sequences!\n"); + break; + case 'b': + default: + fprintf(stderr, "Couldn't find any tables, sequences or indices!\n"); + break; } return (-1); } @@ -407,11 +407,11 @@ tableList(PsqlSettings * ps, bool deep_tablelist, char info_type) int rightsList(PsqlSettings * ps) { - char listbuf[256]; - int nColumns; - int i; + char listbuf[256]; + int nColumns; + int i; - PGresult *res; + PGresult *res; listbuf[0] = '\0'; strcat(listbuf, "SELECT relname, relacl"); @@ -462,13 +462,13 @@ rightsList(PsqlSettings * ps) int tableDesc(PsqlSettings * ps, char *table) { - char descbuf[256]; - int nColumns; - char *rtype; - int i; - int rsize; + char descbuf[256]; + int nColumns; + char *rtype; + int i; + int rsize; - PGresult *res; + PGresult *res; /* Build the query */ @@ -530,7 +530,7 @@ tableDesc(PsqlSettings * ps, char *table) printf("%-32.32s |", rtype); else { - char *newname; + char *newname; newname = malloc(strlen(rtype) + 2); strcpy(newname, rtype + 1); @@ -558,13 +558,13 @@ tableDesc(PsqlSettings * ps, char *table) } } -typedef char *(*READ_ROUTINE) (char *prompt, FILE * source); +typedef char *(*READ_ROUTINE) (char *prompt, FILE * source); /* * gets_noreadline prompt source gets a line of input without calling * readline, the source is ignored */ -static char * +static char * gets_noreadline(char *prompt, FILE * source) { fputs(prompt, stdout); @@ -576,15 +576,15 @@ gets_noreadline(char *prompt, FILE * source) * gets_readline prompt source the routine to get input from GNU readline(), * the source is ignored the prompt argument is used as the prompting string */ -static char * +static char * gets_readline(char *prompt, FILE * source) { - char *s; + char *s; #ifdef HAVE_LIBREADLINE s = readline(prompt); #else - char buf[500]; + char buf[500]; printf("%s", prompt); s = fgets(buf, 500, stdin); @@ -600,11 +600,11 @@ gets_readline(char *prompt, FILE * source) * the routine to read from a file, the prompt argument is ignored the source * argument is a FILE * */ -static char * +static char * gets_fromFile(char *prompt, FILE * source) { - char *line; - int len; + char *line; + int len; line = malloc(MAX_QUERY_BUFFER + 1); @@ -634,8 +634,8 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query, const bool copy_in, const bool copy_out, FILE * copystream) { - PGresult *results; - PGnotify *notify; + PGresult *results; + PGnotify *notify; if (settings->singleStep) fprintf(stdout, "\n**************************************" @@ -664,76 +664,76 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query, { switch (PQresultStatus(results)) { - case PGRES_TUPLES_OK: - if (settings->gfname) - { - PsqlSettings ps = *settings; - FILE *fp; - - ps.queryFout = stdout; - fp = setFout(&ps, settings->gfname); - if (!fp || fp == stdout) + case PGRES_TUPLES_OK: + if (settings->gfname) { - *success_p = false; + PsqlSettings ps = *settings; + FILE *fp; + + ps.queryFout = stdout; + fp = setFout(&ps, settings->gfname); + if (!fp || fp == stdout) + { + *success_p = false; + break; + } + else + *success_p = true; + PQprint(fp, + results, + &(settings->opt)); + if (ps.pipe) + pclose(fp); + else + fclose(fp); + free(settings->gfname); + settings->gfname = NULL; break; } else + { *success_p = true; - PQprint(fp, - results, - &(settings->opt)); - if (ps.pipe) - pclose(fp); - else - fclose(fp); - free(settings->gfname); - settings->gfname = NULL; + PQprint(settings->queryFout, + results, + &(settings->opt)); + fflush(settings->queryFout); + } break; - } - else - { + case PGRES_EMPTY_QUERY: + *success_p = true; + break; + case PGRES_COMMAND_OK: *success_p = true; - PQprint(settings->queryFout, - results, - &(settings->opt)); - fflush(settings->queryFout); - } - break; - case PGRES_EMPTY_QUERY: - *success_p = true; - break; - case PGRES_COMMAND_OK: - *success_p = true; - if (!settings->quiet) - printf("%s\n", PQcmdStatus(results)); - break; - case PGRES_COPY_OUT: - *success_p = true; - if (copy_out) - { - handleCopyOut(results, settings->quiet, copystream); - } - else - { if (!settings->quiet) - printf("Copy command returns...\n"); + printf("%s\n", PQcmdStatus(results)); + break; + case PGRES_COPY_OUT: + *success_p = true; + if (copy_out) + { + handleCopyOut(results, settings->quiet, copystream); + } + else + { + if (!settings->quiet) + printf("Copy command returns...\n"); - handleCopyOut(results, settings->quiet, stdout); - } - break; - case PGRES_COPY_IN: - *success_p = true; - if (copy_in) - handleCopyIn(results, false, copystream); - else - handleCopyIn(results, !settings->quiet, stdin); - break; - case PGRES_NONFATAL_ERROR: - case PGRES_FATAL_ERROR: - case PGRES_BAD_RESPONSE: - *success_p = false; - fprintf(stderr, "%s", PQerrorMessage(settings->db)); - break; + handleCopyOut(results, settings->quiet, stdout); + } + break; + case PGRES_COPY_IN: + *success_p = true; + if (copy_in) + handleCopyIn(results, false, copystream); + else + handleCopyIn(results, !settings->quiet, stdin); + break; + case PGRES_NONFATAL_ERROR: + case PGRES_FATAL_ERROR: + case PGRES_BAD_RESPONSE: + *success_p = false; + fprintf(stderr, "%s", PQerrorMessage(settings->db)); + break; } if (PQstatus(settings->db) == CONNECTION_BAD) @@ -763,8 +763,8 @@ SendQuery(bool * success_p, PsqlSettings * settings, const char *query, static void editFile(char *fname) { - char *editorName; - char *sys; + char *editorName; + char *sys; editorName = getenv("EDITOR"); if (!editorName) @@ -780,7 +780,7 @@ editFile(char *fname) free(sys); } -static bool +static bool toggle(PsqlSettings * settings, bool * sw, char *msg) { *sw = !*sw; @@ -798,36 +798,36 @@ unescape(char *dest, const char *source) Return as the string <dest> the value of string <source> with escape sequences turned into the bytes they represent. -----------------------------------------------------------------------------*/ - char *p; - bool esc; /* Last character we saw was the escape + char *p; + bool esc; /* Last character we saw was the escape * character (/) */ esc = false; /* Haven't seen escape character yet */ for (p = (char *) source; *p; p++) { - char c; /* Our output character */ + char c; /* Our output character */ if (esc) { switch (*p) { - case 'n': - c = '\n'; - break; - case 'r': - c = '\r'; - break; - case 't': - c = '\t'; - break; - case 'f': - c = '\f'; - break; - case '\\': - c = '\\'; - break; - default: - c = *p; + case 'n': + c = '\n'; + break; + case 'r': + c = '\r'; + break; + case 't': + c = '\t'; + break; + case 'f': + c = '\f'; + break; + case '\\': + c = '\\'; + break; + default: + c = *p; } esc = false; } @@ -856,14 +856,14 @@ parse_slash_copy(const char *args, char *table, const int table_len, bool * from_p, bool * error_p) { - char work_args[200]; + char work_args[200]; /* * A copy of the \copy command arguments, except that we modify it as * we parse to suit our parsing needs. */ - char *table_tok, - *fromto_tok; + char *table_tok, + *fromto_tok; strncpy(work_args, args, sizeof(work_args)); work_args[sizeof(work_args) - 1] = '\0'; @@ -903,7 +903,7 @@ parse_slash_copy(const char *args, char *table, const int table_len, } if (!*error_p) { - char *file_tok; + char *file_tok; file_tok = strtok(NULL, " "); if (file_tok == NULL) @@ -942,22 +942,22 @@ do_copy(const char *args, PsqlSettings * settings) should do all the things a backend copy can do. ----------------------------------------------------------------------------*/ - char query[200]; + char query[200]; /* The COPY command we send to the back end */ - bool from; + bool from; /* The direction of the copy is from a file to a table. */ - char file[MAXPATHLEN + 1]; + char file[MAXPATHLEN + 1]; /* The pathname of the file from/to which we copy */ - char table[NAMEDATALEN]; + char table[NAMEDATALEN]; /* The name of the table from/to which we copy */ - bool syntax_error; + bool syntax_error; /* The \c command has invalid syntax */ - FILE *copystream; + FILE *copystream; parse_slash_copy(args, table, sizeof(table), file, sizeof(file), &from, &syntax_error); @@ -986,8 +986,7 @@ do_copy(const char *args, PsqlSettings * settings) from ? "from" : "to", strerror(errno), errno); else { - bool success; /* The query succeeded at the - * backend */ + bool success;/* The query succeeded at the backend */ SendQuery(&success, settings, query, from, !from, copystream); fclose(copystream); @@ -1012,10 +1011,10 @@ do_connect(const char *new_dbname, fprintf(stderr, "\\connect must be followed by a database name\n"); else { - PGconn *olddb = settings->db; - static char *userenv = NULL; - char *old_userenv = NULL; - const char *dbparam; + PGconn *olddb = settings->db; + static char *userenv = NULL; + char *old_userenv = NULL; + const char *dbparam; if (new_user != NULL) { @@ -1074,12 +1073,12 @@ static void do_edit(const char *filename_arg, char *query, int *status_p) { - int fd; - char tmp[64]; - char *fname; - int cc; - const int ql = strlen(query); - bool error; + int fd; + char tmp[64]; + char *fname; + int cc; + const int ql = strlen(query); + bool error; if (filename_arg) { @@ -1161,9 +1160,8 @@ do_help(PsqlSettings * ps, const char *topic) if (!topic) { - char left_center_right; /* Which column we're - * displaying */ - int i; /* Index into QL_HELP[] */ + char left_center_right; /* Which column we're displaying */ + int i; /* Index into QL_HELP[] */ printf("type \\h <cmd> where <cmd> is one of the following:\n"); @@ -1173,18 +1171,18 @@ do_help(PsqlSettings * ps, const char *topic) { switch (left_center_right) { - case 'L': - printf(" %-25s", QL_HELP[i].cmd); - left_center_right = 'C'; - break; - case 'C': - printf("%-25s", QL_HELP[i].cmd); - left_center_right = 'R'; - break; - case 'R': - printf("%-25s\n", QL_HELP[i].cmd); - left_center_right = 'L'; - break; + case 'L': + printf(" %-25s", QL_HELP[i].cmd); + left_center_right = 'C'; + break; + case 'C': + printf("%-25s", QL_HELP[i].cmd); + left_center_right = 'R'; + break; + case 'R': + printf("%-25s\n", QL_HELP[i].cmd); + left_center_right = 'L'; + break; }; i++; } @@ -1194,12 +1192,12 @@ do_help(PsqlSettings * ps, const char *topic) } else { - int i; /* Index into QL_HELP[] */ - bool help_found; /* We found the help he asked for */ + int i; /* Index into QL_HELP[] */ + bool help_found; /* We found the help he asked for */ - int usePipe = 0; - char *pagerenv; - FILE *fout; + int usePipe = 0; + char *pagerenv; + FILE *fout; if (strcmp(topic, "*") == 0 && (ps->notty == 0) && @@ -1248,8 +1246,8 @@ do_shell(const char *command) if (!command) { - char *sys; - char *shellName; + char *sys; + char *shellName; shellName = getenv("SHELL"); if (shellName == NULL) @@ -1288,28 +1286,28 @@ HandleSlashCmds(PsqlSettings * settings, char *line, char *query) { - int status = CMD_SKIP_LINE; - char *optarg; + int status = CMD_SKIP_LINE; + char *optarg; /* * Pointer inside the <cmd> string to the argument of the slash * command, assuming it is a one-character slash command. If it's not * a one-character command, this is meaningless. */ - char *optarg2; + char *optarg2; /* * Pointer inside the <cmd> string to the argument of the slash * command assuming it's not a one-character command. If it's a * one-character command, this is meaningless. */ - char *cmd; + char *cmd; /* * String: value of the slash command, less the slash and with escape * sequences decoded. */ - int blank_loc; + int blank_loc; /* Offset within <cmd> of first blank */ @@ -1342,271 +1340,271 @@ HandleSlashCmds(PsqlSettings * settings, switch (cmd[0]) { - case 'a': /* toggles to align fields on output */ - toggle(settings, &settings->opt.align, "field alignment"); - break; - case 'C': /* define new caption */ - if (settings->opt.caption) - { - free(settings->opt.caption); - settings->opt.caption = NULL; - } - if (optarg && !(settings->opt.caption = strdup(optarg))) - { - perror("malloc"); - exit(CMD_TERMINATE); - } - break; - case 'c': - { - if (strncmp(cmd, "copy ", strlen("copy ")) == 0) - do_copy(optarg2, settings); - else if (strncmp(cmd, "connect ", strlen("connect ")) == 0 || - strcmp(cmd, "connect") == 0 /* issue error message */ ) + case 'a': /* toggles to align fields on output */ + toggle(settings, &settings->opt.align, "field alignment"); + break; + case 'C': /* define new caption */ + if (settings->opt.caption) + { + free(settings->opt.caption); + settings->opt.caption = NULL; + } + if (optarg && !(settings->opt.caption = strdup(optarg))) + { + perror("malloc"); + exit(CMD_TERMINATE); + } + break; + case 'c': { - char *optarg3 = NULL; - int blank_loc2; + if (strncmp(cmd, "copy ", strlen("copy ")) == 0) + do_copy(optarg2, settings); + else if (strncmp(cmd, "connect ", strlen("connect ")) == 0 || + strcmp(cmd, "connect") == 0 /* issue error message */ ) + { + char *optarg3 = NULL; + int blank_loc2; - if (optarg2) + if (optarg2) + { + blank_loc2 = strcspn(optarg2, " \t"); + if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0') + optarg3 = NULL; + else + { + optarg3 = optarg2 + blank_loc2 + + strspn(optarg2 + blank_loc2, " \t"); + *(optarg2 + blank_loc2) = '\0'; + } + } + do_connect(optarg2, optarg3, settings); + } + else { - blank_loc2 = strcspn(optarg2, " \t"); - if (blank_loc2 == 0 || *(optarg2 + blank_loc2) == '\0') - optarg3 = NULL; - else + char *optarg3 = NULL; + int blank_loc2; + + if (optarg) { - optarg3 = optarg2 + blank_loc2 + - strspn(optarg2 + blank_loc2, " \t"); - *(optarg2 + blank_loc2) = '\0'; + blank_loc2 = strcspn(optarg, " \t"); + if (blank_loc2 == 0 || *(optarg + blank_loc2) == '\0') + optarg3 = NULL; + else + { + optarg3 = optarg + blank_loc2 + + strspn(optarg + blank_loc2, " \t"); + *(optarg + blank_loc2) = '\0'; + } } + do_connect(optarg, optarg3, settings); } - do_connect(optarg2, optarg3, settings); + } + break; + case 'd': /* \d describe tables or columns in a + * table */ + if (strncmp(cmd, "dt", 2) == 0) + { /* only tables */ + tableList(settings, 0, 't'); + } + else if (strncmp(cmd, "di", 2) == 0) + { /* only indices */ + tableList(settings, 0, 'i'); + } + else if (strncmp(cmd, "ds", 2) == 0) + { /* only sequences */ + tableList(settings, 0, 'S'); + } + else if (!optarg) + { /* show tables, sequences and indices */ + tableList(settings, 0, 'b'); + } + else if (strcmp(optarg, "*") == 0) + { /* show everything */ + if (tableList(settings, 0, 'b') == 0) + tableList(settings, 1, 'b'); } else + { /* describe the specified table */ + tableDesc(settings, optarg); + } + break; + case 'e': /* edit */ + { + do_edit(optarg, query, &status); + break; + } + case 'E': { - char *optarg3 = NULL; - int blank_loc2; + FILE *fd; + static char *lastfile; + struct stat st, + st2; if (optarg) { - blank_loc2 = strcspn(optarg, " \t"); - if (blank_loc2 == 0 || *(optarg + blank_loc2) == '\0') - optarg3 = NULL; - else + if (lastfile) + free(lastfile); + lastfile = malloc(strlen(optarg + 1)); + if (!lastfile) { - optarg3 = optarg + blank_loc2 + - strspn(optarg + blank_loc2, " \t"); - *(optarg + blank_loc2) = '\0'; + perror("malloc"); + exit(CMD_TERMINATE); } + strcpy(lastfile, optarg); } - do_connect(optarg, optarg3, settings); + else if (!lastfile) + { + fprintf(stderr, "\\r must be followed by a file name initially\n"); + break; + } + stat(lastfile, &st); + editFile(lastfile); + if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL)) + { + perror(lastfile); + break; + } + if (st2.st_mtime == st.st_mtime) + { + if (!settings->quiet) + fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile); + fclose(fd); + break; + } + MainLoop(settings, fd); + fclose(fd); + break; } - } - break; - case 'd': /* \d describe tables or columns in a - * table */ - if (strncmp(cmd, "dt", 2) == 0) - { /* only tables */ - tableList(settings, 0, 't'); - } - else if (strncmp(cmd, "di", 2) == 0) - { /* only indices */ - tableList(settings, 0, 'i'); - } - else if (strncmp(cmd, "ds", 2) == 0) - { /* only sequences */ - tableList(settings, 0, 'S'); - } - else if (!optarg) - { /* show tables, sequences and indices */ - tableList(settings, 0, 'b'); - } - else if (strcmp(optarg, "*") == 0) - { /* show everything */ - if (tableList(settings, 0, 'b') == 0) - tableList(settings, 1, 'b'); - } - else - { /* describe the specified table */ - tableDesc(settings, optarg); - } - break; - case 'e': /* edit */ - { - do_edit(optarg, query, &status); - break; - } - case 'E': - { - FILE *fd; - static char *lastfile; - struct stat st, - st2; - - if (optarg) + case 'f': { - if (lastfile) - free(lastfile); - lastfile = malloc(strlen(optarg + 1)); - if (!lastfile) + char *fs = DEFAULT_FIELD_SEP; + + if (optarg) + fs = optarg; + if (settings->opt.fieldSep) + free(settings->opt.fieldSep); + if (!(settings->opt.fieldSep = strdup(fs))) { perror("malloc"); exit(CMD_TERMINATE); } - strcpy(lastfile, optarg); + if (!settings->quiet) + printf("field separator changed to '%s'\n", settings->opt.fieldSep); + break; } - else if (!lastfile) + case 'g': /* \g means send query */ + if (!optarg) + settings->gfname = NULL; + else if (!(settings->gfname = strdup(optarg))) { - fprintf(stderr, "\\r must be followed by a file name initially\n"); - break; + perror("malloc"); + exit(CMD_TERMINATE); } - stat(lastfile, &st); - editFile(lastfile); - if ((stat(lastfile, &st2) == -1) || ((fd = fopen(lastfile, "r")) == NULL)) + status = CMD_SEND; + break; + case 'h': /* help */ { - perror(lastfile); + do_help(settings, optarg); break; } - if (st2.st_mtime == st.st_mtime) + case 'i': /* \i is include file */ { - if (!settings->quiet) - fprintf(stderr, "warning: %s not modified. query not executed\n", lastfile); + FILE *fd; + + if (!optarg) + { + fprintf(stderr, "\\i must be followed by a file name\n"); + break; + } + if ((fd = fopen(optarg, "r")) == NULL) + { + fprintf(stderr, "file named %s could not be opened\n", optarg); + break; + } + MainLoop(settings, fd); fclose(fd); break; } - MainLoop(settings, fd); - fclose(fd); + case 'l': /* \l is list database */ + listAllDbs(settings); break; - } - case 'f': - { - char *fs = DEFAULT_FIELD_SEP; - - if (optarg) - fs = optarg; - if (settings->opt.fieldSep) - free(settings->opt.fieldSep); - if (!(settings->opt.fieldSep = strdup(fs))) + case 'H': + if (toggle(settings, &settings->opt.html3, "HTML3.0 tabular output")) + settings->opt.standard = 0; + break; + case 'o': + setFout(settings, optarg); + break; + case 'p': + if (query) { - perror("malloc"); - exit(CMD_TERMINATE); + fputs(query, stdout); + fputc('\n', stdout); } - if (!settings->quiet) - printf("field separator changed to '%s'\n", settings->opt.fieldSep); break; - } - case 'g': /* \g means send query */ - if (!optarg) - settings->gfname = NULL; - else if (!(settings->gfname = strdup(optarg))) - { - perror("malloc"); - exit(CMD_TERMINATE); - } - status = CMD_SEND; - break; - case 'h': /* help */ - { - do_help(settings, optarg); + case 'q': /* \q is quit */ + status = CMD_TERMINATE; break; - } - case 'i': /* \i is include file */ - { - FILE *fd; - + case 'r': /* reset(clear) the buffer */ + query[0] = '\0'; + if (!settings->quiet) + printf("buffer reset(cleared)\n"); + break; + case 's': /* \s is save history to a file */ if (!optarg) + optarg = "/dev/tty"; +#ifdef HAVE_HISTORY + if (write_history(optarg) != 0) + fprintf(stderr, "cannot write history to %s\n", optarg); +#endif + break; + case 'm': /* monitor like type-setting */ + if (toggle(settings, &settings->opt.standard, "standard SQL separaters and padding")) { - fprintf(stderr, "\\i must be followed by a file name\n"); - break; + settings->opt.html3 = settings->opt.expanded = 0; + settings->opt.align = settings->opt.header = 1; + if (settings->opt.fieldSep) + free(settings->opt.fieldSep); + settings->opt.fieldSep = strdup("|"); + if (!settings->quiet) + printf("field separator changed to '%s'\n", settings->opt.fieldSep); } - if ((fd = fopen(optarg, "r")) == NULL) + else { - fprintf(stderr, "file named %s could not be opened\n", optarg); - break; + if (settings->opt.fieldSep) + free(settings->opt.fieldSep); + settings->opt.fieldSep = strdup(DEFAULT_FIELD_SEP); + if (!settings->quiet) + printf("field separator changed to '%s'\n", settings->opt.fieldSep); } - MainLoop(settings, fd); - fclose(fd); break; - } - case 'l': /* \l is list database */ - listAllDbs(settings); - break; - case 'H': - if (toggle(settings, &settings->opt.html3, "HTML3.0 tabular output")) - settings->opt.standard = 0; - break; - case 'o': - setFout(settings, optarg); - break; - case 'p': - if (query) - { - fputs(query, stdout); - fputc('\n', stdout); - } - break; - case 'q': /* \q is quit */ - status = CMD_TERMINATE; - break; - case 'r': /* reset(clear) the buffer */ - query[0] = '\0'; - if (!settings->quiet) - printf("buffer reset(cleared)\n"); - break; - case 's': /* \s is save history to a file */ - if (!optarg) - optarg = "/dev/tty"; -#ifdef HAVE_HISTORY - if (write_history(optarg) != 0) - fprintf(stderr, "cannot write history to %s\n", optarg); -#endif - break; - case 'm': /* monitor like type-setting */ - if (toggle(settings, &settings->opt.standard, "standard SQL separaters and padding")) - { - settings->opt.html3 = settings->opt.expanded = 0; - settings->opt.align = settings->opt.header = 1; - if (settings->opt.fieldSep) - free(settings->opt.fieldSep); - settings->opt.fieldSep = strdup("|"); - if (!settings->quiet) - printf("field separator changed to '%s'\n", settings->opt.fieldSep); - } - else - { - if (settings->opt.fieldSep) - free(settings->opt.fieldSep); - settings->opt.fieldSep = strdup(DEFAULT_FIELD_SEP); - if (!settings->quiet) - printf("field separator changed to '%s'\n", settings->opt.fieldSep); - } - break; - case 'z': /* list table rights (grant/revoke) */ - rightsList(settings); - break; - case 't': /* toggle headers */ - toggle(settings, &settings->opt.header, "output headings and row count"); - break; - case 'T': /* define html <table ...> option */ - if (settings->opt.tableOpt) - free(settings->opt.tableOpt); - if (!optarg) - settings->opt.tableOpt = NULL; - else if (!(settings->opt.tableOpt = strdup(optarg))) - { - perror("malloc"); - exit(CMD_TERMINATE); - } - break; - case 'x': - toggle(settings, &settings->opt.expanded, "expanded table representation"); - break; - case '!': - do_shell(optarg); - break; - default: - case '?': /* \? is help */ - slashUsage(settings); - break; + case 'z': /* list table rights (grant/revoke) */ + rightsList(settings); + break; + case 't': /* toggle headers */ + toggle(settings, &settings->opt.header, "output headings and row count"); + break; + case 'T': /* define html <table ...> option */ + if (settings->opt.tableOpt) + free(settings->opt.tableOpt); + if (!optarg) + settings->opt.tableOpt = NULL; + else if (!(settings->opt.tableOpt = strdup(optarg))) + { + perror("malloc"); + exit(CMD_TERMINATE); + } + break; + case 'x': + toggle(settings, &settings->opt.expanded, "expanded table representation"); + break; + case '!': + do_shell(optarg); + break; + default: + case '?': /* \? is help */ + slashUsage(settings); + break; } free(cmd); return status; @@ -1624,13 +1622,13 @@ HandleSlashCmds(PsqlSettings * settings, static int MainLoop(PsqlSettings * settings, FILE * source) { - char *line; /* line of input */ - char *xcomment; /* start of extended comment */ - int len; /* length of the line */ - char query[MAX_QUERY_BUFFER]; /* multi-line query + char *line; /* line of input */ + char *xcomment; /* start of extended comment */ + int len; /* length of the line */ + char query[MAX_QUERY_BUFFER]; /* multi-line query * storage */ - int successResult = 1; - int slashCmdStatus = CMD_SEND; + int successResult = 1; + int slashCmdStatus = CMD_SEND; /* * slashCmdStatus can be: CMD_UNKNOWN - send currently constructed @@ -1641,16 +1639,16 @@ MainLoop(PsqlSettings * settings, FILE * source) * entirely CMD_NEWEDIT - new query supplied by edit */ - bool querySent = false; - bool interactive; - READ_ROUTINE GetNextLine; - bool eof = 0; + bool querySent = false; + bool interactive; + READ_ROUTINE GetNextLine; + bool eof = 0; /* We've reached the end of our command input. */ - bool success; - bool in_quote; - int paren_level; - char *query_start; + bool success; + bool in_quote; + int paren_level; + char *query_start; interactive = ((source == stdin) && !settings->notty); if (interactive) @@ -1772,7 +1770,7 @@ MainLoop(PsqlSettings * settings, FILE * source) } else { - int i; + int i; for (i = 0; i < len; i++) { @@ -1802,7 +1800,7 @@ MainLoop(PsqlSettings * settings, FILE * source) } else if (line[i] == '\\') { - char hold_char = line[i]; + char hold_char = line[i]; line[i] = '\0'; if (query_start[0] != '\0') @@ -1849,7 +1847,7 @@ MainLoop(PsqlSettings * settings, FILE * source) } else if (!paren_level && line[i] == ';') { - char hold_char = line[i + 1]; + char hold_char = line[i + 1]; line[i + 1] = '\0'; if (query_start[0] != '\0') @@ -1955,23 +1953,23 @@ MainLoop(PsqlSettings * settings, FILE * source) int main(int argc, char **argv) { - extern char *optarg; - extern int optind; + extern char *optarg; + extern int optind; - char *dbname = NULL; - char *host = NULL; - char *port = NULL; - char *qfilename = NULL; - char errbuf[ERROR_MSG_LENGTH]; + char *dbname = NULL; + char *host = NULL; + char *port = NULL; + char *qfilename = NULL; + char errbuf[ERROR_MSG_LENGTH]; - PsqlSettings settings; + PsqlSettings settings; - char *singleQuery = NULL; + char *singleQuery = NULL; - bool listDatabases = 0; - int successResult = 1; - bool singleSlashCmd = 0; - int c; + bool listDatabases = 0; + int successResult = 1; + bool singleSlashCmd = 0; + int c; memset(&settings, 0, sizeof settings); settings.opt.align = 1; @@ -1995,73 +1993,73 @@ main(int argc, char **argv) { switch (c) { - case 'A': - settings.opt.align = 0; - break; - case 'a': - fe_setauthsvc(optarg, errbuf); - break; - case 'c': - singleQuery = strdup(optarg); - if (singleQuery[0] == '\\') - { - singleSlashCmd = 1; - } - break; - case 'd': - dbname = optarg; - break; - case 'e': - settings.echoQuery = 1; - break; - case 'f': - qfilename = optarg; - break; - case 'F': - settings.opt.fieldSep = strdup(optarg); - break; - case 'l': - listDatabases = 1; - break; - case 'h': - host = optarg; - break; - case 'H': - settings.opt.html3 = 1; - break; - case 'n': - settings.useReadline = 0; - break; - case 'o': - setFout(&settings, optarg); - break; - case 'p': - port = optarg; - break; - case 'q': - settings.quiet = 1; - break; - case 's': - settings.singleStep = 1; - break; - case 'S': - settings.singleLineMode = 1; - break; - case 't': - settings.opt.header = 0; - break; - case 'T': - settings.opt.tableOpt = strdup(optarg); - break; - case 'u': - settings.getPassword = 1; - break; - case 'x': - settings.opt.expanded = 1; - break; - default: - usage(argv[0]); - break; + case 'A': + settings.opt.align = 0; + break; + case 'a': + fe_setauthsvc(optarg, errbuf); + break; + case 'c': + singleQuery = strdup(optarg); + if (singleQuery[0] == '\\') + { + singleSlashCmd = 1; + } + break; + case 'd': + dbname = optarg; + break; + case 'e': + settings.echoQuery = 1; + break; + case 'f': + qfilename = optarg; + break; + case 'F': + settings.opt.fieldSep = strdup(optarg); + break; + case 'l': + listDatabases = 1; + break; + case 'h': + host = optarg; + break; + case 'H': + settings.opt.html3 = 1; + break; + case 'n': + settings.useReadline = 0; + break; + case 'o': + setFout(&settings, optarg); + break; + case 'p': + port = optarg; + break; + case 'q': + settings.quiet = 1; + break; + case 's': + settings.singleStep = 1; + break; + case 'S': + settings.singleLineMode = 1; + break; + case 't': + settings.opt.header = 0; + break; + case 'T': + settings.opt.tableOpt = strdup(optarg); + break; + case 'u': + settings.getPassword = 1; + break; + case 'x': + settings.opt.expanded = 1; + break; + default: + usage(argv[0]); + break; } } /* if we still have an argument, use it as the database name */ @@ -2073,9 +2071,9 @@ main(int argc, char **argv) if (settings.getPassword) { - char username[9]; - char password[9]; - char *connect_string; + char username[9]; + char password[9]; + char *connect_string; prompt_for_password(username, password); @@ -2119,7 +2117,7 @@ main(int argc, char **argv) * read in a file full of queries instead of reading in queries * interactively */ - char *line; + char *line; if (singleSlashCmd) { @@ -2138,8 +2136,7 @@ main(int argc, char **argv) { if (singleQuery) { - bool success; /* The query succeeded at the - * backend */ + bool success;/* The query succeeded at the backend */ SendQuery(&success, &settings, singleQuery, false, false, 0); successResult = success; @@ -2161,9 +2158,9 @@ main(int argc, char **argv) static void handleCopyOut(PGresult * res, bool quiet, FILE * copystream) { - bool copydone; - char copybuf[COPYBUFSIZ]; - int ret; + bool copydone; + char copybuf[COPYBUFSIZ]; + int ret; copydone = false; /* Can't be done; haven't started. */ @@ -2182,14 +2179,14 @@ handleCopyOut(PGresult * res, bool quiet, FILE * copystream) fputs(copybuf, copystream); switch (ret) { - case EOF: - copydone = true; - /* FALLTHROUGH */ - case 0: - fputc('\n', copystream); - break; - case 1: - break; + case EOF: + copydone = true; + /* FALLTHROUGH */ + case 0: + fputc('\n', copystream); + break; + case 1: + break; } } } @@ -2202,13 +2199,13 @@ handleCopyOut(PGresult * res, bool quiet, FILE * copystream) static void handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream) { - bool copydone = false; - bool firstload; - bool linedone; - char copybuf[COPYBUFSIZ]; - char *s; - int buflen; - int c; + bool copydone = false; + bool firstload; + bool linedone; + char copybuf[COPYBUFSIZ]; + char *s; + int buflen; + int c; if (mustprompt) { @@ -2263,7 +2260,7 @@ handleCopyIn(PGresult * res, const bool mustprompt, FILE * copystream) * try to open fname and return a FILE *, if it fails, use stdout, instead */ -static FILE * +static FILE * setFout(PsqlSettings * ps, char *fname) { if (ps->queryFout && ps->queryFout != stdout) @@ -2304,11 +2301,11 @@ setFout(PsqlSettings * ps, char *fname) static void prompt_for_password(char *username, char *password) { - int length; + int length; #ifdef HAVE_TERMIOS_H - struct termios t_orig, - t; + struct termios t_orig, + t; #endif @@ -2318,7 +2315,7 @@ prompt_for_password(char *username, char *password) /* skip rest of the line */ if (length > 0 && username[length - 1] != '\n') { - static char buf[512]; + static char buf[512]; do { @@ -2344,7 +2341,7 @@ prompt_for_password(char *username, char *password) /* skip rest of the line */ if (length > 0 && password[length - 1] != '\n') { - static char buf[512]; + static char buf[512]; do { @@ -2357,12 +2354,12 @@ prompt_for_password(char *username, char *password) printf("\n\n"); } -static char * +static char * make_connect_string(char *host, char *port, char *dbname, char *username, char *password) { - int connect_string_len = 0; - char *connect_string; + int connect_string_len = 0; + char *connect_string; if (host) connect_string_len += 6 + strlen(host); /* 6 == "host=" + " " */ diff --git a/src/bin/psql/psqlHelp.h b/src/bin/psql/psqlHelp.h index f9f372a8add..abc00b33f9a 100644 --- a/src/bin/psql/psqlHelp.h +++ b/src/bin/psql/psqlHelp.h @@ -5,16 +5,16 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psqlHelp.h,v 1.23 1997/09/07 04:55:23 momjian Exp $ + * $Id: psqlHelp.h,v 1.24 1997/09/08 02:33:43 momjian Exp $ * *------------------------------------------------------------------------- */ struct _helpStruct { - char *cmd; /* the command name */ - char *help; /* the help associated with it */ - char *syntax; /* the syntax associated with it */ + char *cmd; /* the command name */ + char *help; /* the help associated with it */ + char *syntax; /* the syntax associated with it */ }; static struct _helpStruct QL_HELP[] = { diff --git a/src/bin/psql/stringutils.c b/src/bin/psql/stringutils.c index cf34622209e..a868be9ddd6 100644 --- a/src/bin/psql/stringutils.c +++ b/src/bin/psql/stringutils.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.11 1997/09/07 04:55:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/bin/psql/stringutils.c,v 1.12 1997/09/08 02:33:45 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,12 +30,12 @@ /* MODIFIES the string passed in and returns the head of it */ #ifdef NOT_USED -static char * +static char * leftTrim(char *s) { - char *s2 = s; - int shift = 0; - int j = 0; + char *s2 = s; + int shift = 0; + int j = 0; while (isspace(*s)) { @@ -53,10 +53,10 @@ leftTrim(char *s) #endif -char * +char * rightTrim(char *s) { - char *sEnd; + char *sEnd; sEnd = s + strlen(s) - 1; while (sEnd >= s && isspace(*sEnd)) @@ -69,7 +69,7 @@ rightTrim(char *s) } #ifdef NOT_USED -static char * +static char * doubleTrim(char *s) { strcpy(s, leftTrim(rightTrim(s))); @@ -82,18 +82,18 @@ doubleTrim(char *s) void testStringUtils() { - static char *tests[] = {" goodbye \n", /* space on both ends */ + static char *tests[] = {" goodbye \n", /* space on both ends */ "hello world", /* no spaces to trim */ "", /* empty string */ "a", /* string with one char */ " ", /* string with one whitespace */ NULL_STR}; - int i = 0; + int i = 0; while (tests[i] != NULL_STR) { - char *t; + char *t; t = strdup(tests[i]); printf("leftTrim(%s) = ", t); diff --git a/src/bin/psql/stringutils.h b/src/bin/psql/stringutils.h index 2bc8795f4c4..79669d3452e 100644 --- a/src/bin/psql/stringutils.h +++ b/src/bin/psql/stringutils.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringutils.h,v 1.5 1997/09/07 04:55:32 momjian Exp $ + * $Id: stringutils.h,v 1.6 1997/09/08 02:33:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,10 +27,10 @@ /* removes whitespaces from the left, right and both sides of a string */ /* MODIFIES the string passed in and returns the head of it */ -extern char *rightTrim(char *s); +extern char *rightTrim(char *s); #ifdef STRINGUTILS_TEST -extern void testStringUtils(); +extern void testStringUtils(); #endif diff --git a/src/include/access/attnum.h b/src/include/access/attnum.h index 24a757ac3c7..910e07fc111 100644 --- a/src/include/access/attnum.h +++ b/src/include/access/attnum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: attnum.h,v 1.5 1997/09/07 04:55:45 momjian Exp $ + * $Id: attnum.h,v 1.6 1997/09/08 02:34:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ /* * user defined attribute numbers start at 1. -ay 2/95 */ -typedef int16 AttrNumber; +typedef int16 AttrNumber; #define InvalidAttrNumber 0 diff --git a/src/include/access/funcindex.h b/src/include/access/funcindex.h index 6257ab97916..9bd92e3a777 100644 --- a/src/include/access/funcindex.h +++ b/src/include/access/funcindex.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: funcindex.h,v 1.3 1997/09/07 04:55:47 momjian Exp $ + * $Id: funcindex.h,v 1.4 1997/09/08 02:34:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,11 +15,11 @@ typedef struct { - int nargs; - Oid arglist[8]; - Oid procOid; - NameData funcName; -} FuncIndexInfo; + int nargs; + Oid arglist[8]; + Oid procOid; + NameData funcName; +} FuncIndexInfo; typedef FuncIndexInfo *FuncIndexInfoPtr; diff --git a/src/include/access/genam.h b/src/include/access/genam.h index 6bb73416c5a..0bdf32bdc84 100644 --- a/src/include/access/genam.h +++ b/src/include/access/genam.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: genam.h,v 1.8 1997/09/07 04:55:48 momjian Exp $ + * $Id: genam.h,v 1.9 1997/09/08 02:34:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,34 +24,34 @@ */ extern Relation index_open(Oid relationId); extern Relation index_openr(char *relationName); -extern void index_close(Relation relation); -extern InsertIndexResult +extern void index_close(Relation relation); +extern InsertIndexResult index_insert(Relation relation, Datum * datum, char *nulls, ItemPointer heap_t_ctid, Relation heapRel); -extern void index_delete(Relation relation, ItemPointer indexItem); -extern IndexScanDesc +extern void index_delete(Relation relation, ItemPointer indexItem); +extern IndexScanDesc index_beginscan(Relation relation, bool scanFromEnd, uint16 numberOfKeys, ScanKey key); -extern void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key); -extern void index_endscan(IndexScanDesc scan); -extern RetrieveIndexResult +extern void index_rescan(IndexScanDesc scan, bool scanFromEnd, ScanKey key); +extern void index_endscan(IndexScanDesc scan); +extern RetrieveIndexResult index_getnext(IndexScanDesc scan, ScanDirection direction); -extern RegProcedure +extern RegProcedure index_getprocid(Relation irel, AttrNumber attnum, uint16 procnum); -extern Datum +extern Datum GetIndexValue(HeapTuple tuple, TupleDesc hTupDesc, int attOff, AttrNumber attrNums[], FuncIndexInfo * fInfo, bool * attNull, Buffer buffer); /* in genam.c */ -extern IndexScanDesc +extern IndexScanDesc RelationGetIndexScan(Relation relation, bool scanFromEnd, uint16 numberOfKeys, ScanKey key); -extern void IndexScanMarkPosition(IndexScanDesc scan); -extern void IndexScanRestorePosition(IndexScanDesc scan); +extern void IndexScanMarkPosition(IndexScanDesc scan); +extern void IndexScanRestorePosition(IndexScanDesc scan); #endif /* GENAM_H */ diff --git a/src/include/access/gist.h b/src/include/access/gist.h index ff21dd50cd1..c80d206cb0c 100644 --- a/src/include/access/gist.h +++ b/src/include/access/gist.h @@ -51,8 +51,8 @@ typedef struct GISTPageOpaqueData { - uint32 flags; -} GISTPageOpaqueData; + uint32 flags; +} GISTPageOpaqueData; typedef GISTPageOpaqueData *GISTPageOpaque; @@ -65,22 +65,22 @@ typedef GISTPageOpaqueData *GISTPageOpaque; typedef struct GISTSTACK { struct GISTSTACK *gs_parent; - OffsetNumber gs_child; - BlockNumber gs_blk; -} GISTSTACK; + OffsetNumber gs_child; + BlockNumber gs_blk; +} GISTSTACK; typedef struct GISTSTATE { - func_ptr consistentFn; - func_ptr unionFn; - func_ptr compressFn; - func_ptr decompressFn; - func_ptr penaltyFn; - func_ptr picksplitFn; - func_ptr equalFn; - bool haskeytype; - bool keytypbyval; -} GISTSTATE; + func_ptr consistentFn; + func_ptr unionFn; + func_ptr compressFn; + func_ptr decompressFn; + func_ptr penaltyFn; + func_ptr picksplitFn; + func_ptr equalFn; + bool haskeytype; + bool keytypbyval; +} GISTSTATE; /* @@ -92,9 +92,9 @@ typedef struct GISTScanOpaqueData { struct GISTSTACK *s_stack; struct GISTSTACK *s_markstk; - uint16 s_flags; + uint16 s_flags; struct GISTSTATE *giststate; -} GISTScanOpaqueData; +} GISTScanOpaqueData; typedef GISTScanOpaqueData *GISTScanOpaque; @@ -128,13 +128,13 @@ typedef GISTScanOpaqueData *GISTScanOpaque; */ typedef struct GIST_SPLITVEC { - OffsetNumber *spl_left; /* array of entries that go left */ - int spl_nleft; /* size of this array */ - char *spl_ldatum; /* Union of keys in spl_left */ - OffsetNumber *spl_right; /* array of entries that go right */ - int spl_nright; /* size of the array */ - char *spl_rdatum; /* Union of keys in spl_right */ -} GIST_SPLITVEC; + OffsetNumber *spl_left; /* array of entries that go left */ + int spl_nleft; /* size of this array */ + char *spl_ldatum; /* Union of keys in spl_left */ + OffsetNumber *spl_right; /* array of entries that go right */ + int spl_nright; /* size of the array */ + char *spl_rdatum; /* Union of keys in spl_right */ +} GIST_SPLITVEC; /* ** An entry on a GiST node. Contains the key (pred), as well as @@ -144,13 +144,13 @@ typedef struct GIST_SPLITVEC */ typedef struct GISTENTRY { - char *pred; - Relation rel; - Page page; - OffsetNumber offset; - int bytes; - bool leafkey; -} GISTENTRY; + char *pred; + Relation rel; + Page page; + OffsetNumber offset; + int bytes; + bool leafkey; +} GISTENTRY; /* ** macro to initialize a GISTENTRY @@ -169,22 +169,22 @@ typedef struct txtrange * flag: NINF means that lower is negative infinity; PINF means that * * upper is positive infinity. 0 means that both are numbers. */ - int32 vl_len; - int32 flag; - char bytes[2]; -} TXTRANGE; + int32 vl_len; + int32 flag; + char bytes[2]; +} TXTRANGE; typedef struct intrange { - int lower; - int upper; + int lower; + int upper; /* * flag: NINF means that lower is negative infinity; PINF means that * * upper is positive infinity. 0 means that both are numbers. */ - int flag; -} INTRANGE; + int flag; +} INTRANGE; extern void gistbuild(Relation heap, @@ -193,12 +193,12 @@ gistbuild(Relation heap, uint16 pint, Datum * params, FuncIndexInfo * finfo, PredInfo * predInfo); -extern InsertIndexResult +extern InsertIndexResult gistinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel); -extern void _gistdump(Relation r); -extern void gistfreestack(GISTSTACK * s); -extern void initGISTstate(GISTSTATE * giststate, Relation index); +extern void _gistdump(Relation r); +extern void gistfreestack(GISTSTACK * s); +extern void initGISTstate(GISTSTATE * giststate, Relation index); extern void gistdentryinit(GISTSTATE * giststate, GISTENTRY * e, char *pr, Relation r, Page pg, OffsetNumber o, int b, bool l); diff --git a/src/include/access/gistscan.h b/src/include/access/gistscan.h index 46aa621631d..a5a5f782198 100644 --- a/src/include/access/gistscan.h +++ b/src/include/access/gistscan.h @@ -16,13 +16,13 @@ #include <storage/block.h> #include <utils/rel.h> -extern IndexScanDesc +extern IndexScanDesc gistbeginscan(Relation r, bool fromEnd, uint16 nkeys, ScanKey key); -extern void gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key); -extern void gistmarkpos(IndexScanDesc s); -extern void gistrestrpos(IndexScanDesc s); -extern void gistendscan(IndexScanDesc s); -extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); +extern void gistrescan(IndexScanDesc s, bool fromEnd, ScanKey key); +extern void gistmarkpos(IndexScanDesc s); +extern void gistrestrpos(IndexScanDesc s); +extern void gistendscan(IndexScanDesc s); +extern void gistadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); #endif /* GISTSCAN_H */ diff --git a/src/include/access/giststrat.h b/src/include/access/giststrat.h index 1007dd3ec26..42bdf847aef 100644 --- a/src/include/access/giststrat.h +++ b/src/include/access/giststrat.h @@ -15,7 +15,7 @@ #include <access/strat.h> #include <utils/rel.h> -extern StrategyNumber +extern StrategyNumber RelationGetGISTStrategy(Relation r, AttrNumber attnum, RegProcedure proc); diff --git a/src/include/access/hash.h b/src/include/access/hash.h index 14fd50c34cf..f9b93e0de77 100644 --- a/src/include/access/hash.h +++ b/src/include/access/hash.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hash.h,v 1.8 1997/09/07 04:55:54 momjian Exp $ + * $Id: hash.h,v 1.9 1997/09/08 02:34:08 momjian Exp $ * * NOTES * modeled after Margo Seltzer's hash implementation for unix. @@ -39,10 +39,10 @@ * macro OADDR_OF(S, O) where S is the splitnumber and O is the page * offset. */ -typedef uint32 Bucket; -typedef bits16 OverflowPageAddress; -typedef uint32 SplitNumber; -typedef uint32 PageOffset; +typedef uint32 Bucket; +typedef bits16 OverflowPageAddress; +typedef uint32 SplitNumber; +typedef uint32 PageOffset; /* A valid overflow address will always have a page offset >= 1 */ #define InvalidOvflAddress 0 @@ -77,13 +77,12 @@ typedef uint32 PageOffset; typedef struct HashPageOpaqueData { - bits16 hasho_flag; /* is this page a bucket or ovfl */ - Bucket hasho_bucket; /* bucket number this pg belongs - * to */ + bits16 hasho_flag; /* is this page a bucket or ovfl */ + Bucket hasho_bucket; /* bucket number this pg belongs to */ OverflowPageAddress hasho_oaddr; /* ovfl address of this ovfl pg */ - BlockNumber hasho_nextblkno; /* next ovfl blkno */ - BlockNumber hasho_prevblkno; /* previous ovfl (or bucket) blkno */ -} HashPageOpaqueData; + BlockNumber hasho_nextblkno;/* next ovfl blkno */ + BlockNumber hasho_prevblkno;/* previous ovfl (or bucket) blkno */ +} HashPageOpaqueData; typedef HashPageOpaqueData *HashPageOpaque; @@ -97,9 +96,9 @@ typedef HashPageOpaqueData *HashPageOpaque; typedef struct HashScanOpaqueData { - Buffer hashso_curbuf; - Buffer hashso_mrkbuf; -} HashScanOpaqueData; + Buffer hashso_curbuf; + Buffer hashso_mrkbuf; +} HashScanOpaqueData; typedef HashScanOpaqueData *HashScanOpaque; @@ -140,31 +139,28 @@ typedef HashScanOpaqueData *HashScanOpaque; typedef struct HashMetaPageData { - PageHeaderData hashm_phdr; /* pad for page header (do not use) */ - uint32 hashm_magic;/* magic no. for hash tables */ - uint32 hashm_version; /* version ID */ - uint32 hashm_nkeys;/* number of keys stored in the table */ - uint16 hashm_ffactor; /* fill factor */ - uint16 hashm_bsize;/* bucket size (bytes) - must be a power + PageHeaderData hashm_phdr; /* pad for page header (do not use) */ + uint32 hashm_magic; /* magic no. for hash tables */ + uint32 hashm_version; /* version ID */ + uint32 hashm_nkeys; /* number of keys stored in the table */ + uint16 hashm_ffactor; /* fill factor */ + uint16 hashm_bsize; /* bucket size (bytes) - must be a power * of 2 */ - uint16 hashm_bshift; /* bucket shift */ - uint16 hashm_bmsize; /* bitmap array size (bytes) - - * must be a power of 2 */ - uint32 hashm_maxbucket; /* ID of maximum bucket in use */ - uint32 hashm_highmask; /* mask to modulo into entire - * table */ - uint32 hashm_lowmask; /* mask to modulo into lower half - * of table */ - uint32 hashm_ovflpoint; /* pageno. from which ovflpgs - * being allocated */ - uint32 hashm_lastfreed; /* last ovflpage freed */ - uint32 hashm_nmaps;/* Initial number of bitmaps */ - uint32 hashm_spares[NCACHED]; /* spare pages available - * at splitpoints */ - BlockNumber hashm_mapp[NCACHED]; /* blknumbers of ovfl page - * maps */ - RegProcedure hashm_procid; /* hash procedure id from pg_proc */ -} HashMetaPageData; + uint16 hashm_bshift; /* bucket shift */ + uint16 hashm_bmsize; /* bitmap array size (bytes) - must be a + * power of 2 */ + uint32 hashm_maxbucket;/* ID of maximum bucket in use */ + uint32 hashm_highmask; /* mask to modulo into entire table */ + uint32 hashm_lowmask; /* mask to modulo into lower half of table */ + uint32 hashm_ovflpoint;/* pageno. from which ovflpgs being + * allocated */ + uint32 hashm_lastfreed;/* last ovflpage freed */ + uint32 hashm_nmaps; /* Initial number of bitmaps */ + uint32 hashm_spares[NCACHED]; /* spare pages available at + * splitpoints */ + BlockNumber hashm_mapp[NCACHED]; /* blknumbers of ovfl page maps */ + RegProcedure hashm_procid; /* hash procedure id from pg_proc */ +} HashMetaPageData; typedef HashMetaPageData *HashMetaPage; @@ -179,12 +175,12 @@ typedef HashMetaPageData *HashMetaPage; #define NKEYS hashm_nkeys #define SPARES hashm_spares -extern bool BuildingHash; +extern bool BuildingHash; typedef struct HashItemData { - IndexTupleData hash_itup; -} HashItemData; + IndexTupleData hash_itup; +} HashItemData; typedef HashItemData *HashItem; @@ -256,32 +252,32 @@ extern void hashbuild(Relation heap, Relation index, int natts, AttrNumber * attnum, IndexStrategy istrat, uint16 pcount, Datum * params, FuncIndexInfo * finfo, PredInfo * predInfo); -extern InsertIndexResult +extern InsertIndexResult hashinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel); -extern char *hashgettuple(IndexScanDesc scan, ScanDirection dir); -extern char * +extern char *hashgettuple(IndexScanDesc scan, ScanDirection dir); +extern char * hashbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey); -extern void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); -extern void hashendscan(IndexScanDesc scan); -extern void hashmarkpos(IndexScanDesc scan); -extern void hashrestrpos(IndexScanDesc scan); -extern void hashdelete(Relation rel, ItemPointer tid); +extern void hashrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); +extern void hashendscan(IndexScanDesc scan); +extern void hashmarkpos(IndexScanDesc scan); +extern void hashrestrpos(IndexScanDesc scan); +extern void hashdelete(Relation rel, ItemPointer tid); /* hashfunc.c */ -extern uint32 hashint2(int16 key); -extern uint32 hashint4(uint32 key); -extern uint32 hashfloat4(float32 keyp); -extern uint32 hashfloat8(float64 keyp); -extern uint32 hashoid(Oid key); -extern uint32 hashchar(char key); -extern uint32 hashchar2(uint16 intkey); -extern uint32 hashchar4(uint32 intkey); -extern uint32 hashchar8(char *key); -extern uint32 hashchar16(char *key); -extern uint32 hashtext(struct varlena * key); -extern uint32 hashname(NameData * n); +extern uint32 hashint2(int16 key); +extern uint32 hashint4(uint32 key); +extern uint32 hashfloat4(float32 keyp); +extern uint32 hashfloat8(float64 keyp); +extern uint32 hashoid(Oid key); +extern uint32 hashchar(char key); +extern uint32 hashchar2(uint16 intkey); +extern uint32 hashchar4(uint32 intkey); +extern uint32 hashchar8(char *key); +extern uint32 hashchar16(char *key); +extern uint32 hashtext(struct varlena * key); +extern uint32 hashname(NameData * n); /* private routines */ @@ -290,9 +286,9 @@ extern InsertIndexResult _hash_doinsert(Relation rel, HashItem hitem); /* hashovfl.c */ -extern Buffer _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf); -extern Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf); -extern int32 +extern Buffer _hash_addovflpage(Relation rel, Buffer * metabufp, Buffer buf); +extern Buffer _hash_freeovflpage(Relation rel, Buffer ovflbuf); +extern int32 _hash_initbitmap(Relation rel, HashMetaPage metap, int32 pnum, int32 nbits, int32 ndx); extern void @@ -301,23 +297,23 @@ _hash_squeezebucket(Relation rel, HashMetaPage metap, /* hashpage.c */ -extern void _hash_metapinit(Relation rel); -extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access); -extern void _hash_relbuf(Relation rel, Buffer buf, int access); -extern void _hash_wrtbuf(Relation rel, Buffer buf); -extern void _hash_wrtnorelbuf(Relation rel, Buffer buf); -extern Page +extern void _hash_metapinit(Relation rel); +extern Buffer _hash_getbuf(Relation rel, BlockNumber blkno, int access); +extern void _hash_relbuf(Relation rel, Buffer buf, int access); +extern void _hash_wrtbuf(Relation rel, Buffer buf); +extern void _hash_wrtnorelbuf(Relation rel, Buffer buf); +extern Page _hash_chgbufaccess(Relation rel, Buffer * bufp, int from_access, int to_access); -extern void _hash_pageinit(Page page, Size size); -extern void _hash_pagedel(Relation rel, ItemPointer tid); -extern void _hash_expandtable(Relation rel, Buffer metabuf); +extern void _hash_pageinit(Page page, Size size); +extern void _hash_pagedel(Relation rel, ItemPointer tid); +extern void _hash_expandtable(Relation rel, Buffer metabuf); /* hashscan.c */ -extern void _hash_regscan(IndexScanDesc scan); -extern void _hash_dropscan(IndexScanDesc scan); -extern void _hash_adjscans(Relation rel, ItemPointer tid); +extern void _hash_regscan(IndexScanDesc scan); +extern void _hash_dropscan(IndexScanDesc scan); +extern void _hash_adjscans(Relation rel, ItemPointer tid); /* hashsearch.c */ @@ -326,20 +322,20 @@ _hash_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP, HashMetaPage metap); extern RetrieveIndexResult _hash_next(IndexScanDesc scan, ScanDirection dir); extern RetrieveIndexResult _hash_first(IndexScanDesc scan, ScanDirection dir); -extern bool +extern bool _hash_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir, Buffer metabuf); /* hashutil.c */ -extern ScanKey +extern ScanKey _hash_mkscankey(Relation rel, IndexTuple itup, HashMetaPage metap); -extern void _hash_freeskey(ScanKey skey); -extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup); +extern void _hash_freeskey(ScanKey skey); +extern bool _hash_checkqual(IndexScanDesc scan, IndexTuple itup); extern HashItem _hash_formitem(IndexTuple itup); -extern Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key); -extern uint32 _hash_log2(uint32 num); -extern void _hash_checkpage(Page page, int flags); +extern Bucket _hash_call(Relation rel, HashMetaPage metap, Datum key); +extern uint32 _hash_log2(uint32 num); +extern void _hash_checkpage(Page page, int flags); #endif /* HASH_H */ diff --git a/src/include/access/heapam.h b/src/include/access/heapam.h index 15f5685e86a..c82b23e742c 100644 --- a/src/include/access/heapam.h +++ b/src/include/access/heapam.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: heapam.h,v 1.12 1997/09/07 04:55:55 momjian Exp $ + * $Id: heapam.h,v 1.13 1997/09/08 02:34:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,57 +25,54 @@ typedef struct HeapAccessStatisticsData { - time_t init_global_timestamp; /* time global statistics - * started */ - time_t local_reset_timestamp; /* last time local reset - * was done */ - time_t last_request_timestamp; /* last time stats were - * requested */ - - int global_open; - int global_openr; - int global_close; - int global_beginscan; - int global_rescan; - int global_endscan; - int global_getnext; - int global_fetch; - int global_insert; - int global_delete; - int global_replace; - int global_markpos; - int global_restrpos; - int global_BufferGetRelation; - int global_RelationIdGetRelation; - int global_RelationIdGetRelation_Buf; - int global_RelationNameGetRelation; - int global_getreldesc; - int global_heapgettup; - int global_RelationPutHeapTuple; - int global_RelationPutLongHeapTuple; - - int local_open; - int local_openr; - int local_close; - int local_beginscan; - int local_rescan; - int local_endscan; - int local_getnext; - int local_fetch; - int local_insert; - int local_delete; - int local_replace; - int local_markpos; - int local_restrpos; - int local_BufferGetRelation; - int local_RelationIdGetRelation; - int local_RelationIdGetRelation_Buf; - int local_RelationNameGetRelation; - int local_getreldesc; - int local_heapgettup; - int local_RelationPutHeapTuple; - int local_RelationPutLongHeapTuple; -} HeapAccessStatisticsData; + time_t init_global_timestamp; /* time global statistics started */ + time_t local_reset_timestamp; /* last time local reset was done */ + time_t last_request_timestamp; /* last time stats were requested */ + + int global_open; + int global_openr; + int global_close; + int global_beginscan; + int global_rescan; + int global_endscan; + int global_getnext; + int global_fetch; + int global_insert; + int global_delete; + int global_replace; + int global_markpos; + int global_restrpos; + int global_BufferGetRelation; + int global_RelationIdGetRelation; + int global_RelationIdGetRelation_Buf; + int global_RelationNameGetRelation; + int global_getreldesc; + int global_heapgettup; + int global_RelationPutHeapTuple; + int global_RelationPutLongHeapTuple; + + int local_open; + int local_openr; + int local_close; + int local_beginscan; + int local_rescan; + int local_endscan; + int local_getnext; + int local_fetch; + int local_insert; + int local_delete; + int local_replace; + int local_markpos; + int local_restrpos; + int local_BufferGetRelation; + int local_RelationIdGetRelation; + int local_RelationIdGetRelation_Buf; + int local_RelationNameGetRelation; + int local_getreldesc; + int local_heapgettup; + int local_RelationPutHeapTuple; + int local_RelationPutLongHeapTuple; +} HeapAccessStatisticsData; typedef HeapAccessStatisticsData *HeapAccessStatistics; @@ -115,58 +112,58 @@ extern HeapAccessStatistics heap_access_stats; /* in stats.c */ /* heap_create, heap_creatr, and heap_destroy are declared in catalog/heap.h */ /* heapam.c */ -extern void doinsert(Relation relation, HeapTuple tup); +extern void doinsert(Relation relation, HeapTuple tup); extern Relation heap_open(Oid relationId); extern Relation heap_openr(char *relationName); -extern void heap_close(Relation relation); -extern HeapScanDesc +extern void heap_close(Relation relation); +extern HeapScanDesc heap_beginscan(Relation relation, int atend, TimeQual timeQual, unsigned nkeys, ScanKey key); -extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key); -extern void heap_endscan(HeapScanDesc sdesc); +extern void heap_rescan(HeapScanDesc sdesc, bool scanFromEnd, ScanKey key); +extern void heap_endscan(HeapScanDesc sdesc); extern HeapTuple heap_getnext(HeapScanDesc scandesc, int backw, Buffer * b); -extern HeapTuple +extern HeapTuple heap_fetch(Relation relation, TimeQual timeQual, ItemPointer tid, Buffer * b); -extern Oid heap_insert(Relation relation, HeapTuple tup); -extern int heap_delete(Relation relation, ItemPointer tid); +extern Oid heap_insert(Relation relation, HeapTuple tup); +extern int heap_delete(Relation relation, ItemPointer tid); extern int heap_replace(Relation relation, ItemPointer otid, HeapTuple tup); -extern void heap_markpos(HeapScanDesc sdesc); -extern void heap_restrpos(HeapScanDesc sdesc); +extern void heap_markpos(HeapScanDesc sdesc); +extern void heap_restrpos(HeapScanDesc sdesc); /* in common/heaptuple.c */ -extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]); +extern Size ComputeDataSize(TupleDesc tupleDesc, Datum value[], char nulls[]); extern void DataFill(char *data, TupleDesc tupleDesc, Datum value[], char nulls[], char *infomask, bits8 * bit); -extern int heap_attisnull(HeapTuple tup, int attnum); -extern int heap_sysattrlen(AttrNumber attno); -extern bool heap_sysattrbyval(AttrNumber attno); -extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum); -extern char * +extern int heap_attisnull(HeapTuple tup, int attnum); +extern int heap_sysattrlen(AttrNumber attno); +extern bool heap_sysattrbyval(AttrNumber attno); +extern char *heap_getsysattr(HeapTuple tup, Buffer b, int attnum); +extern char * fastgetattr(HeapTuple tup, int attnum, TupleDesc att, bool * isnull); extern HeapTuple heap_copytuple(HeapTuple tuple); -extern HeapTuple +extern HeapTuple heap_formtuple(TupleDesc tupleDescriptor, Datum value[], char nulls[]); -extern HeapTuple +extern HeapTuple heap_modifytuple(HeapTuple tuple, Buffer buffer, Relation relation, Datum replValue[], char replNull[], char repl[]); -HeapTuple heap_addheader(uint32 natts, int structlen, char *structure); +HeapTuple heap_addheader(uint32 natts, int structlen, char *structure); /* in common/heap/stats.c */ -extern void PrintHeapAccessStatistics(HeapAccessStatistics stats); -extern void initam(void); +extern void PrintHeapAccessStatistics(HeapAccessStatistics stats); +extern void initam(void); /* hio.c */ extern void RelationPutHeapTuple(Relation relation, BlockNumber blockIndex, HeapTuple tuple); -extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); +extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); #endif /* HEAPAM_H */ diff --git a/src/include/access/hio.h b/src/include/access/hio.h index 05c9dc330c9..e4bd0404f64 100644 --- a/src/include/access/hio.h +++ b/src/include/access/hio.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hio.h,v 1.4 1997/09/07 04:55:56 momjian Exp $ + * $Id: hio.h,v 1.5 1997/09/08 02:34:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,6 @@ extern void RelationPutHeapTuple(Relation relation, BlockNumber blockIndex, HeapTuple tuple); -extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); +extern void RelationPutHeapTupleAtEnd(Relation relation, HeapTuple tuple); #endif /* HIO_H */ diff --git a/src/include/access/htup.h b/src/include/access/htup.h index 02d708bb0ad..3b6b32b98f9 100644 --- a/src/include/access/htup.h +++ b/src/include/access/htup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: htup.h,v 1.4 1997/09/07 04:55:58 momjian Exp $ + * $Id: htup.h,v 1.5 1997/09/08 02:34:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,36 +29,36 @@ typedef struct HeapTupleData { - unsigned int t_len; /* length of entire tuple */ + unsigned int t_len; /* length of entire tuple */ ItemPointerData t_ctid; /* current TID of this tuple */ ItemPointerData t_chain; /* replaced tuple TID */ - Oid t_oid; /* OID of this tuple -- 4 bytes */ + Oid t_oid; /* OID of this tuple -- 4 bytes */ - CommandId t_cmin; /* insert CID stamp -- 2 bytes each */ - CommandId t_cmax; /* delete CommandId stamp */ + CommandId t_cmin; /* insert CID stamp -- 2 bytes each */ + CommandId t_cmax; /* delete CommandId stamp */ - TransactionId t_xmin; /* insert XID stamp -- 4 bytes each */ - TransactionId t_xmax; /* delete XID stamp */ + TransactionId t_xmin; /* insert XID stamp -- 4 bytes each */ + TransactionId t_xmax; /* delete XID stamp */ - AbsoluteTime t_tmin; /* time stamps -- 4 bytes each */ - AbsoluteTime t_tmax; + AbsoluteTime t_tmin; /* time stamps -- 4 bytes each */ + AbsoluteTime t_tmax; - int16 t_natts; /* number of attributes */ - char t_vtype; /* not used - padding */ + int16 t_natts; /* number of attributes */ + char t_vtype; /* not used - padding */ - char t_infomask; /* whether tuple as null or variable + char t_infomask; /* whether tuple as null or variable * length attributes */ - uint8 t_hoff; /* sizeof tuple header */ + uint8 t_hoff; /* sizeof tuple header */ - bits8 t_bits[MinHeapTupleBitmapSize / 8]; + bits8 t_bits[MinHeapTupleBitmapSize / 8]; /* bit map of domains */ /* MORE DATA FOLLOWS AT END OF STRUCT */ -} HeapTupleData; +} HeapTupleData; typedef HeapTupleData *HeapTuple; diff --git a/src/include/access/ibit.h b/src/include/access/ibit.h index 87e2fec53fd..6b1bc08dce1 100644 --- a/src/include/access/ibit.h +++ b/src/include/access/ibit.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: ibit.h,v 1.5 1997/09/07 04:56:01 momjian Exp $ + * $Id: ibit.h,v 1.6 1997/09/08 02:34:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,9 +17,9 @@ typedef struct IndexAttributeBitMapData { - char bits[(MaxIndexAttributeNumber + MaxBitsPerByte - 1) - / MaxBitsPerByte]; -} IndexAttributeBitMapData; + char bits[(MaxIndexAttributeNumber + MaxBitsPerByte - 1) + / MaxBitsPerByte]; +} IndexAttributeBitMapData; typedef IndexAttributeBitMapData *IndexAttributeBitMap; diff --git a/src/include/access/iqual.h b/src/include/access/iqual.h index 233c2f61f87..20fc9ecee3e 100644 --- a/src/include/access/iqual.h +++ b/src/include/access/iqual.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: iqual.h,v 1.5 1997/09/07 04:56:04 momjian Exp $ + * $Id: iqual.h,v 1.6 1997/09/08 02:34:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,9 +22,9 @@ * ---------------- */ -extern int NIndexTupleProcessed; +extern int NIndexTupleProcessed; -extern bool +extern bool index_keytest(IndexTuple tuple, TupleDesc tupdesc, int scanKeySize, ScanKey key); diff --git a/src/include/access/istrat.h b/src/include/access/istrat.h index 377a8463446..fa1ea6396f6 100644 --- a/src/include/access/istrat.h +++ b/src/include/access/istrat.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: istrat.h,v 1.6 1997/09/07 04:56:05 momjian Exp $ + * $Id: istrat.h,v 1.7 1997/09/08 02:34:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,18 +47,18 @@ */ #define IndexStrategyIsValid(s) PointerIsValid(s) -extern StrategyMap +extern StrategyMap IndexStrategyGetStrategyMap(IndexStrategy indexStrategy, StrategyNumber maxStrategyNum, AttrNumber attrNum); -extern Size +extern Size AttributeNumberGetIndexStrategySize(AttrNumber maxAttributeNumber, StrategyNumber maxStrategyNumber); -extern StrategyNumber +extern StrategyNumber RelationGetStrategy(Relation relation, AttrNumber attributeNumber, StrategyEvaluation evaluation, RegProcedure procedure); -extern bool +extern bool RelationInvokeStrategy(Relation relation, StrategyEvaluation evaluation, AttrNumber attributeNumber, StrategyNumber strategy, Datum left, Datum right); diff --git a/src/include/access/itup.h b/src/include/access/itup.h index 742078a3bd1..09249822518 100644 --- a/src/include/access/itup.h +++ b/src/include/access/itup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itup.h,v 1.6 1997/09/07 04:56:05 momjian Exp $ + * $Id: itup.h,v 1.7 1997/09/08 02:34:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,14 +30,14 @@ typedef struct IndexTupleData * tuple. */ - unsigned short t_info; /* various info about tuple */ + unsigned short t_info; /* various info about tuple */ /* * please make sure sizeof(IndexTupleData) is MAXALIGN'ed. See * IndexInfoFindDataOffset() for the reason. */ -} IndexTupleData; /* MORE DATA FOLLOWS AT END OF STRUCT */ +} IndexTupleData; /* MORE DATA FOLLOWS AT END OF STRUCT */ typedef IndexTupleData *IndexTuple; @@ -45,7 +45,7 @@ typedef IndexTupleData *IndexTuple; typedef struct InsertIndexResultData { ItemPointerData pointerData; -} InsertIndexResultData; +} InsertIndexResultData; typedef InsertIndexResultData *InsertIndexResult; @@ -54,7 +54,7 @@ typedef struct RetrieveIndexResultData { ItemPointerData index_iptr; ItemPointerData heap_iptr; -} RetrieveIndexResultData; +} RetrieveIndexResultData; typedef RetrieveIndexResultData *RetrieveIndexResult; @@ -66,9 +66,9 @@ typedef RetrieveIndexResultData *RetrieveIndexResult; */ typedef struct PredInfo { - Node *pred; - Node *oldPred; -} PredInfo; + Node *pred; + Node *oldPred; +} PredInfo; /* ---------------- @@ -89,16 +89,16 @@ typedef struct PredInfo /* indextuple.h */ -extern IndexTuple +extern IndexTuple index_formtuple(TupleDesc tupleDescriptor, Datum value[], char null[]); -extern Datum +extern Datum index_getattr(IndexTuple tuple, AttrNumber attNum, TupleDesc tupDesc, bool * isNullOutP); -extern RetrieveIndexResult +extern RetrieveIndexResult FormRetrieveIndexResult(ItemPointer indexItemPointer, ItemPointer heapItemPointer); -extern void CopyIndexTuple(IndexTuple source, IndexTuple * target); +extern void CopyIndexTuple(IndexTuple source, IndexTuple * target); #endif /* ITUP_H */ diff --git a/src/include/access/nbtree.h b/src/include/access/nbtree.h index 0062431d6cb..813e557d55c 100644 --- a/src/include/access/nbtree.h +++ b/src/include/access/nbtree.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nbtree.h,v 1.15 1997/09/07 04:56:06 momjian Exp $ + * $Id: nbtree.h,v 1.16 1997/09/08 02:34:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,9 +40,9 @@ typedef struct BTPageOpaqueData { - BlockNumber btpo_prev; - BlockNumber btpo_next; - uint16 btpo_flags; + BlockNumber btpo_prev; + BlockNumber btpo_next; + uint16 btpo_flags; #define BTP_LEAF (1 << 0) #define BTP_ROOT (1 << 1) @@ -50,7 +50,7 @@ typedef struct BTPageOpaqueData #define BTP_META (1 << 3) #define BTP_CHAIN (1 << 4) -} BTPageOpaqueData; +} BTPageOpaqueData; typedef BTPageOpaqueData *BTPageOpaque; @@ -67,14 +67,14 @@ typedef BTPageOpaqueData *BTPageOpaque; typedef struct BTScanOpaqueData { - Buffer btso_curbuf; - Buffer btso_mrkbuf; - uint16 qual_ok; /* 0 for quals like key == 1 && key > 2 */ - uint16 numberOfKeys; /* number of keys */ - uint16 numberOfFirstKeys; /* number of keys for 1st + Buffer btso_curbuf; + Buffer btso_mrkbuf; + uint16 qual_ok; /* 0 for quals like key == 1 && key > 2 */ + uint16 numberOfKeys; /* number of keys */ + uint16 numberOfFirstKeys; /* number of keys for 1st * attribute */ - ScanKey keyData; /* key descriptor */ -} BTScanOpaqueData; + ScanKey keyData; /* key descriptor */ +} BTScanOpaqueData; typedef BTScanOpaqueData *BTScanOpaque; @@ -99,12 +99,12 @@ typedef BTScanOpaqueData *BTScanOpaque; typedef struct BTItemData { #ifndef BTREE_VERSION_1 - Oid bti_oid; - int32 bti_dummy; /* padding to make bti_itup align at + Oid bti_oid; + int32 bti_dummy; /* padding to make bti_itup align at * 8-byte boundary */ #endif - IndexTupleData bti_itup; -} BTItemData; + IndexTupleData bti_itup; +} BTItemData; typedef BTItemData *BTItem; @@ -131,25 +131,25 @@ typedef BTItemData *BTItem; typedef struct BTStackData { - BlockNumber bts_blkno; - OffsetNumber bts_offset; - BTItem bts_btitem; + BlockNumber bts_blkno; + OffsetNumber bts_offset; + BTItem bts_btitem; struct BTStackData *bts_parent; -} BTStackData; +} BTStackData; typedef BTStackData *BTStack; typedef struct BTPageState { - Buffer btps_buf; - Page btps_page; - BTItem btps_lastbti; - OffsetNumber btps_lastoff; - OffsetNumber btps_firstoff; - int btps_level; - bool btps_doupper; + Buffer btps_buf; + Page btps_page; + BTItem btps_lastbti; + OffsetNumber btps_lastoff; + OffsetNumber btps_firstoff; + int btps_level; + bool btps_doupper; struct BTPageState *btps_next; -} BTPageState; +} BTPageState; /* * We need to be able to tell the difference between read and write @@ -213,105 +213,105 @@ typedef struct BTPageState /* * prototypes for functions in nbtinsert.c */ -extern InsertIndexResult +extern InsertIndexResult _bt_doinsert(Relation rel, BTItem btitem, bool index_is_unique, Relation heapRel); /* default is to allow duplicates */ -extern bool +extern bool _bt_itemcmp(Relation rel, Size keysz, BTItem item1, BTItem item2, StrategyNumber strat); /* * prototypes for functions in nbtpage.c */ -extern void _bt_metapinit(Relation rel); -extern Buffer _bt_getroot(Relation rel, int access); -extern Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access); -extern void _bt_relbuf(Relation rel, Buffer buf, int access); -extern void _bt_wrtbuf(Relation rel, Buffer buf); -extern void _bt_wrtnorelbuf(Relation rel, Buffer buf); -extern void _bt_pageinit(Page page, Size size); -extern void _bt_metaproot(Relation rel, BlockNumber rootbknum, int level); -extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access); -extern void _bt_pagedel(Relation rel, ItemPointer tid); +extern void _bt_metapinit(Relation rel); +extern Buffer _bt_getroot(Relation rel, int access); +extern Buffer _bt_getbuf(Relation rel, BlockNumber blkno, int access); +extern void _bt_relbuf(Relation rel, Buffer buf, int access); +extern void _bt_wrtbuf(Relation rel, Buffer buf); +extern void _bt_wrtnorelbuf(Relation rel, Buffer buf); +extern void _bt_pageinit(Page page, Size size); +extern void _bt_metaproot(Relation rel, BlockNumber rootbknum, int level); +extern Buffer _bt_getstackbuf(Relation rel, BTStack stack, int access); +extern void _bt_pagedel(Relation rel, ItemPointer tid); /* * prototypes for functions in nbtree.c */ -extern bool BuildingBtree; /* in nbtree.c */ +extern bool BuildingBtree; /* in nbtree.c */ extern void btbuild(Relation heap, Relation index, int natts, AttrNumber * attnum, IndexStrategy istrat, uint16 pcount, Datum * params, FuncIndexInfo * finfo, PredInfo * predInfo); -extern InsertIndexResult +extern InsertIndexResult btinsert(Relation rel, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel); -extern char *btgettuple(IndexScanDesc scan, ScanDirection dir); -extern char * +extern char *btgettuple(IndexScanDesc scan, ScanDirection dir); +extern char * btbeginscan(Relation rel, bool fromEnd, uint16 keysz, ScanKey scankey); -extern void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); -extern void btmovescan(IndexScanDesc scan, Datum v); -extern void btendscan(IndexScanDesc scan); -extern void btmarkpos(IndexScanDesc scan); -extern void btrestrpos(IndexScanDesc scan); -extern void btdelete(Relation rel, ItemPointer tid); +extern void btrescan(IndexScanDesc scan, bool fromEnd, ScanKey scankey); +extern void btmovescan(IndexScanDesc scan, Datum v); +extern void btendscan(IndexScanDesc scan); +extern void btmarkpos(IndexScanDesc scan); +extern void btrestrpos(IndexScanDesc scan); +extern void btdelete(Relation rel, ItemPointer tid); /* * prototypes for functions in nbtscan.c */ -extern void _bt_regscan(IndexScanDesc scan); -extern void _bt_dropscan(IndexScanDesc scan); -extern void _bt_adjscans(Relation rel, ItemPointer tid, int op); +extern void _bt_regscan(IndexScanDesc scan); +extern void _bt_dropscan(IndexScanDesc scan); +extern void _bt_adjscans(Relation rel, ItemPointer tid, int op); /* * prototypes for functions in nbtsearch.c */ -extern BTStack +extern BTStack _bt_search(Relation rel, int keysz, ScanKey scankey, Buffer * bufP); -extern Buffer +extern Buffer _bt_moveright(Relation rel, Buffer buf, int keysz, ScanKey scankey, int access); -extern bool +extern bool _bt_skeycmp(Relation rel, Size keysz, ScanKey scankey, Page page, ItemId itemid, StrategyNumber strat); -extern OffsetNumber +extern OffsetNumber _bt_binsrch(Relation rel, Buffer buf, int keysz, ScanKey scankey, int srchtype); extern RetrieveIndexResult _bt_next(IndexScanDesc scan, ScanDirection dir); extern RetrieveIndexResult _bt_first(IndexScanDesc scan, ScanDirection dir); -extern bool _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); +extern bool _bt_step(IndexScanDesc scan, Buffer * bufP, ScanDirection dir); /* * prototypes for functions in nbtstrat.c */ -extern StrategyNumber +extern StrategyNumber _bt_getstrat(Relation rel, AttrNumber attno, RegProcedure proc); -extern bool +extern bool _bt_invokestrat(Relation rel, AttrNumber attno, StrategyNumber strat, Datum left, Datum right); /* * prototypes for functions in nbtutils.c */ -extern ScanKey _bt_mkscankey(Relation rel, IndexTuple itup); -extern void _bt_freeskey(ScanKey skey); -extern void _bt_freestack(BTStack stack); -extern void _bt_orderkeys(Relation relation, BTScanOpaque so); -extern bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok); -extern BTItem _bt_formitem(IndexTuple itup); +extern ScanKey _bt_mkscankey(Relation rel, IndexTuple itup); +extern void _bt_freeskey(ScanKey skey); +extern void _bt_freestack(BTStack stack); +extern void _bt_orderkeys(Relation relation, BTScanOpaque so); +extern bool _bt_checkkeys(IndexScanDesc scan, IndexTuple tuple, Size * keysok); +extern BTItem _bt_formitem(IndexTuple itup); /* * prototypes for functions in nbtsort.c */ -extern void *_bt_spoolinit(Relation index, int ntapes, bool isunique); -extern void _bt_spooldestroy(void *spool); -extern void _bt_spool(Relation index, BTItem btitem, void *spool); -extern void _bt_leafbuild(Relation index, void *spool); +extern void *_bt_spoolinit(Relation index, int ntapes, bool isunique); +extern void _bt_spooldestroy(void *spool); +extern void _bt_spool(Relation index, BTItem btitem, void *spool); +extern void _bt_leafbuild(Relation index, void *spool); #endif /* NBTREE_H */ diff --git a/src/include/access/printtup.h b/src/include/access/printtup.h index 65994dbe7ef..a86a4596d66 100644 --- a/src/include/access/printtup.h +++ b/src/include/access/printtup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: printtup.h,v 1.3 1997/09/07 04:56:07 momjian Exp $ + * $Id: printtup.h,v 1.4 1997/09/08 02:34:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,11 +16,11 @@ #include <access/htup.h> #include <access/tupdesc.h> -extern Oid typtoout(Oid type); -extern void printtup(HeapTuple tuple, TupleDesc typeinfo); -extern void showatts(char *name, TupleDesc attinfo); -extern void debugtup(HeapTuple tuple, TupleDesc typeinfo); -extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo); -extern Oid gettypelem(Oid type); +extern Oid typtoout(Oid type); +extern void printtup(HeapTuple tuple, TupleDesc typeinfo); +extern void showatts(char *name, TupleDesc attinfo); +extern void debugtup(HeapTuple tuple, TupleDesc typeinfo); +extern void printtup_internal(HeapTuple tuple, TupleDesc typeinfo); +extern Oid gettypelem(Oid type); #endif /* PRINTTUP_H */ diff --git a/src/include/access/relscan.h b/src/include/access/relscan.h index 356bcefc529..c4270c433ed 100644 --- a/src/include/access/relscan.h +++ b/src/include/access/relscan.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: relscan.h,v 1.6 1997/09/07 04:56:08 momjian Exp $ + * $Id: relscan.h,v 1.7 1997/09/08 02:34:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,41 +21,41 @@ typedef ItemPointerData MarkData; typedef struct HeapScanDescData { - Relation rs_rd; /* pointer to relation descriptor */ - HeapTuple rs_ptup; /* previous tuple in scan */ - HeapTuple rs_ctup; /* current tuple in scan */ - HeapTuple rs_ntup; /* next tuple in scan */ - Buffer rs_pbuf; /* previous buffer in scan */ - Buffer rs_cbuf; /* current buffer in scan */ - Buffer rs_nbuf; /* next buffer in scan */ + Relation rs_rd; /* pointer to relation descriptor */ + HeapTuple rs_ptup; /* previous tuple in scan */ + HeapTuple rs_ctup; /* current tuple in scan */ + HeapTuple rs_ntup; /* next tuple in scan */ + Buffer rs_pbuf; /* previous buffer in scan */ + Buffer rs_cbuf; /* current buffer in scan */ + Buffer rs_nbuf; /* next buffer in scan */ ItemPointerData rs_mptid; /* marked previous tid */ ItemPointerData rs_mctid; /* marked current tid */ ItemPointerData rs_mntid; /* marked next tid */ ItemPointerData rs_mcd; /* marked current delta XXX ??? */ - bool rs_atend; /* restart scan at end? */ - TimeQual rs_tr; /* time qualification */ - uint16 rs_cdelta; /* current delta in chain */ - uint16 rs_nkeys; /* number of attributes in keys */ - ScanKey rs_key; /* key descriptors */ -} HeapScanDescData; + bool rs_atend; /* restart scan at end? */ + TimeQual rs_tr; /* time qualification */ + uint16 rs_cdelta; /* current delta in chain */ + uint16 rs_nkeys; /* number of attributes in keys */ + ScanKey rs_key; /* key descriptors */ +} HeapScanDescData; typedef HeapScanDescData *HeapScanDesc; typedef struct IndexScanDescData { - Relation relation; /* relation descriptor */ - void *opaque; /* am-specific slot */ + Relation relation; /* relation descriptor */ + void *opaque; /* am-specific slot */ ItemPointerData previousItemData; /* previous index pointer */ ItemPointerData currentItemData; /* current index pointer */ ItemPointerData nextItemData; /* next index pointer */ - MarkData previousMarkData; /* marked previous pointer */ - MarkData currentMarkData; /* marked current pointer */ - MarkData nextMarkData; /* marked next pointer */ - uint8 flags; /* scan position flags */ - bool scanFromEnd;/* restart scan at end? */ - uint16 numberOfKeys; /* number of key attributes */ - ScanKey keyData; /* key descriptor */ -} IndexScanDescData; + MarkData previousMarkData; /* marked previous pointer */ + MarkData currentMarkData;/* marked current pointer */ + MarkData nextMarkData; /* marked next pointer */ + uint8 flags; /* scan position flags */ + bool scanFromEnd; /* restart scan at end? */ + uint16 numberOfKeys; /* number of key attributes */ + ScanKey keyData; /* key descriptor */ +} IndexScanDescData; typedef IndexScanDescData *IndexScanDesc; diff --git a/src/include/access/rtree.h b/src/include/access/rtree.h index 98699eba37f..e8c05bdd299 100644 --- a/src/include/access/rtree.h +++ b/src/include/access/rtree.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rtree.h,v 1.7 1997/09/07 04:56:09 momjian Exp $ + * $Id: rtree.h,v 1.8 1997/09/08 02:34:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,8 +42,8 @@ typedef struct RTreePageOpaqueData { - uint32 flags; -} RTreePageOpaqueData; + uint32 flags; +} RTreePageOpaqueData; typedef RTreePageOpaqueData *RTreePageOpaque; @@ -54,9 +54,9 @@ typedef RTreePageOpaqueData *RTreePageOpaque; typedef struct RTSTACK { struct RTSTACK *rts_parent; - OffsetNumber rts_child; - BlockNumber rts_blk; -} RTSTACK; + OffsetNumber rts_child; + BlockNumber rts_blk; +} RTSTACK; /* * When we're doing a scan, we need to keep track of the parent stack @@ -72,10 +72,10 @@ typedef struct RTreeScanOpaqueData { struct RTSTACK *s_stack; struct RTSTACK *s_markstk; - uint16 s_flags; - uint16 s_internalNKey; - ScanKey s_internalKey; -} RTreeScanOpaqueData; + uint16 s_flags; + uint16 s_internalNKey; + ScanKey s_internalKey; +} RTreeScanOpaqueData; typedef RTreeScanOpaqueData *RTreeScanOpaque; @@ -105,7 +105,7 @@ typedef RTreeScanOpaqueData *RTreeScanOpaque; #define RTOP_SPLIT 1 /* defined in rtree.c */ -extern void freestack(RTSTACK * s); +extern void freestack(RTSTACK * s); /* rget.c */ extern RetrieveIndexResult rtgettuple(IndexScanDesc s, ScanDirection dir); @@ -114,25 +114,25 @@ extern RetrieveIndexResult rtgettuple(IndexScanDesc s, ScanDirection dir); * RTree code. * Defined in access/index-rtree/ */ -extern InsertIndexResult +extern InsertIndexResult rtinsert(Relation r, Datum * datum, char *nulls, ItemPointer ht_ctid, Relation heapRel); -extern char *rtdelete(Relation r, ItemPointer tid); +extern char *rtdelete(Relation r, ItemPointer tid); extern RetrieveIndexResult rtgettuple(IndexScanDesc s, ScanDirection dir); -extern IndexScanDesc +extern IndexScanDesc rtbeginscan(Relation r, bool fromEnd, uint16 nkeys, ScanKey key); -extern void rtendscan(IndexScanDesc s); -extern void rtmarkpos(IndexScanDesc s); -extern void rtrestrpos(IndexScanDesc s); -extern void rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key); +extern void rtendscan(IndexScanDesc s); +extern void rtmarkpos(IndexScanDesc s); +extern void rtrestrpos(IndexScanDesc s); +extern void rtrescan(IndexScanDesc s, bool fromEnd, ScanKey key); extern void rtbuild(Relation heap, Relation index, int natts, AttrNumber * attnum, IndexStrategy istrat, uint16 pcount, Datum * params, FuncIndexInfo * finfo, PredInfo * predInfo); -extern void _rtdump(Relation r); +extern void _rtdump(Relation r); /* rtscan.c */ extern void @@ -140,7 +140,7 @@ rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); /* rtstrat.h */ -extern RegProcedure +extern RegProcedure RTMapOperator(Relation r, AttrNumber attnum, RegProcedure proc); diff --git a/src/include/access/rtscan.h b/src/include/access/rtscan.h index b91fc2fa066..edcd56f75c1 100644 --- a/src/include/access/rtscan.h +++ b/src/include/access/rtscan.h @@ -6,12 +6,12 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rtscan.h,v 1.2 1997/09/07 04:56:10 momjian Exp $ + * $Id: rtscan.h,v 1.3 1997/09/08 02:34:24 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef RTSCAN_H -void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); +void rtadjscans(Relation r, int op, BlockNumber blkno, OffsetNumber offnum); #endif /* RTSCAN_H */ diff --git a/src/include/access/rtstrat.h b/src/include/access/rtstrat.h index 3f33f04e914..e03cc42acba 100644 --- a/src/include/access/rtstrat.h +++ b/src/include/access/rtstrat.h @@ -6,13 +6,13 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rtstrat.h,v 1.2 1997/09/07 04:56:11 momjian Exp $ + * $Id: rtstrat.h,v 1.3 1997/09/08 02:34:25 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef RTSTRAT_H -extern RegProcedure +extern RegProcedure RTMapOperator(Relation r, AttrNumber attnum, RegProcedure proc); diff --git a/src/include/access/skey.h b/src/include/access/skey.h index 44c43c88758..3de53f89964 100644 --- a/src/include/access/skey.h +++ b/src/include/access/skey.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: skey.h,v 1.4 1997/09/07 04:56:13 momjian Exp $ + * $Id: skey.h,v 1.5 1997/09/08 02:34:26 momjian Exp $ * * * Note: @@ -20,13 +20,13 @@ typedef struct ScanKeyData { - bits16 sk_flags; /* flags */ - AttrNumber sk_attno; /* domain number */ - RegProcedure sk_procedure; /* procedure OID */ - func_ptr sk_func; - int32 sk_nargs; - Datum sk_argument;/* data to compare */ -} ScanKeyData; + bits16 sk_flags; /* flags */ + AttrNumber sk_attno; /* domain number */ + RegProcedure sk_procedure; /* procedure OID */ + func_ptr sk_func; + int32 sk_nargs; + Datum sk_argument; /* data to compare */ +} ScanKeyData; typedef ScanKeyData *ScanKey; @@ -44,7 +44,7 @@ typedef ScanKeyData *ScanKey; /* * prototypes for functions in access/common/scankey.c */ -extern void ScanKeyEntrySetIllegal(ScanKey entry); +extern void ScanKeyEntrySetIllegal(ScanKey entry); extern void ScanKeyEntryInitialize(ScanKey entry, bits16 flags, AttrNumber attributeNumber, RegProcedure procedure, Datum argument); diff --git a/src/include/access/strat.h b/src/include/access/strat.h index 035582ef766..222a45f8f7b 100644 --- a/src/include/access/strat.h +++ b/src/include/access/strat.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: strat.h,v 1.5 1997/09/07 04:56:14 momjian Exp $ + * $Id: strat.h,v 1.6 1997/09/08 02:34:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,50 +16,51 @@ #include <access/skey.h> -typedef uint16 StrategyNumber; +typedef uint16 StrategyNumber; #define InvalidStrategy 0 typedef struct StrategyTransformMapData { - StrategyNumber strategy[1];/* VARIABLE LENGTH ARRAY */ -} StrategyTransformMapData; /* VARIABLE LENGTH + StrategyNumber strategy[1]; /* VARIABLE LENGTH ARRAY */ +} StrategyTransformMapData; /* VARIABLE LENGTH - * STRUCTURE */ + * + * STRUCTURE */ typedef StrategyTransformMapData *StrategyTransformMap; typedef struct StrategyOperatorData { - StrategyNumber strategy; - bits16 flags; /* scan qualification flags h/skey.h */ -} StrategyOperatorData; + StrategyNumber strategy; + bits16 flags; /* scan qualification flags h/skey.h */ +} StrategyOperatorData; typedef StrategyOperatorData *StrategyOperator; typedef struct StrategyTermData { /* conjunctive term */ - uint16 degree; + uint16 degree; StrategyOperatorData operatorData[1]; /* VARIABLE LENGTH */ -} StrategyTermData; /* VARIABLE LENGTH STRUCTURE */ +} StrategyTermData; /* VARIABLE LENGTH STRUCTURE */ typedef StrategyTermData *StrategyTerm; typedef struct StrategyExpressionData { /* disjunctive normal form */ - StrategyTerm term[1]; /* VARIABLE LENGTH ARRAY */ -} StrategyExpressionData; /* VARIABLE LENGTH STRUCTURE */ + StrategyTerm term[1]; /* VARIABLE LENGTH ARRAY */ +} StrategyExpressionData; /* VARIABLE LENGTH STRUCTURE */ typedef StrategyExpressionData *StrategyExpression; typedef struct StrategyEvaluationData { - StrategyNumber maxStrategy; + StrategyNumber maxStrategy; StrategyTransformMap negateTransform; StrategyTransformMap commuteTransform; StrategyTransformMap negateCommuteTransform; StrategyExpression expression[12]; /* XXX VARIABLE LENGTH */ -} StrategyEvaluationData; /* VARIABLE LENGTH STRUCTURE */ +} StrategyEvaluationData; /* VARIABLE LENGTH STRUCTURE */ typedef StrategyEvaluationData *StrategyEvaluation; @@ -78,15 +79,15 @@ typedef StrategyEvaluationData *StrategyEvaluation; typedef struct StrategyMapData { - ScanKeyData entry[1]; /* VARIABLE LENGTH ARRAY */ -} StrategyMapData;/* VARIABLE LENGTH STRUCTURE */ + ScanKeyData entry[1]; /* VARIABLE LENGTH ARRAY */ +} StrategyMapData; /* VARIABLE LENGTH STRUCTURE */ typedef StrategyMapData *StrategyMap; typedef struct IndexStrategyData { StrategyMapData strategyMapData[1]; /* VARIABLE LENGTH ARRAY */ -} IndexStrategyData; /* VARIABLE LENGTH STRUCTURE */ +} IndexStrategyData; /* VARIABLE LENGTH STRUCTURE */ typedef IndexStrategyData *IndexStrategy; diff --git a/src/include/access/transam.h b/src/include/access/transam.h index 98a07aad102..7a898c4eb5d 100644 --- a/src/include/access/transam.h +++ b/src/include/access/transam.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: transam.h,v 1.8 1997/09/07 04:56:14 momjian Exp $ + * $Id: transam.h,v 1.9 1997/09/08 02:34:27 momjian Exp $ * * NOTES * Transaction System Version 101 now support proper oid @@ -85,8 +85,8 @@ typedef unsigned char XidStatus;/* (2 bits) */ */ typedef struct LogRelationContentsData { - int TransSystemVersion; -} LogRelationContentsData; + int TransSystemVersion; +} LogRelationContentsData; typedef LogRelationContentsData *LogRelationContents; @@ -104,8 +104,8 @@ typedef LogRelationContentsData *LogRelationContents; */ typedef struct TimeRelationContentsData { - int TransSystemVersion; -} TimeRelationContentsData; + int TransSystemVersion; +} TimeRelationContentsData; typedef TimeRelationContentsData *TimeRelationContents; @@ -127,11 +127,11 @@ typedef TimeRelationContentsData *TimeRelationContents; */ typedef struct VariableRelationContentsData { - int TransSystemVersion; - TransactionId nextXidData; - TransactionId lastXidData; - Oid nextOid; -} VariableRelationContentsData; + int TransSystemVersion; + TransactionId nextXidData; + TransactionId lastXidData; + Oid nextOid; +} VariableRelationContentsData; typedef VariableRelationContentsData *VariableRelationContents; @@ -144,25 +144,25 @@ typedef VariableRelationContentsData *VariableRelationContents; * prototypes for functions in transam/transam.c */ extern AbsoluteTime TransactionIdGetCommitTime(TransactionId transactionId); -extern void InitializeTransactionLog(void); -extern bool TransactionIdDidCommit(TransactionId transactionId); -extern bool TransactionIdDidAbort(TransactionId transactionId); -extern void TransactionIdCommit(TransactionId transactionId); -extern void TransactionIdAbort(TransactionId transactionId); +extern void InitializeTransactionLog(void); +extern bool TransactionIdDidCommit(TransactionId transactionId); +extern bool TransactionIdDidAbort(TransactionId transactionId); +extern void TransactionIdCommit(TransactionId transactionId); +extern void TransactionIdAbort(TransactionId transactionId); /* in transam/transsup.c */ -extern void AmiTransactionOverride(bool flag); +extern void AmiTransactionOverride(bool flag); extern void TransComputeBlockNumber(Relation relation, TransactionId transactionId, BlockNumber * blockNumberOutP); -extern XidStatus +extern XidStatus TransBlockNumberGetXidStatus(Relation relation, BlockNumber blockNumber, TransactionId xid, bool * failP); extern void TransBlockNumberSetXidStatus(Relation relation, BlockNumber blockNumber, TransactionId xid, XidStatus xstatus, bool * failP); -extern AbsoluteTime +extern AbsoluteTime TransBlockNumberGetCommitTime(Relation relation, BlockNumber blockNumber, TransactionId xid, bool * failP); extern void @@ -171,11 +171,11 @@ TransBlockNumberSetCommitTime(Relation relation, bool * failP); /* in transam/varsup.c */ -extern void VariableRelationPutNextXid(TransactionId xid); -extern void GetNewTransactionId(TransactionId * xid); -extern void UpdateLastCommittedXid(TransactionId xid); -extern void GetNewObjectId(Oid * oid_return); -extern void CheckMaxObjectId(Oid assigned_oid); +extern void VariableRelationPutNextXid(TransactionId xid); +extern void GetNewTransactionId(TransactionId * xid); +extern void UpdateLastCommittedXid(TransactionId xid); +extern void GetNewObjectId(Oid * oid_return); +extern void CheckMaxObjectId(Oid assigned_oid); /* ---------------- * global variable extern declarations @@ -196,12 +196,12 @@ extern TransactionId NullTransactionId; extern TransactionId AmiTransactionId; extern TransactionId FirstTransactionId; -extern int RecoveryCheckingEnableState; +extern int RecoveryCheckingEnableState; /* in transsup.c */ -extern bool AMI_OVERRIDE; +extern bool AMI_OVERRIDE; /* in varsup.c */ -extern int OidGenLockId; +extern int OidGenLockId; #endif /* TRAMSAM_H */ diff --git a/src/include/access/tupdesc.h b/src/include/access/tupdesc.h index 4196e6b955c..870098b2c0d 100644 --- a/src/include/access/tupdesc.h +++ b/src/include/access/tupdesc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tupdesc.h,v 1.9 1997/09/07 04:56:16 momjian Exp $ + * $Id: tupdesc.h,v 1.10 1997/09/08 02:34:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,27 +20,27 @@ typedef struct attrDefault { - AttrNumber adnum; - char *adbin; - char *adsrc; -} AttrDefault; + AttrNumber adnum; + char *adbin; + char *adsrc; +} AttrDefault; typedef struct constrCheck { - char *ccname; - char *ccbin; - char *ccsrc; -} ConstrCheck; + char *ccname; + char *ccbin; + char *ccsrc; +} ConstrCheck; /* This structure contains constraints of a tuple */ typedef struct tupleConstr { - AttrDefault *defval; - ConstrCheck *check; - uint16 num_defval; - uint16 num_check; - bool has_not_null; -} TupleConstr; + AttrDefault *defval; + ConstrCheck *check; + uint16 num_defval; + uint16 num_check; + bool has_not_null; +} TupleConstr; /* * This structure contains all information (i.e. from Classes @@ -48,12 +48,12 @@ typedef struct tupleConstr */ typedef struct tupleDesc { - int natts; + int natts; /* Number of attributes in the tuple */ AttributeTupleForm *attrs; /* attrs[N] is a pointer to the description of Attribute Number N+1. */ - TupleConstr *constr; -} *TupleDesc; + TupleConstr *constr; +} *TupleDesc; extern TupleDesc CreateTemplateTupleDesc(int natts); @@ -63,9 +63,9 @@ extern TupleDesc CreateTupleDescCopy(TupleDesc tupdesc); extern TupleDesc CreateTupleDescCopyConstr(TupleDesc tupdesc); -extern void FreeTupleDesc(TupleDesc tupdesc); +extern void FreeTupleDesc(TupleDesc tupdesc); -extern bool +extern bool TupleDescInitEntry(TupleDesc desc, AttrNumber attributeNumber, char *attributeName, diff --git a/src/include/access/valid.h b/src/include/access/valid.h index 7eb639230ab..58d1eb56429 100644 --- a/src/include/access/valid.h +++ b/src/include/access/valid.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: valid.h,v 1.5 1997/09/07 04:56:18 momjian Exp $ + * $Id: valid.h,v 1.6 1997/09/08 02:34:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,16 +22,16 @@ * ---------------- */ -extern bool +extern bool heap_keytest(HeapTuple t, TupleDesc tupdesc, int nkeys, ScanKey keys); -extern HeapTuple +extern HeapTuple heap_tuple_satisfies(ItemId itemId, Relation relation, Buffer buffer, PageHeader disk_page, TimeQual qual, int nKeys, ScanKey key); -extern bool TupleUpdatedByCurXactAndCmd(HeapTuple t); +extern bool TupleUpdatedByCurXactAndCmd(HeapTuple t); #endif /* VALID_H */ diff --git a/src/include/access/xact.h b/src/include/access/xact.h index e8ed4123f06..69aea57ff11 100644 --- a/src/include/access/xact.h +++ b/src/include/access/xact.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: xact.h,v 1.7 1997/09/07 04:56:19 momjian Exp $ + * $Id: xact.h,v 1.8 1997/09/08 02:34:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,13 +21,13 @@ */ typedef struct TransactionStateData { - TransactionId transactionIdData; - CommandId commandId; - CommandId scanCommandId; - AbsoluteTime startTime; - int state; - int blockState; -} TransactionStateData; + TransactionId transactionIdData; + CommandId commandId; + CommandId scanCommandId; + AbsoluteTime startTime; + int state; + int blockState; +} TransactionStateData; /* ---------------- * transaction states @@ -57,44 +57,44 @@ typedef TransactionStateData *TransactionState; * extern definitions * ---------------- */ -extern int TransactionFlushEnabled(void); -extern void SetTransactionFlushEnabled(bool state); +extern int TransactionFlushEnabled(void); +extern void SetTransactionFlushEnabled(bool state); -extern bool IsTransactionState(void); -extern bool IsAbortedTransactionBlockState(void); -extern void OverrideTransactionSystem(bool flag); +extern bool IsTransactionState(void); +extern bool IsAbortedTransactionBlockState(void); +extern void OverrideTransactionSystem(bool flag); extern TransactionId GetCurrentTransactionId(void); extern CommandId GetCurrentCommandId(void); extern CommandId GetScanCommandId(void); -extern void SetScanCommandId(CommandId); +extern void SetScanCommandId(CommandId); extern AbsoluteTime GetCurrentTransactionStartTime(void); -extern bool TransactionIdIsCurrentTransactionId(TransactionId xid); -extern bool CommandIdIsCurrentCommandId(CommandId cid); -extern bool CommandIdGEScanCommandId(CommandId cid); -extern void CommandCounterIncrement(void); -extern void InitializeTransactionSystem(void); -extern bool CurrentXactInProgress(void); -extern void StartTransactionCommand(void); -extern void CommitTransactionCommand(void); -extern void AbortCurrentTransaction(void); -extern void BeginTransactionBlock(void); -extern void EndTransactionBlock(void); -extern bool IsTransactionBlock(void); -extern void UserAbortTransactionBlock(void); +extern bool TransactionIdIsCurrentTransactionId(TransactionId xid); +extern bool CommandIdIsCurrentCommandId(CommandId cid); +extern bool CommandIdGEScanCommandId(CommandId cid); +extern void CommandCounterIncrement(void); +extern void InitializeTransactionSystem(void); +extern bool CurrentXactInProgress(void); +extern void StartTransactionCommand(void); +extern void CommitTransactionCommand(void); +extern void AbortCurrentTransaction(void); +extern void BeginTransactionBlock(void); +extern void EndTransactionBlock(void); +extern bool IsTransactionBlock(void); +extern void UserAbortTransactionBlock(void); extern TransactionId DisabledTransactionId; /* defined in xid.c */ extern TransactionId xidin(char *representation); -extern char *xidout(TransactionId transactionId); -extern bool xideq(TransactionId xid1, TransactionId xid2); -extern bool TransactionIdIsValid(TransactionId transactionId); -extern void StoreInvalidTransactionId(TransactionId * destination); +extern char *xidout(TransactionId transactionId); +extern bool xideq(TransactionId xid1, TransactionId xid2); +extern bool TransactionIdIsValid(TransactionId transactionId); +extern void StoreInvalidTransactionId(TransactionId * destination); extern void TransactionIdStore(TransactionId transactionId, TransactionId * destination); -extern bool TransactionIdEquals(TransactionId id1, TransactionId id2); -extern bool TransactionIdIsLessThan(TransactionId id1, TransactionId id2); -extern void TransactionIdAdd(TransactionId * xid, int value); +extern bool TransactionIdEquals(TransactionId id1, TransactionId id2); +extern bool TransactionIdIsLessThan(TransactionId id1, TransactionId id2); +extern void TransactionIdAdd(TransactionId * xid, int value); #endif /* XACT_H */ diff --git a/src/include/bootstrap/bootstrap.h b/src/include/bootstrap/bootstrap.h index 3adecdcdbd3..ccf54e892ae 100644 --- a/src/include/bootstrap/bootstrap.h +++ b/src/include/bootstrap/bootstrap.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bootstrap.h,v 1.6 1997/09/07 04:56:23 momjian Exp $ + * $Id: bootstrap.h,v 1.7 1997/09/08 02:34:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,18 +21,18 @@ typedef struct hashnode { - int strnum; /* Index into string table */ + int strnum; /* Index into string table */ struct hashnode *next; -} hashnode; +} hashnode; #define EMITPROMPT printf("> ") extern Relation reldesc; extern AttributeTupleForm attrtypes[MAXATTR]; -extern int numattr; -extern int DebugMode; +extern int numattr; +extern int DebugMode; -extern int BootstrapMain(int ac, char *av[]); +extern int BootstrapMain(int ac, char *av[]); extern void index_register(char *heap, char *ind, @@ -43,18 +43,18 @@ index_register(char *heap, FuncIndexInfo * finfo, PredInfo * predInfo); -extern void err_out(void); -extern void InsertOneTuple(Oid objectid); -extern void closerel(char *name); -extern void boot_openrel(char *name); -extern char *LexIDStr(int ident_num); - -extern void DefineAttr(char *name, char *type, int attnum); -extern void InsertOneValue(Oid objectid, char *value, int i); -extern void InsertOneNull(int i); -extern char *MapArrayTypeName(char *s); -extern char *CleanUpStr(char *s); -extern int EnterString(char *str); -extern void build_indices(void); +extern void err_out(void); +extern void InsertOneTuple(Oid objectid); +extern void closerel(char *name); +extern void boot_openrel(char *name); +extern char *LexIDStr(int ident_num); + +extern void DefineAttr(char *name, char *type, int attnum); +extern void InsertOneValue(Oid objectid, char *value, int i); +extern void InsertOneNull(int i); +extern char *MapArrayTypeName(char *s); +extern char *CleanUpStr(char *s); +extern int EnterString(char *str); +extern void build_indices(void); #endif /* BOOTSTRAP_H */ diff --git a/src/include/c.h b/src/include/c.h index cf9367c0fd1..bb5ec57db3c 100644 --- a/src/include/c.h +++ b/src/include/c.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: c.h,v 1.17 1997/09/07 04:55:35 momjian Exp $ + * $Id: c.h,v 1.18 1997/09/08 02:33:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,10 +61,10 @@ #define false ((char) 0) #define true ((char) 1) #ifndef __cplusplus -typedef char bool; +typedef char bool; #endif /* not C++ */ -typedef bool *BoolPtr; +typedef bool *BoolPtr; #ifndef TRUE #define TRUE 1 @@ -94,7 +94,7 @@ typedef bool *BoolPtr; * XXX Pointer arithmetic is done with this, so it can't be void * * under "true" ANSI compilers. */ -typedef char *Pointer; +typedef char *Pointer; #ifndef NULL /* @@ -116,7 +116,7 @@ typedef char *Pointer; * Pointer -- * Variable containing address of any memory resident object. */ -typedef char *Pointer; +typedef char *Pointer; #ifndef NULL /* @@ -228,35 +228,35 @@ typedef unsigned int uint32; /* >= 32 bits */ * Since sizeof(floatN) may be > sizeof(char *), always pass * floatN by reference. */ -typedef float float32data; -typedef double float64data; -typedef float *float32; +typedef float float32data; +typedef double float64data; +typedef float *float32; typedef double *float64; /* * boolN -- * Boolean value, AT LEAST N BITS IN SIZE. */ -typedef uint8 bool8; /* >= 8 bits */ -typedef uint16 bool16; /* >= 16 bits */ -typedef uint32 bool32; /* >= 32 bits */ +typedef uint8 bool8; /* >= 8 bits */ +typedef uint16 bool16; /* >= 16 bits */ +typedef uint32 bool32; /* >= 32 bits */ /* * bitsN -- * Unit of bitwise operation, AT LEAST N BITS IN SIZE. */ -typedef uint8 bits8; /* >= 8 bits */ -typedef uint16 bits16; /* >= 16 bits */ -typedef uint32 bits32; /* >= 32 bits */ +typedef uint8 bits8; /* >= 8 bits */ +typedef uint16 bits16; /* >= 16 bits */ +typedef uint32 bits32; /* >= 32 bits */ /* * wordN -- * Unit of storage, AT LEAST N BITS IN SIZE, * used to fetch/store data. */ -typedef uint8 word8; /* >= 8 bits */ -typedef uint16 word16; /* >= 16 bits */ -typedef uint32 word32; /* >= 32 bits */ +typedef uint8 word8; /* >= 8 bits */ +typedef uint16 word16; /* >= 16 bits */ +typedef uint32 word32; /* >= 32 bits */ /* * Size -- @@ -276,8 +276,8 @@ typedef unsigned int Index; #define MAXDIM 6 typedef struct { - int indx[MAXDIM]; -} IntArray; + int indx[MAXDIM]; +} IntArray; /* * Offset -- @@ -319,7 +319,7 @@ typedef signed int Offset; */ typedef unsigned long Datum; /* XXX sizeof(long) >= sizeof(void *) */ -typedef Datum *DatumPtr; +typedef Datum *DatumPtr; #define GET_1_BYTE(datum) (((Datum) (datum)) & 0x000000ff) #define GET_2_BYTES(datum) (((Datum) (datum)) & 0x0000ffff) @@ -564,11 +564,11 @@ typedef Datum *DatumPtr; * Exception Handling definitions */ -typedef char *ExcMessage; +typedef char *ExcMessage; typedef struct Exception { - ExcMessage message; -} Exception; + ExcMessage message; +} Exception; /* * NO_ASSERT_CHECKING, if defined, turns off all the assertions. @@ -712,7 +712,7 @@ ExceptionalCondition(char *conditionName, * form is used by assert and the exception handling stuff * ---------------- */ -extern char *form(const char *fmt,...); +extern char *form(const char *fmt,...); diff --git a/src/include/catalog/catalog.h b/src/include/catalog/catalog.h index c888d8648de..e0b77b4779d 100644 --- a/src/include/catalog/catalog.h +++ b/src/include/catalog/catalog.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: catalog.h,v 1.3 1997/09/07 04:56:25 momjian Exp $ + * $Id: catalog.h,v 1.4 1997/09/08 02:34:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,10 +15,10 @@ #include <access/tupdesc.h> -extern char *relpath(char relname[]); -extern bool IsSystemRelationName(char *relname); -extern bool IsSharedSystemRelationName(char *relname); -extern Oid newoid(void); -extern void fillatt(TupleDesc att); +extern char *relpath(char relname[]); +extern bool IsSystemRelationName(char *relname); +extern bool IsSharedSystemRelationName(char *relname); +extern Oid newoid(void); +extern void fillatt(TupleDesc att); #endif /* CATALOG_H */ diff --git a/src/include/catalog/catname.h b/src/include/catalog/catname.h index 8dcf95b45ab..2130a472d07 100644 --- a/src/include/catalog/catname.h +++ b/src/include/catalog/catname.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: catname.h,v 1.5 1997/09/07 04:56:27 momjian Exp $ + * $Id: catname.h,v 1.6 1997/09/08 02:34:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,6 +49,6 @@ #define RelCheckRelationName "pg_relcheck" #define TriggerRelationName "pg_trigger" -extern char *SharedSystemRelationNames[]; +extern char *SharedSystemRelationNames[]; #endif /* CATNAME_H */ diff --git a/src/include/catalog/heap.h b/src/include/catalog/heap.h index 616aa9e42ef..c16ec918dde 100644 --- a/src/include/catalog/heap.h +++ b/src/include/catalog/heap.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: heap.h,v 1.5 1997/09/07 04:56:29 momjian Exp $ + * $Id: heap.h,v 1.6 1997/09/08 02:34:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,16 +17,16 @@ extern Relation heap_creatr(char *relname, unsigned smgr, TupleDesc att); -extern Oid +extern Oid heap_create(char relname[], char *typename, int arch, unsigned smgr, TupleDesc tupdesc); -extern void heap_destroy(char relname[]); -extern void heap_destroyr(Relation r); +extern void heap_destroy(char relname[]); +extern void heap_destroyr(Relation r); -extern void InitTempRelList(void); -extern void DestroyTempRels(void); +extern void InitTempRelList(void); +extern void DestroyTempRels(void); #endif /* HEAP_H */ diff --git a/src/include/catalog/index.h b/src/include/catalog/index.h index 5ce47e90168..d85e30535ec 100644 --- a/src/include/catalog/index.h +++ b/src/include/catalog/index.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: index.h,v 1.6 1997/09/07 04:56:31 momjian Exp $ + * $Id: index.h,v 1.7 1997/09/08 02:34:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,11 +18,11 @@ #include <access/itup.h> #include <access/funcindex.h> -extern Form_pg_am - AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId); +extern Form_pg_am + AccessMethodObjectIdGetAccessMethodTupleForm(Oid accessMethodObjectId); extern void - UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate); + UpdateIndexPredicate(Oid indexoid, Node * oldPred, Node * predicate); extern void InitIndexStrategy(int numatts, @@ -44,7 +44,7 @@ index_create(char *heapRelationName, bool islossy, bool unique); -extern void index_destroy(Oid indexId); +extern void index_destroy(Oid indexId); extern void FormIndexDatum(int numberOfAttributes, @@ -52,7 +52,7 @@ FormIndexDatum(int numberOfAttributes, TupleDesc heapDescriptor, Buffer buffer, Datum * datum, char *nullv, FuncIndexInfoPtr fInfo); -extern void UpdateStats(Oid relid, long reltuples, bool hasindex); +extern void UpdateStats(Oid relid, long reltuples, bool hasindex); extern void FillDummyExprContext(ExprContext * econtext, TupleTableSlot * slot, @@ -64,7 +64,7 @@ index_build(Relation heapRelation, Relation indexRelation, uint16 parameterCount, Datum * parameter, FuncIndexInfo * funcInfo, PredInfo * predInfo); -extern bool IndexIsUnique(Oid indexId); -extern bool IndexIsUniqueNoCache(Oid indexId); +extern bool IndexIsUnique(Oid indexId); +extern bool IndexIsUniqueNoCache(Oid indexId); #endif /* INDEX_H */ diff --git a/src/include/catalog/indexing.h b/src/include/catalog/indexing.h index c428aec8a22..664249ccbcb 100644 --- a/src/include/catalog/indexing.h +++ b/src/include/catalog/indexing.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: indexing.h,v 1.5 1997/09/07 04:56:32 momjian Exp $ + * $Id: indexing.h,v 1.6 1997/09/08 02:34:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,41 +46,41 @@ #define RelCheckIndex "pg_relcheckind" #define TriggerRelidIndex "pg_trigrelidind" -extern char *Name_pg_attr_indices[]; -extern char *Name_pg_proc_indices[]; -extern char *Name_pg_type_indices[]; -extern char *Name_pg_class_indices[]; -extern char *Name_pg_attrdef_indices[]; -extern char *Name_pg_relcheck_indices[]; -extern char *Name_pg_trigger_indices[]; +extern char *Name_pg_attr_indices[]; +extern char *Name_pg_proc_indices[]; +extern char *Name_pg_type_indices[]; +extern char *Name_pg_class_indices[]; +extern char *Name_pg_attrdef_indices[]; +extern char *Name_pg_relcheck_indices[]; +extern char *Name_pg_trigger_indices[]; -extern char *IndexedCatalogNames[]; +extern char *IndexedCatalogNames[]; /* * indexing.c prototypes * * Functions for each index to perform the necessary scan on a cache miss. */ -extern void CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]); -extern void CatalogCloseIndices(int nIndices, Relation * idescs); +extern void CatalogOpenIndices(int nIndices, char *names[], Relation idescs[]); +extern void CatalogCloseIndices(int nIndices, Relation * idescs); extern void CatalogIndexInsert(Relation * idescs, int nIndices, Relation heapRelation, HeapTuple heapTuple); -extern bool CatalogHasIndex(char *catName, Oid catId); +extern bool CatalogHasIndex(char *catName, Oid catId); -extern HeapTuple +extern HeapTuple AttributeNameIndexScan(Relation heapRelation, Oid relid, char *attname); -extern HeapTuple +extern HeapTuple AttributeNumIndexScan(Relation heapRelation, Oid relid, AttrNumber attnum); extern HeapTuple ProcedureOidIndexScan(Relation heapRelation, Oid procId); -extern HeapTuple +extern HeapTuple ProcedureNameIndexScan(Relation heapRelation, char *procName, int nargs, Oid * argTypes); extern HeapTuple ProcedureSrcIndexScan(Relation heapRelation, text * procSrc); diff --git a/src/include/catalog/pg_aggregate.h b/src/include/catalog/pg_aggregate.h index 39f8c5d697a..60b8cc42302 100644 --- a/src/include/catalog/pg_aggregate.h +++ b/src/include/catalog/pg_aggregate.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_aggregate.h,v 1.9 1997/09/07 04:56:36 momjian Exp $ + * $Id: pg_aggregate.h,v 1.10 1997/09/08 02:34:54 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -44,17 +44,17 @@ */ CATALOG(pg_aggregate) { - NameData aggname; - Oid aggowner; - regproc aggtransfn1; - regproc aggtransfn2; - regproc aggfinalfn; - Oid aggbasetype; - Oid aggtranstype1; - Oid aggtranstype2; - Oid aggfinaltype; - text agginitval1;/* VARIABLE LENGTH FIELD */ - text agginitval2;/* VARIABLE LENGTH FIELD */ + NameData aggname; + Oid aggowner; + regproc aggtransfn1; + regproc aggtransfn2; + regproc aggfinalfn; + Oid aggbasetype; + Oid aggtranstype1; + Oid aggtranstype2; + Oid aggfinaltype; + text agginitval1; /* VARIABLE LENGTH FIELD */ + text agginitval2; /* VARIABLE LENGTH FIELD */ } FormData_pg_aggregate; /* ---------------- @@ -139,7 +139,7 @@ AggregateCreate(char *aggName, char *aggtransfn2typeName, char *agginitval1, char *agginitval2); -extern char * +extern char * AggNameGetInitVal(char *aggName, Oid basetype, int xfuncno, bool * isNull); diff --git a/src/include/catalog/pg_am.h b/src/include/catalog/pg_am.h index 361c102b502..7c83398fe1f 100644 --- a/src/include/catalog/pg_am.h +++ b/src/include/catalog/pg_am.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_am.h,v 1.3 1997/09/07 04:56:37 momjian Exp $ + * $Id: pg_am.h,v 1.4 1997/09/08 02:34:55 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -35,28 +35,28 @@ */ CATALOG(pg_am) { - NameData amname; - Oid amowner; - char amkind; - int2 amstrategies; - int2 amsupport; - regproc amgettuple; - regproc aminsert; - regproc amdelete; - regproc amgetattr; - regproc amsetlock; - regproc amsettid; - regproc amfreetuple; - regproc ambeginscan; - regproc amrescan; - regproc amendscan; - regproc ammarkpos; - regproc amrestrpos; - regproc amopen; - regproc amclose; - regproc ambuild; - regproc amcreate; - regproc amdestroy; + NameData amname; + Oid amowner; + char amkind; + int2 amstrategies; + int2 amsupport; + regproc amgettuple; + regproc aminsert; + regproc amdelete; + regproc amgetattr; + regproc amsetlock; + regproc amsettid; + regproc amfreetuple; + regproc ambeginscan; + regproc amrescan; + regproc amendscan; + regproc ammarkpos; + regproc amrestrpos; + regproc amopen; + regproc amclose; + regproc ambuild; + regproc amcreate; + regproc amdestroy; } FormData_pg_am; /* ---------------- diff --git a/src/include/catalog/pg_amop.h b/src/include/catalog/pg_amop.h index 7e42e0f4f0f..b2cb9a26f86 100644 --- a/src/include/catalog/pg_amop.h +++ b/src/include/catalog/pg_amop.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amop.h,v 1.6 1997/09/07 04:56:37 momjian Exp $ + * $Id: pg_amop.h,v 1.7 1997/09/08 02:34:56 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,12 +32,12 @@ */ CATALOG(pg_amop) { - Oid amopid; - Oid amopclaid; - Oid amopopr; - int2 amopstrategy; - regproc amopselect; - regproc amopnpages; + Oid amopid; + Oid amopclaid; + Oid amopopr; + int2 amopstrategy; + regproc amopselect; + regproc amopnpages; } FormData_pg_amop; /* ---------------- diff --git a/src/include/catalog/pg_amproc.h b/src/include/catalog/pg_amproc.h index e9aca5c73e7..ea4069543b2 100644 --- a/src/include/catalog/pg_amproc.h +++ b/src/include/catalog/pg_amproc.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_amproc.h,v 1.5 1997/09/07 04:56:39 momjian Exp $ + * $Id: pg_amproc.h,v 1.6 1997/09/08 02:34:57 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -34,10 +34,10 @@ */ CATALOG(pg_amproc) { - Oid amid; - Oid amopclaid; - Oid amproc; - int2 amprocnum; + Oid amid; + Oid amopclaid; + Oid amproc; + int2 amprocnum; } FormData_pg_amproc; /* ---------------- diff --git a/src/include/catalog/pg_attrdef.h b/src/include/catalog/pg_attrdef.h index 9fc546f05b2..6a3b6309d99 100644 --- a/src/include/catalog/pg_attrdef.h +++ b/src/include/catalog/pg_attrdef.h @@ -28,10 +28,10 @@ */ CATALOG(pg_attrdef) BOOTSTRAP { - Oid adrelid; - int2 adnum; - text adbin; - text adsrc; + Oid adrelid; + int2 adnum; + text adbin; + text adsrc; } FormData_pg_attrdef; /* ---------------- diff --git a/src/include/catalog/pg_attribute.h b/src/include/catalog/pg_attribute.h index 5150463c324..1729aeb2cdb 100644 --- a/src/include/catalog/pg_attribute.h +++ b/src/include/catalog/pg_attribute.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_attribute.h,v 1.15 1997/09/07 04:56:41 momjian Exp $ + * $Id: pg_attribute.h,v 1.16 1997/09/08 02:35:02 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -40,9 +40,9 @@ */ CATALOG(pg_attribute) BOOTSTRAP { - Oid attrelid; - NameData attname; - Oid atttypid; + Oid attrelid; + NameData attname; + Oid atttypid; /* * atttypid is the OID of the instance in Catalog Class pg_type that @@ -51,15 +51,15 @@ CATALOG(pg_attribute) BOOTSTRAP * attalign attributes of this instance, so they had better match or * Postgres will fail. */ - float4 attdisbursion; - int2 attlen; + float4 attdisbursion; + int2 attlen; /* * attlen is a copy of the typlen field from pg_type for this * attribute. See atttypid above. See struct TypeTupleFormData for * definition. */ - int2 attnum; + int2 attnum; /* * attnum is the "attribute number" for the attribute: A value that @@ -74,8 +74,8 @@ CATALOG(pg_attribute) BOOTSTRAP * * Note that (attnum - 1) is often used as the index to an array. */ - int4 attnelems; - int4 attcacheoff; + int4 attnelems; + int4 attcacheoff; /* * fastgetattr() uses attcacheoff to cache byte offsets of attributes @@ -84,25 +84,25 @@ CATALOG(pg_attribute) BOOTSTRAP * tuple descriptor, we may then update attcacheoff in the copies. * This speeds up the attribute walking process. */ - bool attbyval; + bool attbyval; /* * attbyval is a copy of the typbyval field from pg_type for this * attribute. See atttypid above. See struct TypeTupleFormData for * definition. */ - bool attisset; - char attalign; + bool attisset; + char attalign; /* * attalign is a copy of the typalign field from pg_type for this * attribute. See atttypid above. See struct TypeTupleFormData for * definition. */ - bool attnotnull; + bool attnotnull; /* This flag represents the "NOT NULL" constraint */ - bool atthasdef; + bool atthasdef; /* Has DEFAULT value or not */ } FormData_pg_attribute; diff --git a/src/include/catalog/pg_class.h b/src/include/catalog/pg_class.h index 2be1ebd90b5..83751152897 100644 --- a/src/include/catalog/pg_class.h +++ b/src/include/catalog/pg_class.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_class.h,v 1.10 1997/09/07 04:56:42 momjian Exp $ + * $Id: pg_class.h,v 1.11 1997/09/08 02:35:03 momjian Exp $ * * NOTES * ``pg_relation'' is being replaced by ``pg_class''. currently @@ -52,33 +52,33 @@ */ CATALOG(pg_class) BOOTSTRAP { - NameData relname; - Oid reltype; - Oid relowner; - Oid relam; - int4 relpages; - int4 reltuples; - int4 relexpires; /* really used as a abstime, but fudge it + NameData relname; + Oid reltype; + Oid relowner; + Oid relam; + int4 relpages; + int4 reltuples; + int4 relexpires; /* really used as a abstime, but fudge it * for now */ - int4 relpreserved; /* really used as a reltime, but - * fudge it for now */ - bool relhasindex; - bool relisshared; - char relkind; - char relarch; /* 'h' = heavy, 'l' = light, 'n' = no + int4 relpreserved; /* really used as a reltime, but fudge it + * for now */ + bool relhasindex; + bool relisshared; + char relkind; + char relarch; /* 'h' = heavy, 'l' = light, 'n' = no * archival */ - int2 relnatts; + int2 relnatts; /* * relnatts is the number of user attributes this class has. There * must be exactly this many instances in Class pg_attribute for this * class which have attnum > 0 (= user attribute). */ - int2 relsmgr; - int2 relchecks; /* # of CHECK constraints */ - int2 reltriggers;/* # of TRIGGERs */ - bool relhasrules; - aclitem relacl[1]; /* this is here for the catalog */ + int2 relsmgr; + int2 relchecks; /* # of CHECK constraints */ + int2 reltriggers; /* # of TRIGGERs */ + bool relhasrules; + aclitem relacl[1]; /* this is here for the catalog */ } FormData_pg_class; #define CLASS_TUPLE_SIZE \ diff --git a/src/include/catalog/pg_database.h b/src/include/catalog/pg_database.h index bd77e23a5df..10015c7cc69 100644 --- a/src/include/catalog/pg_database.h +++ b/src/include/catalog/pg_database.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_database.h,v 1.4 1997/09/07 04:56:43 momjian Exp $ + * $Id: pg_database.h,v 1.5 1997/09/08 02:35:04 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,9 +32,9 @@ */ CATALOG(pg_database) BOOTSTRAP { - NameData datname; - int4 datdba; - text datpath; /* VARIABLE LENGTH FIELD */ + NameData datname; + int4 datdba; + text datpath; /* VARIABLE LENGTH FIELD */ } FormData_pg_database; /* ---------------- diff --git a/src/include/catalog/pg_defaults.h b/src/include/catalog/pg_defaults.h index a35c06c4db8..4aaa234b8e3 100644 --- a/src/include/catalog/pg_defaults.h +++ b/src/include/catalog/pg_defaults.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_defaults.h,v 1.3 1997/09/07 04:56:44 momjian Exp $ + * $Id: pg_defaults.h,v 1.4 1997/09/08 02:35:05 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,8 +32,8 @@ */ CATALOG(pg_defaults) BOOTSTRAP { - NameData defname; - NameData defvalue; + NameData defname; + NameData defvalue; } FormData_pg_defaults; /* ---------------- diff --git a/src/include/catalog/pg_demon.h b/src/include/catalog/pg_demon.h index 0bdb0151aa1..86bb1628d3e 100644 --- a/src/include/catalog/pg_demon.h +++ b/src/include/catalog/pg_demon.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_demon.h,v 1.3 1997/09/07 04:56:45 momjian Exp $ + * $Id: pg_demon.h,v 1.4 1997/09/08 02:35:06 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,10 +32,10 @@ */ CATALOG(pg_demon) BOOTSTRAP { - Oid demserid; - NameData demname; - Oid demowner; - regproc demcode; + Oid demserid; + NameData demname; + Oid demowner; + regproc demcode; } FormData_pg_demon; /* ---------------- diff --git a/src/include/catalog/pg_group.h b/src/include/catalog/pg_group.h index 3661b5149fe..5680c0fe1b6 100644 --- a/src/include/catalog/pg_group.h +++ b/src/include/catalog/pg_group.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_group.h,v 1.3 1997/09/07 04:56:46 momjian Exp $ + * $Id: pg_group.h,v 1.4 1997/09/08 02:35:07 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -26,9 +26,9 @@ CATALOG(pg_group) BOOTSTRAP { - NameData groname; - int4 grosysid; - int4 grolist[1]; + NameData groname; + int4 grosysid; + int4 grolist[1]; } FormData_pg_group; /* VARIABLE LENGTH STRUCTURE */ diff --git a/src/include/catalog/pg_hosts.h b/src/include/catalog/pg_hosts.h index 633b28579b6..a31b9d736af 100644 --- a/src/include/catalog/pg_hosts.h +++ b/src/include/catalog/pg_hosts.h @@ -10,7 +10,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_hosts.h,v 1.3 1997/09/07 04:56:46 momjian Exp $ + * $Id: pg_hosts.h,v 1.4 1997/09/08 02:35:09 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -30,9 +30,9 @@ CATALOG(pg_hosts) BOOTSTRAP { - NameData dbName; - text address; - text mask; + NameData dbName; + text address; + text mask; } FormData_pg_hosts; typedef FormData_pg_hosts *Form_pg_hosts; diff --git a/src/include/catalog/pg_index.h b/src/include/catalog/pg_index.h index 0ebaea1c76a..a466d4dfd0c 100644 --- a/src/include/catalog/pg_index.h +++ b/src/include/catalog/pg_index.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_index.h,v 1.4 1997/09/07 04:56:47 momjian Exp $ + * $Id: pg_index.h,v 1.5 1997/09/08 02:35:12 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -41,20 +41,19 @@ */ CATALOG(pg_index) { - Oid indexrelid; - Oid indrelid; - Oid indproc; /* registered procedure for functional + Oid indexrelid; + Oid indrelid; + Oid indproc; /* registered procedure for functional * index */ - int28 indkey; - oid8 indclass; - bool indisclustered; - bool indisarchived; - bool indislossy; /* do we fetch false tuples (lossy + int28 indkey; + oid8 indclass; + bool indisclustered; + bool indisarchived; + bool indislossy; /* do we fetch false tuples (lossy * compression)? */ - bool indhaskeytype; /* does key type != attribute - * type? */ - bool indisunique;/* is this a unique index? */ - text indpred; /* query plan for partial index predicate */ + bool indhaskeytype; /* does key type != attribute type? */ + bool indisunique; /* is this a unique index? */ + text indpred; /* query plan for partial index predicate */ } FormData_pg_index; #define INDEX_MAX_KEYS 8 /* maximum number of keys in an index diff --git a/src/include/catalog/pg_inheritproc.h b/src/include/catalog/pg_inheritproc.h index f53561a51ca..60bad51b939 100644 --- a/src/include/catalog/pg_inheritproc.h +++ b/src/include/catalog/pg_inheritproc.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_inheritproc.h,v 1.3 1997/09/07 04:56:50 momjian Exp $ + * $Id: pg_inheritproc.h,v 1.4 1997/09/08 02:35:13 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,10 +32,10 @@ */ CATALOG(pg_inheritproc) { - NameData inhproname; - Oid inhargrel; - Oid inhdefrel; - Oid inhproc; + NameData inhproname; + Oid inhargrel; + Oid inhdefrel; + Oid inhproc; } FormData_pg_inheritproc; /* ---------------- diff --git a/src/include/catalog/pg_inherits.h b/src/include/catalog/pg_inherits.h index 8913b613ed0..7cb1584f5c6 100644 --- a/src/include/catalog/pg_inherits.h +++ b/src/include/catalog/pg_inherits.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_inherits.h,v 1.3 1997/09/07 04:56:51 momjian Exp $ + * $Id: pg_inherits.h,v 1.4 1997/09/08 02:35:14 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,9 +32,9 @@ */ CATALOG(pg_inherits) { - Oid inhrel; - Oid inhparent; - int4 inhseqno; + Oid inhrel; + Oid inhparent; + int4 inhseqno; } FormData_pg_inherits; /* ---------------- diff --git a/src/include/catalog/pg_ipl.h b/src/include/catalog/pg_ipl.h index 4e735f8dc33..ea3eb34512a 100644 --- a/src/include/catalog/pg_ipl.h +++ b/src/include/catalog/pg_ipl.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_ipl.h,v 1.3 1997/09/07 04:56:52 momjian Exp $ + * $Id: pg_ipl.h,v 1.4 1997/09/08 02:35:15 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,9 +32,9 @@ */ CATALOG(pg_ipl) { - Oid iplrel; - Oid iplipl; - int4 iplseqno; + Oid iplrel; + Oid iplipl; + int4 iplseqno; } FormData_pg_ipl; /* ---------------- diff --git a/src/include/catalog/pg_language.h b/src/include/catalog/pg_language.h index 1a1ac577aad..8c8490b4861 100644 --- a/src/include/catalog/pg_language.h +++ b/src/include/catalog/pg_language.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_language.h,v 1.3 1997/09/07 04:56:53 momjian Exp $ + * $Id: pg_language.h,v 1.4 1997/09/08 02:35:16 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,8 +32,8 @@ */ CATALOG(pg_language) { - NameData lanname; - text lancompiler;/* VARIABLE LENGTH FIELD */ + NameData lanname; + text lancompiler; /* VARIABLE LENGTH FIELD */ } FormData_pg_language; /* ---------------- diff --git a/src/include/catalog/pg_listener.h b/src/include/catalog/pg_listener.h index c1826a317a4..d80bf9df299 100644 --- a/src/include/catalog/pg_listener.h +++ b/src/include/catalog/pg_listener.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_listener.h,v 1.3 1997/09/07 04:56:54 momjian Exp $ + * $Id: pg_listener.h,v 1.4 1997/09/08 02:35:17 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -33,9 +33,9 @@ CATALOG(pg_listener) { - NameData relname; - int4 listenerpid; - int4 notification; + NameData relname; + int4 listenerpid; + int4 notification; } FormData_pg_listener; /* ---------------- diff --git a/src/include/catalog/pg_log.h b/src/include/catalog/pg_log.h index 977b1f9cccf..0cf9dc130bc 100644 --- a/src/include/catalog/pg_log.h +++ b/src/include/catalog/pg_log.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_log.h,v 1.3 1997/09/07 04:56:55 momjian Exp $ + * $Id: pg_log.h,v 1.4 1997/09/08 02:35:18 momjian Exp $ * * NOTES * The structures and macros used by the transam/ code @@ -29,7 +29,7 @@ CATALOG(pg_log) BOOTSTRAP { - Oid logfoo; + Oid logfoo; } FormData_pg_log; typedef FormData_pg_log *Form_pg_log; diff --git a/src/include/catalog/pg_magic.h b/src/include/catalog/pg_magic.h index 7c92c2e3c55..c979f815dcc 100644 --- a/src/include/catalog/pg_magic.h +++ b/src/include/catalog/pg_magic.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_magic.h,v 1.3 1997/09/07 04:56:57 momjian Exp $ + * $Id: pg_magic.h,v 1.4 1997/09/08 02:35:18 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,8 +32,8 @@ */ CATALOG(pg_magic) BOOTSTRAP { - NameData magname; - NameData magvalue; + NameData magname; + NameData magvalue; } FormData_pg_magic; /* ---------------- diff --git a/src/include/catalog/pg_opclass.h b/src/include/catalog/pg_opclass.h index f047de2c890..0d3b9abb8a4 100644 --- a/src/include/catalog/pg_opclass.h +++ b/src/include/catalog/pg_opclass.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_opclass.h,v 1.4 1997/09/07 04:56:58 momjian Exp $ + * $Id: pg_opclass.h,v 1.5 1997/09/08 02:35:19 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -33,8 +33,8 @@ CATALOG(pg_opclass) { - NameData opcname; - Oid opcdeftype; + NameData opcname; + Oid opcdeftype; } FormData_pg_opclass; /* ---------------- diff --git a/src/include/catalog/pg_operator.h b/src/include/catalog/pg_operator.h index 111974e4722..fdc90746328 100644 --- a/src/include/catalog/pg_operator.h +++ b/src/include/catalog/pg_operator.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_operator.h,v 1.14 1997/09/07 04:57:00 momjian Exp $ + * $Id: pg_operator.h,v 1.15 1997/09/08 02:35:20 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -35,22 +35,22 @@ */ CATALOG(pg_operator) { - NameData oprname; - Oid oprowner; - int2 oprprec; - char oprkind; - bool oprisleft; - bool oprcanhash; - Oid oprleft; - Oid oprright; - Oid oprresult; - Oid oprcom; - Oid oprnegate; - Oid oprlsortop; - Oid oprrsortop; - regproc oprcode; - regproc oprrest; - regproc oprjoin; + NameData oprname; + Oid oprowner; + int2 oprprec; + char oprkind; + bool oprisleft; + bool oprcanhash; + Oid oprleft; + Oid oprright; + Oid oprresult; + Oid oprcom; + Oid oprnegate; + Oid oprlsortop; + Oid oprrsortop; + regproc oprcode; + regproc oprrest; + regproc oprjoin; } FormData_pg_operator; /* ---------------- diff --git a/src/include/catalog/pg_parg.h b/src/include/catalog/pg_parg.h index f5423f70862..28404998565 100644 --- a/src/include/catalog/pg_parg.h +++ b/src/include/catalog/pg_parg.h @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_parg.h,v 1.4 1997/09/07 04:57:01 momjian Exp $ + * $Id: pg_parg.h,v 1.5 1997/09/08 02:35:21 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -33,10 +33,10 @@ */ CATALOG(pg_parg) { - Oid parproid; - int2 parnum; - char parbound; - Oid partype; + Oid parproid; + int2 parnum; + char parbound; + Oid partype; } FormData_pg_parg; /* ---------------- diff --git a/src/include/catalog/pg_proc.h b/src/include/catalog/pg_proc.h index 2c9dfc9710e..2d08131cf22 100644 --- a/src/include/catalog/pg_proc.h +++ b/src/include/catalog/pg_proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_proc.h,v 1.28 1997/09/07 04:57:03 momjian Exp $ + * $Id: pg_proc.h,v 1.29 1997/09/08 02:35:23 momjian Exp $ * * NOTES * The script catalog/genbki.sh reads this file and generates .bki @@ -38,22 +38,22 @@ */ CATALOG(pg_proc) BOOTSTRAP { - NameData proname; - Oid proowner; - Oid prolang; - bool proisinh; - bool proistrusted; - bool proiscachable; - int2 pronargs; - bool proretset; - Oid prorettype; - oid8 proargtypes; - int4 probyte_pct; - int4 properbyte_cpu; - int4 propercall_cpu; - int4 prooutin_ratio; - text prosrc; /* VARIABLE LENGTH FIELD */ - bytea probin; /* VARIABLE LENGTH FIELD */ + NameData proname; + Oid proowner; + Oid prolang; + bool proisinh; + bool proistrusted; + bool proiscachable; + int2 pronargs; + bool proretset; + Oid prorettype; + oid8 proargtypes; + int4 probyte_pct; + int4 properbyte_cpu; + int4 propercall_cpu; + int4 prooutin_ratio; + text prosrc; /* VARIABLE LENGTH FIELD */ + bytea probin; /* VARIABLE LENGTH FIELD */ } FormData_pg_proc; /* ---------------- @@ -1103,7 +1103,7 @@ DATA(insert OID = 1319 ( currval PGUID 11 f t f 1 f 23 "25" 100 0 0 100 fo /* * prototypes for functions pg_proc.c */ -extern Oid +extern Oid ProcedureCreate(char *procedureName, bool returnsSet, char *returnTypeName, diff --git a/src/include/catalog/pg_relcheck.h b/src/include/catalog/pg_relcheck.h index c0ca6604756..2b80bd94243 100644 --- a/src/include/catalog/pg_relcheck.h +++ b/src/include/catalog/pg_relcheck.h @@ -28,10 +28,10 @@ */ CATALOG(pg_relcheck) BOOTSTRAP { - Oid rcrelid; - NameData rcname; - text rcbin; - text rcsrc; + Oid rcrelid; + NameData rcname; + text rcbin; + text rcsrc; } FormData_pg_relcheck; /* ---------------- diff --git a/src/include/catalog/pg_rewrite.h b/src/include/catalog/pg_rewrite.h index 8491d238954..3cf2afde97a 100644 --- a/src/include/catalog/pg_rewrite.h +++ b/src/include/catalog/pg_rewrite.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_rewrite.h,v 1.3 1997/09/07 04:57:08 momjian Exp $ + * $Id: pg_rewrite.h,v 1.4 1997/09/08 02:35:25 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,13 +32,13 @@ */ CATALOG(pg_rewrite) { - NameData rulename; - char ev_type; - Oid ev_class; - int2 ev_attr; - bool is_instead; - text ev_qual; /* VARLENA */ - text action; /* VARLENA */ + NameData rulename; + char ev_type; + Oid ev_class; + int2 ev_attr; + bool is_instead; + text ev_qual; /* VARLENA */ + text action; /* VARLENA */ } FormData_pg_rewrite; /* ---------------- diff --git a/src/include/catalog/pg_server.h b/src/include/catalog/pg_server.h index 8c0c642dc13..dc74805645a 100644 --- a/src/include/catalog/pg_server.h +++ b/src/include/catalog/pg_server.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_server.h,v 1.3 1997/09/07 04:57:09 momjian Exp $ + * $Id: pg_server.h,v 1.4 1997/09/08 02:35:26 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,9 +32,9 @@ */ CATALOG(pg_server) BOOTSTRAP { - NameData sername; - int2 serpid; - int2 serport; + NameData sername; + int2 serpid; + int2 serport; } FormData_pg_server; /* ---------------- diff --git a/src/include/catalog/pg_statistic.h b/src/include/catalog/pg_statistic.h index 6059bbd477c..7b0919b1e1d 100644 --- a/src/include/catalog/pg_statistic.h +++ b/src/include/catalog/pg_statistic.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_statistic.h,v 1.3 1997/09/07 04:57:10 momjian Exp $ + * $Id: pg_statistic.h,v 1.4 1997/09/08 02:35:27 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,11 +32,11 @@ */ CATALOG(pg_statistic) { - Oid starelid; - int2 staattnum; - Oid staop; - text stalokey; /* VARIABLE LENGTH FIELD */ - text stahikey; /* VARIABLE LENGTH FIELD */ + Oid starelid; + int2 staattnum; + Oid staop; + text stalokey; /* VARIABLE LENGTH FIELD */ + text stahikey; /* VARIABLE LENGTH FIELD */ } FormData_pg_statistic; /* ---------------- diff --git a/src/include/catalog/pg_time.h b/src/include/catalog/pg_time.h index f1955930f06..57675110372 100644 --- a/src/include/catalog/pg_time.h +++ b/src/include/catalog/pg_time.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_time.h,v 1.3 1997/09/07 04:57:10 momjian Exp $ + * $Id: pg_time.h,v 1.4 1997/09/08 02:35:28 momjian Exp $ * * NOTES * The structures and macros used by the transam/ code @@ -29,7 +29,7 @@ CATALOG(pg_time) BOOTSTRAP { - Oid timefoo; + Oid timefoo; } FormData_pg_time; typedef FormData_pg_time *Form_pg_time; diff --git a/src/include/catalog/pg_trigger.h b/src/include/catalog/pg_trigger.h index 08472839ef0..83fcbef656b 100644 --- a/src/include/catalog/pg_trigger.h +++ b/src/include/catalog/pg_trigger.h @@ -28,14 +28,14 @@ */ CATALOG(pg_trigger) BOOTSTRAP { - Oid tgrelid; /* triggered relation */ - NameData tgname; /* trigger' name */ - Oid tgfoid; /* OID of function to be called */ - int2 tgtype; /* BEFORE/AFTER UPDATE/DELETE/INSERT + Oid tgrelid; /* triggered relation */ + NameData tgname; /* trigger' name */ + Oid tgfoid; /* OID of function to be called */ + int2 tgtype; /* BEFORE/AFTER UPDATE/DELETE/INSERT * ROW/STATEMENT */ - int2 tgnargs; /* # of extra arguments in tgargs */ - int28 tgattr; /* UPDATE of attr1, attr2 ... (NI) */ - bytea tgargs; /* first\000second\000tgnargs\000 */ + int2 tgnargs; /* # of extra arguments in tgargs */ + int28 tgattr; /* UPDATE of attr1, attr2 ... (NI) */ + bytea tgargs; /* first\000second\000tgnargs\000 */ } FormData_pg_trigger; /* ---------------- diff --git a/src/include/catalog/pg_type.h b/src/include/catalog/pg_type.h index 9083dad4452..650c1955fdc 100644 --- a/src/include/catalog/pg_type.h +++ b/src/include/catalog/pg_type.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_type.h,v 1.17 1997/09/07 04:57:12 momjian Exp $ + * $Id: pg_type.h,v 1.18 1997/09/08 02:35:32 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -39,17 +39,17 @@ */ CATALOG(pg_type) BOOTSTRAP { - NameData typname; - Oid typowner; - int2 typlen; + NameData typname; + Oid typowner; + int2 typlen; /* * typlen is the number of bytes we use to represent a value of this * type, e.g. 4 for an int4. But for a variable length type, typlen * is -1. */ - int2 typprtlen; - bool typbyval; + int2 typprtlen; + bool typbyval; /* * typbyval determines whether internal Postgres routines pass a value @@ -70,11 +70,11 @@ CATALOG(pg_type) BOOTSTRAP * with the declared length, and typbyval is used somewhere. - tgl * 97/03/20) */ - char typtype; - bool typisdefined; - char typdelim; - Oid typrelid; - Oid typelem; + char typtype; + bool typisdefined; + char typdelim; + Oid typrelid; + Oid typelem; /* * typelem is NULL if this is not an array type. If this is an array @@ -84,11 +84,11 @@ CATALOG(pg_type) BOOTSTRAP * (Note that zero ("0") rather than _null_ is used in the declarations. * - tgl 97/03/20) */ - regproc typinput; - regproc typoutput; - regproc typreceive; - regproc typsend; - char typalign; + regproc typinput; + regproc typoutput; + regproc typreceive; + regproc typsend; + char typalign; /* * typalign is the alignment required when storing a value of this @@ -105,7 +105,7 @@ CATALOG(pg_type) BOOTSTRAP * (This might actually be flexible depending on machine architecture, * but I doubt it - BRYANH 96.08). */ - text typdefault; /* VARIABLE LENGTH FIELD */ + text typdefault; /* VARIABLE LENGTH FIELD */ } TypeTupleFormData; /* ---------------- @@ -326,9 +326,9 @@ DATA(insert OID = 1296 ( timestamp PGUID 4 19 t b t \054 0 0 timestamp_in time /* * prototypes for functions in pg_type.c */ -extern Oid TypeGet(char *typeName, bool * defined); -extern Oid TypeShellMake(char *typeName); -extern Oid +extern Oid TypeGet(char *typeName, bool * defined); +extern Oid TypeShellMake(char *typeName); +extern Oid TypeCreate(char *typeName, Oid relationOid, int16 internalSize, @@ -342,8 +342,8 @@ TypeCreate(char *typeName, char *elementTypeName, char *defaultTypeValue, bool passedByValue, char alignment); -extern void TypeRename(char *oldTypeName, char *newTypeName); -extern char *makeArrayTypeName(char *typeName); +extern void TypeRename(char *oldTypeName, char *newTypeName); +extern char *makeArrayTypeName(char *typeName); #endif /* PG_TYPE_H */ diff --git a/src/include/catalog/pg_user.h b/src/include/catalog/pg_user.h index 904e35cd15d..7f7bd8b6525 100644 --- a/src/include/catalog/pg_user.h +++ b/src/include/catalog/pg_user.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_user.h,v 1.4 1997/09/07 04:57:13 momjian Exp $ + * $Id: pg_user.h,v 1.5 1997/09/08 02:35:34 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -21,7 +21,7 @@ /* Prototype required for superuser() from superuser.c */ -bool superuser(void); +bool superuser(void); /* ---------------- * pg_user definition. cpp turns this into @@ -30,12 +30,12 @@ bool superuser(void); */ CATALOG(pg_user) BOOTSTRAP { - NameData usename; - int4 usesysid; - bool usecreatedb; - bool usetrace; - bool usesuper; - bool usecatupd; + NameData usename; + int4 usesysid; + bool usecreatedb; + bool usetrace; + bool usesuper; + bool usecatupd; } FormData_pg_user; /* ---------------- diff --git a/src/include/catalog/pg_variable.h b/src/include/catalog/pg_variable.h index ef685f35719..95063125c8a 100644 --- a/src/include/catalog/pg_variable.h +++ b/src/include/catalog/pg_variable.h @@ -9,7 +9,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_variable.h,v 1.3 1997/09/07 04:57:15 momjian Exp $ + * $Id: pg_variable.h,v 1.4 1997/09/08 02:35:34 momjian Exp $ * * NOTES * The structures and macros used by the transam/ code @@ -29,7 +29,7 @@ CATALOG(pg_variable) BOOTSTRAP { - Oid varfoo; + Oid varfoo; } FormData_pg_variable; typedef FormData_pg_variable *Form_pg_variable; diff --git a/src/include/catalog/pg_version.h b/src/include/catalog/pg_version.h index ba1249ab04e..96b0c2125f1 100644 --- a/src/include/catalog/pg_version.h +++ b/src/include/catalog/pg_version.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_version.h,v 1.4 1997/09/07 04:57:17 momjian Exp $ + * $Id: pg_version.h,v 1.5 1997/09/08 02:35:35 momjian Exp $ * * NOTES * the genbki.sh script reads this file and generates .bki @@ -32,9 +32,9 @@ */ CATALOG(pg_version) { - Oid verrelid; - Oid verbaseid; - int4 vertime; /* really should be some abstime */ + Oid verrelid; + Oid verbaseid; + int4 vertime; /* really should be some abstime */ } FormData_pg_version; /* ---------------- diff --git a/src/include/commands/async.h b/src/include/commands/async.h index 4f63c7fde71..498cec4fbfd 100644 --- a/src/include/commands/async.h +++ b/src/include/commands/async.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: async.h,v 1.6 1997/09/07 04:57:19 momjian Exp $ + * $Id: async.h,v 1.7 1997/09/08 02:35:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,11 +15,11 @@ #include <nodes/memnodes.h> -extern void Async_NotifyHandler(SIGNAL_ARGS); -extern void Async_Notify(char *relname); -extern void Async_NotifyAtCommit(void); -extern void Async_NotifyAtAbort(void); -extern void Async_Listen(char *relname, int pid); +extern void Async_NotifyHandler(SIGNAL_ARGS); +extern void Async_Notify(char *relname); +extern void Async_NotifyAtCommit(void); +extern void Async_NotifyAtAbort(void); +extern void Async_Listen(char *relname, int pid); extern GlobalMemory notifyContext; diff --git a/src/include/commands/cluster.h b/src/include/commands/cluster.h index 7f305c60144..5847d6b3c95 100644 --- a/src/include/commands/cluster.h +++ b/src/include/commands/cluster.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994-5, Regents of the University of California * - * $Id: cluster.h,v 1.3 1997/09/07 04:57:21 momjian Exp $ + * $Id: cluster.h,v 1.4 1997/09/08 02:35:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,6 @@ /* * functions */ -extern void cluster(char oldrelname[], char oldindexname[]); +extern void cluster(char oldrelname[], char oldindexname[]); #endif /* CLUSTER_H */ diff --git a/src/include/commands/command.h b/src/include/commands/command.h index 78c4aa5ea0e..57b2ff6c783 100644 --- a/src/include/commands/command.h +++ b/src/include/commands/command.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: command.h,v 1.5 1997/09/07 04:57:22 momjian Exp $ + * $Id: command.h,v 1.6 1997/09/08 02:35:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ PerformPortalFetch(char *name, bool forward, int count, * PerformPortalClose -- * Performs the POSTQUEL function CLOSE. */ -extern void PerformPortalClose(char *name, CommandDest dest); +extern void PerformPortalClose(char *name, CommandDest dest); -extern void PortalCleanup(Portal portal); +extern void PortalCleanup(Portal portal); /* * PerformAddAttribute -- diff --git a/src/include/commands/creatinh.h b/src/include/commands/creatinh.h index 52926dbe9f8..11364a48627 100644 --- a/src/include/commands/creatinh.h +++ b/src/include/commands/creatinh.h @@ -6,15 +6,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: creatinh.h,v 1.2 1997/09/07 04:57:24 momjian Exp $ + * $Id: creatinh.h,v 1.3 1997/09/08 02:35:44 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef CREATINH_H #define CREATINH_H -extern void DefineRelation(CreateStmt * stmt); -extern void RemoveRelation(char *name); -extern char *MakeArchiveName(Oid relid); +extern void DefineRelation(CreateStmt * stmt); +extern void RemoveRelation(char *name); +extern char *MakeArchiveName(Oid relid); #endif /* CREATINH_H */ diff --git a/src/include/commands/defrem.h b/src/include/commands/defrem.h index 8d916477380..88003629d1d 100644 --- a/src/include/commands/defrem.h +++ b/src/include/commands/defrem.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: defrem.h,v 1.8 1997/09/07 04:57:25 momjian Exp $ + * $Id: defrem.h,v 1.9 1997/09/08 02:35:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,25 +32,25 @@ extern void ExtendIndex(char *indexRelationName, Expr * predicate, List * rangetable); -extern void RemoveIndex(char *name); +extern void RemoveIndex(char *name); /* * prototypes in define.c */ -extern void CreateFunction(ProcedureStmt * stmt, CommandDest dest); -extern void DefineOperator(char *name, List * parameters); -extern void DefineAggregate(char *name, List * parameters); -extern void DefineType(char *name, List * parameters); -extern void CreateFunction(ProcedureStmt * stmt, CommandDest dest); +extern void CreateFunction(ProcedureStmt * stmt, CommandDest dest); +extern void DefineOperator(char *name, List * parameters); +extern void DefineAggregate(char *name, List * parameters); +extern void DefineType(char *name, List * parameters); +extern void CreateFunction(ProcedureStmt * stmt, CommandDest dest); /* * prototypes in remove.c */ -extern void RemoveFunction(char *functionName, int nargs, List * argNameList); +extern void RemoveFunction(char *functionName, int nargs, List * argNameList); extern void RemoveOperator(char *operatorName, char *typeName1, char *typeName2); -extern void RemoveType(char *typeName); -extern void RemoveAggregate(char *aggName, char *aggType); +extern void RemoveType(char *typeName); +extern void RemoveAggregate(char *aggName, char *aggType); #endif /* DEFREM_H */ diff --git a/src/include/commands/explain.h b/src/include/commands/explain.h index f41f4dfa885..42aa7fd8d95 100644 --- a/src/include/commands/explain.h +++ b/src/include/commands/explain.h @@ -5,13 +5,13 @@ * * Copyright (c) 1994-5, Regents of the University of California * - * $Id: explain.h,v 1.3 1997/09/07 04:57:26 momjian Exp $ + * $Id: explain.h,v 1.4 1997/09/08 02:35:52 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef EXPLAIN_H #define EXPLAIN_H -extern void ExplainQuery(Query * query, bool verbose, CommandDest dest); +extern void ExplainQuery(Query * query, bool verbose, CommandDest dest); #endif /* EXPLAIN_H */ diff --git a/src/include/commands/purge.h b/src/include/commands/purge.h index 7c4d276afdb..de3f9c62a41 100644 --- a/src/include/commands/purge.h +++ b/src/include/commands/purge.h @@ -6,14 +6,14 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: purge.h,v 1.2 1997/09/07 04:57:26 momjian Exp $ + * $Id: purge.h,v 1.3 1997/09/08 02:35:53 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef PURGE_H #define PURGE_H -extern int32 +extern int32 RelationPurge(char *relationName, char *absoluteTimeString, char *relativeTimeString); diff --git a/src/include/commands/recipe.h b/src/include/commands/recipe.h index 82a3e01cae0..5e0d5286eb9 100644 --- a/src/include/commands/recipe.h +++ b/src/include/commands/recipe.h @@ -5,13 +5,13 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: recipe.h,v 1.2 1997/09/07 04:57:28 momjian Exp $ + * $Id: recipe.h,v 1.3 1997/09/08 02:35:56 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef RECIPE_H #define RECIPE_H -extern void beginRecipe(RecipeStmt * stmt); +extern void beginRecipe(RecipeStmt * stmt); #endif /* RECIPE_H */ diff --git a/src/include/commands/sequence.h b/src/include/commands/sequence.h index 88497253b32..54f0ecd6c27 100644 --- a/src/include/commands/sequence.h +++ b/src/include/commands/sequence.h @@ -25,9 +25,9 @@ #define SEQ_COL_FIRSTCOL SEQ_COL_NAME #define SEQ_COL_LASTCOL SEQ_COL_CALLED -extern void DefineSequence(CreateSeqStmt * stmt); -extern int4 nextval(struct varlena * seqname); -extern int4 currval(struct varlena * seqname); -extern void CloseSequences(void); +extern void DefineSequence(CreateSeqStmt * stmt); +extern int4 nextval(struct varlena * seqname); +extern int4 currval(struct varlena * seqname); +extern void CloseSequences(void); #endif /* SEQUENCE_H */ diff --git a/src/include/commands/trigger.h b/src/include/commands/trigger.h index 0f125a0de6a..6ba0394fdf7 100644 --- a/src/include/commands/trigger.h +++ b/src/include/commands/trigger.h @@ -13,16 +13,16 @@ #include "access/htup.h" #include "utils/rel.h" -typedef uint32 TriggerEvent; +typedef uint32 TriggerEvent; typedef struct TriggerData { - TriggerEvent tg_event; - Relation tg_relation; - HeapTuple tg_trigtuple; - HeapTuple tg_newtuple; - Trigger *tg_trigger; -} TriggerData; + TriggerEvent tg_event; + Relation tg_relation; + HeapTuple tg_trigtuple; + HeapTuple tg_newtuple; + Trigger *tg_trigger; +} TriggerData; extern TriggerData *CurrentTriggerData; @@ -58,15 +58,15 @@ extern TriggerData *CurrentTriggerData; (!TRIGGER_FIRED_BEFORE (event)) -extern void CreateTrigger(CreateTrigStmt * stmt); -extern void DropTrigger(DropTrigStmt * stmt); -extern void RelationRemoveTriggers(Relation rel); +extern void CreateTrigger(CreateTrigStmt * stmt); +extern void DropTrigger(DropTrigStmt * stmt); +extern void RelationRemoveTriggers(Relation rel); extern HeapTuple ExecBRInsertTriggers(Relation rel, HeapTuple tuple); -extern void ExecARInsertTriggers(Relation rel, HeapTuple tuple); -extern bool ExecBRDeleteTriggers(Relation rel, ItemPointer tupleid); -extern void ExecARDeleteTriggers(Relation rel, ItemPointer tupleid); +extern void ExecARInsertTriggers(Relation rel, HeapTuple tuple); +extern bool ExecBRDeleteTriggers(Relation rel, ItemPointer tupleid); +extern void ExecARDeleteTriggers(Relation rel, ItemPointer tupleid); extern HeapTuple ExecBRUpdateTriggers(Relation rel, ItemPointer tupleid, HeapTuple tuple); -extern void ExecARUpdateTriggers(Relation rel, ItemPointer tupleid, HeapTuple tuple); +extern void ExecARUpdateTriggers(Relation rel, ItemPointer tupleid, HeapTuple tuple); #endif /* TRIGGER_H */ diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index 59863f2d574..d2a4565688a 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: vacuum.h,v 1.8 1997/09/07 04:57:33 momjian Exp $ + * $Id: vacuum.h,v 1.9 1997/09/08 02:36:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,92 +18,92 @@ typedef struct VAttListData { - int val_dummy; + int val_dummy; struct VAttListData *val_next; -} VAttListData; +} VAttListData; typedef VAttListData *VAttList; typedef struct VPageDescrData { - BlockNumber vpd_blkno; /* BlockNumber of this Page */ - Size vpd_free; /* FreeSpace on this Page */ - uint16 vpd_nusd; /* Number of OffNums used by vacuum */ - uint16 vpd_noff; /* Number of OffNums free or to be free */ - OffsetNumber vpd_voff[1];/* Array of its OffNums */ -} VPageDescrData; + BlockNumber vpd_blkno; /* BlockNumber of this Page */ + Size vpd_free; /* FreeSpace on this Page */ + uint16 vpd_nusd; /* Number of OffNums used by vacuum */ + uint16 vpd_noff; /* Number of OffNums free or to be free */ + OffsetNumber vpd_voff[1]; /* Array of its OffNums */ +} VPageDescrData; typedef VPageDescrData *VPageDescr; typedef struct VPageListData { - int vpl_nemend; /* Number of "empty" end-pages */ - int vpl_npages; /* Number of pages in vpl_pgdesc */ - VPageDescr *vpl_pgdesc; /* Descriptions of pages */ -} VPageListData; + int vpl_nemend; /* Number of "empty" end-pages */ + int vpl_npages; /* Number of pages in vpl_pgdesc */ + VPageDescr *vpl_pgdesc; /* Descriptions of pages */ +} VPageListData; typedef VPageListData *VPageList; typedef struct { - FuncIndexInfo finfo; - FuncIndexInfo *finfoP; - IndexTupleForm tform; - int natts; -} IndDesc; + FuncIndexInfo finfo; + FuncIndexInfo *finfoP; + IndexTupleForm tform; + int natts; +} IndDesc; typedef struct { AttributeTupleForm attr; - Datum best, - guess1, - guess2, - max, - min; - int16 best_len, - guess1_len, - guess2_len, - max_len, - min_len; - int32 best_cnt, - guess1_cnt, - guess1_hits, - guess2_hits, - null_cnt, - nonnull_cnt; - int32 max_cnt, - min_cnt; - func_ptr f_cmpeq, - f_cmplt, - f_cmpgt; - regproc outfunc; - bool initialized; -} VacAttrStats; + Datum best, + guess1, + guess2, + max, + min; + int16 best_len, + guess1_len, + guess2_len, + max_len, + min_len; + int32 best_cnt, + guess1_cnt, + guess1_hits, + guess2_hits, + null_cnt, + nonnull_cnt; + int32 max_cnt, + min_cnt; + func_ptr f_cmpeq, + f_cmplt, + f_cmpgt; + regproc outfunc; + bool initialized; +} VacAttrStats; typedef struct VRelListData { - Oid vrl_relid; + Oid vrl_relid; struct VRelListData *vrl_next; -} VRelListData; +} VRelListData; typedef VRelListData *VRelList; typedef struct VRelStats { - Oid relid; - int ntups; - int npages; - Size min_tlen; - Size max_tlen; - bool hasindex; - int va_natts; /* number of attrs being analyzed */ - VacAttrStats *vacattrstats; -} VRelStats; - -extern bool VacuumRunning; - -extern void vc_abort(void); -extern void vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec); + Oid relid; + int ntups; + int npages; + Size min_tlen; + Size max_tlen; + bool hasindex; + int va_natts; /* number of attrs being analyzed */ + VacAttrStats *vacattrstats; +} VRelStats; + +extern bool VacuumRunning; + +extern void vc_abort(void); +extern void vacuum(char *vacrel, bool verbose, bool analyze, List * va_spec); #define ATTNVALS_SCALE 1000000000 /* XXX so it can act as a float4 */ diff --git a/src/include/commands/view.h b/src/include/commands/view.h index 2e46fb6f4df..f4190c1f0be 100644 --- a/src/include/commands/view.h +++ b/src/include/commands/view.h @@ -6,15 +6,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: view.h,v 1.2 1997/09/07 04:57:40 momjian Exp $ + * $Id: view.h,v 1.3 1997/09/08 02:36:05 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef VIEW_H #define VIEW_H -extern char *MakeRetrieveViewRuleName(char *view_name); -extern void DefineView(char *view_name, Query * view_parse); -extern void RemoveView(char *view_name); +extern char *MakeRetrieveViewRuleName(char *view_name); +extern void DefineView(char *view_name, Query * view_parse); +extern void RemoveView(char *view_name); #endif /* VIEW_H */ diff --git a/src/include/executor/execFlatten.h b/src/include/executor/execFlatten.h index d51864edf0e..3682f6319b5 100644 --- a/src/include/executor/execFlatten.h +++ b/src/include/executor/execFlatten.h @@ -6,16 +6,16 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execFlatten.h,v 1.3 1997/09/07 04:57:41 momjian Exp $ + * $Id: execFlatten.h,v 1.4 1997/09/08 02:36:08 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef EXECFLATTEN_H #define EXECFLATTEN_H -extern Datum ExecEvalIter(Iter * iterNode, ExprContext * econtext, bool * resultIsNull, bool * iterIsDone); +extern Datum ExecEvalIter(Iter * iterNode, ExprContext * econtext, bool * resultIsNull, bool * iterIsDone); -extern void ExecEvalFjoin(TargetEntry * tlist, ExprContext * econtext, bool * isNullVect, bool * fj_isDone); +extern void ExecEvalFjoin(TargetEntry * tlist, ExprContext * econtext, bool * isNullVect, bool * fj_isDone); #endif /* EXECFLATTEN_H */ diff --git a/src/include/executor/execdebug.h b/src/include/executor/execdebug.h index 61d298403b3..4337b3d1b4c 100644 --- a/src/include/executor/execdebug.h +++ b/src/include/executor/execdebug.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execdebug.h,v 1.3 1997/09/07 04:57:44 momjian Exp $ + * $Id: execdebug.h,v 1.4 1997/09/08 02:36:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -176,13 +176,13 @@ * ---------------- */ #ifdef EXEC_TUPLECOUNT -extern int NTupleProcessed; -extern int NTupleRetrieved; -extern int NTupleReplaced; -extern int NTupleAppended; -extern int NTupleDeleted; -extern int NIndexTupleProcessed; -extern int NIndexTupleInserted; +extern int NTupleProcessed; +extern int NTupleRetrieved; +extern int NTupleReplaced; +extern int NTupleAppended; +extern int NTupleDeleted; +extern int NIndexTupleProcessed; +extern int NIndexTupleInserted; #define IncrRetrieved() NTupleRetrieved++ #define IncrAppended() NTupleAppended++ @@ -377,7 +377,7 @@ extern int NIndexTupleInserted; */ #undef NOTYET -extern long NDirectFileRead; -extern long NDirectFileWrite; +extern long NDirectFileRead; +extern long NDirectFileWrite; #endif /* ExecDebugIncluded */ diff --git a/src/include/executor/execdesc.h b/src/include/executor/execdesc.h index 7f24b7630f0..f97e196f4fe 100644 --- a/src/include/executor/execdesc.h +++ b/src/include/executor/execdesc.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execdesc.h,v 1.4 1997/09/07 04:57:47 momjian Exp $ + * $Id: execdesc.h,v 1.5 1997/09/08 02:36:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,11 +26,11 @@ */ typedef struct QueryDesc { - CmdType operation; /* CMD_SELECT, CMD_UPDATE, etc. */ - Query *parsetree; - Plan *plantree; - CommandDest dest; /* the destination output of the execution */ -} QueryDesc; + CmdType operation; /* CMD_SELECT, CMD_UPDATE, etc. */ + Query *parsetree; + Plan *plantree; + CommandDest dest; /* the destination output of the execution */ +} QueryDesc; /* in pquery.c */ extern QueryDesc * diff --git a/src/include/executor/executor.h b/src/include/executor/executor.h index c96f7439b6c..efa8dc3f01d 100644 --- a/src/include/executor/executor.h +++ b/src/include/executor/executor.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: executor.h,v 1.11 1997/09/07 04:57:47 momjian Exp $ + * $Id: executor.h,v 1.12 1997/09/08 02:36:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,20 +30,20 @@ extern void ExecOpenScanR(Oid relOid, int nkeys, ScanKey skeys, bool isindex, ScanDirection dir, TimeQual timeRange, Relation * returnRelation, Pointer * returnScanDesc); -extern void ExecCloseR(Plan * node); -extern void ExecReScan(Plan * node, ExprContext * exprCtxt, Plan * parent); -extern HeapScanDesc +extern void ExecCloseR(Plan * node); +extern void ExecReScan(Plan * node, ExprContext * exprCtxt, Plan * parent); +extern HeapScanDesc ExecReScanR(Relation relDesc, HeapScanDesc scanDesc, ScanDirection direction, int nkeys, ScanKey skeys); -extern void ExecMarkPos(Plan * node); -extern void ExecRestrPos(Plan * node); +extern void ExecMarkPos(Plan * node); +extern void ExecRestrPos(Plan * node); extern Relation ExecCreatR(TupleDesc tupType, Oid relationOid); /* * prototypes from functions in execJunk.c */ extern JunkFilter *ExecInitJunkFilter(List * targetList); -extern bool +extern bool ExecGetJunkAttribute(JunkFilter * junkfilter, TupleTableSlot * slot, char *attrName, Datum * value, bool * isNull); extern HeapTuple ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot); @@ -54,39 +54,39 @@ extern HeapTuple ExecRemoveJunk(JunkFilter * junkfilter, TupleTableSlot * slot); */ extern TupleDesc ExecutorStart(QueryDesc * queryDesc, EState * estate); extern TupleTableSlot *ExecutorRun(QueryDesc * queryDesc, EState * estate, int feature, int count); -extern void ExecutorEnd(QueryDesc * queryDesc, EState * estate); +extern void ExecutorEnd(QueryDesc * queryDesc, EState * estate); extern HeapTuple ExecConstraints(char *caller, Relation rel, HeapTuple tuple); /* * prototypes from functions in execProcnode.c */ -extern bool ExecInitNode(Plan * node, EState * estate, Plan * parent); +extern bool ExecInitNode(Plan * node, EState * estate, Plan * parent); extern TupleTableSlot *ExecProcNode(Plan * node, Plan * parent); -extern int ExecCountSlotsNode(Plan * node); -extern void ExecEndNode(Plan * node, Plan * parent); +extern int ExecCountSlotsNode(Plan * node); +extern void ExecEndNode(Plan * node, Plan * parent); /* * prototypes from functions in execQual.c */ -extern bool execConstByVal; -extern int execConstLen; +extern bool execConstByVal; +extern int execConstLen; -extern Datum +extern Datum ExecExtractResult(TupleTableSlot * slot, AttrNumber attnum, bool * isNull); -extern Datum +extern Datum ExecEvalParam(Param * expression, ExprContext * econtext, bool * isNull); /* stop here */ -extern char * +extern char * GetAttributeByName(TupleTableSlot * slot, char *attname, bool * isNull); -extern Datum +extern Datum ExecEvalExpr(Node * expression, ExprContext * econtext, bool * isNull, bool * isDone); -extern bool ExecQual(List * qual, ExprContext * econtext); -extern int ExecTargetListLength(List * targetlist); +extern bool ExecQual(List * qual, ExprContext * econtext); +extern int ExecTargetListLength(List * targetlist); extern TupleTableSlot *ExecProject(ProjectionInfo * projInfo, bool * isDone); /* @@ -98,7 +98,7 @@ extern TupleTableSlot *ExecScan(Scan * node, TupleTableSlot * (*accessMtd) ()); * prototypes from functions in execTuples.c */ extern TupleTable ExecCreateTupleTable(int initialSize); -extern void ExecDestroyTupleTable(TupleTable table, bool shouldFree); +extern void ExecDestroyTupleTable(TupleTable table, bool shouldFree); extern TupleTableSlot *ExecAllocTableSlot(TupleTable table); extern TupleTableSlot * ExecStoreTuple(HeapTuple tuple, @@ -106,19 +106,19 @@ ExecStoreTuple(HeapTuple tuple, Buffer buffer, bool shouldFree); extern TupleTableSlot *ExecClearTuple(TupleTableSlot * slot); -extern bool ExecSetSlotPolicy(TupleTableSlot * slot, bool shouldFree); -extern TupleDesc +extern bool ExecSetSlotPolicy(TupleTableSlot * slot, bool shouldFree); +extern TupleDesc ExecSetSlotDescriptor(TupleTableSlot * slot, TupleDesc tupdesc); -extern void ExecSetSlotDescriptorIsNew(TupleTableSlot * slot, bool isNew); -extern void ExecIncrSlotBufferRefcnt(TupleTableSlot * slot); -extern bool TupIsNull(TupleTableSlot * slot); -extern void ExecInitResultTupleSlot(EState * estate, CommonState * commonstate); +extern void ExecSetSlotDescriptorIsNew(TupleTableSlot * slot, bool isNew); +extern void ExecIncrSlotBufferRefcnt(TupleTableSlot * slot); +extern bool TupIsNull(TupleTableSlot * slot); +extern void ExecInitResultTupleSlot(EState * estate, CommonState * commonstate); extern void ExecInitScanTupleSlot(EState * estate, CommonScanState * commonscanstate); -extern void ExecInitMarkedTupleSlot(EState * estate, MergeJoinState * mergestate); -extern void ExecInitOuterTupleSlot(EState * estate, HashJoinState * hashstate); +extern void ExecInitMarkedTupleSlot(EState * estate, MergeJoinState * mergestate); +extern void ExecInitOuterTupleSlot(EState * estate, HashJoinState * hashstate); extern TupleDesc ExecGetTupType(Plan * node); extern TupleDesc ExecTypeFromTL(List * targetList); @@ -126,21 +126,21 @@ extern TupleDesc ExecTypeFromTL(List * targetList); /* * prototypes from functions in execTuples.c */ -extern void ResetTupleCount(void); +extern void ResetTupleCount(void); extern void ExecAssignNodeBaseInfo(EState * estate, CommonState * basenode, Plan * parent); -extern void ExecAssignExprContext(EState * estate, CommonState * commonstate); +extern void ExecAssignExprContext(EState * estate, CommonState * commonstate); extern void ExecAssignResultType(CommonState * commonstate, TupleDesc tupDesc); extern void ExecAssignResultTypeFromOuterPlan(Plan * node, CommonState * commonstate); -extern void ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate); +extern void ExecAssignResultTypeFromTL(Plan * node, CommonState * commonstate); extern TupleDesc ExecGetResultType(CommonState * commonstate); -extern void ExecAssignProjectionInfo(Plan * node, CommonState * commonstate); -extern void ExecFreeProjectionInfo(CommonState * commonstate); +extern void ExecAssignProjectionInfo(Plan * node, CommonState * commonstate); +extern void ExecFreeProjectionInfo(CommonState * commonstate); extern TupleDesc ExecGetScanType(CommonScanState * csstate); extern void ExecAssignScanType(CommonScanState * csstate, @@ -153,11 +153,11 @@ extern AttributeTupleForm ExecGetTypeInfo(Relation relDesc); extern void ExecOpenIndices(Oid resultRelationOid, RelationInfo * resultRelationInfo); -extern void ExecCloseIndices(RelationInfo * resultRelationInfo); +extern void ExecCloseIndices(RelationInfo * resultRelationInfo); extern void ExecInsertIndexTuples(TupleTableSlot * slot, ItemPointer tupleid, EState * estate, bool is_update); -extern void resetVarAttrLenForCreateTable(TupleDesc tupType); +extern void resetVarAttrLenForCreateTable(TupleDesc tupType); extern void setVarAttrLenForCreateTable(TupleDesc tupType, List * targetList, List * rangeTable); diff --git a/src/include/executor/functions.h b/src/include/executor/functions.h index 475f9309b8c..72b399663ca 100644 --- a/src/include/executor/functions.h +++ b/src/include/executor/functions.h @@ -6,18 +6,18 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: functions.h,v 1.2 1997/09/07 04:57:48 momjian Exp $ + * $Id: functions.h,v 1.3 1997/09/08 02:36:18 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef FUNCTIONS_H #define FUNCTIONS_H -extern Datum +extern Datum ProjectAttribute(TupleDesc TD, TargetEntry * tlist, HeapTuple tup, bool * isnullP); -extern Datum +extern Datum postquel_function(Func * funcNode, char **args, bool * isNull, bool * isDone); diff --git a/src/include/executor/hashjoin.h b/src/include/executor/hashjoin.h index e705c5c77d6..6950bb25bde 100644 --- a/src/include/executor/hashjoin.h +++ b/src/include/executor/hashjoin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hashjoin.h,v 1.4 1997/09/07 04:57:49 momjian Exp $ + * $Id: hashjoin.h,v 1.5 1997/09/08 02:36:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ * because the hashtable may reallocate in difference processes * ----------------- */ -typedef int RelativeAddr; +typedef int RelativeAddr; /* ------------------ * the relative addresses are always relative to the head of the @@ -30,8 +30,8 @@ typedef int RelativeAddr; #define ABSADDR(X) ((X) < 0 ? NULL: (char*)hashtable + X) #define RELADDR(X) (RelativeAddr)((char*)(X) - (char*)hashtable) -typedef char **charPP; -typedef int *intP; +typedef char **charPP; +typedef int *intP; /* ---------------------------------------------------------------- * hash-join hash table structures @@ -39,43 +39,43 @@ typedef int *intP; */ typedef struct HashTableData { - int nbuckets; - int totalbuckets; - int bucketsize; - IpcMemoryId shmid; - RelativeAddr top; /* char* */ - RelativeAddr bottom; /* char* */ - RelativeAddr overflownext; /* char* */ - RelativeAddr batch; /* char* */ - RelativeAddr readbuf; /* char* */ - int nbatch; - RelativeAddr outerbatchNames; /* RelativeAddr* */ - RelativeAddr outerbatchPos; /* RelativeAddr* */ - RelativeAddr innerbatchNames; /* RelativeAddr* */ - RelativeAddr innerbatchPos; /* RelativeAddr* */ - RelativeAddr innerbatchSizes; /* int* */ - int curbatch; - int nprocess; - int pcount; -} HashTableData; /* real hash table follows here */ + int nbuckets; + int totalbuckets; + int bucketsize; + IpcMemoryId shmid; + RelativeAddr top; /* char* */ + RelativeAddr bottom; /* char* */ + RelativeAddr overflownext; /* char* */ + RelativeAddr batch; /* char* */ + RelativeAddr readbuf; /* char* */ + int nbatch; + RelativeAddr outerbatchNames; /* RelativeAddr* */ + RelativeAddr outerbatchPos; /* RelativeAddr* */ + RelativeAddr innerbatchNames; /* RelativeAddr* */ + RelativeAddr innerbatchPos; /* RelativeAddr* */ + RelativeAddr innerbatchSizes; /* int* */ + int curbatch; + int nprocess; + int pcount; +} HashTableData; /* real hash table follows here */ typedef HashTableData *HashJoinTable; typedef struct OverflowTupleData { - RelativeAddr tuple; /* HeapTuple */ - RelativeAddr next; /* struct OverflowTupleData * */ -} OverflowTupleData; /* real tuple follows here */ + RelativeAddr tuple; /* HeapTuple */ + RelativeAddr next; /* struct OverflowTupleData * */ +} OverflowTupleData; /* real tuple follows here */ typedef OverflowTupleData *OverflowTuple; typedef struct HashBucketData { - RelativeAddr top; /* HeapTuple */ - RelativeAddr bottom; /* HeapTuple */ - RelativeAddr firstotuple;/* OverflowTuple */ - RelativeAddr lastotuple; /* OverflowTuple */ -} HashBucketData; /* real bucket follows here */ + RelativeAddr top; /* HeapTuple */ + RelativeAddr bottom; /* HeapTuple */ + RelativeAddr firstotuple; /* OverflowTuple */ + RelativeAddr lastotuple; /* OverflowTuple */ +} HashBucketData; /* real bucket follows here */ typedef HashBucketData *HashBucket; diff --git a/src/include/executor/nodeAgg.h b/src/include/executor/nodeAgg.h index bae4f1bc726..01110ba9fc2 100644 --- a/src/include/executor/nodeAgg.h +++ b/src/include/executor/nodeAgg.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeAgg.h,v 1.2 1997/09/07 04:57:50 momjian Exp $ + * $Id: nodeAgg.h,v 1.3 1997/09/08 02:36:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,8 +14,8 @@ #define NODEAGG_H extern TupleTableSlot *ExecAgg(Agg * node); -extern bool ExecInitAgg(Agg * node, EState * estate, Plan * parent); -extern int ExecCountSlotsAgg(Agg * node); -extern void ExecEndAgg(Agg * node); +extern bool ExecInitAgg(Agg * node, EState * estate, Plan * parent); +extern int ExecCountSlotsAgg(Agg * node); +extern void ExecEndAgg(Agg * node); #endif /* NODEAGG_H */ diff --git a/src/include/executor/nodeAppend.h b/src/include/executor/nodeAppend.h index 2aa98a67c5b..0ad131a7c4e 100644 --- a/src/include/executor/nodeAppend.h +++ b/src/include/executor/nodeAppend.h @@ -6,16 +6,16 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeAppend.h,v 1.3 1997/09/07 04:57:51 momjian Exp $ + * $Id: nodeAppend.h,v 1.4 1997/09/08 02:36:22 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef NODEAPPEND_H #define NODEAPPEND_H -extern bool ExecInitAppend(Append * node, EState * estate, Plan * parent); -extern int ExecCountSlotsAppend(Append * node); +extern bool ExecInitAppend(Append * node, EState * estate, Plan * parent); +extern int ExecCountSlotsAppend(Append * node); extern TupleTableSlot *ExecProcAppend(Append * node); -extern void ExecEndAppend(Append * node); +extern void ExecEndAppend(Append * node); #endif /* NODEAPPEND_H */ diff --git a/src/include/executor/nodeGroup.h b/src/include/executor/nodeGroup.h index ddf32d766a5..26d398d8bb5 100644 --- a/src/include/executor/nodeGroup.h +++ b/src/include/executor/nodeGroup.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeGroup.h,v 1.2 1997/09/07 04:57:52 momjian Exp $ + * $Id: nodeGroup.h,v 1.3 1997/09/08 02:36:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,8 +14,8 @@ #define NODEGROUP_H extern TupleTableSlot *ExecGroup(Group * node); -extern bool ExecInitGroup(Group * node, EState * estate, Plan * parent); -extern int ExecCountSlotsGroup(Group * node); -extern void ExecEndGroup(Group * node); +extern bool ExecInitGroup(Group * node, EState * estate, Plan * parent); +extern int ExecCountSlotsGroup(Group * node); +extern void ExecEndGroup(Group * node); #endif /* NODEGROUP_H */ diff --git a/src/include/executor/nodeHash.h b/src/include/executor/nodeHash.h index 561e192aaf5..c18403b030f 100644 --- a/src/include/executor/nodeHash.h +++ b/src/include/executor/nodeHash.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHash.h,v 1.3 1997/09/07 04:57:52 momjian Exp $ + * $Id: nodeHash.h,v 1.4 1997/09/08 02:36:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,21 +14,21 @@ #define NODEHASH_H extern TupleTableSlot *ExecHash(Hash * node); -extern bool ExecInitHash(Hash * node, EState * estate, Plan * parent); -extern int ExecCountSlotsHash(Hash * node); -extern void ExecEndHash(Hash * node); +extern bool ExecInitHash(Hash * node, EState * estate, Plan * parent); +extern int ExecCountSlotsHash(Hash * node); +extern void ExecEndHash(Hash * node); extern HashJoinTable ExecHashTableCreate(Hash * node); extern void ExecHashTableInsert(HashJoinTable hashtable, ExprContext * econtext, Var * hashkey, File * batches); -extern void ExecHashTableDestroy(HashJoinTable hashtable); +extern void ExecHashTableDestroy(HashJoinTable hashtable); extern int ExecHashGetBucket(HashJoinTable hashtable, ExprContext * econtext, Var * hashkey); -extern HeapTuple +extern HeapTuple ExecScanHashBucket(HashJoinState * hjstate, HashBucket bucket, HeapTuple curtuple, List * hjclauses, ExprContext * econtext); -extern void ExecHashTableReset(HashJoinTable hashtable, int ntuples); +extern void ExecHashTableReset(HashJoinTable hashtable, int ntuples); #endif /* NODEHASH_H */ diff --git a/src/include/executor/nodeHashjoin.h b/src/include/executor/nodeHashjoin.h index 17d88862432..e26f92c65fc 100644 --- a/src/include/executor/nodeHashjoin.h +++ b/src/include/executor/nodeHashjoin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeHashjoin.h,v 1.3 1997/09/07 04:57:53 momjian Exp $ + * $Id: nodeHashjoin.h,v 1.4 1997/09/08 02:36:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,13 +15,13 @@ extern TupleTableSlot *ExecHashJoin(HashJoin * node); -extern bool ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent); +extern bool ExecInitHashJoin(HashJoin * node, EState * estate, Plan * parent); -extern int ExecCountSlotsHashJoin(HashJoin * node); +extern int ExecCountSlotsHashJoin(HashJoin * node); -extern void ExecEndHashJoin(HashJoin * node); +extern void ExecEndHashJoin(HashJoin * node); -extern char * +extern char * ExecHashJoinSaveTuple(HeapTuple heapTuple, char *buffer, File file, char *position); diff --git a/src/include/executor/nodeIndexscan.h b/src/include/executor/nodeIndexscan.h index e111f7ed2ee..4137ec90f7b 100644 --- a/src/include/executor/nodeIndexscan.h +++ b/src/include/executor/nodeIndexscan.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeIndexscan.h,v 1.3 1997/09/07 04:57:54 momjian Exp $ + * $Id: nodeIndexscan.h,v 1.4 1997/09/08 02:36:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,20 +15,20 @@ extern TupleTableSlot *ExecIndexScan(IndexScan * node); -extern void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent); +extern void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent); -extern void ExecEndIndexScan(IndexScan * node); +extern void ExecEndIndexScan(IndexScan * node); -extern void ExecIndexMarkPos(IndexScan * node); +extern void ExecIndexMarkPos(IndexScan * node); -extern void ExecIndexRestrPos(IndexScan * node); +extern void ExecIndexRestrPos(IndexScan * node); -extern void ExecUpdateIndexScanKeys(IndexScan * node, ExprContext * econtext); +extern void ExecUpdateIndexScanKeys(IndexScan * node, ExprContext * econtext); -extern bool ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent); +extern bool ExecInitIndexScan(IndexScan * node, EState * estate, Plan * parent); -extern int ExecCountSlotsIndexScan(IndexScan * node); +extern int ExecCountSlotsIndexScan(IndexScan * node); -extern void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent); +extern void ExecIndexReScan(IndexScan * node, ExprContext * exprCtxt, Plan * parent); #endif /* NODEINDEXSCAN_H */ diff --git a/src/include/executor/nodeMaterial.h b/src/include/executor/nodeMaterial.h index c1833b11594..cd97d6b3c9a 100644 --- a/src/include/executor/nodeMaterial.h +++ b/src/include/executor/nodeMaterial.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeMaterial.h,v 1.2 1997/09/07 04:57:55 momjian Exp $ + * $Id: nodeMaterial.h,v 1.3 1997/09/08 02:36:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,10 +14,10 @@ #define NODEMATERIAL_H extern TupleTableSlot *ExecMaterial(Material * node); -extern bool ExecInitMaterial(Material * node, EState * estate, Plan * parent); -extern int ExecCountSlotsMaterial(Material * node); -extern void ExecEndMaterial(Material * node); -extern List ExecMaterialMarkPos(Material * node); -extern void ExecMaterialRestrPos(Material * node); +extern bool ExecInitMaterial(Material * node, EState * estate, Plan * parent); +extern int ExecCountSlotsMaterial(Material * node); +extern void ExecEndMaterial(Material * node); +extern List ExecMaterialMarkPos(Material * node); +extern void ExecMaterialRestrPos(Material * node); #endif /* NODEMATERIAL_H */ diff --git a/src/include/executor/nodeMergejoin.h b/src/include/executor/nodeMergejoin.h index 7e496734b44..5bd870fabd4 100644 --- a/src/include/executor/nodeMergejoin.h +++ b/src/include/executor/nodeMergejoin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeMergejoin.h,v 1.4 1997/09/07 04:57:56 momjian Exp $ + * $Id: nodeMergejoin.h,v 1.5 1997/09/08 02:36:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,10 +15,10 @@ extern TupleTableSlot *ExecMergeJoin(MergeJoin * node); -extern bool ExecInitMergeJoin(MergeJoin * node, EState * estate, Plan * parent); +extern bool ExecInitMergeJoin(MergeJoin * node, EState * estate, Plan * parent); -extern int ExecCountSlotsMergeJoin(MergeJoin * node); +extern int ExecCountSlotsMergeJoin(MergeJoin * node); -extern void ExecEndMergeJoin(MergeJoin * node); +extern void ExecEndMergeJoin(MergeJoin * node); #endif /* NODEMERGEJOIN_H; */ diff --git a/src/include/executor/nodeNestloop.h b/src/include/executor/nodeNestloop.h index 8b387841e60..f68539e2929 100644 --- a/src/include/executor/nodeNestloop.h +++ b/src/include/executor/nodeNestloop.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeNestloop.h,v 1.2 1997/09/07 04:57:57 momjian Exp $ + * $Id: nodeNestloop.h,v 1.3 1997/09/08 02:36:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,8 +14,8 @@ #define NODENESTLOOP_H extern TupleTableSlot *ExecNestLoop(NestLoop * node, Plan * parent); -extern bool ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent); -extern int ExecCountSlotsNestLoop(NestLoop * node); -extern void ExecEndNestLoop(NestLoop * node); +extern bool ExecInitNestLoop(NestLoop * node, EState * estate, Plan * parent); +extern int ExecCountSlotsNestLoop(NestLoop * node); +extern void ExecEndNestLoop(NestLoop * node); #endif /* NODENESTLOOP_H */ diff --git a/src/include/executor/nodeResult.h b/src/include/executor/nodeResult.h index 40ef4a7b4da..2dcb411db94 100644 --- a/src/include/executor/nodeResult.h +++ b/src/include/executor/nodeResult.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeResult.h,v 1.2 1997/09/07 04:57:58 momjian Exp $ + * $Id: nodeResult.h,v 1.3 1997/09/08 02:36:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,8 +14,8 @@ #define NODERESULT_H extern TupleTableSlot *ExecResult(Result * node); -extern bool ExecInitResult(Result * node, EState * estate, Plan * parent); -extern int ExecCountSlotsResult(Result * node); -extern void ExecEndResult(Result * node); +extern bool ExecInitResult(Result * node, EState * estate, Plan * parent); +extern int ExecCountSlotsResult(Result * node); +extern void ExecEndResult(Result * node); #endif /* NODERESULT_H */ diff --git a/src/include/executor/nodeSeqscan.h b/src/include/executor/nodeSeqscan.h index 56237dc80d4..22154ea1f2c 100644 --- a/src/include/executor/nodeSeqscan.h +++ b/src/include/executor/nodeSeqscan.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSeqscan.h,v 1.3 1997/09/07 04:57:59 momjian Exp $ + * $Id: nodeSeqscan.h,v 1.4 1997/09/08 02:36:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,11 +14,11 @@ #define NODESEQSCAN_H extern TupleTableSlot *ExecSeqScan(SeqScan * node); -extern bool ExecInitSeqScan(SeqScan * node, EState * estate, Plan * parent); -extern int ExecCountSlotsSeqScan(SeqScan * node); -extern void ExecEndSeqScan(SeqScan * node); -extern void ExecSeqReScan(SeqScan * node, ExprContext * exprCtxt, Plan * parent); -extern void ExecSeqMarkPos(SeqScan * node); -extern void ExecSeqRestrPos(SeqScan * node); +extern bool ExecInitSeqScan(SeqScan * node, EState * estate, Plan * parent); +extern int ExecCountSlotsSeqScan(SeqScan * node); +extern void ExecEndSeqScan(SeqScan * node); +extern void ExecSeqReScan(SeqScan * node, ExprContext * exprCtxt, Plan * parent); +extern void ExecSeqMarkPos(SeqScan * node); +extern void ExecSeqRestrPos(SeqScan * node); #endif /* NODESEQSCAN_H */ diff --git a/src/include/executor/nodeSort.h b/src/include/executor/nodeSort.h index 428805702eb..a4c0a1b388c 100644 --- a/src/include/executor/nodeSort.h +++ b/src/include/executor/nodeSort.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeSort.h,v 1.2 1997/09/07 04:58:00 momjian Exp $ + * $Id: nodeSort.h,v 1.3 1997/09/08 02:36:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,10 +14,10 @@ #define NODESORT_H extern TupleTableSlot *ExecSort(Sort * node); -extern bool ExecInitSort(Sort * node, EState * estate, Plan * parent); -extern int ExecCountSlotsSort(Sort * node); -extern void ExecEndSort(Sort * node); -extern void ExecSortMarkPos(Sort * node); -extern void ExecSortRestrPos(Sort * node); +extern bool ExecInitSort(Sort * node, EState * estate, Plan * parent); +extern int ExecCountSlotsSort(Sort * node); +extern void ExecEndSort(Sort * node); +extern void ExecSortMarkPos(Sort * node); +extern void ExecSortRestrPos(Sort * node); #endif /* NODESORT_H */ diff --git a/src/include/executor/nodeTee.h b/src/include/executor/nodeTee.h index 7235030d670..a0fb3831424 100644 --- a/src/include/executor/nodeTee.h +++ b/src/include/executor/nodeTee.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeTee.h,v 1.2 1997/09/07 04:58:00 momjian Exp $ + * $Id: nodeTee.h,v 1.3 1997/09/08 02:36:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,9 +14,9 @@ #define NODETEE_H extern TupleTableSlot *ExecTee(Tee * node, Plan * parent); -extern bool ExecInitTee(Tee * node, EState * estate, Plan * parent); -extern void ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent); -extern void ExecEndTee(Tee * node, Plan * parent); -extern int ExecCountSlotsTee(Tee * node); +extern bool ExecInitTee(Tee * node, EState * estate, Plan * parent); +extern void ExecTeeReScan(Tee * node, ExprContext * exprCtxt, Plan * parent); +extern void ExecEndTee(Tee * node, Plan * parent); +extern int ExecCountSlotsTee(Tee * node); #endif /* NODETEE_H */ diff --git a/src/include/executor/nodeUnique.h b/src/include/executor/nodeUnique.h index c66fa827cab..24042581f34 100644 --- a/src/include/executor/nodeUnique.h +++ b/src/include/executor/nodeUnique.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeUnique.h,v 1.2 1997/09/07 04:58:01 momjian Exp $ + * $Id: nodeUnique.h,v 1.3 1997/09/08 02:36:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,8 +14,8 @@ #define NODEUNIQUE_H extern TupleTableSlot *ExecUnique(Unique * node); -extern bool ExecInitUnique(Unique * node, EState * estate, Plan * parent); -extern int ExecCountSlotsUnique(Unique * node); -extern void ExecEndUnique(Unique * node); +extern bool ExecInitUnique(Unique * node, EState * estate, Plan * parent); +extern int ExecCountSlotsUnique(Unique * node); +extern void ExecEndUnique(Unique * node); #endif /* NODEUNIQUE_H */ diff --git a/src/include/executor/spi.h b/src/include/executor/spi.h index fee2056f9f8..34ffef800ab 100644 --- a/src/include/executor/spi.h +++ b/src/include/executor/spi.h @@ -36,11 +36,11 @@ typedef struct { - uint32 alloced; /* # of alloced vals */ - uint32 free; /* # of free vals */ - TupleDesc tupdesc; /* tuple descriptor */ - HeapTuple *vals; /* tuples */ -} SPITupleTable; + uint32 alloced; /* # of alloced vals */ + uint32 free; /* # of free vals */ + TupleDesc tupdesc; /* tuple descriptor */ + HeapTuple *vals; /* tuples */ +} SPITupleTable; #define SPI_ERROR_CONNECT -1 #define SPI_ERROR_COPY -2 @@ -65,22 +65,22 @@ typedef struct #define SPI_OK_UPDATE 9 #define SPI_OK_CURSOR 10 -extern uint32 SPI_processed; +extern uint32 SPI_processed; extern SPITupleTable *SPI_tuptable; -extern int SPI_result; +extern int SPI_result; -extern int SPI_connect(void); -extern int SPI_finish(void); -extern int SPI_exec(char *src, int tcount); -extern int SPI_execp(void *plan, char **values, char *Nulls, int tcount); -extern void *SPI_prepare(char *src, int nargs, Oid * argtypes); -extern void *SPI_saveplan(void *plan); +extern int SPI_connect(void); +extern int SPI_finish(void); +extern int SPI_exec(char *src, int tcount); +extern int SPI_execp(void *plan, char **values, char *Nulls, int tcount); +extern void *SPI_prepare(char *src, int nargs, Oid * argtypes); +extern void *SPI_saveplan(void *plan); -extern int SPI_fnumber(TupleDesc tupdesc, char *fname); -extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber); -extern char *SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull); -extern char *SPI_gettype(TupleDesc tupdesc, int fnumber); -extern Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber); -extern char *SPI_getrelname(Relation rel); +extern int SPI_fnumber(TupleDesc tupdesc, char *fname); +extern char *SPI_getvalue(HeapTuple tuple, TupleDesc tupdesc, int fnumber); +extern char *SPI_getbinval(HeapTuple tuple, TupleDesc tupdesc, int fnumber, bool * isnull); +extern char *SPI_gettype(TupleDesc tupdesc, int fnumber); +extern Oid SPI_gettypeid(TupleDesc tupdesc, int fnumber); +extern char *SPI_getrelname(Relation rel); #endif /* SPI_H */ diff --git a/src/include/executor/tuptable.h b/src/include/executor/tuptable.h index fcef30cd8e4..ae824188163 100644 --- a/src/include/executor/tuptable.h +++ b/src/include/executor/tuptable.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tuptable.h,v 1.5 1997/09/07 04:58:03 momjian Exp $ + * $Id: tuptable.h,v 1.6 1997/09/08 02:36:45 momjian Exp $ * * NOTES * The tuple table interface is getting pretty ugly. @@ -46,14 +46,14 @@ */ typedef struct TupleTableSlot { - NodeTag type; - HeapTuple val; - bool ttc_shouldFree; - bool ttc_descIsNew; - TupleDesc ttc_tupleDescriptor; - Buffer ttc_buffer; - int ttc_whichplan; -} TupleTableSlot; + NodeTag type; + HeapTuple val; + bool ttc_shouldFree; + bool ttc_descIsNew; + TupleDesc ttc_tupleDescriptor; + Buffer ttc_buffer; + int ttc_whichplan; +} TupleTableSlot; /* ---------------- * tuple table data structure @@ -61,10 +61,10 @@ typedef struct TupleTableSlot */ typedef struct TupleTableData { - int size; /* size of the table */ - int next; /* next available slot number */ + int size; /* size of the table */ + int next; /* next available slot number */ TupleTableSlot *array; /* array of TupleTableSlot's */ -} TupleTableData; +} TupleTableData; typedef TupleTableData *TupleTable; diff --git a/src/include/lib/dllist.h b/src/include/lib/dllist.h index 15a18d88c6f..af0c580cc93 100644 --- a/src/include/lib/dllist.h +++ b/src/include/lib/dllist.h @@ -26,7 +26,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dllist.h,v 1.5 1997/09/07 04:58:07 momjian Exp $ + * $Id: dllist.h,v 1.6 1997/09/08 02:36:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,32 +40,32 @@ struct Dlelem; typedef struct Dlelem { - struct Dlelem *dle_next; /* next element */ - struct Dlelem *dle_prev; /* previous element */ - void *dle_val; /* value of the element */ - struct Dllist *dle_list; /* what list this element is in */ -} Dlelem; + struct Dlelem *dle_next; /* next element */ + struct Dlelem *dle_prev; /* previous element */ + void *dle_val; /* value of the element */ + struct Dllist *dle_list; /* what list this element is in */ +} Dlelem; typedef struct Dllist { - Dlelem *dll_head; - Dlelem *dll_tail; -} Dllist; + Dlelem *dll_head; + Dlelem *dll_tail; +} Dllist; -extern Dllist *DLNewList(void);/* initialize a new list */ -extern void DLFreeList(Dllist *); /* free up a list and all the +extern Dllist *DLNewList(void); /* initialize a new list */ +extern void DLFreeList(Dllist *); /* free up a list and all the * nodes in it */ -extern Dlelem *DLNewElem(void *val); -extern void DLFreeElem(Dlelem *); -extern Dlelem *DLGetHead(Dllist *); -extern Dlelem *DLGetTail(Dllist *); -extern Dlelem *DLRemTail(Dllist * l); -extern Dlelem *DLGetPred(Dlelem *); /* get predecessor */ -extern Dlelem *DLGetSucc(Dlelem *); /* get successor */ -extern void DLRemove(Dlelem *); /* removes node from list */ -extern void DLAddHead(Dllist * list, Dlelem * node); -extern void DLAddTail(Dllist * list, Dlelem * node); -extern Dlelem *DLRemHead(Dllist * list); /* remove and return the +extern Dlelem *DLNewElem(void *val); +extern void DLFreeElem(Dlelem *); +extern Dlelem *DLGetHead(Dllist *); +extern Dlelem *DLGetTail(Dllist *); +extern Dlelem *DLRemTail(Dllist * l); +extern Dlelem *DLGetPred(Dlelem *); /* get predecessor */ +extern Dlelem *DLGetSucc(Dlelem *); /* get successor */ +extern void DLRemove(Dlelem *); /* removes node from list */ +extern void DLAddHead(Dllist * list, Dlelem * node); +extern void DLAddTail(Dllist * list, Dlelem * node); +extern Dlelem *DLRemHead(Dllist * list); /* remove and return the * head */ #define DLE_VAL(x) (x->dle_val) diff --git a/src/include/lib/fstack.h b/src/include/lib/fstack.h index 99f10b9006c..f5236c67bba 100644 --- a/src/include/lib/fstack.h +++ b/src/include/lib/fstack.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fstack.h,v 1.3 1997/09/07 04:58:09 momjian Exp $ + * $Id: fstack.h,v 1.4 1997/09/08 02:36:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ typedef FixedItemData *FixedItem; struct FixedItemData { - FixedItem next; /* next item or NULL */ + FixedItem next; /* next item or NULL */ }; /* @@ -48,10 +48,10 @@ struct FixedItemData */ typedef struct FixedStackData { - FixedItem top; /* Top item on the stack or NULL */ - Offset offset; /* Offset from struct base to item */ + FixedItem top; /* Top item on the stack or NULL */ + Offset offset; /* Offset from struct base to item */ /* this could be signed short int! */ -} FixedStackData; +} FixedStackData; typedef FixedStackData *FixedStack; @@ -62,7 +62,7 @@ typedef FixedStackData *FixedStack; * Exceptions: * BadArg if stack is invalid pointer. */ -extern void FixedStackInit(FixedStack stack, Offset offset); +extern void FixedStackInit(FixedStack stack, Offset offset); /* * FixedStackPop -- @@ -71,7 +71,7 @@ extern void FixedStackInit(FixedStack stack, Offset offset); * Exceptions: * BadArg if stack is invalid. */ -Pointer FixedStackPop(FixedStack stack); +Pointer FixedStackPop(FixedStack stack); /* * FixedStackPush -- @@ -81,7 +81,7 @@ Pointer FixedStackPop(FixedStack stack); * BadArg if stack is invalid. * BadArg if pointer is invalid. */ -extern void FixedStackPush(FixedStack stack, Pointer pointer); +extern void FixedStackPush(FixedStack stack, Pointer pointer); /* * FixedStackGetTop -- @@ -94,7 +94,7 @@ extern void FixedStackPush(FixedStack stack, Pointer pointer); * Exceptions: * BadArg if stack is invalid. */ -extern Pointer FixedStackGetTop(FixedStack stack); +extern Pointer FixedStackGetTop(FixedStack stack); /* * FixedStackGetNext -- @@ -109,6 +109,6 @@ extern Pointer FixedStackGetTop(FixedStack stack); * BadArg if pointer is invalid. * BadArg if stack does not contain pointer. */ -extern Pointer FixedStackGetNext(FixedStack stack, Pointer pointer); +extern Pointer FixedStackGetNext(FixedStack stack, Pointer pointer); #endif /* FSTACK_H */ diff --git a/src/include/lib/hasht.h b/src/include/lib/hasht.h index 1d28c2ca28f..4c036f8e25c 100644 --- a/src/include/lib/hasht.h +++ b/src/include/lib/hasht.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hasht.h,v 1.3 1997/09/07 04:58:11 momjian Exp $ + * $Id: hasht.h,v 1.4 1997/09/08 02:36:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,8 +16,8 @@ #include <utils/hsearch.h> -typedef void (*HashtFunc) (); +typedef void (*HashtFunc) (); -extern void HashTableWalk(HTAB * hashtable, HashtFunc function, int arg); +extern void HashTableWalk(HTAB * hashtable, HashtFunc function, int arg); #endif /* HASHT_H */ diff --git a/src/include/lib/stringinfo.h b/src/include/lib/stringinfo.h index f127d8cdd01..b2b71ef27d0 100644 --- a/src/include/lib/stringinfo.h +++ b/src/include/lib/stringinfo.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.h,v 1.3 1997/09/07 04:58:14 momjian Exp $ + * $Id: stringinfo.h,v 1.4 1997/09/08 02:36:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,10 +25,10 @@ */ typedef struct StringInfoData { - char *data; - int maxlen; - int len; -} StringInfoData; + char *data; + int maxlen; + int len; +} StringInfoData; typedef StringInfoData *StringInfo; @@ -42,6 +42,6 @@ extern StringInfo makeStringInfo(void); * appendStringInfo * similar to 'strcat' but reallocates more space if necessary... */ -extern void appendStringInfo(StringInfo str, char *buffer); +extern void appendStringInfo(StringInfo str, char *buffer); #endif /* STRINGINFO_H */ diff --git a/src/include/libpq/auth.h b/src/include/libpq/auth.h index a159b7a5ebd..11f57f1b9e9 100644 --- a/src/include/libpq/auth.h +++ b/src/include/libpq/auth.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: auth.h,v 1.5 1997/09/07 04:58:16 momjian Exp $ + * $Id: auth.h,v 1.6 1997/09/08 02:36:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,12 +30,12 @@ #define DEFAULT_CLIENT_AUTHSVC "kerberos" #endif /* KRB4 || KRB5 */ -extern int fe_sendauth(MsgType msgtype, Port * port, char *hostname); -extern void fe_setauthsvc(char *name); -extern MsgType fe_getauthsvc(); -extern char *fe_getauthname(void); -extern int be_recvauth(MsgType msgtype, Port * port, char *username, StartupInfo * sp); -extern void be_setauthsvc(char *name); +extern int fe_sendauth(MsgType msgtype, Port * port, char *hostname); +extern void fe_setauthsvc(char *name); +extern MsgType fe_getauthsvc(); +extern char *fe_getauthname(void); +extern int be_recvauth(MsgType msgtype, Port * port, char *username, StartupInfo * sp); +extern void be_setauthsvc(char *name); /* the value that matches any dbName value when doing host based authentication*/ diff --git a/src/include/libpq/be-fsstubs.h b/src/include/libpq/be-fsstubs.h index 2ea347a9b3e..2aef0e6a403 100644 --- a/src/include/libpq/be-fsstubs.h +++ b/src/include/libpq/be-fsstubs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: be-fsstubs.h,v 1.3 1997/09/07 04:58:18 momjian Exp $ + * $Id: be-fsstubs.h,v 1.4 1997/09/08 02:37:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,20 +21,20 @@ #define LOread(f,l) loread(f,l) #define LOwrite(f,b) lowrite(f,b) -extern Oid lo_import(text * filename); -extern int4 lo_export(Oid lobjId, text * filename); +extern Oid lo_import(text * filename); +extern int4 lo_export(Oid lobjId, text * filename); -extern Oid lo_creat(int mode); +extern Oid lo_creat(int mode); -extern int lo_open(Oid lobjId, int mode); -extern int lo_close(int fd); -extern int lo_read(int fd, char *buf, int len); -extern int lo_write(int fd, char *buf, int len); -extern int lo_lseek(int fd, int offset, int whence); -extern int lo_tell(int fd); -extern int lo_unlink(Oid lobjId); +extern int lo_open(Oid lobjId, int mode); +extern int lo_close(int fd); +extern int lo_read(int fd, char *buf, int len); +extern int lo_write(int fd, char *buf, int len); +extern int lo_lseek(int fd, int offset, int whence); +extern int lo_tell(int fd); +extern int lo_unlink(Oid lobjId); extern struct varlena *loread(int fd, int len); -extern int lowrite(int fd, struct varlena * wbuf); +extern int lowrite(int fd, struct varlena * wbuf); #endif /* BE_FSSTUBS_H */ diff --git a/src/include/libpq/libpq-be.h b/src/include/libpq/libpq-be.h index 4550461d06e..bddfa1888b4 100644 --- a/src/include/libpq/libpq-be.h +++ b/src/include/libpq/libpq-be.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-be.h,v 1.5 1997/09/07 04:58:20 momjian Exp $ + * $Id: libpq-be.h,v 1.6 1997/09/08 02:37:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,24 +30,24 @@ */ /* in be-dumpdata.c */ -extern void be_portalinit(void); -extern void be_portalpush(PortalEntry * entry); +extern void be_portalinit(void); +extern void be_portalpush(PortalEntry * entry); extern PortalEntry *be_portalpop(void); extern PortalEntry *be_currentportal(void); extern PortalEntry *be_newportal(void); extern void be_typeinit(PortalEntry * entry, TupleDesc attrs, int natts); -extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo); +extern void be_printtup(HeapTuple tuple, TupleDesc typeinfo); /* in be-pqexec.c */ -extern char * +extern char * PQfn(int fnid, int *result_buf, int result_len, int result_is_int, PQArgBlock * args, int nargs); -extern char *PQexec(char *query); -extern int pqtest_PQexec(char *q); -extern int pqtest_PQfn(char *q); -extern int32 pqtest(struct varlena * vlena); +extern char *PQexec(char *query); +extern int pqtest_PQexec(char *q); +extern int pqtest_PQfn(char *q); +extern int32 pqtest(struct varlena * vlena); #endif /* LIBPQ_BE_H */ diff --git a/src/include/libpq/libpq-fs.h b/src/include/libpq/libpq-fs.h index 4e7f4e37a2e..ffa20f634d9 100644 --- a/src/include/libpq/libpq-fs.h +++ b/src/include/libpq/libpq-fs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fs.h,v 1.4 1997/09/07 04:58:22 momjian Exp $ + * $Id: libpq-fs.h,v 1.5 1997/09/08 02:37:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,9 +22,9 @@ struct pgdirent { - unsigned long d_ino; - unsigned short d_namlen; - char d_name[MAXNAMLEN + 1]; + unsigned long d_ino; + unsigned short d_namlen; + char d_name[MAXNAMLEN + 1]; }; /* diff --git a/src/include/libpq/libpq.h b/src/include/libpq/libpq.h index 1b074cba118..e983a91c0fe 100644 --- a/src/include/libpq/libpq.h +++ b/src/include/libpq/libpq.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq.h,v 1.6 1997/09/07 04:58:24 momjian Exp $ + * $Id: libpq.h,v 1.7 1997/09/08 02:37:08 momjian Exp $ * * NOTES * This file contains definitions for structures and @@ -29,14 +29,14 @@ */ typedef struct { - int len; - int isint; + int len; + int isint; union { - int *ptr; /* can't use void (dec compiler barfs) */ - int integer; - } u; -} PQArgBlock; + int *ptr; /* can't use void (dec compiler barfs) */ + int integer; + } u; +} PQArgBlock; /* ---------------- * TypeBlock -- @@ -47,10 +47,10 @@ typedef struct typedef struct TypeBlock { - char name[NAMEDATALEN]; /* name of the attribute */ - int adtid; /* adtid of the type */ - int adtsize; /* adtsize of the type */ -} TypeBlock; + char name[NAMEDATALEN]; /* name of the attribute */ + int adtid; /* adtid of the type */ + int adtsize; /* adtsize of the type */ +} TypeBlock; /* ---------------- * TupleBlock -- @@ -61,12 +61,12 @@ typedef struct TypeBlock typedef struct TupleBlock { - char **values[TupleBlockSize]; /* an array of tuples */ - int *lengths[TupleBlockSize]; /* an array of length vec. + char **values[TupleBlockSize]; /* an array of tuples */ + int *lengths[TupleBlockSize]; /* an array of length vec. * foreach tuple */ struct TupleBlock *next; /* next tuple block */ - int tuple_index;/* current tuple index */ -} TupleBlock; + int tuple_index; /* current tuple index */ +} TupleBlock; /* ---------------- * GroupBuffer -- @@ -75,12 +75,12 @@ typedef struct TupleBlock */ typedef struct GroupBuffer { - int no_tuples; /* number of tuples in this group */ - int no_fields; /* number of attributes */ - TypeBlock *types; /* types of the attributes */ - TupleBlock *tuples; /* tuples in this group */ + int no_tuples; /* number of tuples in this group */ + int no_fields; /* number of attributes */ + TypeBlock *types; /* types of the attributes */ + TupleBlock *tuples; /* tuples in this group */ struct GroupBuffer *next; /* next group */ -} GroupBuffer; +} GroupBuffer; /* ---------------- * PortalBuffer -- @@ -89,11 +89,11 @@ typedef struct GroupBuffer */ typedef struct PortalBuffer { - int rule_p; /* 1 if this is an asynchronized portal. */ - int no_tuples; /* number of tuples in this portal buffer */ - int no_groups; /* number of tuple groups */ - GroupBuffer *groups; /* linked list of tuple groups */ -} PortalBuffer; + int rule_p; /* 1 if this is an asynchronized portal. */ + int no_tuples; /* number of tuples in this portal buffer */ + int no_groups; /* number of tuple groups */ + GroupBuffer *groups; /* linked list of tuple groups */ +} PortalBuffer; /* ---------------- * PortalEntry -- @@ -107,30 +107,30 @@ typedef struct PortalBuffer typedef struct PortalEntry { - char name[PortalNameLength]; /* name of this portal */ - PortalBuffer *portal; /* tuples contained in this portal */ - Pointer portalcxt; /* memory context (for backend) */ - Pointer result; /* result for PQexec */ -} PortalEntry; + char name[PortalNameLength]; /* name of this portal */ + PortalBuffer *portal; /* tuples contained in this portal */ + Pointer portalcxt; /* memory context (for backend) */ + Pointer result; /* result for PQexec */ +} PortalEntry; #define PORTALS_INITIAL_SIZE 32 #define PORTALS_GROW_BY 32 /* in portalbuf.c */ extern PortalEntry **portals; -extern size_t portals_array_size; +extern size_t portals_array_size; /* * Asynchronous notification */ typedef struct PQNotifyList { - char relname[NAMEDATALEN]; /* name of relation - * containing data */ - int be_pid; /* process id of backend */ - int valid; /* has this already been handled by user. */ + char relname[NAMEDATALEN]; /* name of relation containing + * data */ + int be_pid; /* process id of backend */ + int valid; /* has this already been handled by user. */ /* SLNode Node; */ -} PQNotifyList; +} PQNotifyList; /* * Exceptions. @@ -141,9 +141,9 @@ typedef struct PQNotifyList /* in portal.c */ extern Exception MemoryError, - PortalError, - PostquelError, - ProtocolError; + PortalError, + PostquelError, + ProtocolError; /* * POSTGRES backend dependent Constants. @@ -154,7 +154,7 @@ extern Exception MemoryError, #define COMMAND_LENGTH 20 #define REMARK_LENGTH 80 -extern char PQerrormsg[ERROR_MSG_LENGTH]; /* in portal.c */ +extern char PQerrormsg[ERROR_MSG_LENGTH]; /* in portal.c */ /* * External functions. @@ -163,22 +163,22 @@ extern char PQerrormsg[ERROR_MSG_LENGTH]; /* in portal.c */ /* * prototypes for functions in portal.c */ -extern void pqdebug(char *target, char *msg); -extern void pqdebug2(char *target, char *msg1, char *msg2); -extern void PQtrace(void); -extern void PQuntrace(void); -extern int PQnportals(int rule_p); -extern void PQpnames(char **pnames, int rule_p); +extern void pqdebug(char *target, char *msg); +extern void pqdebug2(char *target, char *msg1, char *msg2); +extern void PQtrace(void); +extern void PQuntrace(void); +extern int PQnportals(int rule_p); +extern void PQpnames(char **pnames, int rule_p); extern PortalBuffer *PQparray(char *pname); -extern int PQrulep(PortalBuffer * portal); -extern int PQntuples(PortalBuffer * portal); -extern int PQninstances(PortalBuffer * portal); -extern int PQngroups(PortalBuffer * portal); -extern int PQntuplesGroup(PortalBuffer * portal, int group_index); -extern int PQninstancesGroup(PortalBuffer * portal, int group_index); -extern int PQnfieldsGroup(PortalBuffer * portal, int group_index); -extern int PQfnumberGroup(PortalBuffer * portal, int group_index, char *field_name); -extern char *PQfnameGroup(PortalBuffer * portal, int group_index, int field_number); +extern int PQrulep(PortalBuffer * portal); +extern int PQntuples(PortalBuffer * portal); +extern int PQninstances(PortalBuffer * portal); +extern int PQngroups(PortalBuffer * portal); +extern int PQntuplesGroup(PortalBuffer * portal, int group_index); +extern int PQninstancesGroup(PortalBuffer * portal, int group_index); +extern int PQnfieldsGroup(PortalBuffer * portal, int group_index); +extern int PQfnumberGroup(PortalBuffer * portal, int group_index, char *field_name); +extern char *PQfnameGroup(PortalBuffer * portal, int group_index, int field_number); extern int PQftypeGroup(PortalBuffer * portal, int group_index, int field_number); @@ -186,79 +186,79 @@ extern int PQfsizeGroup(PortalBuffer * portal, int group_index, int field_number); extern GroupBuffer *PQgroup(PortalBuffer * portal, int tuple_index); -extern int PQgetgroup(PortalBuffer * portal, int tuple_index); -extern int PQnfields(PortalBuffer * portal, int tuple_index); -extern int PQfnumber(PortalBuffer * portal, int tuple_index, char *field_name); -extern char *PQfname(PortalBuffer * portal, int tuple_index, int field_number); -extern int PQftype(PortalBuffer * portal, int tuple_index, int field_number); -extern int PQfsize(PortalBuffer * portal, int tuple_index, int field_number); -extern int PQsametype(PortalBuffer * portal, int tuple_index1, int tuple_index2); -extern char *PQgetvalue(PortalBuffer * portal, int tuple_index, int field_number); -extern char *PQgetAttr(PortalBuffer * portal, int tuple_index, int field_number); -extern int PQgetlength(PortalBuffer * portal, int tuple_index, int field_number); -extern void PQclear(char *pname); -extern void PQcleanNotify(void); -extern void PQnotifies_init(void); +extern int PQgetgroup(PortalBuffer * portal, int tuple_index); +extern int PQnfields(PortalBuffer * portal, int tuple_index); +extern int PQfnumber(PortalBuffer * portal, int tuple_index, char *field_name); +extern char *PQfname(PortalBuffer * portal, int tuple_index, int field_number); +extern int PQftype(PortalBuffer * portal, int tuple_index, int field_number); +extern int PQfsize(PortalBuffer * portal, int tuple_index, int field_number); +extern int PQsametype(PortalBuffer * portal, int tuple_index1, int tuple_index2); +extern char *PQgetvalue(PortalBuffer * portal, int tuple_index, int field_number); +extern char *PQgetAttr(PortalBuffer * portal, int tuple_index, int field_number); +extern int PQgetlength(PortalBuffer * portal, int tuple_index, int field_number); +extern void PQclear(char *pname); +extern void PQcleanNotify(void); +extern void PQnotifies_init(void); extern PQNotifyList *PQnotifies(void); -extern void PQremoveNotify(PQNotifyList * nPtr); -extern void PQappendNotify(char *relname, int pid); +extern void PQremoveNotify(PQNotifyList * nPtr); +extern void PQappendNotify(char *relname, int pid); /* * prototypes for functions in portalbuf.c */ -extern caddr_t pbuf_alloc(size_t size); -extern void pbuf_free(caddr_t pointer); +extern caddr_t pbuf_alloc(size_t size); +extern void pbuf_free(caddr_t pointer); extern PortalBuffer *pbuf_addPortal(void); extern GroupBuffer *pbuf_addGroup(PortalBuffer * portal); extern TypeBlock *pbuf_addTypes(int n); extern TupleBlock *pbuf_addTuples(void); -extern char **pbuf_addTuple(int n); -extern int *pbuf_addTupleValueLengths(int n); -extern char *pbuf_addValues(int n); +extern char **pbuf_addTuple(int n); +extern int *pbuf_addTupleValueLengths(int n); +extern char *pbuf_addValues(int n); extern PortalEntry *pbuf_addEntry(void); -extern void pbuf_freeEntry(int i); -extern void pbuf_freeTypes(TypeBlock * types); -extern void pbuf_freeTuples(TupleBlock * tuples, int no_tuples, int no_fields); -extern void pbuf_freeGroup(GroupBuffer * group); -extern void pbuf_freePortal(PortalBuffer * portal); -extern int pbuf_getIndex(char *pname); -extern void pbuf_setportalinfo(PortalEntry * entry, char *pname); +extern void pbuf_freeEntry(int i); +extern void pbuf_freeTypes(TypeBlock * types); +extern void pbuf_freeTuples(TupleBlock * tuples, int no_tuples, int no_fields); +extern void pbuf_freeGroup(GroupBuffer * group); +extern void pbuf_freePortal(PortalBuffer * portal); +extern int pbuf_getIndex(char *pname); +extern void pbuf_setportalinfo(PortalEntry * entry, char *pname); extern PortalEntry *pbuf_setup(char *pname); -extern void pbuf_close(char *pname); +extern void pbuf_close(char *pname); extern GroupBuffer *pbuf_findGroup(PortalBuffer * portal, int group_index); -extern int pbuf_findFnumber(GroupBuffer * group, char *field_name); -extern void pbuf_checkFnumber(GroupBuffer * group, int field_number); -extern char *pbuf_findFname(GroupBuffer * group, int field_number); +extern int pbuf_findFnumber(GroupBuffer * group, char *field_name); +extern void pbuf_checkFnumber(GroupBuffer * group, int field_number); +extern char *pbuf_findFname(GroupBuffer * group, int field_number); /* * prototypes for functions in pqcomm.c */ -extern void pq_init(int fd); -extern void pq_gettty(char *tp); -extern int pq_getport(void); -extern void pq_close(void); -extern void pq_flush(void); -extern int pq_getstr(char *s, int maxlen); -extern int PQgetline(char *s, int maxlen); -extern int PQputline(char *s); -extern int pq_getnchar(char *s, int off, int maxlen); -extern int pq_getint(int b); -extern void pq_putstr(char *s); -extern void pq_putnchar(char *s, int n); -extern void pq_putint(int i, int b); -extern int pq_sendoob(char *msg, int len); -extern int pq_recvoob(char *msgPtr, int *lenPtr); -extern int pq_getinaddr(struct sockaddr_in * sin, char *host, int port); -extern int pq_getinserv(struct sockaddr_in * sin, char *host, char *serv); +extern void pq_init(int fd); +extern void pq_gettty(char *tp); +extern int pq_getport(void); +extern void pq_close(void); +extern void pq_flush(void); +extern int pq_getstr(char *s, int maxlen); +extern int PQgetline(char *s, int maxlen); +extern int PQputline(char *s); +extern int pq_getnchar(char *s, int off, int maxlen); +extern int pq_getint(int b); +extern void pq_putstr(char *s); +extern void pq_putnchar(char *s, int n); +extern void pq_putint(int i, int b); +extern int pq_sendoob(char *msg, int len); +extern int pq_recvoob(char *msgPtr, int *lenPtr); +extern int pq_getinaddr(struct sockaddr_in * sin, char *host, int port); +extern int pq_getinserv(struct sockaddr_in * sin, char *host, char *serv); extern int pq_connect(char *dbname, char *user, char *args, char *hostName, char *debugTty, char *execFile, short portName); -extern int StreamOpen(char *hostName, short portName, Port * port); -extern void pq_regoob(void (*fptr) ()); -extern void pq_unregoob(void); -extern void pq_async_notify(void); -extern int StreamServerPort(char *hostName, short portName, int *fdP); -extern int StreamConnection(int server_fd, Port * port); -extern void StreamClose(int sock); +extern int StreamOpen(char *hostName, short portName, Port * port); +extern void pq_regoob(void (*fptr) ()); +extern void pq_unregoob(void); +extern void pq_async_notify(void); +extern int StreamServerPort(char *hostName, short portName, int *fdP); +extern int StreamConnection(int server_fd, Port * port); +extern void StreamClose(int sock); #endif /* LIBPQ_H */ diff --git a/src/include/libpq/pqcomm.h b/src/include/libpq/pqcomm.h index 3aceb3de5b4..83c76aa2690 100644 --- a/src/include/libpq/pqcomm.h +++ b/src/include/libpq/pqcomm.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.h,v 1.11 1997/09/07 04:58:26 momjian Exp $ + * $Id: pqcomm.h,v 1.12 1997/09/08 02:37:08 momjian Exp $ * * NOTES * Some of this should move to libpq.h @@ -62,19 +62,19 @@ typedef enum _MsgType #define LAST_AUTHENTICATION_TYPE 14 -typedef char *Addr; -typedef int PacketLen; /* packet length */ +typedef char *Addr; +typedef int PacketLen; /* packet length */ typedef struct StartupInfo { /* PacketHdr hdr; */ - char database[PATH_SIZE]; /* database name */ - char user[NAMEDATALEN]; /* user name */ - char options[ARGV_SIZE]; /* possible additional args */ - char execFile[ARGV_SIZE]; /* possible backend to use */ - char tty[PATH_SIZE]; /* possible tty for debug output */ -} StartupInfo; + char database[PATH_SIZE]; /* database name */ + char user[NAMEDATALEN]; /* user name */ + char options[ARGV_SIZE]; /* possible additional args */ + char execFile[ARGV_SIZE]; /* possible backend to use */ + char tty[PATH_SIZE]; /* possible tty for debug output */ +} StartupInfo; /* amount of available data in a packet buffer */ #define MESSAGE_SIZE sizeof(StartupInfo) + 5 /* why 5? BJM 2/11/97 */ @@ -88,10 +88,10 @@ typedef struct StartupInfo Be sure to use htonl() and ntohl() on the len and msgtype fields! */ typedef struct PacketBuf { - int len; - MsgType msgtype; - char data[MESSAGE_SIZE]; -} PacketBuf; + int len; + MsgType msgtype; + char data[MESSAGE_SIZE]; +} PacketBuf; /* update the conversion routines StartupInfo2PacketBuf() and PacketBuf2StartupInfo() (decl. below) @@ -103,18 +103,17 @@ typedef struct PacketBuf */ typedef struct Port { - int sock; /* file descriptor */ - int mask; /* select mask */ - int nBytes; /* nBytes read in so far */ + int sock; /* file descriptor */ + int mask; /* select mask */ + int nBytes; /* nBytes read in so far */ struct sockaddr_in laddr; /* local addr (us) */ struct sockaddr_in raddr; /* remote addr (them) */ /* - * PacketBufId id;*//* id of packet buf currently in - * use - */ - PacketBuf buf; /* stream implementation (curr pack buf) */ -} Port; + * PacketBufId id; + *//* id of packet buf currently in use */ + PacketBuf buf; /* stream implementation (curr pack buf) */ +} Port; /* invalid socket descriptor */ #define INVALID_SOCK (-1) @@ -128,33 +127,33 @@ typedef struct Port #define DEFAULT_STRING "" -extern FILE *Pfout, - *Pfin; -extern int PQAsyncNotifyWaiting; +extern FILE *Pfout, + *Pfin; +extern int PQAsyncNotifyWaiting; /* in pqcompriv.c */ -int pqGetShort(int *, FILE *); -int pqGetLong(int *, FILE *); -int pqGetNBytes(char *, size_t, FILE *); -int pqGetString(char *, size_t, FILE *); -int pqGetByte(FILE *); - -int pqPutShort(int, FILE *); -int pqPutLong(int, FILE *); -int pqPutNBytes(const char *, size_t, FILE *); -int pqPutString(const char *, FILE *); -int pqPutByte(int, FILE *); +int pqGetShort(int *, FILE *); +int pqGetLong(int *, FILE *); +int pqGetNBytes(char *, size_t, FILE *); +int pqGetString(char *, size_t, FILE *); +int pqGetByte(FILE *); + +int pqPutShort(int, FILE *); +int pqPutLong(int, FILE *); +int pqPutNBytes(const char *, size_t, FILE *); +int pqPutString(const char *, FILE *); +int pqPutByte(int, FILE *); /* * prototypes for functions in pqpacket.c */ -extern int PacketReceive(Port * port, PacketBuf * buf, char nonBlocking); +extern int PacketReceive(Port * port, PacketBuf * buf, char nonBlocking); extern int PacketSend(Port * port, PacketBuf * buf, PacketLen len, char nonBlocking); /* extern PacketBuf* StartupInfo2PacketBuf(StartupInfo*); */ /* extern StartupInfo* PacketBuf2StartupInfo(PacketBuf*); */ -extern char *name_of_authentication_type(int type); +extern char *name_of_authentication_type(int type); #endif /* PQCOMM_H */ diff --git a/src/include/libpq/pqsignal.h b/src/include/libpq/pqsignal.h index 69bdb21df7e..f85025a1592 100644 --- a/src/include/libpq/pqsignal.h +++ b/src/include/libpq/pqsignal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.6 1997/09/07 04:58:27 momjian Exp $ + * $Id: pqsignal.h,v 1.7 1997/09/08 02:37:09 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -17,7 +17,7 @@ #ifndef PQSIGNAL_H #define PQSIGNAL_H -typedef void (*pqsigfunc) (int); +typedef void (*pqsigfunc) (int); extern pqsigfunc pqsignal(int signo, pqsigfunc func); diff --git a/src/include/miscadmin.h b/src/include/miscadmin.h index 3738bd739cd..2e71ab58744 100644 --- a/src/include/miscadmin.h +++ b/src/include/miscadmin.h @@ -11,7 +11,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: miscadmin.h,v 1.12 1997/09/07 04:55:37 momjian Exp $ + * $Id: miscadmin.h,v 1.13 1997/09/08 02:33:50 momjian Exp $ * * NOTES * some of the information in this file will be moved to @@ -29,18 +29,18 @@ /* * from postmaster/postmaster.c */ -extern int PostmasterMain(int argc, char *argv[]); +extern int PostmasterMain(int argc, char *argv[]); /* * from utils/init/globals.c */ -extern int Portfd; -extern int Noversion; -extern int MasterPid; -extern int Quiet; -extern char *DataDir; +extern int Portfd; +extern int Noversion; +extern int MasterPid; +extern int Quiet; +extern char *DataDir; -extern char OutputFileName[]; +extern char OutputFileName[]; /* * done in storage/backendid.h for now. @@ -48,14 +48,14 @@ extern char OutputFileName[]; * extern BackendId MyBackendId; * extern BackendTag MyBackendTag; */ -extern bool MyDatabaseIdIsInitialized; -extern Oid MyDatabaseId; -extern bool TransactionInitWasProcessed; +extern bool MyDatabaseIdIsInitialized; +extern Oid MyDatabaseId; +extern bool TransactionInitWasProcessed; -extern bool IsUnderPostmaster; -extern bool IsPostmaster; +extern bool IsUnderPostmaster; +extern bool IsPostmaster; -extern short DebugLvl; +extern short DebugLvl; /* Date/Time Configuration * @@ -79,20 +79,20 @@ extern short DebugLvl; #define USE_ISO_DATES 1 #define USE_SQL_DATES 2 -extern int DateStyle; -extern bool EuroDates; -extern bool HasCTZSet; -extern bool CDayLight; -extern int CTimeZone; -extern char CTZName[]; +extern int DateStyle; +extern bool EuroDates; +extern bool HasCTZSet; +extern bool CDayLight; +extern int CTimeZone; +extern char CTZName[]; -extern char FloatFormat[]; -extern char DateFormat[]; +extern char FloatFormat[]; +extern char DateFormat[]; -extern int fsyncOff; -extern int SortMem; +extern int fsyncOff; +extern int SortMem; -extern Oid LastOidProcessed; /* for query rewrite */ +extern Oid LastOidProcessed; /* for query rewrite */ #define MAX_PARSE_BUFFER 8192 @@ -108,17 +108,17 @@ extern Oid LastOidProcessed; /* for query rewrite */ *****************************************************************************/ /* now in utils/init/miscinit.c */ -extern char *GetDatabasePath(void); -extern char *GetDatabaseName(void); -extern void SetDatabaseName(char *name); -extern void SetDatabasePath(char *path); -extern char *getpgusername(void); -extern void SetPgUserName(void); -extern Oid GetUserId(void); -extern void SetUserId(void); -extern int ValidateBackend(char *path); -extern int FindBackend(char *backend, char *argv0); -extern int CheckPathAccess(char *path, char *name, int open_mode); +extern char *GetDatabasePath(void); +extern char *GetDatabaseName(void); +extern void SetDatabaseName(char *name); +extern void SetDatabasePath(char *path); +extern char *getpgusername(void); +extern void SetPgUserName(void); +extern Oid GetUserId(void); +extern void SetUserId(void); +extern int ValidateBackend(char *path); +extern int FindBackend(char *backend, char *argv0); +extern int CheckPathAccess(char *path, char *name, int open_mode); /* lower case version for case-insensitive SQL referenced in pg_proc.h */ #define GetPgUserName() getpgusername() @@ -154,7 +154,7 @@ typedef enum ProcessingMode BootstrapProcessing, /* bootstrap creation of template database */ InitProcessing, /* initializing system */ NormalProcessing /* normal processing */ -} ProcessingMode; +} ProcessingMode; /***************************************************************************** @@ -166,7 +166,7 @@ typedef enum ProcessingMode * XXX AddExitHandler not defined yet. */ -typedef int16 ExitStatus; +typedef int16 ExitStatus; #define NormalExitStatus (0) #define FatalExitStatus (127) @@ -174,20 +174,20 @@ typedef int16 ExitStatus; /* in utils/init/postinit.c */ -extern bool PostgresIsInitialized; +extern bool PostgresIsInitialized; -extern void InitPostgres(char *name); +extern void InitPostgres(char *name); /* in miscinit.c */ -extern void ExitPostgres(ExitStatus status); -extern void StatusBackendExit(int status); -extern void StatusPostmasterExit(int status); - -extern bool IsNoProcessingMode(void); -extern bool IsBootstrapProcessingMode(void); -extern bool IsInitProcessingMode(void); -extern bool IsNormalProcessingMode(void); -extern void SetProcessingMode(ProcessingMode mode); +extern void ExitPostgres(ExitStatus status); +extern void StatusBackendExit(int status); +extern void StatusPostmasterExit(int status); + +extern bool IsNoProcessingMode(void); +extern bool IsBootstrapProcessingMode(void); +extern bool IsInitProcessingMode(void); +extern bool IsNormalProcessingMode(void); +extern void SetProcessingMode(ProcessingMode mode); extern ProcessingMode GetProcessingMode(void); #endif /* MISCADMIN_H */ diff --git a/src/include/nodes/execnodes.h b/src/include/nodes/execnodes.h index 870bdd80186..f8ad7675a5e 100644 --- a/src/include/nodes/execnodes.h +++ b/src/include/nodes/execnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: execnodes.h,v 1.9 1997/09/07 04:58:29 momjian Exp $ + * $Id: execnodes.h,v 1.10 1997/09/08 02:37:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,12 +35,12 @@ */ typedef struct IndexInfo { - NodeTag type; - int ii_NumKeyAttributes; - AttrNumber *ii_KeyAttributeNumbers; + NodeTag type; + int ii_NumKeyAttributes; + AttrNumber *ii_KeyAttributeNumbers; FuncIndexInfoPtr ii_FuncIndexInfo; - Node *ii_Predicate; -} IndexInfo; + Node *ii_Predicate; +} IndexInfo; /* ---------------- * RelationInfo information @@ -59,13 +59,13 @@ typedef struct IndexInfo */ typedef struct RelationInfo { - NodeTag type; - Index ri_RangeTableIndex; - Relation ri_RelationDesc; - int ri_NumIndices; - RelationPtr ri_IndexRelationDescs; - IndexInfo **ri_IndexRelationInfo; -} RelationInfo; + NodeTag type; + Index ri_RangeTableIndex; + Relation ri_RelationDesc; + int ri_NumIndices; + RelationPtr ri_IndexRelationDescs; + IndexInfo **ri_IndexRelationInfo; +} RelationInfo; /* ---------------- * ExprContext @@ -80,17 +80,17 @@ typedef struct RelationInfo */ typedef struct ExprContext { - NodeTag type; + NodeTag type; TupleTableSlot *ecxt_scantuple; TupleTableSlot *ecxt_innertuple; TupleTableSlot *ecxt_outertuple; - Relation ecxt_relation; - Index ecxt_relid; - ParamListInfo ecxt_param_list_info; - List *ecxt_range_table; - Datum *ecxt_values;/* precomputed values for aggreg */ - char *ecxt_nulls; /* null flags for aggreg values */ -} ExprContext; + Relation ecxt_relation; + Index ecxt_relid; + ParamListInfo ecxt_param_list_info; + List *ecxt_range_table; + Datum *ecxt_values; /* precomputed values for aggreg */ + char *ecxt_nulls; /* null flags for aggreg values */ +} ExprContext; /* ---------------- * ProjectionInfo node information @@ -110,13 +110,13 @@ typedef struct ExprContext */ typedef struct ProjectionInfo { - NodeTag type; - List *pi_targetlist; - int pi_len; - Datum *pi_tupValue; - ExprContext *pi_exprContext; + NodeTag type; + List *pi_targetlist; + int pi_len; + Datum *pi_tupValue; + ExprContext *pi_exprContext; TupleTableSlot *pi_slot; -} ProjectionInfo; +} ProjectionInfo; /* ---------------- * JunkFilter @@ -149,15 +149,15 @@ typedef struct ProjectionInfo */ typedef struct JunkFilter { - NodeTag type; - List *jf_targetList; - int jf_length; - TupleDesc jf_tupType; - List *jf_cleanTargetList; - int jf_cleanLength; - TupleDesc jf_cleanTupType; - AttrNumber *jf_cleanMap; -} JunkFilter; + NodeTag type; + List *jf_targetList; + int jf_length; + TupleDesc jf_tupType; + List *jf_cleanTargetList; + int jf_cleanLength; + TupleDesc jf_cleanTupType; + AttrNumber *jf_cleanMap; +} JunkFilter; /* ---------------- * EState information @@ -193,19 +193,19 @@ typedef struct JunkFilter */ typedef struct EState { - NodeTag type; - ScanDirection es_direction; - List *es_range_table; - RelationInfo *es_result_relation_info; - Relation es_into_relation_descriptor; - ParamListInfo es_param_list_info; - int es_BaseId; - TupleTable es_tupleTable; - JunkFilter *es_junkFilter; - int *es_refcount; - uint32 es_processed; /* # of tuples processed */ - Oid es_lastoid; /* last oid processed (by INSERT) */ -} EState; + NodeTag type; + ScanDirection es_direction; + List *es_range_table; + RelationInfo *es_result_relation_info; + Relation es_into_relation_descriptor; + ParamListInfo es_param_list_info; + int es_BaseId; + TupleTable es_tupleTable; + JunkFilter *es_junkFilter; + int *es_refcount; + uint32 es_processed; /* # of tuples processed */ + Oid es_lastoid; /* last oid processed (by INSERT) */ +} EState; /* ---------------- * Executor Type information needed by plannodes.h @@ -258,14 +258,14 @@ typedef struct EState */ typedef struct CommonState { - NodeTag type; /* its first field is NodeTag */ - int cs_base_id; + NodeTag type; /* its first field is NodeTag */ + int cs_base_id; TupleTableSlot *cs_OuterTupleSlot; TupleTableSlot *cs_ResultTupleSlot; - ExprContext *cs_ExprContext; + ExprContext *cs_ExprContext; ProjectionInfo *cs_ProjInfo; - bool cs_TupFromTlist; -} CommonState; + bool cs_TupFromTlist; +} CommonState; /* ---------------------------------------------------------------- @@ -291,9 +291,9 @@ typedef struct CommonState */ typedef struct ResultState { - CommonState cstate; /* its first field is NodeTag */ - int rs_done; -} ResultState; + CommonState cstate; /* its first field is NodeTag */ + int rs_done; +} ResultState; /* ---------------- * AppendState information @@ -321,14 +321,14 @@ typedef struct ResultState */ typedef struct AppendState { - CommonState cstate; /* its first field is NodeTag */ - int as_whichplan; - int as_nplans; - bool *as_initialized; - List *as_rtentries; - List *as_result_relation_info_list; - List *as_junkFilter_list; -} AppendState; + CommonState cstate; /* its first field is NodeTag */ + int as_whichplan; + int as_nplans; + bool *as_initialized; + List *as_rtentries; + List *as_result_relation_info_list; + List *as_junkFilter_list; +} AppendState; /* ---------------------------------------------------------------- * Scan State Information @@ -358,11 +358,11 @@ typedef struct AppendState */ typedef struct CommonScanState { - CommonState cstate; /* its first field is NodeTag */ - Relation css_currentRelation; - HeapScanDesc css_currentScanDesc; + CommonState cstate; /* its first field is NodeTag */ + Relation css_currentRelation; + HeapScanDesc css_currentScanDesc; TupleTableSlot *css_ScanTupleSlot; -} CommonScanState; +} CommonScanState; /* ---------------- * IndexScanState information @@ -392,15 +392,15 @@ typedef struct CommonScanState */ typedef struct IndexScanState { - CommonState cstate; /* its first field is NodeTag */ - int iss_NumIndices; - int iss_IndexPtr; - ScanKey *iss_ScanKeys; - int *iss_NumScanKeys; - Pointer iss_RuntimeKeyInfo; - RelationPtr iss_RelationDescs; + CommonState cstate; /* its first field is NodeTag */ + int iss_NumIndices; + int iss_IndexPtr; + ScanKey *iss_ScanKeys; + int *iss_NumScanKeys; + Pointer iss_RuntimeKeyInfo; + RelationPtr iss_RelationDescs; IndexScanDescPtr iss_ScanDescs; -} IndexScanState; +} IndexScanState; /* ---------------------------------------------------------------- @@ -442,9 +442,9 @@ typedef CommonState JoinState; */ typedef struct NestLoopState { - JoinState jstate; /* its first field is NodeTag */ - bool nl_PortalFlag; -} NestLoopState; + JoinState jstate; /* its first field is NodeTag */ + bool nl_PortalFlag; +} NestLoopState; /* ---------------- * MergeJoinState information @@ -468,12 +468,12 @@ typedef struct NestLoopState */ typedef struct MergeJoinState { - JoinState jstate; /* its first field is NodeTag */ - List *mj_OSortopI; - List *mj_ISortopO; - int mj_JoinState; + JoinState jstate; /* its first field is NodeTag */ + List *mj_OSortopI; + List *mj_ISortopO; + int mj_JoinState; TupleTableSlot *mj_MarkedTupleSlot; -} MergeJoinState; +} MergeJoinState; /* ---------------- * HashJoinState information @@ -510,20 +510,20 @@ typedef struct MergeJoinState */ typedef struct HashJoinState { - JoinState jstate; /* its first field is NodeTag */ - HashJoinTable hj_HashTable; - IpcMemoryId hj_HashTableShmId; - HashBucket hj_CurBucket; - HeapTuple hj_CurTuple; - OverflowTuple hj_CurOTuple; - Var *hj_InnerHashKey; - File *hj_OuterBatches; - File *hj_InnerBatches; - char *hj_OuterReadPos; - int hj_OuterReadBlk; + JoinState jstate; /* its first field is NodeTag */ + HashJoinTable hj_HashTable; + IpcMemoryId hj_HashTableShmId; + HashBucket hj_CurBucket; + HeapTuple hj_CurTuple; + OverflowTuple hj_CurOTuple; + Var *hj_InnerHashKey; + File *hj_OuterBatches; + File *hj_InnerBatches; + char *hj_OuterReadPos; + int hj_OuterReadBlk; TupleTableSlot *hj_OuterTupleSlot; TupleTableSlot *hj_HashTupleSlot; -} HashJoinState; +} HashJoinState; /* ---------------------------------------------------------------- @@ -560,9 +560,9 @@ typedef struct HashJoinState typedef struct MaterialState { CommonScanState csstate; /* its first field is NodeTag */ - bool mat_Flag; - Relation mat_TempRelation; -} MaterialState; + bool mat_Flag; + Relation mat_TempRelation; +} MaterialState; /* --------------------- * AggregateState information @@ -573,8 +573,8 @@ typedef struct MaterialState typedef struct AggState { CommonScanState csstate; /* its first field is NodeTag */ - bool agg_done; -} AggState; + bool agg_done; +} AggState; /* --------------------- * GroupState information @@ -584,10 +584,10 @@ typedef struct AggState typedef struct GroupState { CommonScanState csstate; /* its first field is NodeTag */ - bool grp_useLastTuple; /* last tuple not processed yet */ - bool grp_done; + bool grp_useLastTuple; /* last tuple not processed yet */ + bool grp_done; TupleTableSlot *grp_lastSlot; -} GroupState; +} GroupState; /* ---------------- * SortState information @@ -623,10 +623,10 @@ typedef struct GroupState typedef struct SortState { CommonScanState csstate; /* its first field is NodeTag */ - bool sort_Flag; - ScanKey sort_Keys; - bool cleaned; -} SortState; + bool sort_Flag; + ScanKey sort_Keys; + bool cleaned; +} SortState; /* ---------------- * UniqueState information @@ -668,9 +668,9 @@ typedef CommonState UniqueState; */ typedef struct HashState { - CommonState cstate; /* its first field is NodeTag */ - File *hashBatches; -} HashState; + CommonState cstate; /* its first field is NodeTag */ + File *hashBatches; +} HashState; /* ----------------------- * TeeState information @@ -688,15 +688,15 @@ typedef struct HashState */ typedef struct TeeState { - CommonState cstate; /* its first field is NodeTag */ - int tee_leftPlace; - int tee_rightPlace; - int tee_lastPlace; - char *tee_bufferRelname; - Relation tee_bufferRel; - MemoryContext tee_mcxt; - HeapScanDesc tee_leftScanDesc; - HeapScanDesc tee_rightScanDesc; -} TeeState; + CommonState cstate; /* its first field is NodeTag */ + int tee_leftPlace; + int tee_rightPlace; + int tee_lastPlace; + char *tee_bufferRelname; + Relation tee_bufferRel; + MemoryContext tee_mcxt; + HeapScanDesc tee_leftScanDesc; + HeapScanDesc tee_rightScanDesc; +} TeeState; #endif /* EXECNODES_H */ diff --git a/src/include/nodes/makefuncs.h b/src/include/nodes/makefuncs.h index 04b2c10c442..57583f6773b 100644 --- a/src/include/nodes/makefuncs.h +++ b/src/include/nodes/makefuncs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: makefuncs.h,v 1.4 1997/09/07 04:58:32 momjian Exp $ + * $Id: makefuncs.h,v 1.5 1997/09/08 02:37:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,21 +16,21 @@ #include <nodes/primnodes.h> #include <utils/fcache.h> -extern Oper * +extern Oper * makeOper(Oid opno, Oid opid, Oid opresulttype, int opsize, FunctionCachePtr op_fcache); -extern Var * +extern Var * makeVar(Index varno, AttrNumber varattno, Oid vartype, Index varnoold, AttrNumber varoattno); -extern Resdom * +extern Resdom * makeResdom(AttrNumber resno, Oid restype, int reslen, @@ -39,7 +39,7 @@ makeResdom(AttrNumber resno, Oid reskeyop, int resjunk); -extern Const * +extern Const * makeConst(Oid consttype, Size constlen, Datum constvalue, diff --git a/src/include/nodes/memnodes.h b/src/include/nodes/memnodes.h index 1d5bced1f3c..aa1050af16c 100644 --- a/src/include/nodes/memnodes.h +++ b/src/include/nodes/memnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memnodes.h,v 1.5 1997/09/07 04:58:35 momjian Exp $ + * $Id: memnodes.h,v 1.6 1997/09/08 02:37:19 momjian Exp $ * * XXX the typedefs in this file are different from the other ???nodes.h; * they are pointers to structures instead of the structures themselves. @@ -49,46 +49,46 @@ typedef struct MemoryContextMethodsData { Pointer(*alloc) (); - void (*free_p) (); /* need to use free as a #define, - * so can't use free */ - Pointer(*realloc) (); - char *(*getName) (); - void (*dump) (); -} *MemoryContextMethods; + void (*free_p) (); /* need to use free as a #define, so can't + * use free */ + Pointer(*realloc) (); + char *(*getName) (); + void (*dump) (); +} *MemoryContextMethods; typedef struct MemoryContext { - NodeTag type; + NodeTag type; MemoryContextMethods method; -} *MemoryContext; +} *MemoryContext; /* think about doing this right some time but we'll have explicit fields for now -ay 10/94 */ typedef struct GlobalMemory { - NodeTag type; + NodeTag type; MemoryContextMethods method; - AllocSetData setData; - char *name; + AllocSetData setData; + char *name; OrderedElemData elemData; -} *GlobalMemory; +} *GlobalMemory; typedef MemoryContext *PortalMemoryContext; typedef struct PortalVariableMemory { - NodeTag type; + NodeTag type; MemoryContextMethods method; - AllocSetData setData; -} *PortalVariableMemory; + AllocSetData setData; +} *PortalVariableMemory; typedef struct PortalHeapMemory { - NodeTag type; + NodeTag type; MemoryContextMethods method; - Pointer block; - FixedStackData stackData; -} *PortalHeapMemory; + Pointer block; + FixedStackData stackData; +} *PortalHeapMemory; /* * MemoryContextIsValid -- diff --git a/src/include/nodes/nodeFuncs.h b/src/include/nodes/nodeFuncs.h index 3edc598a833..b1fe7469610 100644 --- a/src/include/nodes/nodeFuncs.h +++ b/src/include/nodes/nodeFuncs.h @@ -6,17 +6,17 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodeFuncs.h,v 1.3 1997/09/07 04:58:37 momjian Exp $ + * $Id: nodeFuncs.h,v 1.4 1997/09/08 02:37:20 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef NODEFUNCS_H #define NODEFUNCS_H -extern bool single_node(Node * node); -extern bool var_is_outer(Var * var); -extern bool var_is_rel(Var * var); -extern Oper *replace_opid(Oper * oper); -extern bool non_null(Expr * c); +extern bool single_node(Node * node); +extern bool var_is_outer(Var * var); +extern bool var_is_rel(Var * var); +extern Oper *replace_opid(Oper * oper); +extern bool non_null(Expr * c); #endif /* NODEFUNCS_H */ diff --git a/src/include/nodes/nodes.h b/src/include/nodes/nodes.h index 944ed7453f2..73c7b84cba9 100644 --- a/src/include/nodes/nodes.h +++ b/src/include/nodes/nodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nodes.h,v 1.12 1997/09/07 04:58:39 momjian Exp $ + * $Id: nodes.h,v 1.13 1997/09/08 02:37:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -209,7 +209,7 @@ typedef enum NodeTag T_SortClause, T_GroupClause, T_SubSelect -} NodeTag; +} NodeTag; /* * The first field of a node of any type is gauranteed to be the NodeTag. @@ -219,8 +219,8 @@ typedef enum NodeTag */ typedef struct Node { - NodeTag type; -} Node; + NodeTag type; +} Node; #define nodeTag(_node_) ((Node*)_node_)->type @@ -253,30 +253,30 @@ typedef struct Node /* * nodes/nodes.c */ -extern Node *newNode(Size size, NodeTag tag); +extern Node *newNode(Size size, NodeTag tag); /* * nodes/{outfuncs.c,print.c} */ #define nodeDisplay pprint -extern char *nodeToString(void *obj); -extern void print(void *obj); +extern char *nodeToString(void *obj); +extern void print(void *obj); /* * nodes/{readfuncs.c,read.c} */ -extern void *stringToNode(char *str); +extern void *stringToNode(char *str); /* * nodes/copyfuncs.c */ -extern void *copyObject(void *obj); +extern void *copyObject(void *obj); /* * nodes/equalfuncs.c */ -extern bool equal(void *a, void *b); +extern bool equal(void *a, void *b); /* ---------------- @@ -284,7 +284,7 @@ extern bool equal(void *a, void *b); * -cim 6/3/90 * ---------------- */ -typedef float Cost; +typedef float Cost; /* * CmdType - @@ -303,7 +303,7 @@ typedef enum CmdType CMD_NOTIFY, CMD_UTILITY /* cmds like create, destroy, copy, * vacuum, etc. */ -} CmdType; +} CmdType; #endif /* NODES_H */ diff --git a/src/include/nodes/params.h b/src/include/nodes/params.h index 78f0d1cd64b..d3e8bd86e8a 100644 --- a/src/include/nodes/params.h +++ b/src/include/nodes/params.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: params.h,v 1.4 1997/09/07 04:58:40 momjian Exp $ + * $Id: params.h,v 1.5 1997/09/08 02:37:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,15 +75,15 @@ typedef struct ParamListInfoData { - int kind; - char *name; - AttrNumber id; - Oid type; - Size length; - bool isnull; - bool byval; - Datum value; -} ParamListInfoData; + int kind; + char *name; + AttrNumber id; + Oid type; + Size length; + bool isnull; + bool byval; + Datum value; +} ParamListInfoData; typedef ParamListInfoData *ParamListInfo; diff --git a/src/include/nodes/parsenodes.h b/src/include/nodes/parsenodes.h index c24d27918c2..aa311129159 100644 --- a/src/include/nodes/parsenodes.h +++ b/src/include/nodes/parsenodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parsenodes.h,v 1.24 1997/09/07 04:58:44 momjian Exp $ + * $Id: parsenodes.h,v 1.25 1997/09/08 02:37:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,39 +33,38 @@ */ typedef struct Query { - NodeTag type; + NodeTag type; - CmdType commandType;/* select|insert|update|delete|utility */ + CmdType commandType; /* select|insert|update|delete|utility */ - Node *utilityStmt;/* non-null if this is a non-optimizable + Node *utilityStmt; /* non-null if this is a non-optimizable * statement */ - int resultRelation; /* target relation (index to - * rtable) */ - char *into; /* portal (cursor) name */ - bool isPortal; /* is this a retrieve into portal? */ - bool isBinary; /* binary portal? */ + int resultRelation; /* target relation (index to rtable) */ + char *into; /* portal (cursor) name */ + bool isPortal; /* is this a retrieve into portal? */ + bool isBinary; /* binary portal? */ - char *uniqueFlag; /* NULL, '*', or Unique attribute name */ - List *sortClause; /* a list of SortClause's */ + char *uniqueFlag; /* NULL, '*', or Unique attribute name */ + List *sortClause; /* a list of SortClause's */ - List *rtable; /* list of range table entries */ - List *targetList; /* target list (of TargetEntry) */ - Node *qual; /* qualifications */ + List *rtable; /* list of range table entries */ + List *targetList; /* target list (of TargetEntry) */ + Node *qual; /* qualifications */ - List *groupClause;/* list of columns to specified in GROUP + List *groupClause; /* list of columns to specified in GROUP * BY */ - Node *havingQual; /* qualification of each group */ + Node *havingQual; /* qualification of each group */ - int qry_numAgg; /* number of aggregates in the target list */ - Aggreg **qry_aggs; /* the aggregates */ + int qry_numAgg; /* number of aggregates in the target list */ + Aggreg **qry_aggs; /* the aggregates */ /* internal to planner */ - List *base_relation_list_; /* base relation list */ - List *join_relation_list_; /* list of relations - * generated by joins */ - bool query_is_archival_; /* archival query flag */ -} Query; + List *base_relation_list_; /* base relation list */ + List *join_relation_list_; /* list of relations generated by + * joins */ + bool query_is_archival_; /* archival query flag */ +} Query; /***************************************************************************** @@ -83,11 +82,11 @@ typedef struct Query */ typedef struct AddAttrStmt { - NodeTag type; - char *relname; /* the relation to add attr */ - bool inh; /* add recursively to children? */ + NodeTag type; + char *relname; /* the relation to add attr */ + bool inh; /* add recursively to children? */ struct ColumnDef *colDef; /* the attribute definition */ -} AddAttrStmt; +} AddAttrStmt; /* ---------------------- * Change ACL Statement @@ -95,11 +94,11 @@ typedef struct AddAttrStmt */ typedef struct ChangeACLStmt { - NodeTag type; + NodeTag type; struct AclItem *aclitem; - unsigned modechg; - List *relNames; -} ChangeACLStmt; + unsigned modechg; + List *relNames; +} ChangeACLStmt; /* ---------------------- * Close Portal Statement @@ -107,9 +106,9 @@ typedef struct ChangeACLStmt */ typedef struct ClosePortalStmt { - NodeTag type; - char *portalname; /* name of the portal (cursor) */ -} ClosePortalStmt; + NodeTag type; + char *portalname; /* name of the portal (cursor) */ +} ClosePortalStmt; /* ---------------------- * Copy Statement @@ -117,14 +116,14 @@ typedef struct ClosePortalStmt */ typedef struct CopyStmt { - NodeTag type; - bool binary; /* is a binary copy? */ - char *relname; /* the relation to copy */ - bool oids; /* copy oid's? */ - int direction; /* TO or FROM */ - char *filename; /* if NULL, use stdin/stdout */ - char *delimiter; /* delimiter character, \t by default */ -} CopyStmt; + NodeTag type; + bool binary; /* is a binary copy? */ + char *relname; /* the relation to copy */ + bool oids; /* copy oid's? */ + int direction; /* TO or FROM */ + char *filename; /* if NULL, use stdin/stdout */ + char *delimiter; /* delimiter character, \t by default */ +} CopyStmt; /* ---------------------- * Create Table Statement @@ -133,32 +132,32 @@ typedef struct CopyStmt typedef enum ArchType { ARCH_NONE, ARCH_LIGHT, ARCH_HEAVY /* archive mode */ -} ArchType; +} ArchType; typedef struct CreateStmt { - NodeTag type; - char *relname; /* the relation to create */ - List *tableElts; /* column definitions list of ColumnDef */ - List *inhRelnames;/* relations to inherit from list of Value + NodeTag type; + char *relname; /* the relation to create */ + List *tableElts; /* column definitions list of ColumnDef */ + List *inhRelnames; /* relations to inherit from list of Value * (string) */ - ArchType archiveType;/* archive mode (ARCH_NONE if none */ - int location; /* smgrid (-1 if none) */ - int archiveLoc; /* smgrid (-1 if none) */ - List *constraints;/* list of constraints (ConstaintDef) */ -} CreateStmt; + ArchType archiveType; /* archive mode (ARCH_NONE if none */ + int location; /* smgrid (-1 if none) */ + int archiveLoc; /* smgrid (-1 if none) */ + List *constraints; /* list of constraints (ConstaintDef) */ +} CreateStmt; typedef enum ConstrType { CONSTR_NONE, CONSTR_CHECK /* type of constaints */ -} ConstrType; +} ConstrType; typedef struct ConstraintDef { - ConstrType type; - char *name; /* name */ - void *def; /* definition */ -} ConstraintDef; + ConstrType type; + char *name; /* name */ + void *def; /* definition */ +} ConstraintDef; /* ---------------------- * Create/Drop TRIGGER Statements @@ -167,26 +166,26 @@ typedef struct ConstraintDef typedef struct CreateTrigStmt { - NodeTag type; - char *trigname; /* TRIGGER' name */ - char *relname; /* triggered relation */ - char *funcname; /* function to call (or NULL) */ - List *args; /* list of (T_String) Values or NULL */ - bool before; /* BEFORE/AFTER */ - bool row; /* ROW/STATEMENT */ - char actions[4]; /* Insert, Update, Delete */ - char *lang; /* NULL (which means Clanguage) */ - char *text; /* AS 'text' */ - List *attr; /* UPDATE OF a, b,... (NI) or NULL */ - char *when; /* WHEN 'a > 10 ...' (NI) or NULL */ -} CreateTrigStmt; + NodeTag type; + char *trigname; /* TRIGGER' name */ + char *relname; /* triggered relation */ + char *funcname; /* function to call (or NULL) */ + List *args; /* list of (T_String) Values or NULL */ + bool before; /* BEFORE/AFTER */ + bool row; /* ROW/STATEMENT */ + char actions[4]; /* Insert, Update, Delete */ + char *lang; /* NULL (which means Clanguage) */ + char *text; /* AS 'text' */ + List *attr; /* UPDATE OF a, b,... (NI) or NULL */ + char *when; /* WHEN 'a > 10 ...' (NI) or NULL */ +} CreateTrigStmt; typedef struct DropTrigStmt { - NodeTag type; - char *trigname; /* TRIGGER' name */ - char *relname; /* triggered relation */ -} DropTrigStmt; + NodeTag type; + char *trigname; /* TRIGGER' name */ + char *relname; /* triggered relation */ +} DropTrigStmt; /* ---------------------- * Create SEQUENCE Statement @@ -195,10 +194,10 @@ typedef struct DropTrigStmt typedef struct CreateSeqStmt { - NodeTag type; - char *seqname; /* the relation to create */ - List *options; -} CreateSeqStmt; + NodeTag type; + char *seqname; /* the relation to create */ + List *options; +} CreateSeqStmt; /* ---------------------- * Create Version Statement @@ -206,12 +205,12 @@ typedef struct CreateSeqStmt */ typedef struct VersionStmt { - NodeTag type; - char *relname; /* the new relation */ - int direction; /* FORWARD | BACKWARD */ - char *fromRelname;/* relation to create a version */ - char *date; /* date of the snapshot */ -} VersionStmt; + NodeTag type; + char *relname; /* the new relation */ + int direction; /* FORWARD | BACKWARD */ + char *fromRelname; /* relation to create a version */ + char *date; /* date of the snapshot */ +} VersionStmt; /* ---------------------- * Create {Operator|Type|Aggregate} Statement @@ -219,11 +218,11 @@ typedef struct VersionStmt */ typedef struct DefineStmt { - NodeTag type; - int defType; /* OPERATOR|P_TYPE|AGGREGATE */ - char *defname; - List *definition; /* a list of DefElem */ -} DefineStmt; + NodeTag type; + int defType; /* OPERATOR|P_TYPE|AGGREGATE */ + char *defname; + List *definition; /* a list of DefElem */ +} DefineStmt; /* ---------------------- * Drop Table Statement @@ -231,10 +230,10 @@ typedef struct DefineStmt */ typedef struct DestroyStmt { - NodeTag type; - List *relNames; /* relations to be dropped */ - bool sequence; -} DestroyStmt; + NodeTag type; + List *relNames; /* relations to be dropped */ + bool sequence; +} DestroyStmt; /* ---------------------- * Extend Index Statement @@ -242,12 +241,12 @@ typedef struct DestroyStmt */ typedef struct ExtendStmt { - NodeTag type; - char *idxname; /* name of the index */ - Node *whereClause;/* qualifications */ - List *rangetable; /* range table, filled in by + NodeTag type; + char *idxname; /* name of the index */ + Node *whereClause; /* qualifications */ + List *rangetable; /* range table, filled in by * transformStmt() */ -} ExtendStmt; +} ExtendStmt; /* ---------------------- * Begin Recipe Statement @@ -255,9 +254,9 @@ typedef struct ExtendStmt */ typedef struct RecipeStmt { - NodeTag type; - char *recipeName; /* name of the recipe */ -} RecipeStmt; + NodeTag type; + char *recipeName; /* name of the recipe */ +} RecipeStmt; /* ---------------------- * Fetch Statement @@ -265,11 +264,11 @@ typedef struct RecipeStmt */ typedef struct FetchStmt { - NodeTag type; - int direction; /* FORWARD or BACKWARD */ - int howMany; /* amount to fetch ("ALL" --> 0) */ - char *portalname; /* name of portal (cursor) */ -} FetchStmt; + NodeTag type; + int direction; /* FORWARD or BACKWARD */ + int howMany; /* amount to fetch ("ALL" --> 0) */ + char *portalname; /* name of portal (cursor) */ +} FetchStmt; /* ---------------------- * Create Index Statement @@ -277,19 +276,18 @@ typedef struct FetchStmt */ typedef struct IndexStmt { - NodeTag type; - char *idxname; /* name of the index */ - char *relname; /* name of relation to index on */ - char *accessMethod; /* name of acess methood (eg. - * btree) */ - List *indexParams;/* a list of IndexElem */ - List *withClause; /* a list of ParamString */ - Node *whereClause;/* qualifications */ - List *rangetable; /* range table, filled in by + NodeTag type; + char *idxname; /* name of the index */ + char *relname; /* name of relation to index on */ + char *accessMethod; /* name of acess methood (eg. btree) */ + List *indexParams; /* a list of IndexElem */ + List *withClause; /* a list of ParamString */ + Node *whereClause; /* qualifications */ + List *rangetable; /* range table, filled in by * transformStmt() */ - bool *lossy; /* is index lossy? */ - bool unique; /* is index unique? */ -} IndexStmt; + bool *lossy; /* is index lossy? */ + bool unique; /* is index unique? */ +} IndexStmt; /* ---------------------- * Move Statement (Not implemented) @@ -297,12 +295,12 @@ typedef struct IndexStmt */ typedef struct MoveStmt { - NodeTag type; - int direction; /* FORWARD or BACKWARD */ - bool to; - int where; - char *portalname; -} MoveStmt; + NodeTag type; + int direction; /* FORWARD or BACKWARD */ + bool to; + int where; + char *portalname; +} MoveStmt; /* ---------------------- * Create Function Statement @@ -310,16 +308,16 @@ typedef struct MoveStmt */ typedef struct ProcedureStmt { - NodeTag type; - char *funcname; /* name of function to create */ - List *defArgs; /* list of definitions a list of strings + NodeTag type; + char *funcname; /* name of function to create */ + List *defArgs; /* list of definitions a list of strings * (as Value *) */ - Node *returnType; /* the return type (as a string or a + Node *returnType; /* the return type (as a string or a * TypeName (ie.setof) */ - List *withClause; /* a list of ParamString */ - char *as; /* the SQL statement or filename */ - char *language; /* C or SQL */ -} ProcedureStmt; + List *withClause; /* a list of ParamString */ + char *as; /* the SQL statement or filename */ + char *language; /* C or SQL */ +} ProcedureStmt; /* ---------------------- * Purge Statement @@ -327,11 +325,11 @@ typedef struct ProcedureStmt */ typedef struct PurgeStmt { - NodeTag type; - char *relname; /* relation to purge */ - char *beforeDate; /* purge before this date */ - char *afterDate; /* purge after this date */ -} PurgeStmt; + NodeTag type; + char *relname; /* relation to purge */ + char *beforeDate; /* purge before this date */ + char *afterDate; /* purge after this date */ +} PurgeStmt; /* ---------------------- * Drop Aggregate Statement @@ -339,10 +337,10 @@ typedef struct PurgeStmt */ typedef struct RemoveAggrStmt { - NodeTag type; - char *aggname; /* aggregate to drop */ - char *aggtype; /* for this type */ -} RemoveAggrStmt; + NodeTag type; + char *aggname; /* aggregate to drop */ + char *aggtype; /* for this type */ +} RemoveAggrStmt; /* ---------------------- * Drop Function Statement @@ -350,10 +348,10 @@ typedef struct RemoveAggrStmt */ typedef struct RemoveFuncStmt { - NodeTag type; - char *funcname; /* function to drop */ - List *args; /* types of the arguments */ -} RemoveFuncStmt; + NodeTag type; + char *funcname; /* function to drop */ + List *args; /* types of the arguments */ +} RemoveFuncStmt; /* ---------------------- * Drop Operator Statement @@ -361,10 +359,10 @@ typedef struct RemoveFuncStmt */ typedef struct RemoveOperStmt { - NodeTag type; - char *opname; /* operator to drop */ - List *args; /* types of the arguments */ -} RemoveOperStmt; + NodeTag type; + char *opname; /* operator to drop */ + List *args; /* types of the arguments */ +} RemoveOperStmt; /* ---------------------- * Drop {Type|Index|Rule|View} Statement @@ -372,10 +370,10 @@ typedef struct RemoveOperStmt */ typedef struct RemoveStmt { - NodeTag type; - int removeType; /* P_TYPE|INDEX|RULE|VIEW */ - char *name; /* name to drop */ -} RemoveStmt; + NodeTag type; + int removeType; /* P_TYPE|INDEX|RULE|VIEW */ + char *name; /* name to drop */ +} RemoveStmt; /* ---------------------- * Alter Table Statement @@ -383,14 +381,14 @@ typedef struct RemoveStmt */ typedef struct RenameStmt { - NodeTag type; - char *relname; /* relation to be altered */ - bool inh; /* recursively alter children? */ - char *column; /* if NULL, rename the relation name to + NodeTag type; + char *relname; /* relation to be altered */ + bool inh; /* recursively alter children? */ + char *column; /* if NULL, rename the relation name to * the new name. Otherwise, rename this * column name. */ - char *newname; /* the new name */ -} RenameStmt; + char *newname; /* the new name */ +} RenameStmt; /* ---------------------- * Create Rule Statement @@ -398,14 +396,14 @@ typedef struct RenameStmt */ typedef struct RuleStmt { - NodeTag type; - char *rulename; /* name of the rule */ - Node *whereClause;/* qualifications */ - CmdType event; /* RETRIEVE */ - struct Attr *object; /* object affected */ - bool instead; /* is a 'do instead'? */ - List *actions; /* the action statements */ -} RuleStmt; + NodeTag type; + char *rulename; /* name of the rule */ + Node *whereClause; /* qualifications */ + CmdType event; /* RETRIEVE */ + struct Attr *object; /* object affected */ + bool instead; /* is a 'do instead'? */ + List *actions; /* the action statements */ +} RuleStmt; /* ---------------------- * Notify Statement @@ -413,9 +411,9 @@ typedef struct RuleStmt */ typedef struct NotifyStmt { - NodeTag type; - char *relname; /* relation to notify */ -} NotifyStmt; + NodeTag type; + char *relname; /* relation to notify */ +} NotifyStmt; /* ---------------------- * Listen Statement @@ -423,9 +421,9 @@ typedef struct NotifyStmt */ typedef struct ListenStmt { - NodeTag type; - char *relname; /* relation to listen on */ -} ListenStmt; + NodeTag type; + char *relname; /* relation to listen on */ +} ListenStmt; /* ---------------------- * {Begin|Abort|End} Transaction Statement @@ -433,9 +431,9 @@ typedef struct ListenStmt */ typedef struct TransactionStmt { - NodeTag type; - int command; /* BEGIN|END|ABORT */ -} TransactionStmt; + NodeTag type; + int command; /* BEGIN|END|ABORT */ +} TransactionStmt; /* ---------------------- * Create View Statement @@ -443,10 +441,10 @@ typedef struct TransactionStmt */ typedef struct ViewStmt { - NodeTag type; - char *viewname; /* name of the view */ - Query *query; /* the SQL statement */ -} ViewStmt; + NodeTag type; + char *viewname; /* name of the view */ + Query *query; /* the SQL statement */ +} ViewStmt; /* ---------------------- * Load Statement @@ -454,9 +452,9 @@ typedef struct ViewStmt */ typedef struct LoadStmt { - NodeTag type; - char *filename; /* file to load */ -} LoadStmt; + NodeTag type; + char *filename; /* file to load */ +} LoadStmt; /* ---------------------- * Createdb Statement @@ -464,9 +462,9 @@ typedef struct LoadStmt */ typedef struct CreatedbStmt { - NodeTag type; - char *dbname; /* database to create */ -} CreatedbStmt; + NodeTag type; + char *dbname; /* database to create */ +} CreatedbStmt; /* ---------------------- * Destroydb Statement @@ -474,9 +472,9 @@ typedef struct CreatedbStmt */ typedef struct DestroydbStmt { - NodeTag type; - char *dbname; /* database to drop */ -} DestroydbStmt; + NodeTag type; + char *dbname; /* database to drop */ +} DestroydbStmt; /* ---------------------- * Cluster Statement (support pbrown's cluster index implementation) @@ -484,10 +482,10 @@ typedef struct DestroydbStmt */ typedef struct ClusterStmt { - NodeTag type; - char *relname; /* relation being indexed */ - char *indexname; /* original index defined */ -} ClusterStmt; + NodeTag type; + char *relname; /* relation being indexed */ + char *indexname; /* original index defined */ +} ClusterStmt; /* ---------------------- * Vacuum Statement @@ -495,12 +493,12 @@ typedef struct ClusterStmt */ typedef struct VacuumStmt { - NodeTag type; - bool verbose; /* print status info */ - bool analyze; /* analyze data */ - char *vacrel; /* table to vacuum */ - List *va_spec; /* columns to analyse */ -} VacuumStmt; + NodeTag type; + bool verbose; /* print status info */ + bool analyze; /* analyze data */ + char *vacrel; /* table to vacuum */ + List *va_spec; /* columns to analyse */ +} VacuumStmt; /* ---------------------- * Explain Statement @@ -508,10 +506,10 @@ typedef struct VacuumStmt */ typedef struct ExplainStmt { - NodeTag type; - Query *query; /* the query */ - bool verbose; /* print plan info */ -} ExplainStmt; + NodeTag type; + Query *query; /* the query */ + bool verbose; /* print plan info */ +} ExplainStmt; /* ---------------------- * Set Statement @@ -520,10 +518,10 @@ typedef struct ExplainStmt typedef struct VariableSetStmt { - NodeTag type; - char *name; - char *value; -} VariableSetStmt; + NodeTag type; + char *name; + char *value; +} VariableSetStmt; /* ---------------------- * Show Statement @@ -532,9 +530,9 @@ typedef struct VariableSetStmt typedef struct VariableShowStmt { - NodeTag type; - char *name; -} VariableShowStmt; + NodeTag type; + char *name; +} VariableShowStmt; /* ---------------------- * Reset Statement @@ -543,9 +541,9 @@ typedef struct VariableShowStmt typedef struct VariableResetStmt { - NodeTag type; - char *name; -} VariableResetStmt; + NodeTag type; + char *name; +} VariableResetStmt; /***************************************************************************** @@ -558,13 +556,13 @@ typedef struct VariableResetStmt */ typedef struct AppendStmt { - NodeTag type; - char *relname; /* relation to insert into */ - List *cols; /* names of the columns */ - List *targetList; /* the target list (of ResTarget) */ - List *fromClause; /* the from clause */ - Node *whereClause;/* qualifications */ -} AppendStmt; + NodeTag type; + char *relname; /* relation to insert into */ + List *cols; /* names of the columns */ + List *targetList; /* the target list (of ResTarget) */ + List *fromClause; /* the from clause */ + Node *whereClause; /* qualifications */ +} AppendStmt; /* ---------------------- * Delete Statement @@ -572,10 +570,10 @@ typedef struct AppendStmt */ typedef struct DeleteStmt { - NodeTag type; - char *relname; /* relation to delete from */ - Node *whereClause;/* qualifications */ -} DeleteStmt; + NodeTag type; + char *relname; /* relation to delete from */ + Node *whereClause; /* qualifications */ +} DeleteStmt; /* ---------------------- * Update Statement @@ -583,12 +581,12 @@ typedef struct DeleteStmt */ typedef struct ReplaceStmt { - NodeTag type; - char *relname; /* relation to update */ - List *targetList; /* the target list (of ResTarget) */ - Node *whereClause;/* qualifications */ - List *fromClause; /* the from clause */ -} ReplaceStmt; + NodeTag type; + char *relname; /* relation to update */ + List *targetList; /* the target list (of ResTarget) */ + Node *whereClause; /* qualifications */ + List *fromClause; /* the from clause */ +} ReplaceStmt; /* ---------------------- * Create Cursor Statement @@ -596,16 +594,16 @@ typedef struct ReplaceStmt */ typedef struct CursorStmt { - NodeTag type; - char *portalname; /* the portal (cursor) to create */ - bool binary; /* a binary (internal) portal? */ - char *unique; /* NULL, "*", or unique attribute name */ - List *targetList; /* the target list (of ResTarget) */ - List *fromClause; /* the from clause */ - Node *whereClause;/* qualifications */ - List *groupClause;/* group by clause */ - List *sortClause; /* sort clause (a list of SortGroupBy's) */ -} CursorStmt; + NodeTag type; + char *portalname; /* the portal (cursor) to create */ + bool binary; /* a binary (internal) portal? */ + char *unique; /* NULL, "*", or unique attribute name */ + List *targetList; /* the target list (of ResTarget) */ + List *fromClause; /* the from clause */ + Node *whereClause; /* qualifications */ + List *groupClause; /* group by clause */ + List *sortClause; /* sort clause (a list of SortGroupBy's) */ +} CursorStmt; /* ---------------------- * Select Statement @@ -613,17 +611,17 @@ typedef struct CursorStmt */ typedef struct RetrieveStmt { - NodeTag type; - char *unique; /* NULL, '*', or unique attribute name */ - char *into; /* name of table (for select into table) */ - List *targetList; /* the target list (of ResTarget) */ - List *fromClause; /* the from clause */ - Node *whereClause;/* qualifications */ - List *groupClause;/* group by clause */ - Node *havingClause; /* having conditional-expression */ - List *selectClause; /* subselect parameters */ - List *sortClause; /* sort clause (a list of SortGroupBy's) */ -} RetrieveStmt; + NodeTag type; + char *unique; /* NULL, '*', or unique attribute name */ + char *into; /* name of table (for select into table) */ + List *targetList; /* the target list (of ResTarget) */ + List *fromClause; /* the from clause */ + Node *whereClause; /* qualifications */ + List *groupClause; /* group by clause */ + Node *havingClause; /* having conditional-expression */ + List *selectClause; /* subselect parameters */ + List *sortClause; /* sort clause (a list of SortGroupBy's) */ +} RetrieveStmt; /**************************************************************************** @@ -635,50 +633,50 @@ typedef struct RetrieveStmt */ typedef struct SubSelect { - NodeTag type; - char *unique; /* NULL, '*', or unique attribute name */ - List *targetList; /* the target list (of ResTarget) */ - List *fromClause; /* the from clause */ - Node *whereClause;/* qualifications */ - List *groupClause;/* group by clause */ - Node *havingClause; /* having conditional-expression */ -} SubSelect; + NodeTag type; + char *unique; /* NULL, '*', or unique attribute name */ + List *targetList; /* the target list (of ResTarget) */ + List *fromClause; /* the from clause */ + Node *whereClause; /* qualifications */ + List *groupClause; /* group by clause */ + Node *havingClause; /* having conditional-expression */ +} SubSelect; /* * TypeName - specifies a type in definitions */ typedef struct TypeName { - NodeTag type; - char *name; /* name of the type */ - bool timezone; /* timezone specified? */ - bool setof; /* is a set? */ - List *arrayBounds;/* array bounds */ - int typlen; /* length for char() and varchar() */ -} TypeName; + NodeTag type; + char *name; /* name of the type */ + bool timezone; /* timezone specified? */ + bool setof; /* is a set? */ + List *arrayBounds; /* array bounds */ + int typlen; /* length for char() and varchar() */ +} TypeName; /* * ParamNo - specifies a parameter reference */ typedef struct ParamNo { - NodeTag type; - int number; /* the number of the parameter */ - TypeName *typename; /* the typecast */ -} ParamNo; + NodeTag type; + int number; /* the number of the parameter */ + TypeName *typename; /* the typecast */ +} ParamNo; /* * A_Expr - binary expressions */ typedef struct A_Expr { - NodeTag type; - int oper; /* type of operation + NodeTag type; + int oper; /* type of operation * {OP,OR,AND,NOT,ISNULL,NOTNULL} */ - char *opname; /* name of operator/function */ - Node *lexpr; /* left argument */ - Node *rexpr; /* right argument */ -} A_Expr; + char *opname; /* name of operator/function */ + Node *lexpr; /* left argument */ + Node *rexpr; /* right argument */ +} A_Expr; /* * Attr - @@ -688,35 +686,35 @@ typedef struct A_Expr */ typedef struct Attr { - NodeTag type; - char *relname; /* name of relation (can be "*") */ - ParamNo *paramNo; /* or a parameter */ - List *attrs; /* attributes (possibly nested); list of + NodeTag type; + char *relname; /* name of relation (can be "*") */ + ParamNo *paramNo; /* or a parameter */ + List *attrs; /* attributes (possibly nested); list of * Values (strings) */ - List *indirection;/* array refs (list of A_Indices') */ -} Attr; + List *indirection; /* array refs (list of A_Indices') */ +} Attr; /* * A_Const - a constant expression */ typedef struct A_Const { - NodeTag type; - Value val; /* the value (with the tag) */ - TypeName *typename; /* typecast */ -} A_Const; + NodeTag type; + Value val; /* the value (with the tag) */ + TypeName *typename; /* typecast */ +} A_Const; /* * ColumnDef - column definition (used in various creates) */ typedef struct ColumnDef { - NodeTag type; - char *colname; /* name of column */ - TypeName *typename; /* type of column */ - bool is_not_null;/* flag to NOT NULL constraint */ - char *defval; /* default value of column */ -} ColumnDef; + NodeTag type; + char *colname; /* name of column */ + TypeName *typename; /* type of column */ + bool is_not_null; /* flag to NOT NULL constraint */ + char *defval; /* default value of column */ +} ColumnDef; /* * Ident - @@ -727,32 +725,32 @@ typedef struct ColumnDef */ typedef struct Ident { - NodeTag type; - char *name; /* its name */ - List *indirection;/* array references */ - bool isRel; /* is a relation - filled in by + NodeTag type; + char *name; /* its name */ + List *indirection; /* array references */ + bool isRel; /* is a relation - filled in by * transformExpr() */ -} Ident; +} Ident; /* * FuncCall - a function/aggregate invocation */ typedef struct FuncCall { - NodeTag type; - char *funcname; /* name of function */ - List *args; /* the arguments (list of exprs) */ -} FuncCall; + NodeTag type; + char *funcname; /* name of function */ + List *args; /* the arguments (list of exprs) */ +} FuncCall; /* * A_Indices - array reference or bounds ([lidx:uidx] or [uidx]) */ typedef struct A_Indices { - NodeTag type; - Node *lidx; /* could be NULL */ - Node *uidx; -} A_Indices; + NodeTag type; + Node *lidx; /* could be NULL */ + Node *uidx; +} A_Indices; /* * ResTarget - @@ -760,77 +758,77 @@ typedef struct A_Indices */ typedef struct ResTarget { - NodeTag type; - char *name; /* name of the result column */ - List *indirection;/* array references */ - Node *val; /* the value of the result (A_Expr or + NodeTag type; + char *name; /* name of the result column */ + List *indirection; /* array references */ + Node *val; /* the value of the result (A_Expr or * Attr) (or A_Const) */ -} ResTarget; +} ResTarget; /* * ParamString - used in with clauses */ typedef struct ParamString { - NodeTag type; - char *name; - char *val; -} ParamString; + NodeTag type; + char *name; + char *val; +} ParamString; /* * TimeRange - specifies a time range */ typedef struct TimeRange { - NodeTag type; - char *startDate; - char *endDate; /* snapshot if NULL */ -} TimeRange; + NodeTag type; + char *startDate; + char *endDate; /* snapshot if NULL */ +} TimeRange; /* * RelExpr - relation expressions */ typedef struct RelExpr { - NodeTag type; - char *relname; /* the relation name */ - bool inh; /* inheritance query */ - TimeRange *timeRange; /* the time range */ -} RelExpr; + NodeTag type; + char *relname; /* the relation name */ + bool inh; /* inheritance query */ + TimeRange *timeRange; /* the time range */ +} RelExpr; /* * SortGroupBy - for order by clause */ typedef struct SortGroupBy { - NodeTag type; - int resno; /* target number */ - char *range; - char *name; /* name of column to sort on */ - char *useOp; /* operator to use */ -} SortGroupBy; + NodeTag type; + int resno; /* target number */ + char *range; + char *name; /* name of column to sort on */ + char *useOp; /* operator to use */ +} SortGroupBy; /* * RangeVar - range variable, used in from clauses */ typedef struct RangeVar { - NodeTag type; - RelExpr *relExpr; /* the relation expression */ - char *name; /* the name to be referenced (optional) */ -} RangeVar; + NodeTag type; + RelExpr *relExpr; /* the relation expression */ + char *name; /* the name to be referenced (optional) */ +} RangeVar; /* * IndexElem - index parameters (used in create index) */ typedef struct IndexElem { - NodeTag type; - char *name; /* name of index */ - List *args; /* if not NULL, function index */ - char *class; - TypeName *tname; /* type of index's keys (optional) */ -} IndexElem; + NodeTag type; + char *name; /* name of index */ + List *args; /* if not NULL, function index */ + char *class; + TypeName *tname; /* type of index's keys (optional) */ +} IndexElem; /* * DefElem - @@ -838,10 +836,10 @@ typedef struct IndexElem */ typedef struct DefElem { - NodeTag type; - char *defname; - Node *arg; /* a (Value *) or a (TypeName *) */ -} DefElem; + NodeTag type; + char *defname; + Node *arg; /* a (Value *) or a (TypeName *) */ +} DefElem; /**************************************************************************** @@ -857,11 +855,11 @@ typedef struct DefElem */ typedef struct TargetEntry { - NodeTag type; - Resdom *resdom; /* fjoin overload this to be a list?? */ - Fjoin *fjoin; - Node *expr; /* can be a list too */ -} TargetEntry; + NodeTag type; + Resdom *resdom; /* fjoin overload this to be a list?? */ + Fjoin *fjoin; + Node *expr; /* can be a list too */ +} TargetEntry; /* * RangeTblEntry - @@ -877,17 +875,17 @@ typedef struct TargetEntry */ typedef struct RangeTblEntry { - NodeTag type; - char *relname; /* real name of the relation */ - TimeRange *timeRange; /* time range */ - char *refname; /* the reference name (specified in the + NodeTag type; + char *relname; /* real name of the relation */ + TimeRange *timeRange; /* time range */ + char *refname; /* the reference name (specified in the * from clause) */ - Oid relid; - bool inh; /* inheritance? */ - bool archive; /* filled in by plan_archive */ - bool inFromCl; /* comes from From Clause */ - TimeQual timeQual; /* filled in by pg_plan */ -} RangeTblEntry; + Oid relid; + bool inh; /* inheritance? */ + bool archive; /* filled in by plan_archive */ + bool inFromCl; /* comes from From Clause */ + TimeQual timeQual; /* filled in by pg_plan */ +} RangeTblEntry; /* * SortClause - @@ -895,10 +893,10 @@ typedef struct RangeTblEntry */ typedef struct SortClause { - NodeTag type; - Resdom *resdom; /* attributes in tlist to be sorted */ - Oid opoid; /* sort operators */ -} SortClause; + NodeTag type; + Resdom *resdom; /* attributes in tlist to be sorted */ + Oid opoid; /* sort operators */ +} SortClause; /* * GroupClause - @@ -906,9 +904,9 @@ typedef struct SortClause */ typedef struct GroupClause { - NodeTag type; - TargetEntry *entry; /* attributes to group on */ - Oid grpOpoid; /* the sort operator to use */ -} GroupClause; + NodeTag type; + TargetEntry *entry; /* attributes to group on */ + Oid grpOpoid; /* the sort operator to use */ +} GroupClause; #endif /* PARSENODES_H */ diff --git a/src/include/nodes/pg_list.h b/src/include/nodes/pg_list.h index 9afe6dfac5e..166ce53bd63 100644 --- a/src/include/nodes/pg_list.h +++ b/src/include/nodes/pg_list.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pg_list.h,v 1.6 1997/09/07 04:58:45 momjian Exp $ + * $Id: pg_list.h,v 1.7 1997/09/08 02:37:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,14 +26,14 @@ */ typedef struct Value { - NodeTag type; /* tag appropriately (eg. T_String) */ + NodeTag type; /* tag appropriately (eg. T_String) */ union ValUnion { - char *str; /* string */ - long ival; - double dval; - } val; -} Value; + char *str; /* string */ + long ival; + double dval; + } val; +} Value; #define intVal(v) (((Value *)v)->val.ival) #define floatVal(v) (((Value *)v)->val.dval) @@ -46,14 +46,14 @@ typedef struct Value */ typedef struct List { - NodeTag type; + NodeTag type; union { - void *ptr_value; - int int_value; - } elem; - struct List *next; -} List; + void *ptr_value; + int int_value; + } elem; + struct List *next; +} List; #define NIL ((List *) NULL) @@ -81,40 +81,40 @@ typedef struct List /* * function prototypes in nodes/list.c */ -extern int length(List * list); -extern List *append(List * list1, List * list2); -extern List *nconc(List * list1, List * list2); -extern List *lcons(void *datum, List * list); -extern bool member(void *foo, List * bar); -extern Value *makeInteger(long i); -extern Value *makeFloat(double d); -extern Value *makeString(char *str); -extern List *makeList(void *elem,...); -extern List *lappend(List * list, void *obj); -extern List *lremove(void *elem, List * list); -extern void freeList(List * list); -extern List *LispRemove(void *elem, List * list); - -extern void *nth(int n, List * l); -extern void set_nth(List * l, int n, void *elem); - -List *lconsi(int datum, List * list); -List *lappendi(List * list, int datum); -extern bool intMember(int, List *); -extern List *intAppend(List * list1, List * list2); - -extern int nthi(int n, List * l); - -extern List *nreverse(List *); -extern List *set_difference(List *, List *); -extern List *set_differencei(List *, List *); -extern List *LispUnion(List * foo, List * bar); -extern List *LispUnioni(List * foo, List * bar); -extern bool same(List * foo, List * bar); +extern int length(List * list); +extern List *append(List * list1, List * list2); +extern List *nconc(List * list1, List * list2); +extern List *lcons(void *datum, List * list); +extern bool member(void *foo, List * bar); +extern Value *makeInteger(long i); +extern Value *makeFloat(double d); +extern Value *makeString(char *str); +extern List *makeList(void *elem,...); +extern List *lappend(List * list, void *obj); +extern List *lremove(void *elem, List * list); +extern void freeList(List * list); +extern List *LispRemove(void *elem, List * list); + +extern void *nth(int n, List * l); +extern void set_nth(List * l, int n, void *elem); + +List *lconsi(int datum, List * list); +List *lappendi(List * list, int datum); +extern bool intMember(int, List *); +extern List *intAppend(List * list1, List * list2); + +extern int nthi(int n, List * l); + +extern List *nreverse(List *); +extern List *set_difference(List *, List *); +extern List *set_differencei(List *, List *); +extern List *LispUnion(List * foo, List * bar); +extern List *LispUnioni(List * foo, List * bar); +extern bool same(List * foo, List * bar); /* should be in nodes.h but needs List */ /* in copyfuncs.c */ -extern List *listCopy(List *); +extern List *listCopy(List *); #endif /* PG_LIST_H */ diff --git a/src/include/nodes/plannodes.h b/src/include/nodes/plannodes.h index 3353602e02c..6942d206fb8 100644 --- a/src/include/nodes/plannodes.h +++ b/src/include/nodes/plannodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: plannodes.h,v 1.7 1997/09/07 04:58:46 momjian Exp $ + * $Id: plannodes.h,v 1.8 1997/09/08 02:37:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,19 +63,19 @@ typedef struct Plan { - NodeTag type; - Cost cost; - int plan_size; - int plan_width; - int plan_tupperpage; - EState *state; /* at execution time, state's of + NodeTag type; + Cost cost; + int plan_size; + int plan_width; + int plan_tupperpage; + EState *state; /* at execution time, state's of * individual nodes point to one EState * for the whole top-level plan */ - List *targetlist; - List *qual; /* Node* or List* ?? */ - struct Plan *lefttree; - struct Plan *righttree; -} Plan; + List *targetlist; + List *qual; /* Node* or List* ?? */ + struct Plan *lefttree; + struct Plan *righttree; +} Plan; /* ---------------- * these are are defined to avoid confusion problems with "left" @@ -104,7 +104,7 @@ typedef struct Plan * existential node * ---------------- */ -typedef Plan Existential; +typedef Plan Existential; /* ---------------- * result node - @@ -113,10 +113,10 @@ typedef Plan Existential; */ typedef struct Result { - Plan plan; - Node *resconstantqual; - ResultState *resstate; -} Result; + Plan plan; + Node *resconstantqual; + ResultState *resstate; +} Result; /* ---------------- * append node @@ -124,12 +124,12 @@ typedef struct Result */ typedef struct Append { - Plan plan; - List *unionplans; - Index unionrelid; - List *unionrtentries; - AppendState *unionstate; -} Append; + Plan plan; + List *unionplans; + Index unionrelid; + List *unionrtentries; + AppendState *unionstate; +} Append; /* * ========== @@ -138,16 +138,16 @@ typedef struct Append */ typedef struct Scan { - Plan plan; - Index scanrelid; /* relid is index into the range table */ + Plan plan; + Index scanrelid; /* relid is index into the range table */ CommonScanState *scanstate; -} Scan; +} Scan; /* ---------------- * sequential scan node * ---------------- */ -typedef Scan SeqScan; +typedef Scan SeqScan; /* ---------------- * index scan node @@ -155,11 +155,11 @@ typedef Scan SeqScan; */ typedef struct IndexScan { - Scan scan; - List *indxid; - List *indxqual; + Scan scan; + List *indxid; + List *indxqual; IndexScanState *indxstate; -} IndexScan; +} IndexScan; /* * ========== @@ -171,7 +171,7 @@ typedef struct IndexScan * Join node * ---------------- */ -typedef Plan Join; +typedef Plan Join; /* ---------------- * nest loop join node @@ -179,9 +179,9 @@ typedef Plan Join; */ typedef struct NestLoop { - Join join; - NestLoopState *nlstate; -} NestLoop; + Join join; + NestLoopState *nlstate; +} NestLoop; /* ---------------- * merge join node @@ -189,13 +189,13 @@ typedef struct NestLoop */ typedef struct MergeJoin { - Join join; - List *mergeclauses; - Oid mergesortop; - Oid *mergerightorder; /* inner sort operator */ - Oid *mergeleftorder; /* outer sort operator */ + Join join; + List *mergeclauses; + Oid mergesortop; + Oid *mergerightorder;/* inner sort operator */ + Oid *mergeleftorder; /* outer sort operator */ MergeJoinState *mergestate; -} MergeJoin; +} MergeJoin; /* ---------------- * hash join (probe) node @@ -203,15 +203,15 @@ typedef struct MergeJoin */ typedef struct HashJoin { - Join join; - List *hashclauses; - Oid hashjoinop; - HashJoinState *hashjoinstate; - HashJoinTable hashjointable; - IpcMemoryKey hashjointablekey; - int hashjointablesize; - bool hashdone; -} HashJoin; + Join join; + List *hashclauses; + Oid hashjoinop; + HashJoinState *hashjoinstate; + HashJoinTable hashjointable; + IpcMemoryKey hashjointablekey; + int hashjointablesize; + bool hashdone; +} HashJoin; /* --------------- * aggregate node @@ -219,11 +219,11 @@ typedef struct HashJoin */ typedef struct Agg { - Plan plan; - int numAgg; - Aggreg **aggs; - AggState *aggstate; -} Agg; + Plan plan; + int numAgg; + Aggreg **aggs; + AggState *aggstate; +} Agg; /* --------------- * group node - @@ -237,13 +237,12 @@ typedef struct Agg */ typedef struct Group { - Plan plan; - bool tuplePerGroup; /* what tuples to return (see - * above) */ - int numCols; /* number of group columns */ - AttrNumber *grpColIdx; /* index into the target list */ - GroupState *grpstate; -} Group; + Plan plan; + bool tuplePerGroup; /* what tuples to return (see above) */ + int numCols; /* number of group columns */ + AttrNumber *grpColIdx; /* index into the target list */ + GroupState *grpstate; +} Group; /* * ========== @@ -252,10 +251,10 @@ typedef struct Group */ typedef struct Temp { - Plan plan; - Oid tempid; - int keycount; -} Temp; + Plan plan; + Oid tempid; + int keycount; +} Temp; /* ---------------- * materialization node @@ -263,11 +262,11 @@ typedef struct Temp */ typedef struct Material { - Plan plan; /* temp node flattened out */ - Oid tempid; - int keycount; - MaterialState *matstate; -} Material; + Plan plan; /* temp node flattened out */ + Oid tempid; + int keycount; + MaterialState *matstate; +} Material; /* ---------------- * sort node @@ -275,13 +274,13 @@ typedef struct Material */ typedef struct Sort { - Plan plan; /* temp node flattened out */ - Oid tempid; - int keycount; - SortState *sortstate; - void *psortstate; - bool cleaned; -} Sort; + Plan plan; /* temp node flattened out */ + Oid tempid; + int keycount; + SortState *sortstate; + void *psortstate; + bool cleaned; +} Sort; /* ---------------- * unique node @@ -289,15 +288,15 @@ typedef struct Sort */ typedef struct Unique { - Plan plan; /* temp node flattened out */ - Oid tempid; - int keycount; - char *uniqueAttr; /* NULL if all attrs, or unique attribute + Plan plan; /* temp node flattened out */ + Oid tempid; + int keycount; + char *uniqueAttr; /* NULL if all attrs, or unique attribute * name */ - AttrNumber uniqueAttrNum; /* attribute number of attribute - * to select distinct on */ - UniqueState *uniquestate; -} Unique; + AttrNumber uniqueAttrNum; /* attribute number of attribute to select + * distinct on */ + UniqueState *uniquestate; +} Unique; /* ---------------- * hash build node @@ -305,13 +304,13 @@ typedef struct Unique */ typedef struct Hash { - Plan plan; - Var *hashkey; - HashState *hashstate; - HashJoinTable hashtable; - IpcMemoryKey hashtablekey; - int hashtablesize; -} Hash; + Plan plan; + Var *hashkey; + HashState *hashstate; + HashJoinTable hashtable; + IpcMemoryKey hashtablekey; + int hashtablesize; +} Hash; /* --------------------- * choose node @@ -319,9 +318,9 @@ typedef struct Hash */ typedef struct Choose { - Plan plan; - List *chooseplanlist; -} Choose; + Plan plan; + List *chooseplanlist; +} Choose; /* ------------------- * Tee node information @@ -332,15 +331,15 @@ typedef struct Choose */ typedef struct Tee { - Plan plan; - Plan *leftParent; - Plan *rightParent; - TeeState *teestate; - char *teeTableName; /* the name of the table to - * materialize the tee into */ - List *rtentries; /* the range table for the plan below the + Plan plan; + Plan *leftParent; + Plan *rightParent; + TeeState *teestate; + char *teeTableName; /* the name of the table to materialize + * the tee into */ + List *rtentries; /* the range table for the plan below the * Tee may be different than the parent * plans */ -} Tee; +} Tee; #endif /* PLANNODES_H */ diff --git a/src/include/nodes/primnodes.h b/src/include/nodes/primnodes.h index 66d5a52a17e..e28c3128857 100644 --- a/src/include/nodes/primnodes.h +++ b/src/include/nodes/primnodes.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: primnodes.h,v 1.8 1997/09/07 04:58:46 momjian Exp $ + * $Id: primnodes.h,v 1.9 1997/09/08 02:37:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,15 +38,15 @@ */ typedef struct Resdom { - NodeTag type; - AttrNumber resno; - Oid restype; - int reslen; - char *resname; - Index reskey; - Oid reskeyop; - int resjunk; -} Resdom; + NodeTag type; + AttrNumber resno; + Oid restype; + int reslen; + char *resname; + Index reskey; + Oid reskeyop; + int resjunk; +} Resdom; /* ------------- * Fjoin @@ -67,13 +67,13 @@ typedef struct Resdom */ typedef struct Fjoin { - NodeTag type; - bool fj_initialized; - int fj_nNodes; - List *fj_innerNode; - DatumPtr fj_results; - BoolPtr fj_alwaysDone; -} Fjoin; + NodeTag type; + bool fj_initialized; + int fj_nNodes; + List *fj_innerNode; + DatumPtr fj_results; + BoolPtr fj_alwaysDone; +} Fjoin; /* ---------------- * Expr @@ -87,16 +87,16 @@ typedef struct Fjoin typedef enum OpType { OP_EXPR, FUNC_EXPR, OR_EXPR, AND_EXPR, NOT_EXPR -} OpType; +} OpType; typedef struct Expr { - NodeTag type; - Oid typeOid; /* oid of the type of this expr */ - OpType opType; /* type of the op */ - Node *oper; /* could be Oper or Func */ - List *args; /* list of argument nodes */ -} Expr; + NodeTag type; + Oid typeOid; /* oid of the type of this expr */ + OpType opType; /* type of the op */ + Node *oper; /* could be Oper or Func */ + List *args; /* list of argument nodes */ +} Expr; /* ---------------- * Var @@ -118,13 +118,13 @@ typedef struct Expr typedef struct Var { - NodeTag type; - Index varno; - AttrNumber varattno; - Oid vartype; - Index varnoold; /* only used by optimizer */ - AttrNumber varoattno; /* only used by optimizer */ -} Var; + NodeTag type; + Index varno; + AttrNumber varattno; + Oid vartype; + Index varnoold; /* only used by optimizer */ + AttrNumber varoattno; /* only used by optimizer */ +} Var; /* ---------------- * Oper @@ -148,13 +148,13 @@ typedef struct Var */ typedef struct Oper { - NodeTag type; - Oid opno; - Oid opid; - Oid opresulttype; - int opsize; + NodeTag type; + Oid opno; + Oid opid; + Oid opresulttype; + int opsize; FunctionCachePtr op_fcache; -} Oper; +} Oper; /* ---------------- @@ -175,15 +175,15 @@ typedef struct Oper */ typedef struct Const { - NodeTag type; - Oid consttype; - Size constlen; - Datum constvalue; - bool constisnull; - bool constbyval; - bool constisset; - bool constiscast; -} Const; + NodeTag type; + Oid consttype; + Size constlen; + Datum constvalue; + bool constisnull; + bool constbyval; + bool constisset; + bool constiscast; +} Const; /* ---------------- * Param @@ -214,13 +214,13 @@ typedef struct Const */ typedef struct Param { - NodeTag type; - int paramkind; - AttrNumber paramid; - char *paramname; - Oid paramtype; - List *param_tlist; -} Param; + NodeTag type; + int paramkind; + AttrNumber paramid; + char *paramname; + Oid paramtype; + List *param_tlist; +} Param; /* ---------------- @@ -240,15 +240,15 @@ typedef struct Param */ typedef struct Func { - NodeTag type; - Oid funcid; - Oid functype; - bool funcisindex; - int funcsize; + NodeTag type; + Oid funcid; + Oid functype; + bool funcisindex; + int funcsize; FunctionCachePtr func_fcache; - List *func_tlist; - List *func_planlist; -} Func; + List *func_tlist; + List *func_planlist; +} Func; /* ---------------- * Aggreg @@ -261,13 +261,13 @@ typedef struct Func */ typedef struct Aggreg { - NodeTag type; - char *aggname; - Oid basetype; /* base type of the aggregate */ - Oid aggtype; /* type of final result */ - Node *target; /* attribute to aggreg on */ - int aggno; /* index to ecxt_values */ -} Aggreg; + NodeTag type; + char *aggname; + Oid basetype; /* base type of the aggregate */ + Oid aggtype; /* type of final result */ + Node *target; /* attribute to aggreg on */ + int aggno; /* index to ecxt_values */ +} Aggreg; /* ---------------- * Array @@ -286,15 +286,15 @@ typedef struct Aggreg */ typedef struct Array { - NodeTag type; - Oid arrayelemtype; - int arrayelemlength; - bool arrayelembyval; - int arrayndim; - IntArray arraylow; - IntArray arrayhigh; - int arraylen; -} Array; + NodeTag type; + Oid arrayelemtype; + int arrayelemlength; + bool arrayelembyval; + int arrayndim; + IntArray arraylow; + IntArray arrayhigh; + int arraylen; +} Array; /* ---------------- * ArrayRef: @@ -310,15 +310,15 @@ typedef struct Array */ typedef struct ArrayRef { - NodeTag type; - int refattrlength; - int refelemlength; - Oid refelemtype; - bool refelembyval; - List *refupperindexpr; - List *reflowerindexpr; - Node *refexpr; - Node *refassgnexpr; -} ArrayRef; + NodeTag type; + int refattrlength; + int refelemlength; + Oid refelemtype; + bool refelembyval; + List *refupperindexpr; + List *reflowerindexpr; + Node *refexpr; + Node *refassgnexpr; +} ArrayRef; #endif /* PRIMNODES_H */ diff --git a/src/include/nodes/print.h b/src/include/nodes/print.h index 8e1a80267d0..bef8ce3a6ce 100644 --- a/src/include/nodes/print.h +++ b/src/include/nodes/print.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: print.h,v 1.3 1997/09/07 04:58:47 momjian Exp $ + * $Id: print.h,v 1.4 1997/09/08 02:37:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,16 +19,16 @@ #include "nodes/relation.h" #include "executor/tuptable.h" -extern void print(void *obj); -extern void pprint(void *obj); -extern void print_rt(List * rtable); -extern void print_expr(Node * expr, List * rtable); -extern void print_keys(List * keys, List * rtable); -extern void print_tl(List * tlist, List * rtable); -extern void print_slot(TupleTableSlot * slot); +extern void print(void *obj); +extern void pprint(void *obj); +extern void print_rt(List * rtable); +extern void print_expr(Node * expr, List * rtable); +extern void print_keys(List * keys, List * rtable); +extern void print_tl(List * tlist, List * rtable); +extern void print_slot(TupleTableSlot * slot); extern void print_plan_recursive(Plan * p, Query * parsetree, int indentLevel, char *label); -extern void print_plan(Plan * p, Query * parsetree); +extern void print_plan(Plan * p, Query * parsetree); #endif /* PRINT_H */ diff --git a/src/include/nodes/readfuncs.h b/src/include/nodes/readfuncs.h index 8a23d550a90..72007ec9132 100644 --- a/src/include/nodes/readfuncs.h +++ b/src/include/nodes/readfuncs.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: readfuncs.h,v 1.3 1997/09/07 04:58:48 momjian Exp $ + * $Id: readfuncs.h,v 1.4 1997/09/08 02:37:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,12 +16,12 @@ /* * prototypes for functions in read.c (the lisp token parser) */ -extern char *lsptok(char *string, int *length); -extern void *nodeRead(bool read_car_only); +extern char *lsptok(char *string, int *length); +extern void *nodeRead(bool read_car_only); /* * prototypes for functions in readfuncs.c */ -extern Node *parsePlanString(void); +extern Node *parsePlanString(void); #endif /* READFUNCS_H */ diff --git a/src/include/nodes/relation.h b/src/include/nodes/relation.h index 7acbc3d466c..4dfcb6692dc 100644 --- a/src/include/nodes/relation.h +++ b/src/include/nodes/relation.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: relation.h,v 1.5 1997/09/07 04:58:48 momjian Exp $ + * $Id: relation.h,v 1.6 1997/09/08 02:37:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,7 +21,7 @@ * List of relation identifiers (indexes into the rangetable). */ -typedef List *Relid; +typedef List *Relid; /* * Rel @@ -73,117 +73,117 @@ typedef List *Relid; typedef struct Rel { - NodeTag type; + NodeTag type; /* all relations: */ - Relid relids; + Relid relids; /* catalog statistics information */ - bool indexed; - int pages; - int tuples; - int size; - int width; + bool indexed; + int pages; + int tuples; + int size; + int width; /* materialization information */ - List *targetlist; - List *pathlist; - struct Path *unorderedpath; - struct Path *cheapestpath; - bool pruneable; + List *targetlist; + List *pathlist; + struct Path *unorderedpath; + struct Path *cheapestpath; + bool pruneable; /* used solely by indices: */ - Oid *classlist; /* classes of AM operators */ - int *indexkeys; /* keys over which we're indexing */ - Oid relam; /* OID of the access method (in pg_am) */ + Oid *classlist; /* classes of AM operators */ + int *indexkeys; /* keys over which we're indexing */ + Oid relam; /* OID of the access method (in pg_am) */ - Oid indproc; - List *indpred; + Oid indproc; + List *indpred; /* used by various scans and joins: */ - Oid *ordering; /* OID of operators in sort order */ - List *clauseinfo; /* restriction clauses */ - List *joininfo; /* join clauses */ - List *innerjoin; - List *superrels; -} Rel; + Oid *ordering; /* OID of operators in sort order */ + List *clauseinfo; /* restriction clauses */ + List *joininfo; /* join clauses */ + List *innerjoin; + List *superrels; +} Rel; -extern Var *get_expr(TargetEntry * foo); +extern Var *get_expr(TargetEntry * foo); typedef struct MergeOrder { - NodeTag type; - Oid join_operator; - Oid left_operator; - Oid right_operator; - Oid left_type; - Oid right_type; -} MergeOrder; + NodeTag type; + Oid join_operator; + Oid left_operator; + Oid right_operator; + Oid left_type; + Oid right_type; +} MergeOrder; typedef enum OrderType { MERGE_ORDER, SORTOP_ORDER -} OrderType; +} OrderType; typedef struct PathOrder { - OrderType ordtype; + OrderType ordtype; union { - Oid *sortop; - MergeOrder *merge; - } ord; -} PathOrder; + Oid *sortop; + MergeOrder *merge; + } ord; +} PathOrder; typedef struct Path { - NodeTag type; + NodeTag type; - Rel *parent; - Cost path_cost; + Rel *parent; + Cost path_cost; - NodeTag pathtype; + NodeTag pathtype; - PathOrder p_ordering; + PathOrder p_ordering; - List *keys; - Cost outerjoincost; - Relid joinid; - List *locclauseinfo; -} Path; + List *keys; + Cost outerjoincost; + Relid joinid; + List *locclauseinfo; +} Path; typedef struct IndexPath { - Path path; - List *indexid; - List *indexqual; - int *indexkeys; /* to transform heap attnos into index + Path path; + List *indexid; + List *indexqual; + int *indexkeys; /* to transform heap attnos into index * ones */ -} IndexPath; +} IndexPath; typedef struct JoinPath { - Path path; - List *pathclauseinfo; - Path *outerjoinpath; - Path *innerjoinpath; -} JoinPath; + Path path; + List *pathclauseinfo; + Path *outerjoinpath; + Path *innerjoinpath; +} JoinPath; typedef struct MergePath { - JoinPath jpath; - List *path_mergeclauses; - List *outersortkeys; - List *innersortkeys; -} MergePath; + JoinPath jpath; + List *path_mergeclauses; + List *outersortkeys; + List *innersortkeys; +} MergePath; typedef struct HashPath { - JoinPath jpath; - List *path_hashclauses; - List *outerhashkeys; - List *innerhashkeys; -} HashPath; + JoinPath jpath; + List *path_hashclauses; + List *outerhashkeys; + List *innerhashkeys; +} HashPath; /****** * Keys @@ -191,17 +191,17 @@ typedef struct HashPath typedef struct OrderKey { - NodeTag type; - int attribute_number; - Index array_index; -} OrderKey; + NodeTag type; + int attribute_number; + Index array_index; +} OrderKey; typedef struct JoinKey { - NodeTag type; - Var *outer; - Var *inner; -} JoinKey; + NodeTag type; + Var *outer; + Var *inner; +} JoinKey; /******* * clause info @@ -209,56 +209,56 @@ typedef struct JoinKey typedef struct CInfo { - NodeTag type; - Expr *clause; /* should be an OP clause */ - Cost selectivity; - bool notclause; - List *indexids; + NodeTag type; + Expr *clause; /* should be an OP clause */ + Cost selectivity; + bool notclause; + List *indexids; /* mergesort only */ - MergeOrder *mergesortorder; + MergeOrder *mergesortorder; /* hashjoin only */ - Oid hashjoinoperator; - Relid cinfojoinid; -} CInfo; + Oid hashjoinoperator; + Relid cinfojoinid; +} CInfo; typedef struct JoinMethod { - NodeTag type; - List *jmkeys; - List *clauses; -} JoinMethod; + NodeTag type; + List *jmkeys; + List *clauses; +} JoinMethod; typedef struct HInfo { - JoinMethod jmethod; - Oid hashop; -} HInfo; + JoinMethod jmethod; + Oid hashop; +} HInfo; typedef struct MInfo { - JoinMethod jmethod; - MergeOrder *m_ordering; -} MInfo; + JoinMethod jmethod; + MergeOrder *m_ordering; +} MInfo; typedef struct JInfo { - NodeTag type; - List *otherrels; - List *jinfoclauseinfo; - bool mergesortable; - bool hashjoinable; - bool inactive; -} JInfo; + NodeTag type; + List *otherrels; + List *jinfoclauseinfo; + bool mergesortable; + bool hashjoinable; + bool inactive; +} JInfo; typedef struct Iter { - NodeTag type; - Node *iterexpr; - Oid itertype; /* type of the iter expr (use for type + NodeTag type; + Node *iterexpr; + Oid itertype; /* type of the iter expr (use for type * checking) */ -} Iter; +} Iter; /* ** Stream: @@ -283,15 +283,15 @@ typedef struct Stream *StreamPtr; typedef struct Stream { - NodeTag type; - Path *pathptr; - CInfo *cinfo; - int *clausetype; - struct Stream *upstream; - struct Stream *downstream; - bool groupup; - Cost groupcost; - Cost groupsel; -} Stream; + NodeTag type; + Path *pathptr; + CInfo *cinfo; + int *clausetype; + struct Stream *upstream; + struct Stream *downstream; + bool groupup; + Cost groupcost; + Cost groupsel; +} Stream; #endif /* RELATION_H */ diff --git a/src/include/optimizer/clauseinfo.h b/src/include/optimizer/clauseinfo.h index 028979eeb11..d6f034a4b58 100644 --- a/src/include/optimizer/clauseinfo.h +++ b/src/include/optimizer/clauseinfo.h @@ -6,21 +6,21 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: clauseinfo.h,v 1.2 1997/09/07 04:58:52 momjian Exp $ + * $Id: clauseinfo.h,v 1.3 1997/09/08 02:37:32 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef CLAUSEINFO_H #define CLAUSEINFO_H -extern bool valid_or_clause(CInfo * clauseinfo); -extern List *get_actual_clauses(List * clauseinfo_list); +extern bool valid_or_clause(CInfo * clauseinfo); +extern List *get_actual_clauses(List * clauseinfo_list); extern void get_relattvals(List * clauseinfo_list, List ** attnos, List ** values, List ** flags); extern void get_joinvars(Oid relid, List * clauseinfo_list, List ** attnos, List ** values, List ** flags); -extern List *get_opnos(List * clauseinfo_list); +extern List *get_opnos(List * clauseinfo_list); #endif /* CLAUSEINFO_H */ diff --git a/src/include/optimizer/clauses.h b/src/include/optimizer/clauses.h index bb8d09a4da4..358b772b3f9 100644 --- a/src/include/optimizer/clauses.h +++ b/src/include/optimizer/clauses.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: clauses.h,v 1.4 1997/09/07 04:58:54 momjian Exp $ + * $Id: clauses.h,v 1.5 1997/09/08 02:37:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,39 +15,39 @@ #include <nodes/primnodes.h> -extern Expr *make_clause(int type, Node * oper, List * args); -extern bool is_opclause(Node * clause); -extern Expr *make_opclause(Oper * op, Var * leftop, Var * rightop); -extern Var *get_leftop(Expr * clause); -extern Var *get_rightop(Expr * clause); - -extern bool is_funcclause(Node * clause); -extern Expr *make_funcclause(Func * func, List * funcargs); - -extern bool or_clause(Node * clause); -extern Expr *make_orclause(List * orclauses); - -extern bool not_clause(Node * clause); -extern Expr *make_notclause(Expr * notclause); -extern Expr *get_notclausearg(Expr * notclause); - -extern bool and_clause(Node * clause); -extern Expr *make_andclause(List * andclauses); - -extern List *pull_constant_clauses(List * quals, List ** constantQual); -extern void clause_relids_vars(Node * clause, List ** relids, List ** vars); -extern int NumRelids(Node * clause); -extern bool contains_not(Node * clause); -extern bool join_clause_p(Node * clause); -extern bool qual_clause_p(Node * clause); -extern void fix_opid(Node * clause); -extern List *fix_opids(List * clauses); +extern Expr *make_clause(int type, Node * oper, List * args); +extern bool is_opclause(Node * clause); +extern Expr *make_opclause(Oper * op, Var * leftop, Var * rightop); +extern Var *get_leftop(Expr * clause); +extern Var *get_rightop(Expr * clause); + +extern bool is_funcclause(Node * clause); +extern Expr *make_funcclause(Func * func, List * funcargs); + +extern bool or_clause(Node * clause); +extern Expr *make_orclause(List * orclauses); + +extern bool not_clause(Node * clause); +extern Expr *make_notclause(Expr * notclause); +extern Expr *get_notclausearg(Expr * notclause); + +extern bool and_clause(Node * clause); +extern Expr *make_andclause(List * andclauses); + +extern List *pull_constant_clauses(List * quals, List ** constantQual); +extern void clause_relids_vars(Node * clause, List ** relids, List ** vars); +extern int NumRelids(Node * clause); +extern bool contains_not(Node * clause); +extern bool join_clause_p(Node * clause); +extern bool qual_clause_p(Node * clause); +extern void fix_opid(Node * clause); +extern List *fix_opids(List * clauses); extern void get_relattval(Node * clause, int *relid, AttrNumber * attno, Datum * constval, int *flag); extern void get_rels_atts(Node * clause, int *relid1, AttrNumber * attno1, int *relid2, AttrNumber * attno2); -extern void CommuteClause(Node * clause); +extern void CommuteClause(Node * clause); #endif /* CLAUSES_H */ diff --git a/src/include/optimizer/cost.h b/src/include/optimizer/cost.h index bb50d92948c..a0ab3a59466 100644 --- a/src/include/optimizer/cost.h +++ b/src/include/optimizer/cost.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: cost.h,v 1.3 1997/09/07 04:58:56 momjian Exp $ + * $Id: cost.h,v 1.4 1997/09/08 02:37:40 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,45 +17,45 @@ * prototypes for costsize.c-- * routines to compute costs and sizes */ -extern bool _enable_seqscan_; -extern bool _enable_indexscan_; -extern bool _enable_sort_; -extern bool _enable_hash_; -extern bool _enable_nestloop_; -extern bool _enable_mergesort_; -extern bool _enable_hashjoin_; +extern bool _enable_seqscan_; +extern bool _enable_indexscan_; +extern bool _enable_sort_; +extern bool _enable_hash_; +extern bool _enable_nestloop_; +extern bool _enable_mergesort_; +extern bool _enable_hashjoin_; -extern Cost cost_seqscan(int relid, int relpages, int reltuples); -extern Cost +extern Cost cost_seqscan(int relid, int relpages, int reltuples); +extern Cost cost_index(Oid indexid, int expected_indexpages, Cost selec, int relpages, int reltuples, int indexpages, int indextuples, bool is_injoin); -extern Cost cost_sort(List * keys, int tuples, int width, bool noread); -extern Cost +extern Cost cost_sort(List * keys, int tuples, int width, bool noread); +extern Cost cost_nestloop(Cost outercost, Cost innercost, int outertuples, int innertuples, int outerpages, bool is_indexjoin); -extern Cost +extern Cost cost_mergesort(Cost outercost, Cost innercost, List * outersortkeys, List * innersortkeys, int outersize, int innersize, int outerwidth, int innerwidth); -extern Cost +extern Cost cost_hashjoin(Cost outercost, Cost innercost, List * outerkeys, List * innerkeys, int outersize, int innersize, int outerwidth, int innerwidth); -extern int compute_rel_size(Rel * rel); -extern int compute_rel_width(Rel * rel); -extern int compute_joinrel_size(JoinPath * joinpath); -extern int page_size(int tuples, int width); +extern int compute_rel_size(Rel * rel); +extern int compute_rel_width(Rel * rel); +extern int compute_joinrel_size(JoinPath * joinpath); +extern int page_size(int tuples, int width); /* * prototypes for fuctions in clausesel.h-- * routines to compute clause selectivities */ -extern void set_clause_selectivities(List * clauseinfo_list, Cost new_selectivity); -extern Cost product_selec(List * clauseinfo_list); -extern void set_rest_relselec(Query * root, List * rel_list); -extern void set_rest_selec(Query * root, List * clauseinfo_list); -extern Cost +extern void set_clause_selectivities(List * clauseinfo_list, Cost new_selectivity); +extern Cost product_selec(List * clauseinfo_list); +extern void set_rest_relselec(Query * root, List * rel_list); +extern void set_rest_selec(Query * root, List * clauseinfo_list); +extern Cost compute_clause_selec(Query * root, Node * clause, List * or_selectivities); diff --git a/src/include/optimizer/geqo.h b/src/include/optimizer/geqo.h index 28f2dd086f7..d9e63a1d8fd 100644 --- a/src/include/optimizer/geqo.h +++ b/src/include/optimizer/geqo.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo.h,v 1.4 1997/09/07 04:58:57 momjian Exp $ + * $Id: geqo.h,v 1.5 1997/09/08 02:37:42 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,12 +52,12 @@ #define SELECTION_BIAS 2.0 /* selective pressure within population */ /* should be 1.5 <= SELECTION_BIAS <= 2.0 */ -int PoolSize; -int Generations; +int PoolSize; +int Generations; -long RandomSeed; /* defaults to (long) time(NULL) in +long RandomSeed; /* defaults to (long) time(NULL) in * geqo_params.c */ -double SelectionBias; +double SelectionBias; /* logarithmic base for rel->size decrease in case of long queries that cause an integer overflow; used in geqo_eval.c */ @@ -66,13 +66,13 @@ double SelectionBias; /* ^^^ */ /* geqo prototypes */ -extern Rel *geqo(Query * root); +extern Rel *geqo(Query * root); -extern void geqo_params(int string_length); +extern void geqo_params(int string_length); -extern Cost geqo_eval(Query * root, Gene * tour, int num_gene); -double geqo_log(double x, double b); -extern Rel *gimme_tree(Query * root, Gene * tour, int rel_count, int num_gene, Rel * outer_rel); +extern Cost geqo_eval(Query * root, Gene * tour, int num_gene); +double geqo_log(double x, double b); +extern Rel *gimme_tree(Query * root, Gene * tour, int rel_count, int num_gene, Rel * outer_rel); #endif /* GEQO_H */ diff --git a/src/include/optimizer/geqo_copy.h b/src/include/optimizer/geqo_copy.h index 5e1d2f931e1..219f503d914 100644 --- a/src/include/optimizer/geqo_copy.h +++ b/src/include/optimizer/geqo_copy.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_copy.h,v 1.2 1997/09/07 04:58:58 momjian Exp $ + * $Id: geqo_copy.h,v 1.3 1997/09/08 02:37:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,6 @@ #define GEQO_COPY_H -extern void geqo_copy(Chromosome * chromo1, Chromosome * chromo2, int string_length); +extern void geqo_copy(Chromosome * chromo1, Chromosome * chromo2, int string_length); #endif /* GEQO_COPY_H */ diff --git a/src/include/optimizer/geqo_gene.h b/src/include/optimizer/geqo_gene.h index b3a685e0d77..03634044110 100644 --- a/src/include/optimizer/geqo_gene.h +++ b/src/include/optimizer/geqo_gene.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_gene.h,v 1.2 1997/09/07 04:58:59 momjian Exp $ + * $Id: geqo_gene.h,v 1.3 1997/09/08 02:37:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,19 +26,19 @@ /* we presume that int instead of Relid is o.k. for Gene; so don't change it! */ typedef -int Gene; +int Gene; typedef struct Chromosome { - Gene *string; - Cost worth; -} Chromosome; + Gene *string; + Cost worth; +} Chromosome; typedef struct Pool { - Chromosome *data; - int size; - int string_length; -} Pool; + Chromosome *data; + int size; + int string_length; +} Pool; #endif /* GEQO_GENE_H */ diff --git a/src/include/optimizer/geqo_misc.h b/src/include/optimizer/geqo_misc.h index d3b72cb3028..83e89698150 100644 --- a/src/include/optimizer/geqo_misc.h +++ b/src/include/optimizer/geqo_misc.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.h,v 1.2 1997/09/07 04:59:00 momjian Exp $ + * $Id: geqo_misc.h,v 1.3 1997/09/08 02:37:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,12 +23,12 @@ #include <stdio.h> -extern void print_pool(FILE * fp, Pool * pool, int start, int stop); -extern void print_gen(FILE * fp, Pool * pool, int generation); -extern void print_edge_table(FILE * fp, Edge * edge_table, int num_gene); +extern void print_pool(FILE * fp, Pool * pool, int start, int stop); +extern void print_gen(FILE * fp, Pool * pool, int generation); +extern void print_edge_table(FILE * fp, Edge * edge_table, int num_gene); -extern void geqo_print_rel(Query * root, Rel * rel); -extern void geqo_print_path(Query * root, Path * path, int indent); -extern void geqo_print_joinclauses(Query * root, List * clauses); +extern void geqo_print_rel(Query * root, Rel * rel); +extern void geqo_print_path(Query * root, Path * path, int indent); +extern void geqo_print_joinclauses(Query * root, List * clauses); #endif /* GEQO_MISC_H */ diff --git a/src/include/optimizer/geqo_mutation.h b/src/include/optimizer/geqo_mutation.h index cc3f613c780..d195ba0c117 100644 --- a/src/include/optimizer/geqo_mutation.h +++ b/src/include/optimizer/geqo_mutation.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_mutation.h,v 1.2 1997/09/07 04:59:01 momjian Exp $ + * $Id: geqo_mutation.h,v 1.3 1997/09/08 02:37:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,6 +22,6 @@ #define GEQO_MUTATION_H -extern void geqo_mutation(Gene * tour, int num_gene); +extern void geqo_mutation(Gene * tour, int num_gene); #endif /* GEQO_MUTATION_H */ diff --git a/src/include/optimizer/geqo_paths.h b/src/include/optimizer/geqo_paths.h index 123367ad7e7..b9a9b7e096c 100644 --- a/src/include/optimizer/geqo_paths.h +++ b/src/include/optimizer/geqo_paths.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_paths.h,v 1.2 1997/09/07 04:59:02 momjian Exp $ + * $Id: geqo_paths.h,v 1.3 1997/09/08 02:37:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ #define GEQO_PATHS_H -extern List *geqo_prune_rels(List * rel_list); -extern void geqo_rel_paths(Rel * rel); +extern List *geqo_prune_rels(List * rel_list); +extern void geqo_rel_paths(Rel * rel); #endif /* GEQO_PATHS_H */ diff --git a/src/include/optimizer/geqo_pool.h b/src/include/optimizer/geqo_pool.h index ffcdc0c50bc..2642a8cc3d6 100644 --- a/src/include/optimizer/geqo_pool.h +++ b/src/include/optimizer/geqo_pool.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_pool.h,v 1.2 1997/09/07 04:59:03 momjian Exp $ + * $Id: geqo_pool.h,v 1.3 1997/09/08 02:37:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,15 +23,15 @@ #define GEQO_POOL_H -extern Pool *alloc_pool(int pool_size, int string_length); -extern void free_pool(Pool * pool); +extern Pool *alloc_pool(int pool_size, int string_length); +extern void free_pool(Pool * pool); -extern void random_init_pool(Query * root, Pool * pool, int strt, int stop); +extern void random_init_pool(Query * root, Pool * pool, int strt, int stop); extern Chromosome *alloc_chromo(int string_length); -extern void free_chromo(Chromosome * chromo); +extern void free_chromo(Chromosome * chromo); -extern void spread_chromo(Chromosome * chromo, Pool * pool); +extern void spread_chromo(Chromosome * chromo, Pool * pool); -extern void sort_pool(Pool * pool); +extern void sort_pool(Pool * pool); #endif /* GEQO_POOL_H */ diff --git a/src/include/optimizer/geqo_recombination.h b/src/include/optimizer/geqo_recombination.h index adcd9343f79..0b678504a46 100644 --- a/src/include/optimizer/geqo_recombination.h +++ b/src/include/optimizer/geqo_recombination.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_recombination.h,v 1.2 1997/09/07 04:59:04 momjian Exp $ + * $Id: geqo_recombination.h,v 1.3 1997/09/08 02:37:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,24 +24,24 @@ #define GEQO_RECOMBINATION_H -extern void init_tour(Gene * tour, int num_gene); +extern void init_tour(Gene * tour, int num_gene); /* edge recombination crossover [ERX] */ typedef struct Edge { - Gene edge_list[4]; /* list of edges */ - int total_edges; - int unused_edges; -} Edge; + Gene edge_list[4]; /* list of edges */ + int total_edges; + int unused_edges; +} Edge; -extern Edge *alloc_edge_table(int num_gene); -extern void free_edge_table(Edge * edge_table); +extern Edge *alloc_edge_table(int num_gene); +extern void free_edge_table(Edge * edge_table); -extern float gimme_edge_table(Gene * tour1, Gene * tour2, int num_gene, Edge * edge_table); +extern float gimme_edge_table(Gene * tour1, Gene * tour2, int num_gene, Edge * edge_table); -extern int gimme_tour(Edge * edge_table, Gene * new_gene, int num_gene); +extern int gimme_tour(Edge * edge_table, Gene * new_gene, int num_gene); /* partially matched crossover [PMX] */ @@ -49,31 +49,31 @@ extern int gimme_tour(Edge * edge_table, Gene * new_gene, int num_gene); #define DAD 1 /* indicator for gene from dad */ #define MOM 0 /* indicator for gene from mom */ -extern void pmx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene); +extern void pmx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene); typedef struct City { - int tour2_position; - int tour1_position; - int used; - int select_list; -} City; + int tour2_position; + int tour1_position; + int used; + int select_list; +} City; -extern City *alloc_city_table(int num_gene); -extern void free_city_table(City * city_table); +extern City *alloc_city_table(int num_gene); +extern void free_city_table(City * city_table); /* cycle crossover [CX] */ -extern int cx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table); +extern int cx(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table); /* position crossover [PX] */ -extern void px(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table); +extern void px(Gene * tour1, Gene * tour2, Gene * offspring, int num_gene, City * city_table); /* order crossover [OX1] according to Davis */ -extern void ox1(Gene * mom, Gene * dad, Gene * offspring, int num_gene, City * city_table); +extern void ox1(Gene * mom, Gene * dad, Gene * offspring, int num_gene, City * city_table); /* order crossover [OX2] according to Syswerda */ -extern void ox2(Gene * mom, Gene * dad, Gene * offspring, int num_gene, City * city_table); +extern void ox2(Gene * mom, Gene * dad, Gene * offspring, int num_gene, City * city_table); #endif /* GEQO_RECOMBINATION_H */ diff --git a/src/include/optimizer/geqo_selection.h b/src/include/optimizer/geqo_selection.h index 289fb73083f..910e2048915 100644 --- a/src/include/optimizer/geqo_selection.h +++ b/src/include/optimizer/geqo_selection.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_selection.h,v 1.2 1997/09/07 04:59:05 momjian Exp $ + * $Id: geqo_selection.h,v 1.3 1997/09/08 02:37:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,6 +23,6 @@ #define GEQO_SELECTION_H -extern void geqo_selection(Chromosome * momma, Chromosome * daddy, Pool * pool, double bias); +extern void geqo_selection(Chromosome * momma, Chromosome * daddy, Pool * pool, double bias); #endif /* GEQO_SELECTION_H */ diff --git a/src/include/optimizer/internal.h b/src/include/optimizer/internal.h index 3180f2e3a89..958c2b5221f 100644 --- a/src/include/optimizer/internal.h +++ b/src/include/optimizer/internal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: internal.h,v 1.8 1997/09/07 04:59:06 momjian Exp $ + * $Id: internal.h,v 1.9 1997/09/08 02:37:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,7 +80,7 @@ #define FLOAT_EQUAL(X,Y) ((X) - (Y) < TOLERANCE) #define FLOAT_IS_ZERO(X) (FLOAT_EQUAL(X,0.0)) -extern int BushyPlanFlag; +extern int BushyPlanFlag; /* #define deactivate_joininfo(joininfo) joininfo->inactive=true*/ /*#define joininfo_inactive(joininfo) joininfo->inactive */ diff --git a/src/include/optimizer/joininfo.h b/src/include/optimizer/joininfo.h index 8294e6cb648..505b6a64c28 100644 --- a/src/include/optimizer/joininfo.h +++ b/src/include/optimizer/joininfo.h @@ -6,15 +6,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: joininfo.h,v 1.2 1997/09/07 04:59:07 momjian Exp $ + * $Id: joininfo.h,v 1.3 1997/09/08 02:37:50 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef JOININFO_H #define JOININFO_H -extern JInfo *joininfo_member(List * join_relids, List * joininfo_list); -extern JInfo *find_joininfo_node(Rel * this_rel, List * join_relids); -extern Var *other_join_clause_var(Var * var, Expr * clause); +extern JInfo *joininfo_member(List * join_relids, List * joininfo_list); +extern JInfo *find_joininfo_node(Rel * this_rel, List * join_relids); +extern Var *other_join_clause_var(Var * var, Expr * clause); #endif /* JOININFO_H */ diff --git a/src/include/optimizer/keys.h b/src/include/optimizer/keys.h index e267777c210..cf85d6ef174 100644 --- a/src/include/optimizer/keys.h +++ b/src/include/optimizer/keys.h @@ -6,16 +6,16 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: keys.h,v 1.3 1997/09/07 04:59:08 momjian Exp $ + * $Id: keys.h,v 1.4 1997/09/08 02:37:51 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef KEYS_H #define KEYS_H -extern bool match_indexkey_operand(int indexkey, Var * operand, Rel * rel); -extern Var *extract_subkey(JoinKey * jk, int which_subkey); -extern bool samekeys(List * keys1, List * keys2); -extern List *collect_index_pathkeys(int *index_keys, List * tlist); +extern bool match_indexkey_operand(int indexkey, Var * operand, Rel * rel); +extern Var *extract_subkey(JoinKey * jk, int which_subkey); +extern bool samekeys(List * keys1, List * keys2); +extern List *collect_index_pathkeys(int *index_keys, List * tlist); #endif /* KEYS_H */ diff --git a/src/include/optimizer/ordering.h b/src/include/optimizer/ordering.h index 7ed360098b7..9d36ac3aaad 100644 --- a/src/include/optimizer/ordering.h +++ b/src/include/optimizer/ordering.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: ordering.h,v 1.4 1997/09/07 04:59:09 momjian Exp $ + * $Id: ordering.h,v 1.5 1997/09/08 02:37:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,13 +15,13 @@ #include <nodes/relation.h> -extern bool +extern bool equal_path_path_ordering(PathOrder * path_ordering1, PathOrder * path_ordering2); -extern bool +extern bool equal_path_merge_ordering(Oid * path_ordering, MergeOrder * merge_ordering); -extern bool +extern bool equal_merge_merge_ordering(MergeOrder * merge_ordering1, MergeOrder * merge_ordering2); diff --git a/src/include/optimizer/pathnode.h b/src/include/optimizer/pathnode.h index 9474e1ea8d9..b5538513007 100644 --- a/src/include/optimizer/pathnode.h +++ b/src/include/optimizer/pathnode.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pathnode.h,v 1.2 1997/09/07 04:59:11 momjian Exp $ + * $Id: pathnode.h,v 1.3 1997/09/08 02:37:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,12 +16,12 @@ /* * prototypes for pathnode.c */ -extern bool path_is_cheaper(Path * path1, Path * path2); -extern Path *set_cheapest(Rel * parent_rel, List * pathlist); -extern List * +extern bool path_is_cheaper(Path * path1, Path * path2); +extern Path *set_cheapest(Rel * parent_rel, List * pathlist); +extern List * add_pathlist(Rel * parent_rel, List * unique_paths, List * new_paths); -extern Path *create_seqscan_path(Rel * rel); +extern Path *create_seqscan_path(Rel * rel); extern IndexPath * create_index_path(Query * root, Rel * rel, Rel * index, List * restriction_clauses, bool is_join_scan); @@ -43,13 +43,13 @@ create_hashjoin_path(Rel * joinrel, int outersize, /* * prototypes for rel.c */ -extern Rel *rel_member(List * relid, List * rels); -extern Rel *get_base_rel(Query * root, int relid); -extern Rel *get_join_rel(Query * root, List * relid); +extern Rel *rel_member(List * relid, List * rels); +extern Rel *get_base_rel(Query * root, int relid); +extern Rel *get_join_rel(Query * root, List * relid); /* * prototypes for indexnode.h */ -extern List *find_relation_indices(Query * root, Rel * rel); +extern List *find_relation_indices(Query * root, Rel * rel); #endif /* PATHNODE_H */ diff --git a/src/include/optimizer/paths.h b/src/include/optimizer/paths.h index 841c4983311..c3403e19a04 100644 --- a/src/include/optimizer/paths.h +++ b/src/include/optimizer/paths.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: paths.h,v 1.2 1997/09/07 04:59:13 momjian Exp $ + * $Id: paths.h,v 1.3 1997/09/08 02:37:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,13 +17,13 @@ /* * allpaths.h */ -extern List *find_paths(Query * root, List * rels); +extern List *find_paths(Query * root, List * rels); /* * indxpath.h * routines to generate index paths */ -extern List * +extern List * find_index_paths(Query * root, Rel * rel, List * indices, List * clauseinfo_list, List * joininfo_list); @@ -32,19 +32,19 @@ find_index_paths(Query * root, Rel * rel, List * indices, * joinpath.h * routines to create join paths */ -extern void find_all_join_paths(Query * root, List * joinrels); +extern void find_all_join_paths(Query * root, List * joinrels); /* * orindxpath.h */ -extern List *create_or_index_paths(Query * root, Rel * rel, List * clauses); +extern List *create_or_index_paths(Query * root, Rel * rel, List * clauses); /* * hashutils.h * routines to deal with hash keys and clauses */ -extern List * +extern List * group_clauses_by_hashop(List * clauseinfo_list, int inner_relid); @@ -52,17 +52,17 @@ group_clauses_by_hashop(List * clauseinfo_list, * joinutils.h * generic join method key/clause routines */ -extern List * +extern List * match_pathkeys_joinkeys(List * pathkeys, List * joinkeys, List * joinclauses, int which_subkey, List ** matchedJoinClausesPtr); -extern List * +extern List * extract_path_keys(List * joinkeys, List * tlist, int which_subkey); -extern Path * +extern Path * match_paths_joinkeys(List * joinkeys, PathOrder * ordering, List * paths, int which_subkey); -extern List * +extern List * new_join_pathkeys(List * outer_pathkeys, List * join_rel_tlist, List * joinclauses); @@ -70,10 +70,10 @@ new_join_pathkeys(List * outer_pathkeys, * mergeutils.h * routines to deal with merge keys and clauses */ -extern List * +extern List * group_clauses_by_order(List * clauseinfo_list, int inner_relid); -extern MInfo * +extern MInfo * match_order_mergeinfo(PathOrder * ordering, List * mergeinfo_list); @@ -81,17 +81,17 @@ match_order_mergeinfo(PathOrder * ordering, * joinrels.h * routines to determine which relations to join */ -extern List *find_join_rels(Query * root, List * outer_rels); -extern void add_new_joininfos(Query * root, List * joinrels, List * outerrels); -extern List *final_join_rels(List * join_rel_list); +extern List *find_join_rels(Query * root, List * outer_rels); +extern void add_new_joininfos(Query * root, List * joinrels, List * outerrels); +extern List *final_join_rels(List * join_rel_list); /* * prototypes for path/prune.c */ -extern List *prune_joinrels(List * rel_list); -extern void prune_rel_paths(List * rel_list); -extern Path *prune_rel_path(Rel * rel, Path * unorderedpath); -extern List *merge_joinrels(List * rel_list1, List * rel_list2); -extern List *prune_oldrels(List * old_rels); +extern List *prune_joinrels(List * rel_list); +extern void prune_rel_paths(List * rel_list); +extern Path *prune_rel_path(Rel * rel, Path * unorderedpath); +extern List *merge_joinrels(List * rel_list1, List * rel_list2); +extern List *prune_oldrels(List * old_rels); #endif /* PATHS_H */ diff --git a/src/include/optimizer/plancat.h b/src/include/optimizer/plancat.h index 1b57c575e15..1a2686e3d31 100644 --- a/src/include/optimizer/plancat.h +++ b/src/include/optimizer/plancat.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: plancat.h,v 1.4 1997/09/07 04:59:15 momjian Exp $ + * $Id: plancat.h,v 1.5 1997/09/08 02:37:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -21,17 +21,17 @@ */ typedef struct IdxInfoRetval { - Oid relid; /* OID of the index relation (not the OID + Oid relid; /* OID of the index relation (not the OID * of the relation being indexed) */ - Oid relam; /* OID of the pg_am of this index */ - int pages; /* number of pages in the index relation */ - int tuples; /* number of tuples in the index relation */ - int *indexkeys; /* keys over which we're indexing */ - Oid *orderOprs; /* operators used for ordering purposes */ - Oid *classlist; /* classes of AM operators */ - Oid indproc; - Node *indpred; -} IdxInfoRetval; + Oid relam; /* OID of the pg_am of this index */ + int pages; /* number of pages in the index relation */ + int tuples; /* number of tuples in the index relation */ + int *indexkeys; /* keys over which we're indexing */ + Oid *orderOprs; /* operators used for ordering purposes */ + Oid *classlist; /* classes of AM operators */ + Oid indproc; + Node *indpred; +} IdxInfoRetval; extern void @@ -40,11 +40,11 @@ relation_info(Query * root, bool * hashindex, int *pages, int *tuples); -extern bool +extern bool index_info(Query * root, bool first, int relid, IdxInfoRetval * info); -extern Cost +extern Cost restriction_selectivity(Oid functionObjectId, Oid operatorObjectId, Oid relationObjectId, @@ -57,12 +57,12 @@ index_selectivity(Oid indid, Oid * classes, List * opnos, Oid relid, List * attnos, List * values, List * flags, int32 nkeys, float *idxPages, float *idxSelec); -extern Cost +extern Cost join_selectivity(Oid functionObjectId, Oid operatorObjectId, Oid relationObjectId1, AttrNumber attributeNumber1, Oid relationObjectId2, AttrNumber attributeNumber2); -extern List *find_inheritance_children(Oid inhparent); -extern List *VersionGetParents(Oid verrelid); +extern List *find_inheritance_children(Oid inhparent); +extern List *VersionGetParents(Oid verrelid); #endif /* PLANCAT_H */ diff --git a/src/include/optimizer/planmain.h b/src/include/optimizer/planmain.h index 9c8abc450d2..2d9c41391a8 100644 --- a/src/include/optimizer/planmain.h +++ b/src/include/optimizer/planmain.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: planmain.h,v 1.2 1997/09/07 04:59:17 momjian Exp $ + * $Id: planmain.h,v 1.3 1997/09/08 02:37:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ /* * prototypes for plan/planmain.c */ -extern Plan * +extern Plan * query_planner(Query * root, int command_type, List * tlist, List * qual); @@ -25,42 +25,42 @@ query_planner(Query * root, /* * prototypes for plan/createplan.c */ -extern Plan *create_plan(Path * best_path); +extern Plan *create_plan(Path * best_path); extern SeqScan * make_seqscan(List * qptlist, List * qpqual, Index scanrelid, Plan * lefttree); -extern Sort * +extern Sort * make_sort(List * tlist, Oid tempid, Plan * lefttree, int keycount); -extern Agg *make_agg(List * tlist, int nagg, Aggreg ** aggs); -extern Group * +extern Agg *make_agg(List * tlist, int nagg, Aggreg ** aggs); +extern Group * make_group(List * tlist, bool tuplePerGroup, int ngrp, AttrNumber * grpColIdx, Sort * lefttree); -extern Unique *make_unique(List * tlist, Plan * lefttree, char *uniqueAttr); -extern List *generate_fjoin(List * tlist); +extern Unique *make_unique(List * tlist, Plan * lefttree, char *uniqueAttr); +extern List *generate_fjoin(List * tlist); /* * prototypes for plan/initsplan.c */ -extern void initialize_base_rels_list(Query * root, List * tlist); -extern void initialize_base_rels_jinfo(Query * root, List * clauses); -extern void initialize_join_clause_info(List * rel_list); -extern void add_missing_vars_to_base_rels(Query * root, List * tlist); +extern void initialize_base_rels_list(Query * root, List * tlist); +extern void initialize_base_rels_jinfo(Query * root, List * clauses); +extern void initialize_join_clause_info(List * rel_list); +extern void add_missing_vars_to_base_rels(Query * root, List * tlist); /* * prototypes for plan/setrefs.c */ -extern void set_tlist_references(Plan * plan); -extern List * +extern void set_tlist_references(Plan * plan); +extern List * join_references(List * clauses, List * outer_tlist, List * inner_tlist); -extern List * +extern List * index_outerjoin_references(List * inner_indxqual, List * outer_tlist, Index inner_relid); -extern void set_result_tlist_references(Result * resultNode); -extern void set_agg_tlist_references(Agg * aggNode); -extern void set_agg_agglist_references(Agg * aggNode); +extern void set_result_tlist_references(Result * resultNode); +extern void set_agg_tlist_references(Agg * aggNode); +extern void set_agg_agglist_references(Agg * aggNode); #endif /* PLANMAIN_H */ diff --git a/src/include/optimizer/planner.h b/src/include/optimizer/planner.h index d8f7be50e6f..9f0375a599e 100644 --- a/src/include/optimizer/planner.h +++ b/src/include/optimizer/planner.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: planner.h,v 1.3 1997/09/07 04:59:18 momjian Exp $ + * $Id: planner.h,v 1.4 1997/09/08 02:37:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ /* */ -extern Plan *planner(Query * parse); -extern void pg_checkretval(Oid rettype, QueryTreeList * querytree_list); +extern Plan *planner(Query * parse); +extern void pg_checkretval(Oid rettype, QueryTreeList * querytree_list); #endif /* PLANNER_H */ diff --git a/src/include/optimizer/prep.h b/src/include/optimizer/prep.h index 6e408a84173..ccc721495b2 100644 --- a/src/include/optimizer/prep.h +++ b/src/include/optimizer/prep.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: prep.h,v 1.3 1997/09/07 04:59:18 momjian Exp $ + * $Id: prep.h,v 1.4 1997/09/08 02:37:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,21 +19,21 @@ /* * prototypes for archive.h */ -extern void plan_archive(List * rt); -extern List *find_archive_rels(Oid relid); +extern void plan_archive(List * rt); +extern List *find_archive_rels(Oid relid); /* * prototypes for prepqual.h */ -extern List * +extern List * preprocess_qualification(Expr * qual, List * tlist, List ** existentialQualPtr); -extern List *cnfify(Expr * qual, bool removeAndFlag); +extern List *cnfify(Expr * qual, bool removeAndFlag); /* * prototypes for preptlist.h */ -extern List * +extern List * preprocess_targetlist(List * tlist, int command_type, Index result_relation, List * range_table); @@ -43,13 +43,13 @@ preprocess_targetlist(List * tlist, int command_type, typedef enum UnionFlag { INHERITS_FLAG, ARCHIVE_FLAG, VERSION_FLAG -} UnionFlag; +} UnionFlag; -extern List * +extern List * find_all_inheritors(List * unexamined_relids, List * examined_relids); -extern int first_matching_rt_entry(List * rangetable, UnionFlag flag); -extern Append * +extern int first_matching_rt_entry(List * rangetable, UnionFlag flag); +extern Append * plan_union_queries(Index rt_index, Query * parse, UnionFlag flag); diff --git a/src/include/optimizer/tlist.h b/src/include/optimizer/tlist.h index e83c1d10677..99299db7571 100644 --- a/src/include/optimizer/tlist.h +++ b/src/include/optimizer/tlist.h @@ -6,30 +6,30 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tlist.h,v 1.3 1997/09/07 04:59:19 momjian Exp $ + * $Id: tlist.h,v 1.4 1997/09/08 02:37:57 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef TLIST_H #define TLIST_H -extern int exec_tlist_length(List * targelist); +extern int exec_tlist_length(List * targelist); extern TargetEntry *tlistentry_member(Var * var, List * targetlist); -extern Expr *matching_tlvar(Var * var, List * targetlist); -extern void add_tl_element(Rel * rel, Var * var); +extern Expr *matching_tlvar(Var * var, List * targetlist); +extern void add_tl_element(Rel * rel, Var * var); extern TargetEntry *create_tl_element(Var * var, int resdomno); -extern List *get_actual_tlist(List * tlist); -extern Resdom *tlist_member(Var * var, List * tlist); -extern Resdom *tlist_resdom(List * tlist, Resdom * resnode); +extern List *get_actual_tlist(List * tlist); +extern Resdom *tlist_member(Var * var, List * tlist); +extern Resdom *tlist_resdom(List * tlist, Resdom * resnode); extern TargetEntry *MakeTLE(Resdom * resdom, Node * expr); -extern Var *get_expr(TargetEntry * tle); +extern Var *get_expr(TargetEntry * tle); extern TargetEntry *match_varid(Var * test_var, List * tlist); -extern List *new_unsorted_tlist(List * targetlist); -extern List *copy_vars(List * target, List * source); -extern List *flatten_tlist(List * tlist); -extern List * +extern List *new_unsorted_tlist(List * targetlist); +extern List *copy_vars(List * target, List * source); +extern List *flatten_tlist(List * tlist); +extern List * flatten_tlist_vars(List * full_tlist, List * flat_tlist); diff --git a/src/include/optimizer/var.h b/src/include/optimizer/var.h index 519b6957249..372e5a27a8c 100644 --- a/src/include/optimizer/var.h +++ b/src/include/optimizer/var.h @@ -6,16 +6,16 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: var.h,v 1.2 1997/09/07 04:59:23 momjian Exp $ + * $Id: var.h,v 1.3 1997/09/08 02:37:58 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef VAR_H #define VAR_H -extern List *pull_varnos(Node * me); -extern bool contain_var_clause(Node * clause); -extern List *pull_var_clause(Node * clause); -extern bool var_equal(Var * var1, Var * var2); +extern List *pull_varnos(Node * me); +extern bool contain_var_clause(Node * clause); +extern List *pull_var_clause(Node * clause); +extern bool var_equal(Var * var1, Var * var2); #endif /* VAR_H */ diff --git a/src/include/optimizer/xfunc.h b/src/include/optimizer/xfunc.h index a608771effb..b8232db4f7a 100644 --- a/src/include/optimizer/xfunc.h +++ b/src/include/optimizer/xfunc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: xfunc.h,v 1.3 1997/09/07 04:59:26 momjian Exp $ + * $Id: xfunc.h,v 1.4 1997/09/08 02:37:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ #define XFUNC_JOINPRD 2 #define XFUNC_UNKNOWN 0 -extern int XfuncMode; /* defined in tcop/postgres.c */ +extern int XfuncMode; /* defined in tcop/postgres.c */ /* defaults for function attributes used for expensive function calculations */ #define BYTE_PCT 100 @@ -49,42 +49,42 @@ extern int XfuncMode; /* defined in tcop/postgres.c */ #define is_join(pathnode) (length(get_relids(get_parent(pathnode))) > 1 ? 1 : 0) /* function prototypes from planner/path/xfunc.c */ -extern void xfunc_trypullup(Rel * rel); +extern void xfunc_trypullup(Rel * rel); extern int xfunc_shouldpull(Path * childpath, JoinPath * parentpath, int whichchild, CInfo * maxcinfopt); -extern CInfo * +extern CInfo * xfunc_pullup(Path * childpath, JoinPath * parentpath, CInfo * cinfo, int whichchild, int clausetype); -extern Cost xfunc_rank(Expr * clause); -extern Cost xfunc_expense(Query * queryInfo, Expr * clause); -extern Cost xfunc_join_expense(JoinPath * path, int whichchild); -extern Cost xfunc_local_expense(Expr * clause); -extern Cost xfunc_func_expense(Expr * node, List * args); -extern int xfunc_width(Expr * clause); +extern Cost xfunc_rank(Expr * clause); +extern Cost xfunc_expense(Query * queryInfo, Expr * clause); +extern Cost xfunc_join_expense(JoinPath * path, int whichchild); +extern Cost xfunc_local_expense(Expr * clause); +extern Cost xfunc_func_expense(Expr * node, List * args); +extern int xfunc_width(Expr * clause); /* static, moved to xfunc.c */ /* extern int xfunc_card_unreferenced(Expr *clause, Relid referenced); */ -extern int xfunc_card_product(Relid relids); -extern List *xfunc_find_references(List * clause); -extern List *xfunc_primary_join(JoinPath * pathnode); -extern Cost xfunc_get_path_cost(Path * pathnode); -extern Cost xfunc_total_path_cost(JoinPath * pathnode); -extern Cost xfunc_expense_per_tuple(JoinPath * joinnode, int whichchild); -extern void xfunc_fixvars(Expr * clause, Rel * rel, int varno); -extern int xfunc_cinfo_compare(void *arg1, void *arg2); -extern int xfunc_clause_compare(void *arg1, void *arg2); -extern void xfunc_disjunct_sort(List * clause_list); -extern int xfunc_disjunct_compare(void *arg1, void *arg2); -extern int xfunc_func_width(RegProcedure funcid, List * args); -extern int xfunc_tuple_width(Relation rd); -extern int xfunc_num_join_clauses(JoinPath * path); -extern List *xfunc_LispRemove(List * foo, List * bar); -extern bool xfunc_copyrel(Rel * from, Rel ** to); +extern int xfunc_card_product(Relid relids); +extern List *xfunc_find_references(List * clause); +extern List *xfunc_primary_join(JoinPath * pathnode); +extern Cost xfunc_get_path_cost(Path * pathnode); +extern Cost xfunc_total_path_cost(JoinPath * pathnode); +extern Cost xfunc_expense_per_tuple(JoinPath * joinnode, int whichchild); +extern void xfunc_fixvars(Expr * clause, Rel * rel, int varno); +extern int xfunc_cinfo_compare(void *arg1, void *arg2); +extern int xfunc_clause_compare(void *arg1, void *arg2); +extern void xfunc_disjunct_sort(List * clause_list); +extern int xfunc_disjunct_compare(void *arg1, void *arg2); +extern int xfunc_func_width(RegProcedure funcid, List * args); +extern int xfunc_tuple_width(Relation rd); +extern int xfunc_num_join_clauses(JoinPath * path); +extern List *xfunc_LispRemove(List * foo, List * bar); +extern bool xfunc_copyrel(Rel * from, Rel ** to); /* * function prototypes for path/predmig.c */ -extern bool xfunc_do_predmig(Path root); +extern bool xfunc_do_predmig(Path root); #endif /* XFUNC_H */ diff --git a/src/include/parser/catalog_utils.h b/src/include/parser/catalog_utils.h index dd2241e19e0..0a449713122 100644 --- a/src/include/parser/catalog_utils.h +++ b/src/include/parser/catalog_utils.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: catalog_utils.h,v 1.11 1997/09/07 04:59:27 momjian Exp $ + * $Id: catalog_utils.h,v 1.12 1997/09/08 02:38:01 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,36 +19,36 @@ typedef HeapTuple Type; typedef HeapTuple Operator; -extern Type get_id_type(Oid id); -extern char *get_id_typname(Oid id); -extern Type type(char *); -extern Oid att_typeid(Relation rd, int attid); -extern int att_attnelems(Relation rd, int attid); -extern Oid typeid(Type tp); -extern int16 tlen(Type t); -extern bool tbyval(Type t); -extern char *tname(Type t); -extern int tbyvalue(Type t); -extern Oid oprid(Operator op); +extern Type get_id_type(Oid id); +extern char *get_id_typname(Oid id); +extern Type type(char *); +extern Oid att_typeid(Relation rd, int attid); +extern int att_attnelems(Relation rd, int attid); +extern Oid typeid(Type tp); +extern int16 tlen(Type t); +extern bool tbyval(Type t); +extern char *tname(Type t); +extern int tbyvalue(Type t); +extern Oid oprid(Operator op); extern Operator oper(char *op, Oid arg1, Oid arg2, bool noWarnings); extern Operator right_oper(char *op, Oid arg); extern Operator left_oper(char *op, Oid arg); -extern int varattno(Relation rd, char *a); -extern bool varisset(Relation rd, char *name); -extern int nf_varattno(Relation rd, char *a); -extern char *getAttrName(Relation rd, int attrno); -extern char *instr2(Type tp, char *string, int typlen); -extern Oid GetArrayElementType(Oid typearray); -extern Oid funcid_get_rettype(Oid funcid); -extern bool +extern int varattno(Relation rd, char *a); +extern bool varisset(Relation rd, char *name); +extern int nf_varattno(Relation rd, char *a); +extern char *getAttrName(Relation rd, int attrno); +extern char *instr2(Type tp, char *string, int typlen); +extern Oid GetArrayElementType(Oid typearray); +extern Oid funcid_get_rettype(Oid funcid); +extern bool func_get_detail(char *funcname, int nargs, Oid * oid_array, Oid * funcid, Oid * rettype, bool * retset, Oid ** true_typeids); -extern Oid typeid_get_retinfunc(Oid type_id); -extern Oid typeid_get_retoutfunc(Oid type_id); -extern Oid typeid_get_relid(Oid type_id); -extern Oid get_typrelid(Type typ); -extern Oid get_typelem(Oid type_id); -extern void func_error(char *caller, char *funcname, int nargs, Oid * argtypes); -extern void agg_error(char *caller, char *aggname, Oid basetypeID); +extern Oid typeid_get_retinfunc(Oid type_id); +extern Oid typeid_get_retoutfunc(Oid type_id); +extern Oid typeid_get_relid(Oid type_id); +extern Oid get_typrelid(Type typ); +extern Oid get_typelem(Oid type_id); +extern void func_error(char *caller, char *funcname, int nargs, Oid * argtypes); +extern void agg_error(char *caller, char *aggname, Oid basetypeID); #endif /* CATALOG_UTILS_H */ diff --git a/src/include/parser/dbcommands.h b/src/include/parser/dbcommands.h index 4a7f32225ca..76b1dc6a0ee 100644 --- a/src/include/parser/dbcommands.h +++ b/src/include/parser/dbcommands.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dbcommands.h,v 1.3 1997/09/07 04:59:29 momjian Exp $ + * $Id: dbcommands.h,v 1.4 1997/09/08 02:38:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ #define SIGKILLDAEMON1 SIGINT #define SIGKILLDAEMON2 SIGTERM -extern void createdb(char *dbname); -extern void destroydb(char *dbname); +extern void createdb(char *dbname); +extern void destroydb(char *dbname); #endif /* DBCOMMANDS_H */ diff --git a/src/include/parser/gramparse.h b/src/include/parser/gramparse.h index 67ed5940f27..96168936851 100644 --- a/src/include/parser/gramparse.h +++ b/src/include/parser/gramparse.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: gramparse.h,v 1.3 1997/09/07 04:59:31 momjian Exp $ + * $Id: gramparse.h,v 1.4 1997/09/08 02:38:11 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,10 +15,10 @@ #define GRAMPARSE_H /* include once only */ /* from scan.l */ -extern void init_io(void); +extern void init_io(void); /* from gram.y */ -extern void parser_init(Oid * typev, int nargs); -extern int yyparse(void); +extern void parser_init(Oid * typev, int nargs); +extern int yyparse(void); #endif /* GRAMPARSE_H */ diff --git a/src/include/parser/keywords.h b/src/include/parser/keywords.h index 1453d60e1a4..9d459cda8ad 100644 --- a/src/include/parser/keywords.h +++ b/src/include/parser/keywords.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: keywords.h,v 1.2 1997/09/07 04:59:34 momjian Exp $ + * $Id: keywords.h,v 1.3 1997/09/08 02:38:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,11 +16,11 @@ typedef struct ScanKeyword { - char *name; - int value; -} ScanKeyword; + char *name; + int value; +} ScanKeyword; extern ScanKeyword *ScanKeywordLookup(char *text); -extern char *AtomValueGetString(int atomval); +extern char *AtomValueGetString(int atomval); #endif /* KEYWORDS_H */ diff --git a/src/include/parser/parse_query.h b/src/include/parser/parse_query.h index decf425ca92..63310a8bd72 100644 --- a/src/include/parser/parse_query.h +++ b/src/include/parser/parse_query.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_query.h,v 1.10 1997/09/07 04:59:36 momjian Exp $ + * $Id: parse_query.h,v 1.11 1997/09/08 02:38:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,44 +19,44 @@ typedef struct QueryTreeList { - int len; /* number of queries */ - Query **qtrees; -} QueryTreeList; + int len; /* number of queries */ + Query **qtrees; +} QueryTreeList; extern RangeTblEntry *refnameRangeTableEntry(List * rtable, char *refname); extern RangeTblEntry *colnameRangeTableEntry(ParseState * pstate, char *colname); -extern int refnameRangeTablePosn(List * rtable, char *refname); +extern int refnameRangeTablePosn(List * rtable, char *refname); extern RangeTblEntry * addRangeTableEntry(ParseState * pstate, char *relname, char *refname, bool inh, bool inFromCl, TimeRange * timeRange); -extern List * +extern List * expandAll(ParseState * pstate, char *relname, char *refname, int *this_resno); -extern TimeQual +extern TimeQual makeTimeRange(char *datestring1, char *datestring2, int timecode); -extern Expr *make_op(char *opname, Node * ltree, Node * rtree); +extern Expr *make_op(char *opname, Node * ltree, Node * rtree); -extern Oid find_atttype(Oid relid, char *attrname); -extern Var * +extern Oid find_atttype(Oid relid, char *attrname); +extern Var * make_var(ParseState * pstate, char *relname, char *attrname, Oid * type_id); extern ArrayRef *make_array_ref(Node * array, List * indirection); extern ArrayRef * make_array_set(Expr * target_expr, List * upperIndexpr, List * lowerIndexpr, Expr * expr); -extern Const *make_const(Value * value); +extern Const *make_const(Value * value); -extern void param_type_init(Oid * typev, int nargs); -extern Oid param_type(int t); +extern void param_type_init(Oid * typev, int nargs); +extern Oid param_type(int t); /* parser.c (was ylib.c) */ extern QueryTreeList *parser(char *str, Oid * typev, int nargs); -extern Node *parser_typecast(Value * expr, TypeName * typename, int typlen); -extern Node *parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen); -extern Aggreg *ParseAgg(char *aggname, Oid basetype, Node * target); +extern Node *parser_typecast(Value * expr, TypeName * typename, int typlen); +extern Node *parser_typecast2(Node * expr, Oid exprType, Type tp, int typlen); +extern Aggreg *ParseAgg(char *aggname, Oid basetype, Node * target); extern void handleTargetColname(ParseState * pstate, char **resname, char *refname, char *colname); @@ -65,12 +65,12 @@ handleTargetColname(ParseState * pstate, char **resname, * analyze.c */ -Oid exprType(Node * expr); -QueryTreeList *parse_analyze(List * querytree_list); +Oid exprType(Node * expr); +QueryTreeList *parse_analyze(List * querytree_list); /* define in parse_query.c, used in gram.y */ -extern Oid *param_type_info; -extern int pfunc_num_args; +extern Oid *param_type_info; +extern int pfunc_num_args; /* useful macros */ #define ISCOMPLEX(type) (typeid_get_relid(type) ? true : false) diff --git a/src/include/parser/parse_state.h b/src/include/parser/parse_state.h index 05f860290fb..ce41c6cd769 100644 --- a/src/include/parser/parse_state.h +++ b/src/include/parser/parse_state.h @@ -4,7 +4,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: parse_state.h,v 1.6 1997/09/07 04:59:37 momjian Exp $ + * $Id: parse_state.h,v 1.7 1997/09/08 02:38:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,17 +18,17 @@ /* state information used during parse analysis */ typedef struct ParseState { - int p_last_resno; - List *p_rtable; - int p_numAgg; - List *p_aggs; - bool p_is_insert; - List *p_insert_columns; - bool p_is_update; - bool p_is_rule; - Relation p_target_relation; - RangeTblEntry *p_target_rangetblentry; -} ParseState; + int p_last_resno; + List *p_rtable; + int p_numAgg; + List *p_aggs; + bool p_is_insert; + List *p_insert_columns; + bool p_is_update; + bool p_is_rule; + Relation p_target_relation; + RangeTblEntry *p_target_rangetblentry; +} ParseState; #endif /* PARSE_QUERY_H */ diff --git a/src/include/parser/scansup.h b/src/include/parser/scansup.h index e3dd13a6064..660a63db4ea 100644 --- a/src/include/parser/scansup.h +++ b/src/include/parser/scansup.h @@ -6,9 +6,9 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: scansup.h,v 1.2 1997/09/07 04:59:39 momjian Exp $ + * $Id: scansup.h,v 1.3 1997/09/08 02:38:16 momjian Exp $ * *------------------------------------------------------------------------- */ -extern char *scanstr(char *s); +extern char *scanstr(char *s); diff --git a/src/include/parser/sysfunc.h b/src/include/parser/sysfunc.h index 2a1f87d8590..6ba643c005c 100644 --- a/src/include/parser/sysfunc.h +++ b/src/include/parser/sysfunc.h @@ -6,4 +6,4 @@ * ------------------------------------------------------------------------- */ -extern char *SystemFunctionHandler(char *funct); +extern char *SystemFunctionHandler(char *funct); diff --git a/src/include/port/hpux.h b/src/include/port/hpux.h index ec0859e521c..447b8ee4427 100644 --- a/src/include/port/hpux.h +++ b/src/include/port/hpux.h @@ -3,8 +3,8 @@ #define HAS_TEST_AND_SET typedef struct { - int sem[4]; -} slock_t; + int sem[4]; +} slock_t; #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 diff --git a/src/include/port/nextstep.h b/src/include/port/nextstep.h index f893b48b03c..d0b43d57163 100644 --- a/src/include/port/nextstep.h +++ b/src/include/port/nextstep.h @@ -3,11 +3,11 @@ #if defined(__STRICT_ANSI__) #define isascii(c) ((unsigned)(c)<=0177) #endif -extern char *strdup(const char *string); +extern char *strdup(const char *string); #ifndef _POSIX_SOURCE typedef unsigned short mode_t; -typedef int sigset_t; +typedef int sigset_t; #define SIG_BLOCK 00 #define SIG_UNBLOCK 01 diff --git a/src/include/port/ultrix4.h b/src/include/port/ultrix4.h index 87678df9ba2..872583bfa42 100644 --- a/src/include/port/ultrix4.h +++ b/src/include/port/ultrix4.h @@ -26,48 +26,48 @@ #include <sys/types.h> /* Declare various types, e.g. size_t, * fd_set */ -extern int strcasecmp(const char *, const char *); -extern void bzero(void *, size_t); +extern int strcasecmp(const char *, const char *); +extern void bzero(void *, size_t); -extern int fp_class_d(double); -extern long random(void); +extern int fp_class_d(double); +extern long random(void); struct rusage; -extern int getrusage(int, struct rusage *); +extern int getrusage(int, struct rusage *); -extern int ioctl(int, unsigned long,...); +extern int ioctl(int, unsigned long,...); -extern int socket(int, int, int); +extern int socket(int, int, int); struct sockaddr; -extern int connect(int, const struct sockaddr *, int); -typedef int ssize_t; -extern ssize_t send(int, const void *, size_t, int); -extern ssize_t recv(int, void *, size_t, int); -extern int setsockopt(int, int, int, const void *, int); -extern int bind(int, const struct sockaddr *, int); -extern int listen(int, int); -extern int accept(int, struct sockaddr *, int *); -extern int getsockname(int, struct sockaddr *, int *); -extern ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, int *); -extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, int); +extern int connect(int, const struct sockaddr *, int); +typedef int ssize_t; +extern ssize_t send(int, const void *, size_t, int); +extern ssize_t recv(int, void *, size_t, int); +extern int setsockopt(int, int, int, const void *, int); +extern int bind(int, const struct sockaddr *, int); +extern int listen(int, int); +extern int accept(int, struct sockaddr *, int *); +extern int getsockname(int, struct sockaddr *, int *); +extern ssize_t recvfrom(int, void *, size_t, int, struct sockaddr *, int *); +extern ssize_t sendto(int, const void *, size_t, int, const struct sockaddr *, int); struct timeval; -extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); +extern int select(int, fd_set *, fd_set *, fd_set *, struct timeval *); -extern int gethostname(char *, int); +extern int gethostname(char *, int); -extern int getopt(int, char *const *, const char *); -extern int putenv(const char *); +extern int getopt(int, char *const *, const char *); +extern int putenv(const char *); -extern pid_t vfork(void); +extern pid_t vfork(void); struct itimerval; -extern int setitimer(int, const struct itimerval *, struct itimerval *); +extern int setitimer(int, const struct itimerval *, struct itimerval *); struct timezone; -extern int gettimeofday(struct timeval *, struct timezone *); +extern int gettimeofday(struct timeval *, struct timezone *); -extern int fsync(int); -extern int ftruncate(int, off_t); +extern int fsync(int); +extern int ftruncate(int, off_t); -extern char *crypt(char *, char *); +extern char *crypt(char *, char *); /* End of ultrix4.h */ diff --git a/src/include/port/univel.h b/src/include/port/univel.h index c0bc9821867..4acd2b1a752 100644 --- a/src/include/port/univel.h +++ b/src/include/port/univel.h @@ -9,10 +9,10 @@ typedef unsigned char slock_t; #endif -extern long random(void); -extern void srandom(int seed); -extern int strcasecmp(char *s1, char *s2); -extern int gethostname(char *name, int namelen); +extern long random(void); +extern void srandom(int seed); +extern int strcasecmp(char *s1, char *s2); +extern int gethostname(char *name, int namelen); #ifndef BIG_ENDIAN #define BIG_ENDIAN 4321 diff --git a/src/include/postgres.h b/src/include/postgres.h index 2e37eb95fd7..706dcc1a41b 100644 --- a/src/include/postgres.h +++ b/src/include/postgres.h @@ -6,7 +6,7 @@ * * Copyright (c) 1995, Regents of the University of California * - * $Id: postgres.h,v 1.7 1997/09/07 04:55:39 momjian Exp $ + * $Id: postgres.h,v 1.8 1997/09/08 02:33:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,22 +47,22 @@ * ---------------------------------------------------------------- */ -typedef int16 int2; -typedef int32 int4; -typedef float float4; -typedef double float8; +typedef int16 int2; +typedef int32 int4; +typedef float float4; +typedef double float8; -typedef int4 aclitem; +typedef int4 aclitem; #define InvalidOid 0 #define OidIsValid(objectId) ((bool) (objectId != InvalidOid)) /* unfortunately, both regproc and RegProcedure are used */ -typedef Oid regproc; -typedef Oid RegProcedure; +typedef Oid regproc; +typedef Oid RegProcedure; /* ptr to func returning (char *) */ -typedef char *((*func_ptr) ()); +typedef char *((*func_ptr) ()); #define RegProcedureIsValid(p) OidIsValid(p) @@ -77,8 +77,8 @@ typedef char *((*func_ptr) ()); */ struct varlena { - int32 vl_len; - char vl_dat[1]; + int32 vl_len; + char vl_dat[1]; }; #define VARSIZE(PTR) (((struct varlena *)(PTR))->vl_len) @@ -90,8 +90,8 @@ typedef struct varlena text; typedef struct char8 { - char data[8]; -} char8; + char data[8]; +} char8; /* ---------------- * char16 @@ -99,18 +99,18 @@ typedef struct char8 */ typedef struct char16 { - char data[16]; -} char16; + char data[16]; +} char16; typedef char16 *Char16; -typedef int2 int28[8]; -typedef Oid oid8[8]; +typedef int2 int28[8]; +typedef Oid oid8[8]; typedef struct nameData { - char data[NAMEDATALEN]; -} NameData; + char data[NAMEDATALEN]; +} NameData; typedef NameData *Name; /* ---------------- @@ -121,9 +121,9 @@ typedef NameData *Name; */ typedef struct OidInt4Data { - Oid oi_oid; - int32 oi_int4; -} OidInt4Data; + Oid oi_oid; + int32 oi_int4; +} OidInt4Data; typedef struct OidInt4Data *OidInt4; @@ -135,9 +135,9 @@ typedef struct OidInt4Data *OidInt4; */ typedef struct OidInt2Data { - Oid oi_oid; - int16 oi_int2; -} OidInt2Data; + Oid oi_oid; + int16 oi_int2; +} OidInt2Data; typedef struct OidInt2Data *OidInt2; @@ -149,9 +149,9 @@ typedef struct OidInt2Data *OidInt2; */ typedef struct OidNameData { - Oid id; - NameData name; -} OidNameData; + Oid id; + NameData name; +} OidNameData; typedef struct OidNameData *OidName; @@ -160,10 +160,10 @@ typedef struct OidNameData *OidName; * ---------------------------------------------------------------- */ -typedef uint32 TransactionId; +typedef uint32 TransactionId; #define InvalidTransactionId 0 -typedef uint16 CommandId; +typedef uint16 CommandId; #define FirstCommandId 0 diff --git a/src/include/regex/cclass.h b/src/include/regex/cclass.h index 271d1e418e6..2ab5eca33f5 100644 --- a/src/include/regex/cclass.h +++ b/src/include/regex/cclass.h @@ -40,10 +40,10 @@ /* character-class table */ static struct cclass { - char *name; - char *chars; - char *multis; -} cclasses[] = + char *name; + char *chars; + char *multis; +} cclasses[] = { { diff --git a/src/include/regex/cname.h b/src/include/regex/cname.h index 8cf78f7cbe5..a333e9c4e5e 100644 --- a/src/include/regex/cname.h +++ b/src/include/regex/cname.h @@ -40,9 +40,9 @@ /* character-name table */ static struct cname { - char *name; - char code; -} cnames[] = + char *name; + char code; +} cnames[] = { { diff --git a/src/include/regex/regex.h b/src/include/regex/regex.h index 18b39768849..94b3ea4a2d8 100644 --- a/src/include/regex/regex.h +++ b/src/include/regex/regex.h @@ -43,21 +43,21 @@ #include <sys/types.h> /* types */ -typedef off_t regoff_t; +typedef off_t regoff_t; typedef struct { - int re_magic; - size_t re_nsub; /* number of parenthesized subexpressions */ - const char *re_endp; /* end pointer for REG_PEND */ + int re_magic; + size_t re_nsub; /* number of parenthesized subexpressions */ + const char *re_endp; /* end pointer for REG_PEND */ struct re_guts *re_g; /* none of your business :-) */ -} regex_t; +} regex_t; typedef struct { - regoff_t rm_so; /* start of match */ - regoff_t rm_eo; /* end of match */ -} regmatch_t; + regoff_t rm_so; /* start of match */ + regoff_t rm_eo; /* end of match */ +} regmatch_t; /* regcomp() flags */ #define REG_BASIC 0000 @@ -97,11 +97,11 @@ typedef struct #define REG_LARGE 01000 /* force large representation */ #define REG_BACKR 02000 /* force use of backref code */ -int pg95_regcomp(regex_t *, const char *, int); -size_t pg95_regerror(int, const regex_t *, char *, size_t); +int pg95_regcomp(regex_t *, const char *, int); +size_t pg95_regerror(int, const regex_t *, char *, size_t); int pg95_regexec(const regex_t *, const char *, size_t, regmatch_t[], int); -void pg95_regfree(regex_t *); +void pg95_regfree(regex_t *); #endif /* !_REGEX_H_ */ diff --git a/src/include/regex/regex2.h b/src/include/regex/regex2.h index 960a6d1dfce..70b03b0250a 100644 --- a/src/include/regex/regex2.h +++ b/src/include/regex/regex2.h @@ -78,7 +78,7 @@ * immediately *preceding* "execution" of that operator. */ typedef unsigned long sop; /* strip operator */ -typedef long sopno; +typedef long sopno; #define OPRMASK 0xf8000000 #define OPDMASK 0x07ffffff @@ -125,12 +125,12 @@ typedef long sopno; */ typedef struct { - uch *ptr; /* -> uch [csetsize] */ - uch mask; /* bit within array */ - uch hash; /* hash code */ - size_t smultis; - char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ -} cset; + uch *ptr; /* -> uch [csetsize] */ + uch mask; /* bit within array */ + uch hash; /* hash code */ + size_t smultis; + char *multis; /* -> char[smulti] ab\0cd\0ef\0\0 */ +} cset; /* note that CHadd and CHsub are unsafe, and CHIN doesn't yield 0/1 */ #define CHadd(cs, c) ((cs)->ptr[(uch)(c)] |= (cs)->mask, (cs)->hash += (c)) @@ -149,32 +149,32 @@ typedef unsigned char cat_t; */ struct re_guts { - int magic; + int magic; #define MAGIC2 ((('R'^0200)<<8)|'E') - sop *strip; /* malloced area for strip */ - int csetsize; /* number of bits in a cset vector */ - int ncsets; /* number of csets in use */ - cset *sets; /* -> cset [ncsets] */ - uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ - int cflags; /* copy of regcomp() cflags argument */ - sopno nstates; /* = number of sops */ - sopno firststate; /* the initial OEND (normally 0) */ - sopno laststate; /* the final OEND */ - int iflags; /* internal flags */ + sop *strip; /* malloced area for strip */ + int csetsize; /* number of bits in a cset vector */ + int ncsets; /* number of csets in use */ + cset *sets; /* -> cset [ncsets] */ + uch *setbits; /* -> uch[csetsize][ncsets/CHAR_BIT] */ + int cflags; /* copy of regcomp() cflags argument */ + sopno nstates; /* = number of sops */ + sopno firststate; /* the initial OEND (normally 0) */ + sopno laststate; /* the final OEND */ + int iflags; /* internal flags */ #define USEBOL 01 /* used ^ */ #define USEEOL 02 /* used $ */ #define BAD 04 /* something wrong */ - int nbol; /* number of ^ used */ - int neol; /* number of $ used */ - int ncategories;/* how many character categories */ - cat_t *categories; /* ->catspace[-CHAR_MIN] */ - char *must; /* match must contain this string */ - int mlen; /* length of must */ - size_t nsub; /* copy of re_nsub */ - int backrefs; /* does it use back references? */ - sopno nplus; /* how deep does it nest +s? */ + int nbol; /* number of ^ used */ + int neol; /* number of $ used */ + int ncategories; /* how many character categories */ + cat_t *categories; /* ->catspace[-CHAR_MIN] */ + char *must; /* match must contain this string */ + int mlen; /* length of must */ + size_t nsub; /* copy of re_nsub */ + int backrefs; /* does it use back references? */ + sopno nplus; /* how deep does it nest +s? */ /* catspace must be last */ - cat_t catspace[1];/* actually [NC] */ + cat_t catspace[1]; /* actually [NC] */ }; /* misc utilities */ diff --git a/src/include/regex/regexp.h b/src/include/regex/regexp.h index cbbb26367df..d8008190708 100644 --- a/src/include/regex/regexp.h +++ b/src/include/regex/regexp.h @@ -49,14 +49,14 @@ #define NSUBEXP 10 typedef struct regexp { - char *startp[NSUBEXP]; - char *endp[NSUBEXP]; - char regstart; /* Internal use only. */ - char reganch; /* Internal use only. */ - char *regmust; /* Internal use only. */ - int regmlen; /* Internal use only. */ - char program[1]; /* Unwarranted chumminess with compiler. */ -} regexp; + char *startp[NSUBEXP]; + char *endp[NSUBEXP]; + char regstart; /* Internal use only. */ + char reganch; /* Internal use only. */ + char *regmust; /* Internal use only. */ + int regmlen; /* Internal use only. */ + char program[1]; /* Unwarranted chumminess with compiler. */ +} regexp; /* since not all systems have cdefs.h, we'll use our own here - jolly */ diff --git a/src/include/rewrite/locks.h b/src/include/rewrite/locks.h index f01f5a713b2..b1336b51c61 100644 --- a/src/include/rewrite/locks.h +++ b/src/include/rewrite/locks.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: locks.h,v 1.4 1997/09/07 05:00:28 momjian Exp $ + * $Id: locks.h,v 1.5 1997/09/08 02:38:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ #include "nodes/parsenodes.h" #include "rewrite/prs2lock.h" -extern List * +extern List * matchLocks(CmdType event, RuleLock * rulelocks, int varno, Query * parsetree); diff --git a/src/include/rewrite/prs2lock.h b/src/include/rewrite/prs2lock.h index 0bf8a258867..b1d2f019d0a 100644 --- a/src/include/rewrite/prs2lock.h +++ b/src/include/rewrite/prs2lock.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: prs2lock.h,v 1.5 1997/09/07 05:00:32 momjian Exp $ + * $Id: prs2lock.h,v 1.6 1997/09/08 02:38:46 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,13 +22,13 @@ */ typedef struct RewriteRule { - Oid ruleId; - CmdType event; - AttrNumber attrno; - Node *qual; - List *actions; - bool isInstead; -} RewriteRule; + Oid ruleId; + CmdType event; + AttrNumber attrno; + Node *qual; + List *actions; + bool isInstead; +} RewriteRule; /* * RuleLock - @@ -38,8 +38,8 @@ typedef struct RewriteRule */ typedef struct RuleLock { - int numLocks; - RewriteRule **rules; -} RuleLock; + int numLocks; + RewriteRule **rules; +} RuleLock; #endif /* REWRITE_H */ diff --git a/src/include/rewrite/rewriteDefine.h b/src/include/rewrite/rewriteDefine.h index 214daa85f56..7dfacf39117 100644 --- a/src/include/rewrite/rewriteDefine.h +++ b/src/include/rewrite/rewriteDefine.h @@ -6,13 +6,13 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteDefine.h,v 1.2 1997/09/07 05:00:33 momjian Exp $ + * $Id: rewriteDefine.h,v 1.3 1997/09/08 02:38:48 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef REWRITEDEFINE_H #define REWRITEDEFINE_H -extern void DefineQueryRewrite(RuleStmt * args); +extern void DefineQueryRewrite(RuleStmt * args); #endif /* REWRITEDEFINE_H */ diff --git a/src/include/rewrite/rewriteHandler.h b/src/include/rewrite/rewriteHandler.h index 3d03f29ba17..f38e7c048d8 100644 --- a/src/include/rewrite/rewriteHandler.h +++ b/src/include/rewrite/rewriteHandler.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteHandler.h,v 1.2 1997/09/07 05:00:34 momjian Exp $ + * $Id: rewriteHandler.h,v 1.3 1997/09/08 02:38:50 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,21 +16,21 @@ struct _rewrite_meta_knowledge { - List *rt; - int rt_index; - bool instead_flag; - int event; - CmdType action; - int current_varno; - int new_varno; - Query *rule_action; - Node *rule_qual; - bool nothing; + List *rt; + int rt_index; + bool instead_flag; + int event; + CmdType action; + int current_varno; + int new_varno; + Query *rule_action; + Node *rule_qual; + bool nothing; }; typedef struct _rewrite_meta_knowledge RewriteInfo; -extern List *QueryRewrite(Query * parsetree); +extern List *QueryRewrite(Query * parsetree); #endif /* REWRITEHANDLER_H */ diff --git a/src/include/rewrite/rewriteManip.h b/src/include/rewrite/rewriteManip.h index 4c8b09e9889..4a2f0afb20c 100644 --- a/src/include/rewrite/rewriteManip.h +++ b/src/include/rewrite/rewriteManip.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteManip.h,v 1.2 1997/09/07 05:00:35 momjian Exp $ + * $Id: rewriteManip.h,v 1.3 1997/09/08 02:38:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,12 +14,12 @@ #define REWRITEMANIP_H /* RewriteManip.c */ -void OffsetVarNodes(Node * node, int offset); -void ChangeVarNodes(Node * node, int old_varno, int new_varno); -void AddQual(Query * parsetree, Node * qual); -void AddNotQual(Query * parsetree, Node * qual); -void FixResdomTypes(List * user_tlist); -void FixNew(RewriteInfo * info, Query * parsetree); +void OffsetVarNodes(Node * node, int offset); +void ChangeVarNodes(Node * node, int old_varno, int new_varno); +void AddQual(Query * parsetree, Node * qual); +void AddNotQual(Query * parsetree, Node * qual); +void FixResdomTypes(List * user_tlist); +void FixNew(RewriteInfo * info, Query * parsetree); void HandleRIRAttributeRule(Query * parsetree, List * rtable, List * targetlist, diff --git a/src/include/rewrite/rewriteRemove.h b/src/include/rewrite/rewriteRemove.h index 947a5815eae..ad69e7af03c 100644 --- a/src/include/rewrite/rewriteRemove.h +++ b/src/include/rewrite/rewriteRemove.h @@ -6,15 +6,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteRemove.h,v 1.2 1997/09/07 05:00:37 momjian Exp $ + * $Id: rewriteRemove.h,v 1.3 1997/09/08 02:38:51 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef REWRITEREMOVE_H #define REWRITEREMOVE_H -extern char *RewriteGetRuleEventRel(char *rulename); -extern void RemoveRewriteRule(char *ruleName); -extern void RelationRemoveRules(Oid relid); +extern char *RewriteGetRuleEventRel(char *rulename); +extern void RemoveRewriteRule(char *ruleName); +extern void RelationRemoveRules(Oid relid); #endif /* REWRITEREMOVE_H */ diff --git a/src/include/rewrite/rewriteSupport.h b/src/include/rewrite/rewriteSupport.h index 7f517ae4ccd..99f198504ef 100644 --- a/src/include/rewrite/rewriteSupport.h +++ b/src/include/rewrite/rewriteSupport.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rewriteSupport.h,v 1.3 1997/09/07 05:00:38 momjian Exp $ + * $Id: rewriteSupport.h,v 1.4 1997/09/08 02:38:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,13 +14,13 @@ #define REWRITESUPPORT_H -extern int IsDefinedRewriteRule(char *ruleName); +extern int IsDefinedRewriteRule(char *ruleName); extern void prs2_addToRelation(Oid relid, Oid ruleId, CmdType event_type, AttrNumber attno, bool isInstead, Node * qual, List * actions); -extern void prs2_deleteFromRelation(Oid relid, Oid ruleId); +extern void prs2_deleteFromRelation(Oid relid, Oid ruleId); #endif /* REWRITESUPPORT_H */ diff --git a/src/include/storage/backendid.h b/src/include/storage/backendid.h index 5abdd770e8c..25be9a4fdcf 100644 --- a/src/include/storage/backendid.h +++ b/src/include/storage/backendid.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: backendid.h,v 1.3 1997/09/07 05:00:40 momjian Exp $ + * $Id: backendid.h,v 1.4 1997/09/08 02:38:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,12 +17,12 @@ * -cim 8/17/90 * ---------------- */ -typedef int16 BackendId; /* unique currently active backend +typedef int16 BackendId; /* unique currently active backend * identifier */ #define InvalidBackendId (-1) -typedef int32 BackendTag; /* unique backend identifier */ +typedef int32 BackendTag; /* unique backend identifier */ #define InvalidBackendTag (-1) diff --git a/src/include/storage/block.h b/src/include/storage/block.h index 9702b53e2eb..a057122438e 100644 --- a/src/include/storage/block.h +++ b/src/include/storage/block.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: block.h,v 1.3 1997/09/07 05:00:42 momjian Exp $ + * $Id: block.h,v 1.4 1997/09/08 02:38:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,7 +27,7 @@ * more or less the only pieces of code that should be accessing disk * blocks directly. */ -typedef uint32 BlockNumber; +typedef uint32 BlockNumber; #define InvalidBlockNumber ((BlockNumber) 0xFFFFFFFF) @@ -49,9 +49,9 @@ typedef uint32 BlockNumber; */ typedef struct BlockIdData { - uint16 bi_hi; - uint16 bi_lo; -} BlockIdData; + uint16 bi_hi; + uint16 bi_lo; +} BlockIdData; typedef BlockIdData *BlockId; /* block identifier */ diff --git a/src/include/storage/buf.h b/src/include/storage/buf.h index 481033c4a73..86288cb3459 100644 --- a/src/include/storage/buf.h +++ b/src/include/storage/buf.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: buf.h,v 1.2 1997/09/07 05:00:45 momjian Exp $ + * $Id: buf.h,v 1.3 1997/09/08 02:38:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #define InvalidBuffer (0) #define UnknownBuffer (-99999) -typedef long Buffer; +typedef long Buffer; /* * BufferIsInvalid -- diff --git a/src/include/storage/buf_internals.h b/src/include/storage/buf_internals.h index aea48e15cb1..482b15d9d10 100644 --- a/src/include/storage/buf_internals.h +++ b/src/include/storage/buf_internals.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: buf_internals.h,v 1.15 1997/09/07 05:00:52 momjian Exp $ + * $Id: buf_internals.h,v 1.16 1997/09/08 02:38:57 momjian Exp $ * * NOTE * If BUFFERPAGE0 is defined, then 0 will be used as a @@ -22,11 +22,11 @@ /* Buf Mgr constants */ /* in bufmgr.c */ -extern int NBuffers; -extern int Data_Descriptors; -extern int Free_List_Descriptor; -extern int Lookup_List_Descriptor; -extern int Num_Descriptors; +extern int NBuffers; +extern int Data_Descriptors; +extern int Free_List_Descriptor; +extern int Lookup_List_Descriptor; +extern int Num_Descriptors; /* * Flags for buffer descriptors @@ -40,19 +40,19 @@ extern int Num_Descriptors; #define BM_IO_ERROR (1 << 6) #define BM_JUST_DIRTIED (1 << 7) -typedef bits16 BufFlags; +typedef bits16 BufFlags; typedef struct sbufdesc BufferDesc; typedef struct sbufdesc BufferHdr; typedef struct buftag BufferTag; /* long * so alignment will be correct */ -typedef long **BufferBlock; +typedef long **BufferBlock; struct buftag { - LRelId relId; - BlockNumber blockNum; /* blknum relative to begin of reln */ + LRelId relId; + BlockNumber blockNum; /* blknum relative to begin of reln */ }; #define CLEAR_BUFFERTAG(a)\ @@ -110,45 +110,44 @@ struct buftag */ struct sbufdesc_unpadded { - Buffer freeNext; - Buffer freePrev; - SHMEM_OFFSET data; - BufferTag tag; - int buf_id; - BufFlags flags; - int16 bufsmgr; - unsigned refcount; + Buffer freeNext; + Buffer freePrev; + SHMEM_OFFSET data; + BufferTag tag; + int buf_id; + BufFlags flags; + int16 bufsmgr; + unsigned refcount; #ifdef HAS_TEST_AND_SET - slock_t io_in_progress_lock; + slock_t io_in_progress_lock; #endif /* HAS_TEST_AND_SET */ - char sb_dbname[NAMEDATALEN]; + char sb_dbname[NAMEDATALEN]; /* NOTE NO PADDING OF THE MEMBER HERE */ - char sb_relname[NAMEDATALEN]; + char sb_relname[NAMEDATALEN]; }; /* THE REAL STRUCTURE - the structure above must match it, minus sb_pad */ struct sbufdesc { - Buffer freeNext; /* link for freelist chain */ - Buffer freePrev; - SHMEM_OFFSET data; /* pointer to data in buf pool */ + Buffer freeNext; /* link for freelist chain */ + Buffer freePrev; + SHMEM_OFFSET data; /* pointer to data in buf pool */ /* tag and id must be together for table lookup to work */ - BufferTag tag; /* file/block identifier */ - int buf_id; /* maps global desc to local desc */ + BufferTag tag; /* file/block identifier */ + int buf_id; /* maps global desc to local desc */ - BufFlags flags; /* described below */ - int16 bufsmgr; /* storage manager id for buffer */ - unsigned refcount; /* # of times buffer is pinned */ + BufFlags flags; /* described below */ + int16 bufsmgr; /* storage manager id for buffer */ + unsigned refcount; /* # of times buffer is pinned */ #ifdef HAS_TEST_AND_SET /* can afford a dedicated lock if test-and-set locks are available */ - slock_t io_in_progress_lock; + slock_t io_in_progress_lock; #endif /* HAS_TEST_AND_SET */ - char sb_dbname[NAMEDATALEN]; /* name of db in which buf - * belongs */ + char sb_dbname[NAMEDATALEN]; /* name of db in which buf belongs */ /* * I padded this structure to a power of 2 (PADDED_SBUFDESC_SIZE) @@ -167,8 +166,8 @@ struct sbufdesc * something important */ - char sb_relname[NAMEDATALEN + /* name of reln */ - PADDED_SBUFDESC_SIZE - sizeof(struct sbufdesc_unpadded)]; + char sb_relname[NAMEDATALEN + /* name of reln */ + PADDED_SBUFDESC_SIZE - sizeof(struct sbufdesc_unpadded)]; }; /* @@ -180,19 +179,19 @@ struct sbufdesc typedef struct _bmtrace { - int bmt_pid; - long bmt_buf; - long bmt_dbid; - long bmt_relid; - int bmt_blkno; - int bmt_op; + int bmt_pid; + long bmt_buf; + long bmt_dbid; + long bmt_relid; + int bmt_blkno; + int bmt_op; #define BMT_NOTUSED 0 #define BMT_ALLOCFND 1 #define BMT_ALLOCNOTFND 2 #define BMT_DEALLOC 3 -} bmtrace; +} bmtrace; #endif /* BMTRACE */ @@ -204,39 +203,39 @@ typedef struct _bmtrace /* Internal routines: only called by buf.c */ /*freelist.c*/ -extern void AddBufferToFreelist(BufferDesc * bf); -extern void PinBuffer(BufferDesc * buf); -extern void PinBuffer_Debug(char *file, int line, BufferDesc * buf); -extern void UnpinBuffer(BufferDesc * buf); +extern void AddBufferToFreelist(BufferDesc * bf); +extern void PinBuffer(BufferDesc * buf); +extern void PinBuffer_Debug(char *file, int line, BufferDesc * buf); +extern void UnpinBuffer(BufferDesc * buf); extern BufferDesc *GetFreeBuffer(void); -extern void InitFreeList(bool init); +extern void InitFreeList(bool init); /* buf_table.c */ -extern void InitBufTable(void); +extern void InitBufTable(void); extern BufferDesc *BufTableLookup(BufferTag * tagPtr); -extern bool BufTableDelete(BufferDesc * buf); -extern bool BufTableInsert(BufferDesc * buf); +extern bool BufTableDelete(BufferDesc * buf); +extern bool BufTableInsert(BufferDesc * buf); /* bufmgr.c */ extern BufferDesc *BufferDescriptors; extern BufferBlock BufferBlocks; -extern long *PrivateRefCount; -extern long *LastRefCount; -extern long *CommitInfoNeedsSave; +extern long *PrivateRefCount; +extern long *LastRefCount; +extern long *CommitInfoNeedsSave; extern SPINLOCK BufMgrLock; /* localbuf.c */ -extern long *LocalRefCount; +extern long *LocalRefCount; extern BufferDesc *LocalBufferDescriptors; -extern int NLocBuffer; +extern int NLocBuffer; extern BufferDesc * LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool * foundPtr); -extern int WriteLocalBuffer(Buffer buffer, bool release); -extern int FlushLocalBuffer(Buffer buffer, bool release); -extern void InitLocalBuffer(void); -extern void LocalBufferSync(void); -extern void ResetLocalBufferPool(void); +extern int WriteLocalBuffer(Buffer buffer, bool release); +extern int FlushLocalBuffer(Buffer buffer, bool release); +extern void InitLocalBuffer(void); +extern void LocalBufferSync(void); +extern void ResetLocalBufferPool(void); #endif /* BUFMGR_INTERNALS_H */ diff --git a/src/include/storage/bufmgr.h b/src/include/storage/bufmgr.h index d432506c7cb..9f65b80f672 100644 --- a/src/include/storage/bufmgr.h +++ b/src/include/storage/bufmgr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufmgr.h,v 1.12 1997/09/07 05:01:06 momjian Exp $ + * $Id: bufmgr.h,v 1.13 1997/09/08 02:38:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,13 +29,13 @@ */ #define MAXBLCKSZ 8192 -typedef void *Block; +typedef void *Block; /* special pageno for bget */ #define P_NEW InvalidBlockNumber /* grow the file to get a new page */ -typedef bits16 BufferLock; +typedef bits16 BufferLock; /********************************************************************** @@ -60,7 +60,7 @@ typedef bits16 BufferLock; #define BufferIsPinned BufferIsValid -extern int ShowPinTrace; +extern int ShowPinTrace; /* * BufferWriteModes (settable via SetBufferWriteMode) @@ -71,38 +71,38 @@ extern int ShowPinTrace; /* * prototypes for functions in bufmgr.c */ -extern Buffer +extern Buffer RelationGetBufferWithBuffer(Relation relation, BlockNumber blockNumber, Buffer buffer); -extern Buffer ReadBuffer(Relation reln, BlockNumber blockNum); -extern int WriteBuffer(Buffer buffer); -extern int WriteNoReleaseBuffer(Buffer buffer); -extern Buffer +extern Buffer ReadBuffer(Relation reln, BlockNumber blockNum); +extern int WriteBuffer(Buffer buffer); +extern int WriteNoReleaseBuffer(Buffer buffer); +extern Buffer ReleaseAndReadBuffer(Buffer buffer, Relation relation, BlockNumber blockNum); -extern void InitBufferPool(IPCKey key); -extern void PrintBufferUsage(FILE * statfp); -extern void ResetBufferUsage(void); -extern void ResetBufferPool(void); -extern int BufferPoolCheckLeak(void); -extern void FlushBufferPool(int StableMainMemoryFlag); -extern bool BufferIsValid(Buffer bufnum); +extern void InitBufferPool(IPCKey key); +extern void PrintBufferUsage(FILE * statfp); +extern void ResetBufferUsage(void); +extern void ResetBufferPool(void); +extern int BufferPoolCheckLeak(void); +extern void FlushBufferPool(int StableMainMemoryFlag); +extern bool BufferIsValid(Buffer bufnum); extern BlockNumber BufferGetBlockNumber(Buffer buffer); extern Relation BufferGetRelation(Buffer buffer); extern BlockNumber RelationGetNumberOfBlocks(Relation relation); -extern Block BufferGetBlock(Buffer buffer); -extern void ReleaseRelationBuffers(Relation rdesc); -extern void DropBuffers(Oid dbid); -extern void PrintBufferDescs(void); -extern void PrintPinnedBufs(void); -extern int BufferShmemSize(void); -extern void IncrBufferRefCount(Buffer buffer); -extern int ReleaseBuffer(Buffer buffer); - -extern void BufferRefCountReset(int *refcountsave); -extern void BufferRefCountRestore(int *refcountsave); -extern int SetBufferWriteMode(int mode); -extern void SetBufferCommitInfoNeedsSave(Buffer buffer); +extern Block BufferGetBlock(Buffer buffer); +extern void ReleaseRelationBuffers(Relation rdesc); +extern void DropBuffers(Oid dbid); +extern void PrintBufferDescs(void); +extern void PrintPinnedBufs(void); +extern int BufferShmemSize(void); +extern void IncrBufferRefCount(Buffer buffer); +extern int ReleaseBuffer(Buffer buffer); + +extern void BufferRefCountReset(int *refcountsave); +extern void BufferRefCountRestore(int *refcountsave); +extern int SetBufferWriteMode(int mode); +extern void SetBufferCommitInfoNeedsSave(Buffer buffer); #endif /* !defined(BufMgrIncluded) */ diff --git a/src/include/storage/bufpage.h b/src/include/storage/bufpage.h index a252ccc3e44..4b031746f0b 100644 --- a/src/include/storage/bufpage.h +++ b/src/include/storage/bufpage.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bufpage.h,v 1.11 1997/09/07 05:01:10 momjian Exp $ + * $Id: bufpage.h,v 1.12 1997/09/08 02:38:59 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -87,7 +87,7 @@ * note that this is actually limited to 2^13 because we have limited * ItemIdData.lp_off and ItemIdData.lp_len to 13 bits (see itemid.h). */ -typedef uint16 LocationIndex; +typedef uint16 LocationIndex; /* @@ -101,8 +101,8 @@ typedef uint16 LocationIndex; */ typedef struct OpaqueData { - uint16 od_pagesize; -} OpaqueData; + uint16 od_pagesize; +} OpaqueData; typedef OpaqueData *Opaque; @@ -112,12 +112,12 @@ typedef OpaqueData *Opaque; */ typedef struct PageHeaderData { - LocationIndex pd_lower; /* offset to start of free space */ - LocationIndex pd_upper; /* offset to end of free space */ - LocationIndex pd_special; /* offset to start of special space */ - OpaqueData pd_opaque; /* AM-generic information */ - ItemIdData pd_linp[1]; /* line pointers */ -} PageHeaderData; + LocationIndex pd_lower; /* offset to start of free space */ + LocationIndex pd_upper; /* offset to end of free space */ + LocationIndex pd_special; /* offset to start of special space */ + OpaqueData pd_opaque; /* AM-generic information */ + ItemIdData pd_linp[1]; /* line pointers */ +} PageHeaderData; typedef PageHeaderData *PageHeader; @@ -125,7 +125,7 @@ typedef enum { ShufflePageManagerMode, OverwritePageManagerMode -} PageManagerMode; +} PageManagerMode; /* ---------------- * misc support macros @@ -279,17 +279,17 @@ typedef enum * ---------------------------------------------------------------- */ -extern void PageInit(Page page, Size pageSize, Size specialSize); -extern OffsetNumber +extern void PageInit(Page page, Size pageSize, Size specialSize); +extern OffsetNumber PageAddItem(Page page, Item item, Size size, OffsetNumber offsetNumber, ItemIdFlags flags); -extern Page PageGetTempPage(Page page, Size specialSize); -extern void PageRestoreTempPage(Page tempPage, Page oldPage); +extern Page PageGetTempPage(Page page, Size specialSize); +extern void PageRestoreTempPage(Page tempPage, Page oldPage); extern OffsetNumber PageGetMaxOffsetNumber(Page page); -extern void PageRepairFragmentation(Page page); -extern Size PageGetFreeSpace(Page page); -extern void PageManagerModeSet(PageManagerMode mode); -extern void PageIndexTupleDelete(Page page, OffsetNumber offset); +extern void PageRepairFragmentation(Page page); +extern Size PageGetFreeSpace(Page page); +extern void PageManagerModeSet(PageManagerMode mode); +extern void PageIndexTupleDelete(Page page, OffsetNumber offset); #endif /* BUFPAGE_H */ diff --git a/src/include/storage/fd.h b/src/include/storage/fd.h index 9fbe004d4a3..e5404154a64 100644 --- a/src/include/storage/fd.h +++ b/src/include/storage/fd.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fd.h,v 1.9 1997/09/07 05:01:12 momjian Exp $ + * $Id: fd.h,v 1.10 1997/09/08 02:39:00 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,41 +40,41 @@ * FileSeek uses the standard UNIX lseek(2) flags. */ -typedef char *FileName; +typedef char *FileName; -typedef int File; +typedef int File; /* originally in libpq-fs.h */ struct pgstat { /* just the fields we need from stat * structure */ - int st_ino; - int st_mode; - unsigned int st_size; - unsigned int st_sizehigh;/* high order bits */ + int st_ino; + int st_mode; + unsigned int st_size; + unsigned int st_sizehigh; /* high order bits */ /* 2^64 == 1.8 x 10^20 bytes */ - int st_uid; - int st_atime_s; /* just the seconds */ - int st_mtime_s; /* since SysV and the new BSD both have */ - int st_ctime_s; /* usec fields.. */ + int st_uid; + int st_atime_s; /* just the seconds */ + int st_mtime_s; /* since SysV and the new BSD both have */ + int st_ctime_s; /* usec fields.. */ }; /* * prototypes for functions in fd.c */ -extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode); -extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode); -extern void FileClose(File file); -extern void FileUnlink(File file); -extern int FileRead(File file, char *buffer, int amount); -extern int FileWrite(File file, char *buffer, int amount); -extern long FileSeek(File file, long offset, int whence); -extern int FileTruncate(File file, int offset); -extern int FileSync(File file); -extern int FileNameUnlink(char *filename); -extern FILE *AllocateFile(char *name, char *mode); -extern void FreeFile(FILE *); -extern void closeAllVfds(void); -extern int pg_fsync(int fd); +extern File FileNameOpenFile(FileName fileName, int fileFlags, int fileMode); +extern File PathNameOpenFile(FileName fileName, int fileFlags, int fileMode); +extern void FileClose(File file); +extern void FileUnlink(File file); +extern int FileRead(File file, char *buffer, int amount); +extern int FileWrite(File file, char *buffer, int amount); +extern long FileSeek(File file, long offset, int whence); +extern int FileTruncate(File file, int offset); +extern int FileSync(File file); +extern int FileNameUnlink(char *filename); +extern FILE *AllocateFile(char *name, char *mode); +extern void FreeFile(FILE *); +extern void closeAllVfds(void); +extern int pg_fsync(int fd); #endif /* FD_H */ diff --git a/src/include/storage/ipc.h b/src/include/storage/ipc.h index 9e08d6b94ee..e75a26c0454 100644 --- a/src/include/storage/ipc.h +++ b/src/include/storage/ipc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: ipc.h,v 1.18 1997/09/07 05:01:14 momjian Exp $ + * $Id: ipc.h,v 1.19 1997/09/08 02:39:01 momjian Exp $ * * NOTES * This file is very architecture-specific. This stuff should actually @@ -28,15 +28,15 @@ #if defined(HAS_TEST_AND_SET) -extern void S_LOCK(slock_t * lock); -extern void S_UNLOCK(slock_t * lock); -extern void S_INIT_LOCK(slock_t * lock); +extern void S_LOCK(slock_t * lock); +extern void S_UNLOCK(slock_t * lock); +extern void S_INIT_LOCK(slock_t * lock); #if (defined(alpha) && !defined(linuxalpha)) || \ defined(hpux) || \ defined(irix5) || \ defined(nextstep) -extern int S_LOCK_FREE(slock_t * lock); +extern int S_LOCK_FREE(slock_t * lock); #else #define S_LOCK_FREE(lock) ((*lock) == 0) @@ -47,14 +47,14 @@ extern int S_LOCK_FREE(slock_t * lock); #ifndef HAVE_UNION_SEMUN union semun { - int val; + int val; struct semid_ds *buf; unsigned short *array; }; #endif -typedef uint16 SystemPortAddress; +typedef uint16 SystemPortAddress; /* semaphore definitions */ @@ -70,8 +70,8 @@ typedef uint16 SystemPortAddress; #define IpcSemIdExist (-3) #define IpcSemIdNotExist (-4) -typedef uint32 IpcSemaphoreKey;/* semaphore key */ -typedef int IpcSemaphoreId; +typedef uint32 IpcSemaphoreKey; /* semaphore key */ +typedef int IpcSemaphoreId; /* shared memory definitions */ @@ -79,37 +79,37 @@ typedef int IpcSemaphoreId; #define IpcMemIdGetFailed (-2) #define IpcMemAttachFailed 0 -typedef uint32 IPCKey; +typedef uint32 IPCKey; #define PrivateIPCKey IPC_PRIVATE #define DefaultIPCKey 17317 -typedef uint32 IpcMemoryKey; /* shared memory key */ -typedef int IpcMemoryId; +typedef uint32 IpcMemoryKey; /* shared memory key */ +typedef int IpcMemoryId; /* ipc.c */ -extern void exitpg(int code); -extern void quasi_exitpg(void); -extern int on_exitpg(void (*function) (), caddr_t arg); +extern void exitpg(int code); +extern void quasi_exitpg(void); +extern int on_exitpg(void (*function) (), caddr_t arg); -extern IpcSemaphoreId +extern IpcSemaphoreId IpcSemaphoreCreate(IpcSemaphoreKey semKey, int semNum, int permission, int semStartValue, int removeOnExit, int *status); -extern void IpcSemaphoreKill(IpcSemaphoreKey key); -extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock); -extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock); -extern int IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem); -extern int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem); -extern IpcMemoryId +extern void IpcSemaphoreKill(IpcSemaphoreKey key); +extern void IpcSemaphoreLock(IpcSemaphoreId semId, int sem, int lock); +extern void IpcSemaphoreUnlock(IpcSemaphoreId semId, int sem, int lock); +extern int IpcSemaphoreGetCount(IpcSemaphoreId semId, int sem); +extern int IpcSemaphoreGetValue(IpcSemaphoreId semId, int sem); +extern IpcMemoryId IpcMemoryCreate(IpcMemoryKey memKey, uint32 size, int permission); extern IpcMemoryId IpcMemoryIdGet(IpcMemoryKey memKey, uint32 size); -extern char *IpcMemoryAttach(IpcMemoryId memId); -extern void IpcMemoryKill(IpcMemoryKey memKey); -extern void CreateAndInitSLockMemory(IPCKey key); -extern void AttachSLockMemory(IPCKey key); +extern char *IpcMemoryAttach(IpcMemoryId memId); +extern void IpcMemoryKill(IpcMemoryKey memKey); +extern void CreateAndInitSLockMemory(IPCKey key); +extern void AttachSLockMemory(IPCKey key); #ifdef HAS_TEST_AND_SET @@ -135,24 +135,24 @@ typedef enum _LockId_ PROCSTRUCTLOCKID, FIRSTFREELOCKID -} _LockId_; +} _LockId_; #define MAX_SPINS FIRSTFREELOCKID typedef struct slock { - slock_t locklock; - unsigned char flag; - short nshlocks; - slock_t shlock; - slock_t exlock; - slock_t comlock; - struct slock *next; -} SLock; - -extern void ExclusiveLock(int lockid); -extern void ExclusiveUnlock(int lockid); -extern bool LockIsFree(int lockid); + slock_t locklock; + unsigned char flag; + short nshlocks; + slock_t shlock; + slock_t exlock; + slock_t comlock; + struct slock *next; +} SLock; + +extern void ExclusiveLock(int lockid); +extern void ExclusiveUnlock(int lockid); +extern bool LockIsFree(int lockid); #else /* HAS_TEST_AND_SET */ @@ -171,7 +171,7 @@ typedef enum _LockId_ PROCSTRUCTLOCKID, OIDGENLOCKID, FIRSTFREELOCKID -} _LockId_; +} _LockId_; #define MAX_SPINS FIRSTFREELOCKID @@ -220,8 +220,8 @@ typedef enum _LockId_ ((key == PrivateIPCKey) ? key : 14 + (key)) /* ipci.c */ -extern IPCKey SystemPortAddressCreateIPCKey(SystemPortAddress address); -extern void CreateSharedMemoryAndSemaphores(IPCKey key); -extern void AttachSharedMemoryAndSemaphores(IPCKey key); +extern IPCKey SystemPortAddressCreateIPCKey(SystemPortAddress address); +extern void CreateSharedMemoryAndSemaphores(IPCKey key); +extern void AttachSharedMemoryAndSemaphores(IPCKey key); #endif /* IPC_H */ diff --git a/src/include/storage/itemid.h b/src/include/storage/itemid.h index 9e5e6f94d4a..1c382fb1b9e 100644 --- a/src/include/storage/itemid.h +++ b/src/include/storage/itemid.h @@ -6,27 +6,27 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itemid.h,v 1.2 1997/09/07 05:01:17 momjian Exp $ + * $Id: itemid.h,v 1.3 1997/09/08 02:39:02 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef ITEMID_H #define ITEMID_H -typedef uint16 ItemOffset; -typedef uint16 ItemLength; +typedef uint16 ItemOffset; +typedef uint16 ItemLength; -typedef bits16 ItemIdFlags; +typedef bits16 ItemIdFlags; typedef struct ItemIdData { /* line pointers */ - unsigned lp_off:13, /* offset to find tup */ + unsigned lp_off:13, /* offset to find tup */ /* can be reduced by 2 if necc. */ - lp_flags:6, /* flags on tuple */ - lp_len:13; /* length of tuple */ -} ItemIdData; + lp_flags:6, /* flags on tuple */ + lp_len:13; /* length of tuple */ +} ItemIdData; typedef struct ItemIdData *ItemId; diff --git a/src/include/storage/itempos.h b/src/include/storage/itempos.h index bea9cd64746..332636ce95f 100644 --- a/src/include/storage/itempos.h +++ b/src/include/storage/itempos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itempos.h,v 1.4 1997/09/07 05:01:20 momjian Exp $ + * $Id: itempos.h,v 1.5 1997/09/08 02:39:02 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,11 +18,11 @@ typedef struct ItemSubpositionData { - Buffer op_db; - ItemId op_lpp; - char *op_cp; /* XXX */ - uint32 op_len; -} ItemSubpositionData; + Buffer op_db; + ItemId op_lpp; + char *op_cp; /* XXX */ + uint32 op_len; +} ItemSubpositionData; typedef ItemSubpositionData *ItemSubposition; diff --git a/src/include/storage/itemptr.h b/src/include/storage/itemptr.h index 3460cd19f9e..b6156ca229c 100644 --- a/src/include/storage/itemptr.h +++ b/src/include/storage/itemptr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: itemptr.h,v 1.5 1997/09/07 05:01:22 momjian Exp $ + * $Id: itemptr.h,v 1.6 1997/09/08 02:39:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,9 +25,9 @@ */ typedef struct ItemPointerData { - BlockIdData ip_blkid; - OffsetNumber ip_posid; -} ItemPointerData; + BlockIdData ip_blkid; + OffsetNumber ip_posid; +} ItemPointerData; typedef ItemPointerData *ItemPointer; @@ -108,6 +108,6 @@ typedef ItemPointerData *ItemPointer; * ---------------- */ -extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2); +extern bool ItemPointerEquals(ItemPointer pointer1, ItemPointer pointer2); #endif /* ITEMPTR_H */ diff --git a/src/include/storage/large_object.h b/src/include/storage/large_object.h index 1144d1ca02d..710b1bac5c2 100644 --- a/src/include/storage/large_object.h +++ b/src/include/storage/large_object.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: large_object.h,v 1.5 1997/09/07 05:01:24 momjian Exp $ + * $Id: large_object.h,v 1.6 1997/09/08 02:39:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,22 +23,22 @@ */ typedef struct LargeObjectDesc { - Relation heap_r; /* heap relation */ - Relation index_r; /* index relation on seqno attribute */ - IndexScanDesc iscan; /* index scan we're using */ - TupleDesc hdesc; /* heap relation tuple desc */ - TupleDesc idesc; /* index relation tuple desc */ - uint32 lowbyte; /* low byte on the current page */ - uint32 highbyte; /* high byte on the current page */ - uint32 offset; /* current seek pointer */ + Relation heap_r; /* heap relation */ + Relation index_r; /* index relation on seqno attribute */ + IndexScanDesc iscan; /* index scan we're using */ + TupleDesc hdesc; /* heap relation tuple desc */ + TupleDesc idesc; /* index relation tuple desc */ + uint32 lowbyte; /* low byte on the current page */ + uint32 highbyte; /* high byte on the current page */ + uint32 offset; /* current seek pointer */ ItemPointerData htid; /* tid of current heap tuple */ #define IFS_RDLOCK (1 << 0) #define IFS_WRLOCK (1 << 1) #define IFS_ATEOF (1 << 2) - u_long flags; /* locking info, etc */ -} LargeObjectDesc; + u_long flags; /* locking info, etc */ +} LargeObjectDesc; /* * Function definitions... @@ -47,11 +47,11 @@ typedef struct LargeObjectDesc /* inversion stuff in inv_api.c */ extern LargeObjectDesc *inv_create(int flags); extern LargeObjectDesc *inv_open(Oid lobjId, int flags); -extern void inv_close(LargeObjectDesc * obj_desc); -extern int inv_destroy(Oid lobjId); -extern int inv_seek(LargeObjectDesc * obj_desc, int offset, int whence); -extern int inv_tell(LargeObjectDesc * obj_desc); -extern int inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes); -extern int inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes); +extern void inv_close(LargeObjectDesc * obj_desc); +extern int inv_destroy(Oid lobjId); +extern int inv_seek(LargeObjectDesc * obj_desc, int offset, int whence); +extern int inv_tell(LargeObjectDesc * obj_desc); +extern int inv_read(LargeObjectDesc * obj_desc, char *buf, int nbytes); +extern int inv_write(LargeObjectDesc * obj_desc, char *buf, int nbytes); #endif /* LARGE_OBJECT_H */ diff --git a/src/include/storage/lmgr.h b/src/include/storage/lmgr.h index debe950c7c5..bd8d50f709f 100644 --- a/src/include/storage/lmgr.h +++ b/src/include/storage/lmgr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: lmgr.h,v 1.6 1997/09/07 05:01:25 momjian Exp $ + * $Id: lmgr.h,v 1.7 1997/09/08 02:39:04 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,31 +22,31 @@ */ typedef struct LRelId { - Oid relId; /* a relation identifier */ - Oid dbId; /* a database identifier */ -} LRelId; + Oid relId; /* a relation identifier */ + Oid dbId; /* a database identifier */ +} LRelId; typedef struct LockInfoData { - bool initialized; - LRelId lRelId; - TransactionId transactionIdData; - uint16 flags; -} LockInfoData; + bool initialized; + LRelId lRelId; + TransactionId transactionIdData; + uint16 flags; +} LockInfoData; typedef LockInfoData *LockInfo; #define LockInfoIsValid(linfo) \ ((PointerIsValid(linfo)) && ((LockInfo) linfo)->initialized) -extern LRelId RelationGetLRelId(Relation relation); -extern Oid LRelIdGetRelationId(LRelId lRelId); -extern void RelationInitLockInfo(Relation relation); -extern void RelationSetLockForDescriptorOpen(Relation relation); -extern void RelationSetLockForRead(Relation relation); -extern void RelationUnsetLockForRead(Relation relation); -extern void RelationSetLockForWrite(Relation relation); -extern void RelationUnsetLockForWrite(Relation relation); +extern LRelId RelationGetLRelId(Relation relation); +extern Oid LRelIdGetRelationId(LRelId lRelId); +extern void RelationInitLockInfo(Relation relation); +extern void RelationSetLockForDescriptorOpen(Relation relation); +extern void RelationSetLockForRead(Relation relation); +extern void RelationUnsetLockForRead(Relation relation); +extern void RelationSetLockForWrite(Relation relation); +extern void RelationUnsetLockForWrite(Relation relation); /* used in vaccum.c */ extern void @@ -66,18 +66,18 @@ RelationSetSingleRLockPage(Relation relation, extern void RelationUnsetSingleRLockPage(Relation relation, ItemPointer itemPointer); -extern void RelationSetRIntentLock(Relation relation); -extern void RelationUnsetRIntentLock(Relation relation); -extern void RelationSetWIntentLock(Relation relation); -extern void RelationUnsetWIntentLock(Relation relation); +extern void RelationSetRIntentLock(Relation relation); +extern void RelationUnsetRIntentLock(Relation relation); +extern void RelationSetWIntentLock(Relation relation); +extern void RelationUnsetWIntentLock(Relation relation); /* single.c */ -extern bool SingleLockReln(LockInfo linfo, LOCKT lockt, int action); -extern bool +extern bool SingleLockReln(LockInfo linfo, LOCKT lockt, int action); +extern bool SingleLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt, int action); /* proc.c */ -extern void InitProcGlobal(IPCKey key); +extern void InitProcGlobal(IPCKey key); #endif /* LMGR_H */ diff --git a/src/include/storage/lock.h b/src/include/storage/lock.h index 2b0f76649b4..89879575342 100644 --- a/src/include/storage/lock.h +++ b/src/include/storage/lock.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: lock.h,v 1.6 1997/09/07 05:01:26 momjian Exp $ + * $Id: lock.h,v 1.7 1997/09/08 02:39:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,7 +17,7 @@ #include <storage/itemptr.h> extern SPINLOCK LockMgrLock; -typedef int MASK; +typedef int MASK; #define INIT_TABLE_SIZE 100 #define MAX_TABLE_SIZE 1000 @@ -36,9 +36,9 @@ typedef int MASK; #define NLOCKS_PER_XACT 40 #define NLOCKENTS NLOCKS_PER_XACT*NBACKENDS -typedef int LOCK_TYPE; -typedef int LOCKT; -typedef int LockTableId; +typedef int LOCK_TYPE; +typedef int LOCKT; +typedef int LockTableId; /* MAX_LOCKTYPES cannot be larger than the bits in MASK */ #define MAX_LOCKTYPES 6 @@ -57,10 +57,10 @@ typedef int LockTableId; typedef struct ltag { - Oid relId; - Oid dbId; + Oid relId; + Oid dbId; ItemPointerData tupleId; -} LOCKTAG; +} LOCKTAG; #define TAGSIZE (sizeof(LOCKTAG)) @@ -86,12 +86,12 @@ typedef struct ltag */ typedef struct lockctl { - LockTableId tableId; - int nLockTypes; - int conflictTab[MAX_LOCKTYPES]; - int prio[MAX_LOCKTYPES]; - SPINLOCK masterLock; -} LOCKCTL; + LockTableId tableId; + int nLockTypes; + int conflictTab[MAX_LOCKTYPES]; + int prio[MAX_LOCKTYPES]; + SPINLOCK masterLock; +} LOCKCTL; /* * lockHash -- hash table on lock Ids, @@ -101,10 +101,10 @@ typedef struct lockctl */ typedef struct ltable { - HTAB *lockHash; - HTAB *xidHash; - LOCKCTL *ctl; -} LOCKTAB; + HTAB *lockHash; + HTAB *xidHash; + LOCKCTL *ctl; +} LOCKTAB; /* ----------------------- * A transaction never conflicts with its own locks. Hence, if @@ -137,30 +137,30 @@ typedef struct ltable typedef struct XIDTAG { - SHMEM_OFFSET lock; - int pid; - TransactionId xid; -} XIDTAG; + SHMEM_OFFSET lock; + int pid; + TransactionId xid; +} XIDTAG; typedef struct XIDLookupEnt { /* tag */ - XIDTAG tag; + XIDTAG tag; /* data */ - int holders[MAX_LOCKTYPES]; - int nHolding; - SHM_QUEUE queue; -} XIDLookupEnt; + int holders[MAX_LOCKTYPES]; + int nHolding; + SHM_QUEUE queue; +} XIDLookupEnt; #define XID_TAGSIZE (sizeof(XIDTAG)) /* originally in procq.h */ typedef struct procQueue { - SHM_QUEUE links; - int size; -} PROC_QUEUE; + SHM_QUEUE links; + int size; +} PROC_QUEUE; /* @@ -177,16 +177,16 @@ typedef struct procQueue typedef struct Lock { /* hash key */ - LOCKTAG tag; + LOCKTAG tag; /* data */ - int mask; - PROC_QUEUE waitProcs; - int holders[MAX_LOCKTYPES]; - int nHolding; - int activeHolders[MAX_LOCKTYPES]; - int nActive; -} LOCK; + int mask; + PROC_QUEUE waitProcs; + int holders[MAX_LOCKTYPES]; + int nHolding; + int activeHolders[MAX_LOCKTYPES]; + int nActive; +} LOCK; #define LockGetLock_nHolders(l) l->nHolders @@ -202,23 +202,23 @@ extern SPINLOCK LockMgrLock; /* * function prototypes */ -extern void InitLocks(void); -extern void LockDisable(int status); -extern LockTableId +extern void InitLocks(void); +extern void LockDisable(int status); +extern LockTableId LockTabInit(char *tabName, MASK * conflictsP, int *prioP, int ntypes); -extern bool LockAcquire(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt); +extern bool LockAcquire(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt); extern int LockResolveConflicts(LOCKTAB * ltable, LOCK * lock, LOCKT lockt, TransactionId xid); -extern bool LockRelease(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt); -extern void GrantLock(LOCK * lock, LOCKT lockt); -extern bool LockReleaseAll(LockTableId tableId, SHM_QUEUE * lockQueue); -extern int LockShmemSize(void); -extern bool LockingDisabled(void); +extern bool LockRelease(LockTableId tableId, LOCKTAG * lockName, LOCKT lockt); +extern void GrantLock(LOCK * lock, LOCKT lockt); +extern bool LockReleaseAll(LockTableId tableId, SHM_QUEUE * lockQueue); +extern int LockShmemSize(void); +extern bool LockingDisabled(void); #ifdef DEADLOCK_DEBUG -extern void DumpLocks(void); +extern void DumpLocks(void); #endif diff --git a/src/include/storage/multilev.h b/src/include/storage/multilev.h index befc6227ae9..3d4aa1edbb9 100644 --- a/src/include/storage/multilev.h +++ b/src/include/storage/multilev.h @@ -7,7 +7,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: multilev.h,v 1.4 1997/09/07 05:01:28 momjian Exp $ + * $Id: multilev.h,v 1.5 1997/09/08 02:39:05 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ #define RELN_LEVEL 0 #define PAGE_LEVEL 1 #define TUPLE_LEVEL 2 -typedef int LOCK_LEVEL; +typedef int LOCK_LEVEL; /* multi.c */ @@ -50,9 +50,9 @@ extern LockTableId ShortTermTableId; * function prototypes */ extern LockTableId InitMultiLevelLockm(void); -extern bool MultiLockReln(LockInfo linfo, LOCKT lockt); -extern bool MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt); -extern bool MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt); -extern bool MultiReleaseReln(LockInfo linfo, LOCKT lockt); +extern bool MultiLockReln(LockInfo linfo, LOCKT lockt); +extern bool MultiLockTuple(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt); +extern bool MultiLockPage(LockInfo linfo, ItemPointer tidPtr, LOCKT lockt); +extern bool MultiReleaseReln(LockInfo linfo, LOCKT lockt); #endif /* MULTILEV_H */ diff --git a/src/include/storage/off.h b/src/include/storage/off.h index 3eadb842a78..3dc72d6701a 100644 --- a/src/include/storage/off.h +++ b/src/include/storage/off.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: off.h,v 1.3 1997/09/07 05:01:29 momjian Exp $ + * $Id: off.h,v 1.4 1997/09/08 02:39:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -19,7 +19,7 @@ * this is a 1-based index into the linp (ItemIdData) array in the * header of each disk page. */ -typedef uint16 OffsetNumber; +typedef uint16 OffsetNumber; #define InvalidOffsetNumber ((OffsetNumber) 0) #define FirstOffsetNumber ((OffsetNumber) 1) diff --git a/src/include/storage/pagenum.h b/src/include/storage/pagenum.h index edd0dc116be..95e2b4beb4d 100644 --- a/src/include/storage/pagenum.h +++ b/src/include/storage/pagenum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pagenum.h,v 1.4 1997/09/07 05:01:32 momjian Exp $ + * $Id: pagenum.h,v 1.5 1997/09/08 02:39:06 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,9 +14,9 @@ #define PAGENUM_H -typedef uint16 PageNumber; +typedef uint16 PageNumber; -typedef uint32 LogicalPageNumber; +typedef uint32 LogicalPageNumber; #define InvalidLogicalPageNumber 0 diff --git a/src/include/storage/pos.h b/src/include/storage/pos.h index c5611ba0c12..46965b9fbdc 100644 --- a/src/include/storage/pos.h +++ b/src/include/storage/pos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pos.h,v 1.3 1997/09/07 05:01:33 momjian Exp $ + * $Id: pos.h,v 1.4 1997/09/08 02:39:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ * pointer array contained on every page that store (heap or index) * tuples. */ -typedef bits16 PositionIdData; +typedef bits16 PositionIdData; typedef PositionIdData *PositionId; /* ---------------- diff --git a/src/include/storage/proc.h b/src/include/storage/proc.h index 92829732714..d8ea70918a7 100644 --- a/src/include/storage/proc.h +++ b/src/include/storage/proc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: proc.h,v 1.6 1997/09/07 05:01:34 momjian Exp $ + * $Id: proc.h,v 1.7 1997/09/08 02:39:07 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,11 +17,11 @@ typedef struct { - int sleeplock; - int semNum; - IpcSemaphoreId semId; + int sleeplock; + int semNum; + IpcSemaphoreId semId; IpcSemaphoreKey semKey; -} SEMA; +} SEMA; /* * Each backend has: @@ -31,30 +31,30 @@ typedef struct proc /* proc->links MUST BE THE FIRST ELEMENT OF STRUCT (see ProcWakeup()) */ - SHM_QUEUE links; /* proc can be waiting for one event(lock) */ - SEMA sem; /* ONE semaphore to sleep on */ - int errType; /* error code tells why we woke up */ + SHM_QUEUE links; /* proc can be waiting for one event(lock) */ + SEMA sem; /* ONE semaphore to sleep on */ + int errType; /* error code tells why we woke up */ - int procId; /* unique number for this structure NOT + int procId; /* unique number for this structure NOT * unique per backend, these things are * reused after the backend dies. */ - int critSects; /* If critSects > 0, we are in sensitive + int critSects; /* If critSects > 0, we are in sensitive * routines that cannot be recovered when * the process fails. */ - int prio; /* priority for sleep queue */ + int prio; /* priority for sleep queue */ - TransactionId xid; /* transaction currently being executed by + TransactionId xid; /* transaction currently being executed by * this proc */ - LOCK *waitLock; /* Lock we're sleeping on */ - int token; /* info for proc wakeup routines */ - int pid; /* This procs process id */ - short sLocks[MAX_SPINS]; /* Spin lock stats */ - SHM_QUEUE lockQueue; /* locks associated with current + LOCK *waitLock; /* Lock we're sleeping on */ + int token; /* info for proc wakeup routines */ + int pid; /* This procs process id */ + short sLocks[MAX_SPINS]; /* Spin lock stats */ + SHM_QUEUE lockQueue; /* locks associated with current * transaction */ -} PROC; +} PROC; /* @@ -68,13 +68,13 @@ typedef struct proc typedef struct procglobal { - SHMEM_OFFSET freeProcs; - int numProcs; - IPCKey currKey; - int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET]; -} PROC_HDR; + SHMEM_OFFSET freeProcs; + int numProcs; + IPCKey currKey; + int32 freeSemMap[MAX_PROC_SEMS / PROC_NSEMS_PER_SET]; +} PROC_HDR; -extern PROC *MyProc; +extern PROC *MyProc; #define PROC_INCR_SLOCK(lock) if (MyProc) (MyProc->sLocks[(lock)])++ #define PROC_DECR_SLOCK(lock) if (MyProc) (MyProc->sLocks[(lock)])-- @@ -94,20 +94,20 @@ extern SPINLOCK ProcStructLock; /* * Function Prototypes */ -extern void InitProcess(IPCKey key); -extern void ProcReleaseLocks(void); -extern bool ProcRemove(int pid); +extern void InitProcess(IPCKey key); +extern void ProcReleaseLocks(void); +extern bool ProcRemove(int pid); /* extern bool ProcKill(int exitStatus, int pid); */ /* make static in storage/lmgr/proc.c -- jolly */ -extern void ProcQueueInit(PROC_QUEUE * queue); +extern void ProcQueueInit(PROC_QUEUE * queue); extern int ProcSleep(PROC_QUEUE * queue, SPINLOCK spinlock, int token, int prio, LOCK * lock); -extern int ProcLockWakeup(PROC_QUEUE * queue, char *ltable, char *lock); -extern void ProcAddLock(SHM_QUEUE * elem); -extern void ProcReleaseSpins(PROC * proc); -extern void ProcFreeAllSemaphores(void); +extern int ProcLockWakeup(PROC_QUEUE * queue, char *ltable, char *lock); +extern void ProcAddLock(SHM_QUEUE * elem); +extern void ProcReleaseSpins(PROC * proc); +extern void ProcFreeAllSemaphores(void); #endif /* PROC_H */ diff --git a/src/include/storage/shmem.h b/src/include/storage/shmem.h index 5812a718717..997c8c1c5e5 100644 --- a/src/include/storage/shmem.h +++ b/src/include/storage/shmem.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: shmem.h,v 1.6 1997/09/07 05:01:35 momjian Exp $ + * $Id: shmem.h,v 1.7 1997/09/08 02:39:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,28 +54,28 @@ extern SPINLOCK BindingLock; /* shmemqueue.c */ typedef struct SHM_QUEUE { - SHMEM_OFFSET prev; - SHMEM_OFFSET next; -} SHM_QUEUE; + SHMEM_OFFSET prev; + SHMEM_OFFSET next; +} SHM_QUEUE; /* shmem.c */ -extern void ShmemBindingTabReset(void); -extern void ShmemCreate(unsigned int key, unsigned int size); -extern int InitShmem(unsigned int key, unsigned int size); -extern long *ShmemAlloc(unsigned long size); -extern int ShmemIsValid(unsigned long addr); -extern HTAB * +extern void ShmemBindingTabReset(void); +extern void ShmemCreate(unsigned int key, unsigned int size); +extern int InitShmem(unsigned int key, unsigned int size); +extern long *ShmemAlloc(unsigned long size); +extern int ShmemIsValid(unsigned long addr); +extern HTAB * ShmemInitHash(char *name, long init_size, long max_size, HASHCTL * infoP, int hash_flags); -extern bool ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr); +extern bool ShmemPIDLookup(int pid, SHMEM_OFFSET * locationPtr); extern SHMEM_OFFSET ShmemPIDDestroy(int pid); -extern long * +extern long * ShmemInitStruct(char *name, unsigned long size, bool * foundPtr); -extern bool TransactionIdIsInProgress(TransactionId xid); +extern bool TransactionIdIsInProgress(TransactionId xid); -typedef int TableID; +typedef int TableID; /* size constants for the binding table */ /* max size of data structure string name */ @@ -88,21 +88,21 @@ typedef int TableID; /* this is a hash bucket in the binding table */ typedef struct { - char key[BTABLE_KEYSIZE]; /* string name */ - unsigned long location; /* location in shared mem */ - unsigned long size; /* numbytes allocated for the structure */ -} BindingEnt; + char key[BTABLE_KEYSIZE]; /* string name */ + unsigned long location; /* location in shared mem */ + unsigned long size; /* numbytes allocated for the structure */ +} BindingEnt; /* * prototypes for functions in shmqueue.c */ -extern void SHMQueueInit(SHM_QUEUE * queue); -extern void SHMQueueElemInit(SHM_QUEUE * queue); -extern void SHMQueueDelete(SHM_QUEUE * queue); -extern void SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem); +extern void SHMQueueInit(SHM_QUEUE * queue); +extern void SHMQueueElemInit(SHM_QUEUE * queue); +extern void SHMQueueDelete(SHM_QUEUE * queue); +extern void SHMQueueInsertTL(SHM_QUEUE * queue, SHM_QUEUE * elem); extern void SHMQueueFirst(SHM_QUEUE * queue, Pointer * nextPtrPtr, SHM_QUEUE * nextQueue); -extern bool SHMQueueEmpty(SHM_QUEUE * queue); +extern bool SHMQueueEmpty(SHM_QUEUE * queue); #endif /* SHMEM_H */ diff --git a/src/include/storage/sinval.h b/src/include/storage/sinval.h index fd9025e875f..55f6b6bd60d 100644 --- a/src/include/storage/sinval.h +++ b/src/include/storage/sinval.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: sinval.h,v 1.5 1997/09/07 05:01:36 momjian Exp $ + * $Id: sinval.h,v 1.6 1997/09/08 02:39:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,14 +18,14 @@ extern SPINLOCK SInvalLock; -extern void CreateSharedInvalidationState(IPCKey key); -extern void AttachSharedInvalidationState(IPCKey key); -extern void InitSharedInvalidationState(void); +extern void CreateSharedInvalidationState(IPCKey key); +extern void AttachSharedInvalidationState(IPCKey key); +extern void InitSharedInvalidationState(void); extern void RegisterSharedInvalid(int cacheId, Index hashIndex, ItemPointer pointer); -extern void InvalidateSharedInvalid(void (*invalFunction) (), - void (*resetFunction) ()); +extern void InvalidateSharedInvalid(void (*invalFunction) (), + void (*resetFunction) ()); #endif /* SINVAL_H */ diff --git a/src/include/storage/sinvaladt.h b/src/include/storage/sinvaladt.h index 12efeb2c8b8..1862cda616e 100644 --- a/src/include/storage/sinvaladt.h +++ b/src/include/storage/sinvaladt.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: sinvaladt.h,v 1.4 1997/09/07 05:01:37 momjian Exp $ + * $Id: sinvaladt.h,v 1.5 1997/09/08 02:39:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,37 +53,37 @@ C----------------End shared segment ------- typedef struct ProcState { - int limit; /* the number of read messages */ - bool resetState; /* true, if backend has to reset its state */ - int tag; /* special tag, recieved from the + int limit; /* the number of read messages */ + bool resetState; /* true, if backend has to reset its state */ + int tag; /* special tag, recieved from the * postmaster */ -} ProcState; +} ProcState; typedef struct SISeg { - IpcSemaphoreId criticalSectionSemaphoreId; /* semaphore id */ - IpcSemaphoreId generalSemaphoreId; /* semaphore id */ - Offset startEntrySection; /* (offset a) */ - Offset endEntrySection; /* (offset a + b) */ - Offset startFreeSpace; /* (offset relative to B) */ - Offset startEntryChain; /* (offset relative to B) */ - Offset endEntryChain; /* (offset relative to B) */ - int numEntries; - int maxNumEntries; - ProcState procState[MaxBackendId]; /* reflects the + IpcSemaphoreId criticalSectionSemaphoreId; /* semaphore id */ + IpcSemaphoreId generalSemaphoreId; /* semaphore id */ + Offset startEntrySection; /* (offset a) */ + Offset endEntrySection;/* (offset a + b) */ + Offset startFreeSpace; /* (offset relative to B) */ + Offset startEntryChain;/* (offset relative to B) */ + Offset endEntryChain; /* (offset relative to B) */ + int numEntries; + int maxNumEntries; + ProcState procState[MaxBackendId]; /* reflects the * invalidation state */ /* here starts the entry section, controlled by offsets */ -} SISeg; +} SISeg; #define SizeSISeg sizeof(SISeg) typedef struct SharedInvalidData { - int cacheId; /* XXX */ - Index hashIndex; + int cacheId; /* XXX */ + Index hashIndex; ItemPointerData pointerData; -} SharedInvalidData; +} SharedInvalidData; typedef SharedInvalidData *SharedInvalid; @@ -91,18 +91,18 @@ typedef SharedInvalidData *SharedInvalid; typedef struct SISegEntry { SharedInvalidData entryData;/* the message data */ - bool isfree; /* entry free? */ - Offset next; /* offset to next entry */ -} SISegEntry; + bool isfree; /* entry free? */ + Offset next; /* offset to next entry */ +} SISegEntry; #define SizeOfOneSISegEntry sizeof(SISegEntry) typedef struct SISegOffsets { - Offset startSegment; /* always 0 (for now) */ - Offset offsetToFirstEntry; /* A + a = B */ - Offset offsetToEndOfSegemnt; /* A + a + b */ -} SISegOffsets; + Offset startSegment; /* always 0 (for now) */ + Offset offsetToFirstEntry; /* A + a = B */ + Offset offsetToEndOfSegemnt; /* A + a + b */ +} SISegOffsets; /****************************************************************************/ @@ -114,20 +114,20 @@ typedef struct SISegOffsets #define SI_SharedLock (-1) #define SI_ExclusiveLock (-255) -extern SISeg *shmInvalBuffer; +extern SISeg *shmInvalBuffer; /* * prototypes for functions in sinvaladt.c */ -extern int SIBackendInit(SISeg * segInOutP); -extern int SISegmentInit(bool killExistingSegment, IPCKey key); +extern int SIBackendInit(SISeg * segInOutP); +extern int SISegmentInit(bool killExistingSegment, IPCKey key); -extern bool SISetDataEntry(SISeg * segP, SharedInvalidData * data); -extern void SISetProcStateInvalid(SISeg * segP); -extern bool SIDelDataEntry(SISeg * segP); +extern bool SISetDataEntry(SISeg * segP, SharedInvalidData * data); +extern void SISetProcStateInvalid(SISeg * segP); +extern bool SIDelDataEntry(SISeg * segP); extern void SIReadEntryData(SISeg * segP, int backendId, void (*invalFunction) (), void (*resetFunction) ()); -extern void SIDelExpiredDataEntries(SISeg * segP); +extern void SIDelExpiredDataEntries(SISeg * segP); #endif /* SINVALADT_H */ diff --git a/src/include/storage/smgr.h b/src/include/storage/smgr.h index 38c2164f891..08ada1ae30c 100644 --- a/src/include/storage/smgr.h +++ b/src/include/storage/smgr.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: smgr.h,v 1.8 1997/09/07 05:01:38 momjian Exp $ + * $Id: smgr.h,v 1.9 1997/09/08 02:39:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,12 +22,12 @@ #define DEFAULT_SMGR 0 -extern int smgrinit(void); -extern int smgrcreate(int16 which, Relation reln); -extern int smgrunlink(int16 which, Relation reln); -extern int smgrextend(int16 which, Relation reln, char *buffer); -extern int smgropen(int16 which, Relation reln); -extern int smgrclose(int16 which, Relation reln); +extern int smgrinit(void); +extern int smgrcreate(int16 which, Relation reln); +extern int smgrunlink(int16 which, Relation reln); +extern int smgrextend(int16 which, Relation reln, char *buffer); +extern int smgropen(int16 which, Relation reln); +extern int smgrclose(int16 which, Relation reln); extern int smgrread(int16 which, Relation reln, BlockNumber blocknum, char *buffer); @@ -40,58 +40,58 @@ smgrflush(int16 which, Relation reln, BlockNumber blocknum, extern int smgrblindwrt(int16 which, char *dbname, char *relname, Oid dbid, Oid relid, BlockNumber blkno, char *buffer); -extern int smgrnblocks(int16 which, Relation reln); -extern int smgrtruncate(int16 which, Relation reln, int nblocks); -extern int smgrcommit(void); -extern bool smgriswo(int16 smgrno); +extern int smgrnblocks(int16 which, Relation reln); +extern int smgrtruncate(int16 which, Relation reln, int nblocks); +extern int smgrcommit(void); +extern bool smgriswo(int16 smgrno); /* internals: move me elsewhere -- ay 7/94 */ /* in md.c */ -extern int mdinit(void); -extern int mdcreate(Relation reln); -extern int mdunlink(Relation reln); -extern int mdextend(Relation reln, char *buffer); -extern int mdopen(Relation reln); -extern int mdclose(Relation reln); -extern int mdread(Relation reln, BlockNumber blocknum, char *buffer); -extern int mdwrite(Relation reln, BlockNumber blocknum, char *buffer); -extern int mdflush(Relation reln, BlockNumber blocknum, char *buffer); +extern int mdinit(void); +extern int mdcreate(Relation reln); +extern int mdunlink(Relation reln); +extern int mdextend(Relation reln, char *buffer); +extern int mdopen(Relation reln); +extern int mdclose(Relation reln); +extern int mdread(Relation reln, BlockNumber blocknum, char *buffer); +extern int mdwrite(Relation reln, BlockNumber blocknum, char *buffer); +extern int mdflush(Relation reln, BlockNumber blocknum, char *buffer); extern int mdblindwrt(char *dbstr, char *relstr, Oid dbid, Oid relid, BlockNumber blkno, char *buffer); -extern int mdnblocks(Relation reln); -extern int mdtruncate(Relation reln, int nblocks); -extern int mdcommit(void); -extern int mdabort(void); +extern int mdnblocks(Relation reln); +extern int mdtruncate(Relation reln, int nblocks); +extern int mdcommit(void); +extern int mdabort(void); /* mm.c */ extern SPINLOCK MMCacheLock; -extern int mminit(void); -extern int mmshutdown(void); -extern int mmcreate(Relation reln); -extern int mmunlink(Relation reln); -extern int mmextend(Relation reln, char *buffer); -extern int mmopen(Relation reln); -extern int mmclose(Relation reln); -extern int mmread(Relation reln, BlockNumber blocknum, char *buffer); -extern int mmwrite(Relation reln, BlockNumber blocknum, char *buffer); -extern int mmflush(Relation reln, BlockNumber blocknum, char *buffer); +extern int mminit(void); +extern int mmshutdown(void); +extern int mmcreate(Relation reln); +extern int mmunlink(Relation reln); +extern int mmextend(Relation reln, char *buffer); +extern int mmopen(Relation reln); +extern int mmclose(Relation reln); +extern int mmread(Relation reln, BlockNumber blocknum, char *buffer); +extern int mmwrite(Relation reln, BlockNumber blocknum, char *buffer); +extern int mmflush(Relation reln, BlockNumber blocknum, char *buffer); extern int mmblindwrt(char *dbstr, char *relstr, Oid dbid, Oid relid, BlockNumber blkno, char *buffer); -extern int mmnblocks(Relation reln); -extern int mmcommit(void); -extern int mmabort(void); -extern int MMShmemSize(void); +extern int mmnblocks(Relation reln); +extern int mmcommit(void); +extern int mmabort(void); +extern int MMShmemSize(void); /* smgrtype.c */ -extern char *smgrout(int2 i); -extern int2 smgrin(char *s); -extern bool smgreq(int2 a, int2 b); -extern bool smgrne(int2 a, int2 b); +extern char *smgrout(int2 i); +extern int2 smgrin(char *s); +extern bool smgreq(int2 a, int2 b); +extern bool smgrne(int2 a, int2 b); #endif /* SMGR_H */ diff --git a/src/include/storage/spin.h b/src/include/storage/spin.h index 0ee24b5ab4b..d41768039eb 100644 --- a/src/include/storage/spin.h +++ b/src/include/storage/spin.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: spin.h,v 1.4 1997/09/07 05:01:39 momjian Exp $ + * $Id: spin.h,v 1.5 1997/09/08 02:39:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,11 +25,11 @@ * */ -typedef int SPINLOCK; +typedef int SPINLOCK; -extern bool CreateSpinlocks(IPCKey key); -extern bool InitSpinLocks(int init, IPCKey key); -extern void SpinAcquire(SPINLOCK lock); -extern void SpinRelease(SPINLOCK lock); +extern bool CreateSpinlocks(IPCKey key); +extern bool InitSpinLocks(int init, IPCKey key); +extern void SpinAcquire(SPINLOCK lock); +extern void SpinRelease(SPINLOCK lock); #endif /* SPIN_H */ diff --git a/src/include/strdup.h b/src/include/strdup.h index 038446494c7..fd91939b03f 100644 --- a/src/include/strdup.h +++ b/src/include/strdup.h @@ -5,4 +5,4 @@ The Postgres strdup() is in src/utils/strdup.c. */ -extern char *strdup(char const *); +extern char *strdup(char const *); diff --git a/src/include/tcop/dest.h b/src/include/tcop/dest.h index aa74fafbfe7..0eeda39c823 100644 --- a/src/include/tcop/dest.h +++ b/src/include/tcop/dest.h @@ -26,7 +26,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dest.h,v 1.9 1997/09/07 05:01:42 momjian Exp $ + * $Id: dest.h,v 1.10 1997/09/08 02:39:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ typedef enum RemoteInternal, /* results sent to frontend process in * internal (binary) form */ SPI /* results sent to SPI manager */ -} CommandDest; +} CommandDest; /* AttrInfo* replaced with TupleDesc, now that TupleDesc also has within it @@ -65,15 +65,15 @@ typedef struct AttrInfo { } AttrInfo; */ -extern void (*DestToFunction(CommandDest dest)) (); -extern void EndCommand(char *commandTag, CommandDest dest); -extern void SendCopyBegin(void); -extern void ReceiveCopyBegin(void); -extern void NullCommand(CommandDest dest); +extern void (*DestToFunction(CommandDest dest)) (); +extern void EndCommand(char *commandTag, CommandDest dest); +extern void SendCopyBegin(void); +extern void ReceiveCopyBegin(void); +extern void NullCommand(CommandDest dest); extern void BeginCommand(char *pname, int operation, TupleDesc attinfo, bool isIntoRel, bool isIntoPortal, char *tag, CommandDest dest); -extern void UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples); +extern void UpdateCommandInfo(int operation, Oid lastoid, uint32 tuples); #endif /* DEST_H */ diff --git a/src/include/tcop/fastpath.h b/src/include/tcop/fastpath.h index 96b5f598eac..68b6e724a3e 100644 --- a/src/include/tcop/fastpath.h +++ b/src/include/tcop/fastpath.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fastpath.h,v 1.2 1997/09/07 05:01:46 momjian Exp $ + * $Id: fastpath.h,v 1.3 1997/09/08 02:39:18 momjian Exp $ * * NOTES * This information pulled out of tcop/fastpath.c and put @@ -26,6 +26,6 @@ #define VAR_LENGTH_ARG (-5) #define MAX_STRING_LENGTH 256 -extern int HandleFunctionRequest(void); +extern int HandleFunctionRequest(void); #endif /* FASTPATH_H */ diff --git a/src/include/tcop/pquery.h b/src/include/tcop/pquery.h index 9d9117315b8..b4c72305aa6 100644 --- a/src/include/tcop/pquery.h +++ b/src/include/tcop/pquery.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pquery.h,v 1.5 1997/09/07 05:01:49 momjian Exp $ + * $Id: pquery.h,v 1.6 1997/09/08 02:39:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,7 +20,7 @@ extern QueryDesc *CreateQueryDesc(Query *parsetree, Plan *plantree, CommandDest dest); */ -extern EState *CreateExecutorState(void); +extern EState *CreateExecutorState(void); extern void diff --git a/src/include/tcop/tcopprot.h b/src/include/tcop/tcopprot.h index 07a3cff98d0..86883ab642b 100644 --- a/src/include/tcop/tcopprot.h +++ b/src/include/tcop/tcopprot.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tcopprot.h,v 1.5 1997/09/07 05:01:56 momjian Exp $ + * $Id: tcopprot.h,v 1.6 1997/09/08 02:39:20 momjian Exp $ * * OLD COMMENTS * This file was created so that other c files could get the two @@ -22,20 +22,20 @@ #include <parser/parse_query.h> #ifndef BOOTSTRAP_INCLUDE -extern List * +extern List * pg_plan(char *query_string, Oid * typev, int nargs, QueryTreeList ** queryListP, CommandDest dest); -extern void pg_eval(char *query_string, char **argv, Oid * typev, int nargs); +extern void pg_eval(char *query_string, char **argv, Oid * typev, int nargs); extern void pg_eval_dest(char *query_string, char **argv, Oid * typev, int nargs, CommandDest dest); #endif /* BOOTSTRAP_HEADER */ -extern void handle_warn(SIGNAL_ARGS); -extern void die(SIGNAL_ARGS); -extern int PostgresMain(int argc, char *argv[]); -extern void ResetUsage(void); -extern void ShowUsage(void); +extern void handle_warn(SIGNAL_ARGS); +extern void die(SIGNAL_ARGS); +extern int PostgresMain(int argc, char *argv[]); +extern void ResetUsage(void); +extern void ShowUsage(void); #endif /* tcopprotIncluded */ diff --git a/src/include/tcop/utility.h b/src/include/tcop/utility.h index f5242ff4738..6dd5add42c5 100644 --- a/src/include/tcop/utility.h +++ b/src/include/tcop/utility.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: utility.h,v 1.3 1997/09/07 05:01:58 momjian Exp $ + * $Id: utility.h,v 1.4 1997/09/08 02:39:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,6 +15,6 @@ #include <executor/execdesc.h> -extern void ProcessUtility(Node * parsetree, CommandDest dest); +extern void ProcessUtility(Node * parsetree, CommandDest dest); #endif /* UTILITY_H */ diff --git a/src/include/tcop/variable.h b/src/include/tcop/variable.h index a687d8fed6f..4792cac9656 100644 --- a/src/include/tcop/variable.h +++ b/src/include/tcop/variable.h @@ -2,7 +2,7 @@ * Headers for handling of 'SET var TO', 'SHOW var' and 'RESET var' * statements * - * $Id: variable.h,v 1.5 1997/09/07 05:02:01 momjian Exp $ + * $Id: variable.h,v 1.6 1997/09/08 02:39:21 momjian Exp $ * */ @@ -16,14 +16,14 @@ struct PGVariables { struct { - bool euro; + bool euro; enum DateFormat format; - } date; + } date; }; extern struct PGVariables PGVariables; /*-----------------------------------------------------------------------*/ -bool SetPGVariable(const char *, const char *); -bool GetPGVariable(const char *); -bool ResetPGVariable(const char *); +bool SetPGVariable(const char *, const char *); +bool GetPGVariable(const char *); +bool ResetPGVariable(const char *); diff --git a/src/include/utils/acl.h b/src/include/utils/acl.h index f6e6a75ab5d..62e472f8e16 100644 --- a/src/include/utils/acl.h +++ b/src/include/utils/acl.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: acl.h,v 1.8 1997/09/07 05:02:05 momjian Exp $ + * $Id: acl.h,v 1.9 1997/09/08 02:39:24 momjian Exp $ * * NOTES * For backward-compatability purposes we have to allow there @@ -29,14 +29,14 @@ * AclId system identifier for the user, group, etc. * XXX currently UNIX uid for users... */ -typedef uint32 AclId; +typedef uint32 AclId; #define ACL_ID_WORLD 0 /* XXX only idtype should be checked */ /* * AclIdType tag that describes if the AclId is a user, group, etc. */ -typedef uint8 AclIdType; +typedef uint8 AclIdType; #define ACL_IDTYPE_WORLD 0x00 #define ACL_IDTYPE_UID 0x01 /* user id - from pg_user */ @@ -48,7 +48,7 @@ typedef uint8 AclIdType; * XXX should probably also stuff the modechg cruft in the * high bits, too. */ -typedef uint8 AclMode; +typedef uint8 AclMode; #define ACL_NO 0 /* no permissions */ #define ACL_AP (1<<0) /* append */ @@ -71,10 +71,10 @@ typedef uint8 AclMode; */ typedef struct AclItem { - AclId ai_id; - AclIdType ai_idtype; - AclMode ai_mode; -} AclItem; + AclId ai_id; + AclIdType ai_idtype; + AclMode ai_mode; +} AclItem; /* Note: if the size of AclItem changes, change the aclitem typlen in pg_type.h */ @@ -125,7 +125,7 @@ typedef ArrayType IdList; #define ACLCHECK_NOT_OWNER 3 /* warning messages. set these in aclchk.c. */ -extern char *aclcheck_error_strings[]; +extern char *aclcheck_error_strings[]; /* * Enable ACL execution tracing and table dumps @@ -135,12 +135,12 @@ extern char *aclcheck_error_strings[]; /* * routines used internally (parser, etc.) */ -extern Acl *aclownerdefault(AclId ownerid); -extern Acl *acldefault(void); -extern Acl *aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg); +extern Acl *aclownerdefault(AclId ownerid); +extern Acl *acldefault(void); +extern Acl *aclinsert3(Acl * old_acl, AclItem * mod_aip, unsigned modechg); -extern char *aclmakepriv(char *old_privlist, char new_priv); -extern char *aclmakeuser(char *user_type, char *user); +extern char *aclmakepriv(char *old_privlist, char new_priv); +extern char *aclmakeuser(char *user_type, char *user); extern ChangeACLStmt * makeAclStmt(char *privs, List * rel_list, char *grantee, char grant_or_revoke); @@ -148,27 +148,27 @@ makeAclStmt(char *privs, List * rel_list, char *grantee, /* * exported routines (from acl.c) */ -extern Acl *makeacl(int n); +extern Acl *makeacl(int n); extern AclItem *aclitemin(char *s); -extern char *aclitemout(AclItem * aip); -extern Acl *aclinsert(Acl * old_acl, AclItem * mod_aip); -extern Acl *aclremove(Acl * old_acl, AclItem * mod_aip); -extern int32 aclcontains(Acl * acl, AclItem * aip); +extern char *aclitemout(AclItem * aip); +extern Acl *aclinsert(Acl * old_acl, AclItem * mod_aip); +extern Acl *aclremove(Acl * old_acl, AclItem * mod_aip); +extern int32 aclcontains(Acl * acl, AclItem * aip); /* * prototypes for functions in aclchk.c */ -extern void ChangeAcl(char *relname, AclItem * mod_aip, unsigned modechg); -extern AclId get_grosysid(char *groname); -extern char *get_groname(AclId grosysid); +extern void ChangeAcl(char *relname, AclItem * mod_aip, unsigned modechg); +extern AclId get_grosysid(char *groname); +extern char *get_groname(AclId grosysid); /* XXX move these elsewhere -pma */ -extern int32 pg_aclcheck(char *relname, char *usename, AclMode mode); -extern int32 pg_ownercheck(char *usename, char *value, int cacheid); -extern int32 +extern int32 pg_aclcheck(char *relname, char *usename, AclMode mode); +extern int32 pg_ownercheck(char *usename, char *value, int cacheid); +extern int32 pg_func_ownercheck(char *usename, char *funcname, int nargs, Oid * arglist); -extern int32 +extern int32 pg_aggr_ownercheck(char *usename, char *aggname, Oid basetypeID); diff --git a/src/include/utils/array.h b/src/include/utils/array.h index e2cd808cbf9..8e8b216fd6a 100644 --- a/src/include/utils/array.h +++ b/src/include/utils/array.h @@ -10,7 +10,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: array.h,v 1.5 1997/09/07 05:02:07 momjian Exp $ + * $Id: array.h,v 1.6 1997/09/08 02:39:26 momjian Exp $ * * NOTES * XXX the data array should be LONGALIGN'd -- notice that the array @@ -26,10 +26,10 @@ typedef struct { - int size; /* total array size (in bytes) */ - int ndim; /* # of dimensions */ - int flags; /* implementation flags */ -} ArrayType; + int size; /* total array size (in bytes) */ + int ndim; /* # of dimensions */ + int flags; /* implementation flags */ +} ArrayType; /* * bitmask of ArrayType flags field: @@ -99,7 +99,7 @@ typedef struct /* #if defined(irix5) */ /* #define RETURN_NULL {*isNull = true; return(0); }*/ - /* #else*//* irix5 */ + /* #else *//* irix5 */ #define RETURN_NULL {*isNull = true; return(0); } /* #endif *//* irix5 */ #define NAME_LEN 30 @@ -107,35 +107,35 @@ typedef struct typedef struct { - char lo_name[NAME_LEN]; - int C[MAXDIM]; -} CHUNK_INFO; + char lo_name[NAME_LEN]; + int C[MAXDIM]; +} CHUNK_INFO; /* * prototypes for functions defined in arrayfuncs.c */ -extern char *array_in(char *string, Oid element_type); -extern char *array_out(ArrayType * v, Oid element_type); -extern char *array_dims(ArrayType * v, bool * isNull); -extern Datum +extern char *array_in(char *string, Oid element_type); +extern char *array_out(ArrayType * v, Oid element_type); +extern char *array_dims(ArrayType * v, bool * isNull); +extern Datum array_ref(ArrayType * array, int n, int indx[], int reftype, int elmlen, int arraylen, bool * isNull); -extern Datum +extern Datum array_clip(ArrayType * array, int n, int upperIndx[], int lowerIndx[], int reftype, int len, bool * isNull); -extern char * +extern char * array_set(ArrayType * array, int n, int indx[], char *dataPtr, int reftype, int elmlen, int arraylen, bool * isNull); -extern char * +extern char * array_assgn(ArrayType * array, int n, int upperIndx[], int lowerIndx[], ArrayType * newArr, int reftype, int len, bool * isNull); -extern int array_eq(ArrayType * array1, ArrayType * array2); +extern int array_eq(ArrayType * array1, ArrayType * array2); extern int _LOtransfer(char **destfd, int size, int nitems, char **srcfd, int isSrcLO, int isDestLO); -extern char *_array_newLO(int *fd, int flag); +extern char *_array_newLO(int *fd, int flag); /* @@ -143,20 +143,20 @@ extern char *_array_newLO(int *fd, int flag); * [these names seem to be too generic. Add prefix for arrays? -- AY] */ -extern int GetOffset(int n, int dim[], int lb[], int indx[]); -extern int getNitems(int n, int a[]); -extern int compute_size(int st[], int endp[], int n, int base); -extern void mda_get_offset_values(int n, int dist[], int PC[], int span[]); -extern void mda_get_range(int n, int span[], int st[], int endp[]); -extern void mda_get_prod(int n, int range[], int P[]); -extern int tuple2linear(int n, int tup[], int scale[]); -extern void array2chunk_coord(int n, int C[], int a_coord[], int c_coord[]); -extern int next_tuple(int n, int curr[], int span[]); +extern int GetOffset(int n, int dim[], int lb[], int indx[]); +extern int getNitems(int n, int a[]); +extern int compute_size(int st[], int endp[], int n, int base); +extern void mda_get_offset_values(int n, int dist[], int PC[], int span[]); +extern void mda_get_range(int n, int span[], int st[], int endp[]); +extern void mda_get_prod(int n, int range[], int P[]); +extern int tuple2linear(int n, int tup[], int scale[]); +extern void array2chunk_coord(int n, int C[], int a_coord[], int c_coord[]); +extern int next_tuple(int n, int curr[], int span[]); /* * prototypes for functions defined in chunk.c */ -extern char * +extern char * _ChunkArray(int fd, FILE * afd, int ndim, int dim[], int baseSize, int *nbytes, char *chunkfile); extern int diff --git a/src/include/utils/bit.h b/src/include/utils/bit.h index ab68c0d6087..e8235b5a3a3 100644 --- a/src/include/utils/bit.h +++ b/src/include/utils/bit.h @@ -6,15 +6,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: bit.h,v 1.2 1997/09/07 05:02:09 momjian Exp $ + * $Id: bit.h,v 1.3 1997/09/08 02:39:29 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef BIT_H #define BIT_H -typedef bits8 *BitArray; -typedef uint32 BitIndex; +typedef bits8 *BitArray; +typedef uint32 BitIndex; #define BitsPerByte 8 @@ -22,18 +22,18 @@ typedef uint32 BitIndex; * BitArraySetBit -- * Sets (to 1) the value of a bit in a bit array. */ -extern void BitArraySetBit(BitArray bitArray, BitIndex bitIndex); +extern void BitArraySetBit(BitArray bitArray, BitIndex bitIndex); /* * BitArrayClearBit -- * Clears (to 0) the value of a bit in a bit array. */ -extern void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex); +extern void BitArrayClearBit(BitArray bitArray, BitIndex bitIndex); /* * BitArrayBitIsSet -- * True iff the bit is set (1) in a bit array. */ -extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex); +extern bool BitArrayBitIsSet(BitArray bitArray, BitIndex bitIndex); #endif /* BIT_H */ diff --git a/src/include/utils/builtins.h b/src/include/utils/builtins.h index 05252ca01e9..cba39b62ac8 100644 --- a/src/include/utils/builtins.h +++ b/src/include/utils/builtins.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: builtins.h,v 1.22 1997/09/07 05:02:11 momjian Exp $ + * $Id: builtins.h,v 1.23 1997/09/08 02:39:32 momjian Exp $ * * NOTES * This should normally only be included by fmgr.h. @@ -29,181 +29,181 @@ * Defined in adt/ */ /* bool.c */ -extern bool boolin(char *b); -extern char *boolout(long b); -extern bool booleq(int8 arg1, int8 arg2); -extern bool boolne(int8 arg1, int8 arg2); -extern bool boollt(int8 arg1, int8 arg2); -extern bool boolgt(int8 arg1, int8 arg2); +extern bool boolin(char *b); +extern char *boolout(long b); +extern bool booleq(int8 arg1, int8 arg2); +extern bool boolne(int8 arg1, int8 arg2); +extern bool boollt(int8 arg1, int8 arg2); +extern bool boolgt(int8 arg1, int8 arg2); /* char.c */ -extern int32 charin(char *ch); -extern char *charout(int32 ch); -extern int32 cidin(char *s); -extern char *cidout(int32 c); -extern char *char16in(char *s); -extern char *char16out(char *s); -extern bool chareq(int8 arg1, int8 arg2); -extern bool charne(int8 arg1, int8 arg2); -extern bool charlt(int8 arg1, int8 arg2); -extern bool charle(int8 arg1, int8 arg2); -extern bool chargt(int8 arg1, int8 arg2); -extern bool charge(int8 arg1, int8 arg2); -extern int8 charpl(int8 arg1, int8 arg2); -extern int8 charmi(int8 arg1, int8 arg2); -extern int8 charmul(int8 arg1, int8 arg2); -extern int8 chardiv(int8 arg1, int8 arg2); -extern bool cideq(int8 arg1, int8 arg2); -extern bool char16eq(char *arg1, char *arg2); -extern bool char16ne(char *arg1, char *arg2); -extern bool char16lt(char *arg1, char *arg2); -extern bool char16le(char *arg1, char *arg2); -extern bool char16gt(char *arg1, char *arg2); -extern bool char16ge(char *arg1, char *arg2); -extern uint16 char2in(char *s); -extern char *char2out(uint16 s); -extern bool char2eq(uint16 a, uint16 b); -extern bool char2ne(uint16 a, uint16 b); -extern bool char2lt(uint16 a, uint16 b); -extern bool char2le(uint16 a, uint16 b); -extern bool char2gt(uint16 a, uint16 b); -extern bool char2ge(uint16 a, uint16 b); -extern int32 char2cmp(uint16 a, uint16 b); -extern uint32 char4in(char *s); -extern char *char4out(uint32 s); -extern bool char4eq(uint32 a, uint32 b); -extern bool char4ne(uint32 a, uint32 b); -extern bool char4lt(uint32 a, uint32 b); -extern bool char4le(uint32 a, uint32 b); -extern bool char4gt(uint32 a, uint32 b); -extern bool char4ge(uint32 a, uint32 b); -extern int32 char4cmp(uint32 a, uint32 b); -extern char *char8in(char *s); -extern char *char8out(char *s); -extern bool char8eq(char *arg1, char *arg2); -extern bool char8ne(char *arg1, char *arg2); -extern bool char8lt(char *arg1, char *arg2); -extern bool char8le(char *arg1, char *arg2); -extern bool char8gt(char *arg1, char *arg2); -extern bool char8ge(char *arg1, char *arg2); -extern int32 char8cmp(char *arg1, char *arg2); +extern int32 charin(char *ch); +extern char *charout(int32 ch); +extern int32 cidin(char *s); +extern char *cidout(int32 c); +extern char *char16in(char *s); +extern char *char16out(char *s); +extern bool chareq(int8 arg1, int8 arg2); +extern bool charne(int8 arg1, int8 arg2); +extern bool charlt(int8 arg1, int8 arg2); +extern bool charle(int8 arg1, int8 arg2); +extern bool chargt(int8 arg1, int8 arg2); +extern bool charge(int8 arg1, int8 arg2); +extern int8 charpl(int8 arg1, int8 arg2); +extern int8 charmi(int8 arg1, int8 arg2); +extern int8 charmul(int8 arg1, int8 arg2); +extern int8 chardiv(int8 arg1, int8 arg2); +extern bool cideq(int8 arg1, int8 arg2); +extern bool char16eq(char *arg1, char *arg2); +extern bool char16ne(char *arg1, char *arg2); +extern bool char16lt(char *arg1, char *arg2); +extern bool char16le(char *arg1, char *arg2); +extern bool char16gt(char *arg1, char *arg2); +extern bool char16ge(char *arg1, char *arg2); +extern uint16 char2in(char *s); +extern char *char2out(uint16 s); +extern bool char2eq(uint16 a, uint16 b); +extern bool char2ne(uint16 a, uint16 b); +extern bool char2lt(uint16 a, uint16 b); +extern bool char2le(uint16 a, uint16 b); +extern bool char2gt(uint16 a, uint16 b); +extern bool char2ge(uint16 a, uint16 b); +extern int32 char2cmp(uint16 a, uint16 b); +extern uint32 char4in(char *s); +extern char *char4out(uint32 s); +extern bool char4eq(uint32 a, uint32 b); +extern bool char4ne(uint32 a, uint32 b); +extern bool char4lt(uint32 a, uint32 b); +extern bool char4le(uint32 a, uint32 b); +extern bool char4gt(uint32 a, uint32 b); +extern bool char4ge(uint32 a, uint32 b); +extern int32 char4cmp(uint32 a, uint32 b); +extern char *char8in(char *s); +extern char *char8out(char *s); +extern bool char8eq(char *arg1, char *arg2); +extern bool char8ne(char *arg1, char *arg2); +extern bool char8lt(char *arg1, char *arg2); +extern bool char8le(char *arg1, char *arg2); +extern bool char8gt(char *arg1, char *arg2); +extern bool char8ge(char *arg1, char *arg2); +extern int32 char8cmp(char *arg1, char *arg2); /* int.c */ -extern int32 int2in(char *num); -extern char *int2out(int16 sh); -extern int16 *int28in(char *shs); -extern char *int28out(int16(*shs)[]); -extern int32 *int44in(char *input_string); -extern char *int44out(int32 an_array[]); -extern int32 int4in(char *num); -extern char *int4out(int32 l); -extern int32 i2toi4(int16 arg1); -extern int16 i4toi2(int32 arg1); -extern bool int4eq(int32 arg1, int32 arg2); -extern bool int4ne(int32 arg1, int32 arg2); -extern bool int4lt(int32 arg1, int32 arg2); -extern bool int4le(int32 arg1, int32 arg2); -extern bool int4gt(int32 arg1, int32 arg2); -extern bool int4ge(int32 arg1, int32 arg2); -extern bool int2eq(int16 arg1, int16 arg2); -extern bool int2ne(int16 arg1, int16 arg2); -extern bool int2lt(int16 arg1, int16 arg2); -extern bool int2le(int16 arg1, int16 arg2); -extern bool int2gt(int16 arg1, int16 arg2); -extern bool int2ge(int16 arg1, int16 arg2); -extern bool int24eq(int32 arg1, int32 arg2); -extern bool int24ne(int32 arg1, int32 arg2); -extern bool int24lt(int32 arg1, int32 arg2); -extern bool int24le(int32 arg1, int32 arg2); -extern bool int24gt(int32 arg1, int32 arg2); -extern bool int24ge(int32 arg1, int32 arg2); -extern bool int42eq(int32 arg1, int32 arg2); -extern bool int42ne(int32 arg1, int32 arg2); -extern bool int42lt(int32 arg1, int32 arg2); -extern bool int42le(int32 arg1, int32 arg2); -extern bool int42gt(int32 arg1, int32 arg2); -extern bool int42ge(int32 arg1, int32 arg2); -extern bool keyfirsteq(int16 * arg1, int16 arg2); -extern int32 int4um(int32 arg); -extern int32 int4pl(int32 arg1, int32 arg2); -extern int32 int4mi(int32 arg1, int32 arg2); -extern int32 int4mul(int32 arg1, int32 arg2); -extern int32 int4div(int32 arg1, int32 arg2); -extern int32 int4inc(int32 arg); -extern int16 int2um(int16 arg); -extern int16 int2pl(int16 arg1, int16 arg2); -extern int16 int2mi(int16 arg1, int16 arg2); -extern int16 int2mul(int16 arg1, int16 arg2); -extern int16 int2div(int16 arg1, int16 arg2); -extern int16 int2inc(int16 arg); -extern int32 int24pl(int32 arg1, int32 arg2); -extern int32 int24mi(int32 arg1, int32 arg2); -extern int32 int24mul(int32 arg1, int32 arg2); -extern int32 int24div(int32 arg1, int32 arg2); -extern int32 int42pl(int32 arg1, int32 arg2); -extern int32 int42mi(int32 arg1, int32 arg2); -extern int32 int42mul(int32 arg1, int32 arg2); -extern int32 int42div(int32 arg1, int32 arg2); -extern int32 int4mod(int32 arg1, int32 arg2); -extern int32 int2mod(int16 arg1, int16 arg2); -extern int32 int24mod(int32 arg1, int32 arg2); -extern int32 int42mod(int32 arg1, int32 arg2); -extern int32 int4fac(int32 arg1); -extern int32 int2fac(int16 arg1); -extern int16 int2larger(int16 arg1, int16 arg2); -extern int16 int2smaller(int16 arg1, int16 arg2); -extern int32 int4larger(int32 arg1, int32 arg2); -extern int32 int4smaller(int32 arg1, int32 arg2); +extern int32 int2in(char *num); +extern char *int2out(int16 sh); +extern int16 *int28in(char *shs); +extern char *int28out(int16(*shs)[]); +extern int32 *int44in(char *input_string); +extern char *int44out(int32 an_array[]); +extern int32 int4in(char *num); +extern char *int4out(int32 l); +extern int32 i2toi4(int16 arg1); +extern int16 i4toi2(int32 arg1); +extern bool int4eq(int32 arg1, int32 arg2); +extern bool int4ne(int32 arg1, int32 arg2); +extern bool int4lt(int32 arg1, int32 arg2); +extern bool int4le(int32 arg1, int32 arg2); +extern bool int4gt(int32 arg1, int32 arg2); +extern bool int4ge(int32 arg1, int32 arg2); +extern bool int2eq(int16 arg1, int16 arg2); +extern bool int2ne(int16 arg1, int16 arg2); +extern bool int2lt(int16 arg1, int16 arg2); +extern bool int2le(int16 arg1, int16 arg2); +extern bool int2gt(int16 arg1, int16 arg2); +extern bool int2ge(int16 arg1, int16 arg2); +extern bool int24eq(int32 arg1, int32 arg2); +extern bool int24ne(int32 arg1, int32 arg2); +extern bool int24lt(int32 arg1, int32 arg2); +extern bool int24le(int32 arg1, int32 arg2); +extern bool int24gt(int32 arg1, int32 arg2); +extern bool int24ge(int32 arg1, int32 arg2); +extern bool int42eq(int32 arg1, int32 arg2); +extern bool int42ne(int32 arg1, int32 arg2); +extern bool int42lt(int32 arg1, int32 arg2); +extern bool int42le(int32 arg1, int32 arg2); +extern bool int42gt(int32 arg1, int32 arg2); +extern bool int42ge(int32 arg1, int32 arg2); +extern bool keyfirsteq(int16 * arg1, int16 arg2); +extern int32 int4um(int32 arg); +extern int32 int4pl(int32 arg1, int32 arg2); +extern int32 int4mi(int32 arg1, int32 arg2); +extern int32 int4mul(int32 arg1, int32 arg2); +extern int32 int4div(int32 arg1, int32 arg2); +extern int32 int4inc(int32 arg); +extern int16 int2um(int16 arg); +extern int16 int2pl(int16 arg1, int16 arg2); +extern int16 int2mi(int16 arg1, int16 arg2); +extern int16 int2mul(int16 arg1, int16 arg2); +extern int16 int2div(int16 arg1, int16 arg2); +extern int16 int2inc(int16 arg); +extern int32 int24pl(int32 arg1, int32 arg2); +extern int32 int24mi(int32 arg1, int32 arg2); +extern int32 int24mul(int32 arg1, int32 arg2); +extern int32 int24div(int32 arg1, int32 arg2); +extern int32 int42pl(int32 arg1, int32 arg2); +extern int32 int42mi(int32 arg1, int32 arg2); +extern int32 int42mul(int32 arg1, int32 arg2); +extern int32 int42div(int32 arg1, int32 arg2); +extern int32 int4mod(int32 arg1, int32 arg2); +extern int32 int2mod(int16 arg1, int16 arg2); +extern int32 int24mod(int32 arg1, int32 arg2); +extern int32 int42mod(int32 arg1, int32 arg2); +extern int32 int4fac(int32 arg1); +extern int32 int2fac(int16 arg1); +extern int16 int2larger(int16 arg1, int16 arg2); +extern int16 int2smaller(int16 arg1, int16 arg2); +extern int32 int4larger(int32 arg1, int32 arg2); +extern int32 int4smaller(int32 arg1, int32 arg2); /* name.c */ extern NameData *namein(char *s); -extern char *nameout(NameData * s); -extern bool nameeq(NameData * arg1, NameData * arg2); -extern bool namene(NameData * arg1, NameData * arg2); -extern bool namelt(NameData * arg1, NameData * arg2); -extern bool namele(NameData * arg1, NameData * arg2); -extern bool namegt(NameData * arg1, NameData * arg2); -extern bool namege(NameData * arg1, NameData * arg2); -extern int namecmp(Name n1, Name n2); -extern int namecpy(Name n1, Name n2); -extern int namestrcpy(Name name, char *str); -extern int namestrcmp(Name name, char *str); +extern char *nameout(NameData * s); +extern bool nameeq(NameData * arg1, NameData * arg2); +extern bool namene(NameData * arg1, NameData * arg2); +extern bool namelt(NameData * arg1, NameData * arg2); +extern bool namele(NameData * arg1, NameData * arg2); +extern bool namegt(NameData * arg1, NameData * arg2); +extern bool namege(NameData * arg1, NameData * arg2); +extern int namecmp(Name n1, Name n2); +extern int namecpy(Name n1, Name n2); +extern int namestrcpy(Name name, char *str); +extern int namestrcmp(Name name, char *str); /* numutils.c */ /* XXX hack. HP-UX has a ltoa (with different arguments) already. */ #ifdef hpux #define ltoa pg_ltoa #endif /* hpux */ -extern int32 pg_atoi(char *s, int size, int c); -extern void itoa(int i, char *a); -extern void ltoa(int32 l, char *a); +extern int32 pg_atoi(char *s, int size, int c); +extern void itoa(int i, char *a); +extern void ltoa(int32 l, char *a); /* * Per-opclass comparison functions for new btrees. These are * stored in pg_amproc and defined in nbtree/ */ -extern int32 btint2cmp(int16 a, int16 b); -extern int32 btint4cmp(int32 a, int32 b); -extern int32 btint24cmp(int16 a, int32 b); -extern int32 btint42cmp(int32 a, int16 b); -extern int32 btfloat4cmp(float32 a, float32 b); -extern int32 btfloat8cmp(float64 a, float64 b); -extern int32 btoidcmp(Oid a, Oid b); -extern int32 btabstimecmp(AbsoluteTime a, AbsoluteTime b); -extern int32 btcharcmp(char a, char b); -extern int32 btchar2cmp(uint16 a, uint16 b); -extern int32 btchar4cmp(uint32 a, uint32 b); -extern int32 btchar8cmp(char *a, char *b); -extern int32 btchar16cmp(char *a, char *b); -extern int32 btnamecmp(NameData * a, NameData * b); -extern int32 bttextcmp(struct varlena * a, struct varlena * b); +extern int32 btint2cmp(int16 a, int16 b); +extern int32 btint4cmp(int32 a, int32 b); +extern int32 btint24cmp(int16 a, int32 b); +extern int32 btint42cmp(int32 a, int16 b); +extern int32 btfloat4cmp(float32 a, float32 b); +extern int32 btfloat8cmp(float64 a, float64 b); +extern int32 btoidcmp(Oid a, Oid b); +extern int32 btabstimecmp(AbsoluteTime a, AbsoluteTime b); +extern int32 btcharcmp(char a, char b); +extern int32 btchar2cmp(uint16 a, uint16 b); +extern int32 btchar4cmp(uint32 a, uint32 b); +extern int32 btchar8cmp(char *a, char *b); +extern int32 btchar16cmp(char *a, char *b); +extern int32 btnamecmp(NameData * a, NameData * b); +extern int32 bttextcmp(struct varlena * a, struct varlena * b); /* support routines for the rtree access method, by opclass */ -extern BOX *rt_box_union(BOX * a, BOX * b); -extern BOX *rt_box_inter(BOX * a, BOX * b); -extern void rt_box_size(BOX * a, float *size); -extern void rt_bigbox_size(BOX * a, float *size); -extern void rt_poly_size(POLYGON * a, float *size); +extern BOX *rt_box_union(BOX * a, BOX * b); +extern BOX *rt_box_inter(BOX * a, BOX * b); +extern void rt_box_size(BOX * a, float *size); +extern void rt_bigbox_size(BOX * a, float *size); +extern void rt_poly_size(POLYGON * a, float *size); extern POLYGON *rt_poly_union(POLYGON * a, POLYGON * b); extern POLYGON *rt_poly_inter(POLYGON * a, POLYGON * b); @@ -213,15 +213,15 @@ extern POLYGON *rt_poly_inter(POLYGON * a, POLYGON * b); in executor/executor.h*/ -extern int32 pqtest(struct varlena * vlena); +extern int32 pqtest(struct varlena * vlena); /* arrayfuncs.c */ /* date.c */ -extern int32 reltimein(char *timestring); -extern char *reltimeout(int32 timevalue); +extern int32 reltimein(char *timestring); +extern char *reltimeout(int32 timevalue); extern TimeInterval tintervalin(char *intervalstr); -extern char *tintervalout(TimeInterval interval); +extern char *tintervalout(TimeInterval interval); extern RelativeTime timespan_reltime(TimeSpan * timespan); extern TimeSpan *reltime_timespan(RelativeTime reltime); extern TimeInterval mktinterval(AbsoluteTime t1, AbsoluteTime t2); @@ -229,309 +229,309 @@ extern AbsoluteTime timepl(AbsoluteTime t1, RelativeTime t2); extern AbsoluteTime timemi(AbsoluteTime t1, RelativeTime t2); /* extern RelativeTime abstimemi(AbsoluteTime t1, AbsoluteTime t2); static*/ -extern int ininterval(AbsoluteTime t, TimeInterval interval); +extern int ininterval(AbsoluteTime t, TimeInterval interval); extern RelativeTime intervalrel(TimeInterval interval); extern AbsoluteTime timenow(void); -extern bool reltimeeq(RelativeTime t1, RelativeTime t2); -extern bool reltimene(RelativeTime t1, RelativeTime t2); -extern bool reltimelt(RelativeTime t1, RelativeTime t2); -extern bool reltimegt(RelativeTime t1, RelativeTime t2); -extern bool reltimele(RelativeTime t1, RelativeTime t2); -extern bool reltimege(RelativeTime t1, RelativeTime t2); -extern bool intervaleq(TimeInterval i1, TimeInterval i2); -extern bool intervalleneq(TimeInterval i, RelativeTime t); -extern bool intervallenne(TimeInterval i, RelativeTime t); -extern bool intervallenlt(TimeInterval i, RelativeTime t); -extern bool intervallengt(TimeInterval i, RelativeTime t); -extern bool intervallenle(TimeInterval i, RelativeTime t); -extern bool intervallenge(TimeInterval i, RelativeTime t); -extern bool intervalct(TimeInterval i1, TimeInterval i2); -extern bool intervalov(TimeInterval i1, TimeInterval i2); +extern bool reltimeeq(RelativeTime t1, RelativeTime t2); +extern bool reltimene(RelativeTime t1, RelativeTime t2); +extern bool reltimelt(RelativeTime t1, RelativeTime t2); +extern bool reltimegt(RelativeTime t1, RelativeTime t2); +extern bool reltimele(RelativeTime t1, RelativeTime t2); +extern bool reltimege(RelativeTime t1, RelativeTime t2); +extern bool intervaleq(TimeInterval i1, TimeInterval i2); +extern bool intervalleneq(TimeInterval i, RelativeTime t); +extern bool intervallenne(TimeInterval i, RelativeTime t); +extern bool intervallenlt(TimeInterval i, RelativeTime t); +extern bool intervallengt(TimeInterval i, RelativeTime t); +extern bool intervallenle(TimeInterval i, RelativeTime t); +extern bool intervallenge(TimeInterval i, RelativeTime t); +extern bool intervalct(TimeInterval i1, TimeInterval i2); +extern bool intervalov(TimeInterval i1, TimeInterval i2); extern AbsoluteTime intervalstart(TimeInterval i); extern AbsoluteTime intervalend(TimeInterval i); -extern int isreltime(char *timestring); -extern text *timeofday(void); +extern int isreltime(char *timestring); +extern text *timeofday(void); /* dt.c */ extern DateTime *datetime_in(char *str); -extern char *datetime_out(DateTime * datetime); +extern char *datetime_out(DateTime * datetime); extern TimeSpan *timespan_in(char *str); -extern char *timespan_out(TimeSpan * timespan); -extern int datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn); +extern char *timespan_out(TimeSpan * timespan); +extern int datetime2tm(DateTime dt, int *tzp, struct tm * tm, double *fsec, char **tzn); /* filename.c */ -extern char *filename_in(char *file); -extern char *filename_out(char *s); +extern char *filename_in(char *file); +extern char *filename_out(char *s); /* float.c */ -extern void CheckFloat8Val(double val); /* used by lex */ -extern float32 float4in(char *num); -extern char *float4out(float32 num); -extern float64 float8in(char *num); -extern char *float8out(float64 num); -extern float32 float4abs(float32 arg1); -extern float32 float4um(float32 arg1); -extern float32 float4larger(float32 arg1, float32 arg2); -extern float32 float4smaller(float32 arg1, float32 arg2); -extern float64 float8abs(float64 arg1); -extern float64 float8um(float64 arg1); -extern float64 float8larger(float64 arg1, float64 arg2); -extern float64 float8smaller(float64 arg1, float64 arg2); -extern float32 float4pl(float32 arg1, float32 arg2); -extern float32 float4mi(float32 arg1, float32 arg2); -extern float32 float4mul(float32 arg1, float32 arg2); -extern float32 float4div(float32 arg1, float32 arg2); -extern float32 float4inc(float32 arg1); -extern float64 float8pl(float64 arg1, float64 arg2); -extern float64 float8mi(float64 arg1, float64 arg2); -extern float64 float8mul(float64 arg1, float64 arg2); -extern float64 float8div(float64 arg1, float64 arg2); -extern float64 float8inc(float64 arg1); -extern bool float4eq(float32 arg1, float32 arg2); -extern bool float4ne(float32 arg1, float32 arg2); -extern bool float4lt(float32 arg1, float32 arg2); -extern bool float4le(float32 arg1, float32 arg2); -extern bool float4gt(float32 arg1, float32 arg2); -extern bool float4ge(float32 arg1, float32 arg2); -extern bool float8eq(float64 arg1, float64 arg2); -extern bool float8ne(float64 arg1, float64 arg2); -extern bool float8lt(float64 arg1, float64 arg2); -extern bool float8le(float64 arg1, float64 arg2); -extern bool float8gt(float64 arg1, float64 arg2); -extern bool float8ge(float64 arg1, float64 arg2); -extern float64 ftod(float32 num); -extern float64 i4tod(int32 num); -extern float64 i2tod(int16 num); -extern float32 dtof(float64 num); -extern int32 dtoi4(float64 num); -extern int16 dtoi2(float64 num); -extern float32 i4tof(int32 num); -extern float32 i2tof(int16 num); -extern int32 ftoi4(float32 num); -extern int16 ftoi2(float32 num); -extern float64 dround(float64 arg1); -extern float64 dtrunc(float64 arg1); -extern float64 dsqrt(float64 arg1); -extern float64 dcbrt(float64 arg1); -extern float64 dpow(float64 arg1, float64 arg2); -extern float64 dexp(float64 arg1); -extern float64 dlog1(float64 arg1); -extern float64 float48pl(float32 arg1, float64 arg2); -extern float64 float48mi(float32 arg1, float64 arg2); -extern float64 float48mul(float32 arg1, float64 arg2); -extern float64 float48div(float32 arg1, float64 arg2); -extern float64 float84pl(float64 arg1, float32 arg2); -extern float64 float84mi(float64 arg1, float32 arg2); -extern float64 float84mul(float64 arg1, float32 arg2); -extern float64 float84div(float64 arg1, float32 arg2); -extern bool float48eq(float32 arg1, float64 arg2); -extern bool float48ne(float32 arg1, float64 arg2); -extern bool float48lt(float32 arg1, float64 arg2); -extern bool float48le(float32 arg1, float64 arg2); -extern bool float48gt(float32 arg1, float64 arg2); -extern bool float48ge(float32 arg1, float64 arg2); -extern bool float84eq(float64 arg1, float32 arg2); -extern bool float84ne(float64 arg1, float32 arg2); -extern bool float84lt(float64 arg1, float32 arg2); -extern bool float84le(float64 arg1, float32 arg2); -extern bool float84gt(float64 arg1, float32 arg2); -extern bool float84ge(float64 arg1, float32 arg2); +extern void CheckFloat8Val(double val); /* used by lex */ +extern float32 float4in(char *num); +extern char *float4out(float32 num); +extern float64 float8in(char *num); +extern char *float8out(float64 num); +extern float32 float4abs(float32 arg1); +extern float32 float4um(float32 arg1); +extern float32 float4larger(float32 arg1, float32 arg2); +extern float32 float4smaller(float32 arg1, float32 arg2); +extern float64 float8abs(float64 arg1); +extern float64 float8um(float64 arg1); +extern float64 float8larger(float64 arg1, float64 arg2); +extern float64 float8smaller(float64 arg1, float64 arg2); +extern float32 float4pl(float32 arg1, float32 arg2); +extern float32 float4mi(float32 arg1, float32 arg2); +extern float32 float4mul(float32 arg1, float32 arg2); +extern float32 float4div(float32 arg1, float32 arg2); +extern float32 float4inc(float32 arg1); +extern float64 float8pl(float64 arg1, float64 arg2); +extern float64 float8mi(float64 arg1, float64 arg2); +extern float64 float8mul(float64 arg1, float64 arg2); +extern float64 float8div(float64 arg1, float64 arg2); +extern float64 float8inc(float64 arg1); +extern bool float4eq(float32 arg1, float32 arg2); +extern bool float4ne(float32 arg1, float32 arg2); +extern bool float4lt(float32 arg1, float32 arg2); +extern bool float4le(float32 arg1, float32 arg2); +extern bool float4gt(float32 arg1, float32 arg2); +extern bool float4ge(float32 arg1, float32 arg2); +extern bool float8eq(float64 arg1, float64 arg2); +extern bool float8ne(float64 arg1, float64 arg2); +extern bool float8lt(float64 arg1, float64 arg2); +extern bool float8le(float64 arg1, float64 arg2); +extern bool float8gt(float64 arg1, float64 arg2); +extern bool float8ge(float64 arg1, float64 arg2); +extern float64 ftod(float32 num); +extern float64 i4tod(int32 num); +extern float64 i2tod(int16 num); +extern float32 dtof(float64 num); +extern int32 dtoi4(float64 num); +extern int16 dtoi2(float64 num); +extern float32 i4tof(int32 num); +extern float32 i2tof(int16 num); +extern int32 ftoi4(float32 num); +extern int16 ftoi2(float32 num); +extern float64 dround(float64 arg1); +extern float64 dtrunc(float64 arg1); +extern float64 dsqrt(float64 arg1); +extern float64 dcbrt(float64 arg1); +extern float64 dpow(float64 arg1, float64 arg2); +extern float64 dexp(float64 arg1); +extern float64 dlog1(float64 arg1); +extern float64 float48pl(float32 arg1, float64 arg2); +extern float64 float48mi(float32 arg1, float64 arg2); +extern float64 float48mul(float32 arg1, float64 arg2); +extern float64 float48div(float32 arg1, float64 arg2); +extern float64 float84pl(float64 arg1, float32 arg2); +extern float64 float84mi(float64 arg1, float32 arg2); +extern float64 float84mul(float64 arg1, float32 arg2); +extern float64 float84div(float64 arg1, float32 arg2); +extern bool float48eq(float32 arg1, float64 arg2); +extern bool float48ne(float32 arg1, float64 arg2); +extern bool float48lt(float32 arg1, float64 arg2); +extern bool float48le(float32 arg1, float64 arg2); +extern bool float48gt(float32 arg1, float64 arg2); +extern bool float48ge(float32 arg1, float64 arg2); +extern bool float84eq(float64 arg1, float32 arg2); +extern bool float84ne(float64 arg1, float32 arg2); +extern bool float84lt(float64 arg1, float32 arg2); +extern bool float84le(float64 arg1, float32 arg2); +extern bool float84gt(float64 arg1, float32 arg2); +extern bool float84ge(float64 arg1, float32 arg2); /* geo_ops.c, geo_selfuncs.c */ -extern double *box_area(BOX * box); +extern double *box_area(BOX * box); /* misc.c */ -extern bool nullvalue(Datum value, bool * isNull); -extern bool nonnullvalue(Datum value, bool * isNull); -extern bool oidrand(Oid o, int32 X); -extern bool oidsrand(int32 X); -extern int32 userfntest(int i); +extern bool nullvalue(Datum value, bool * isNull); +extern bool nonnullvalue(Datum value, bool * isNull); +extern bool oidrand(Oid o, int32 X); +extern bool oidsrand(int32 X); +extern int32 userfntest(int i); /* define macros to replace mixed-case function calls - tgl 97/04/27 */ #define NullValue(v,b) nullvalue(v,b) #define NonNullValue(v,b) nonnullvalue(v,b) /* not_in.c */ -extern bool int4notin(int16 not_in_arg, char *relation_and_attr); -extern bool oidnotin(Oid the_oid, char *compare); +extern bool int4notin(int16 not_in_arg, char *relation_and_attr); +extern bool oidnotin(Oid the_oid, char *compare); /* oid.c */ -extern Oid *oid8in(char *oidString); -extern char *oid8out(Oid(*oidArray)[]); -extern Oid oidin(char *s); -extern char *oidout(Oid o); -extern bool oideq(Oid arg1, Oid arg2); -extern bool oidne(Oid arg1, Oid arg2); -extern bool oid8eq(Oid arg1[], Oid arg2[]); -extern bool oideqint4(Oid arg1, int32 arg2); -extern bool int4eqoid(int32 arg1, Oid arg2); +extern Oid *oid8in(char *oidString); +extern char *oid8out(Oid(*oidArray)[]); +extern Oid oidin(char *s); +extern char *oidout(Oid o); +extern bool oideq(Oid arg1, Oid arg2); +extern bool oidne(Oid arg1, Oid arg2); +extern bool oid8eq(Oid arg1[], Oid arg2[]); +extern bool oideqint4(Oid arg1, int32 arg2); +extern bool int4eqoid(int32 arg1, Oid arg2); /* regexp.c */ -extern bool char2regexeq(uint16 arg1, struct varlena * p); -extern bool char2regexne(uint16 arg1, struct varlena * p); -extern bool char4regexeq(uint32 arg1, struct varlena * p); -extern bool char4regexne(uint32 arg1, struct varlena * p); -extern bool char8regexeq(char *s, struct varlena * p); -extern bool char8regexne(char *s, struct varlena * p); -extern bool char16regexeq(char *s, struct varlena * p); -extern bool char16regexne(char *s, struct varlena * p); -extern bool nameregexeq(NameData * n, struct varlena * p); -extern bool nameregexne(NameData * s, struct varlena * p); -extern bool textregexeq(struct varlena * s, struct varlena * p); -extern bool textregexne(struct varlena * s, struct varlena * p); -extern bool char2icregexeq(uint16 arg1, struct varlena * p); -extern bool char2icregexne(uint16 arg1, struct varlena * p); -extern bool char4icregexeq(uint32 arg1, struct varlena * p); -extern bool char4icregexne(uint32 arg1, struct varlena * p); -extern bool char8icregexeq(char *s, struct varlena * p); -extern bool char8icregexne(char *s, struct varlena * p); -extern bool char16icregexeq(char *s, struct varlena * p); -extern bool char16icregexne(char *s, struct varlena * p); -extern bool nameicregexeq(NameData * s, struct varlena * p); -extern bool nameicregexne(NameData * s, struct varlena * p); -extern bool texticregexeq(struct varlena * s, struct varlena * p); -extern bool texticregexne(struct varlena * s, struct varlena * p); +extern bool char2regexeq(uint16 arg1, struct varlena * p); +extern bool char2regexne(uint16 arg1, struct varlena * p); +extern bool char4regexeq(uint32 arg1, struct varlena * p); +extern bool char4regexne(uint32 arg1, struct varlena * p); +extern bool char8regexeq(char *s, struct varlena * p); +extern bool char8regexne(char *s, struct varlena * p); +extern bool char16regexeq(char *s, struct varlena * p); +extern bool char16regexne(char *s, struct varlena * p); +extern bool nameregexeq(NameData * n, struct varlena * p); +extern bool nameregexne(NameData * s, struct varlena * p); +extern bool textregexeq(struct varlena * s, struct varlena * p); +extern bool textregexne(struct varlena * s, struct varlena * p); +extern bool char2icregexeq(uint16 arg1, struct varlena * p); +extern bool char2icregexne(uint16 arg1, struct varlena * p); +extern bool char4icregexeq(uint32 arg1, struct varlena * p); +extern bool char4icregexne(uint32 arg1, struct varlena * p); +extern bool char8icregexeq(char *s, struct varlena * p); +extern bool char8icregexne(char *s, struct varlena * p); +extern bool char16icregexeq(char *s, struct varlena * p); +extern bool char16icregexne(char *s, struct varlena * p); +extern bool nameicregexeq(NameData * s, struct varlena * p); +extern bool nameicregexne(NameData * s, struct varlena * p); +extern bool texticregexeq(struct varlena * s, struct varlena * p); +extern bool texticregexne(struct varlena * s, struct varlena * p); /* regproc.c */ -extern int32 regprocin(char *proname); -extern char *regprocout(RegProcedure proid); -extern Oid regproctooid(RegProcedure rp); +extern int32 regprocin(char *proname); +extern char *regprocout(RegProcedure proid); +extern Oid regproctooid(RegProcedure rp); /* define macro to replace mixed-case function call - tgl 97/04/27 */ #define RegprocToOid(rp) regproctooid(rp) /* selfuncs.c */ -extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); -extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); -extern float64 intltsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); -extern float64 intgtsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); -extern float64 eqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); -extern float64 neqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); -extern float64 intltjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); -extern float64 intgtjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); -extern float64 btreesel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 btreenpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 hashsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 hashnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 rtsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 rtnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 gistsel(Oid operatorObjectId, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); -extern float64 gistnpage(Oid operatorObjectId, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 eqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); +extern float64 neqsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); +extern float64 intltsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); +extern float64 intgtsel(Oid opid, Oid relid, AttrNumber attno, int32 value, int32 flag); +extern float64 eqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); +extern float64 neqjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); +extern float64 intltjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); +extern float64 intgtjoinsel(Oid opid, Oid relid1, AttrNumber attno1, Oid relid2, AttrNumber attno2); +extern float64 btreesel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 btreenpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 hashsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 hashnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 rtsel(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 rtnpage(Oid operatorOid, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 gistsel(Oid operatorObjectId, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); +extern float64 gistnpage(Oid operatorObjectId, Oid indrelid, AttrNumber attributeNumber, char *constValue, int32 constFlag, int32 nIndexKeys, Oid indexrelid); /* tid.c */ extern ItemPointer tidin(char *str); -extern char *tidout(ItemPointer itemPtr); +extern char *tidout(ItemPointer itemPtr); /* timestamp.c */ -extern time_t timestamp_in(const char *timestamp_str); -extern char *timestamp_out(time_t timestamp); -extern time_t now(void); -bool timestampeq(time_t t1, time_t t2); -bool timestampne(time_t t1, time_t t2); -bool timestamplt(time_t t1, time_t t2); -bool timestampgt(time_t t1, time_t t2); -bool timestample(time_t t1, time_t t2); -bool timestampge(time_t t1, time_t t2); -DateTime *timestamp_datetime(time_t timestamp); +extern time_t timestamp_in(const char *timestamp_str); +extern char *timestamp_out(time_t timestamp); +extern time_t now(void); +bool timestampeq(time_t t1, time_t t2); +bool timestampne(time_t t1, time_t t2); +bool timestamplt(time_t t1, time_t t2); +bool timestampgt(time_t t1, time_t t2); +bool timestample(time_t t1, time_t t2); +bool timestampge(time_t t1, time_t t2); +DateTime *timestamp_datetime(time_t timestamp); /* varchar.c */ -extern char *bpcharin(char *s, int dummy, int typlen); -extern char *bpcharout(char *s); -extern char *varcharin(char *s, int dummy, int typlen); -extern char *varcharout(char *s); -extern bool bpchareq(char *arg1, char *arg2); -extern bool bpcharne(char *arg1, char *arg2); -extern bool bpcharlt(char *arg1, char *arg2); -extern bool bpcharle(char *arg1, char *arg2); -extern bool bpchargt(char *arg1, char *arg2); -extern bool bpcharge(char *arg1, char *arg2); -extern int32 bpcharcmp(char *arg1, char *arg2); -extern bool varchareq(char *arg1, char *arg2); -extern bool varcharne(char *arg1, char *arg2); -extern bool varcharlt(char *arg1, char *arg2); -extern bool varcharle(char *arg1, char *arg2); -extern bool varchargt(char *arg1, char *arg2); -extern bool varcharge(char *arg1, char *arg2); -extern int32 varcharcmp(char *arg1, char *arg2); -extern uint32 hashbpchar(struct varlena * key); -extern uint32 hashvarchar(struct varlena * key); +extern char *bpcharin(char *s, int dummy, int typlen); +extern char *bpcharout(char *s); +extern char *varcharin(char *s, int dummy, int typlen); +extern char *varcharout(char *s); +extern bool bpchareq(char *arg1, char *arg2); +extern bool bpcharne(char *arg1, char *arg2); +extern bool bpcharlt(char *arg1, char *arg2); +extern bool bpcharle(char *arg1, char *arg2); +extern bool bpchargt(char *arg1, char *arg2); +extern bool bpcharge(char *arg1, char *arg2); +extern int32 bpcharcmp(char *arg1, char *arg2); +extern bool varchareq(char *arg1, char *arg2); +extern bool varcharne(char *arg1, char *arg2); +extern bool varcharlt(char *arg1, char *arg2); +extern bool varcharle(char *arg1, char *arg2); +extern bool varchargt(char *arg1, char *arg2); +extern bool varcharge(char *arg1, char *arg2); +extern int32 varcharcmp(char *arg1, char *arg2); +extern uint32 hashbpchar(struct varlena * key); +extern uint32 hashvarchar(struct varlena * key); /* varlena.c */ extern struct varlena *byteain(char *inputText); -extern char *byteaout(struct varlena * vlena); +extern char *byteaout(struct varlena * vlena); extern struct varlena *textin(char *inputText); -extern char *textout(struct varlena * vlena); -extern text *textcat(text * t1, text * t2); -extern bool texteq(struct varlena * arg1, struct varlena * arg2); -extern bool textne(struct varlena * arg1, struct varlena * arg2); -extern bool text_lt(struct varlena * arg1, struct varlena * arg2); -extern bool text_le(struct varlena * arg1, struct varlena * arg2); -extern bool text_gt(struct varlena * arg1, struct varlena * arg2); -extern bool text_ge(struct varlena * arg1, struct varlena * arg2); -extern int32 textpos(text * t1, text * t2); -extern int32 byteaGetSize(struct varlena * v); -extern int32 byteaGetByte(struct varlena * v, int32 n); -extern int32 byteaGetBit(struct varlena * v, int32 n); +extern char *textout(struct varlena * vlena); +extern text *textcat(text * t1, text * t2); +extern bool texteq(struct varlena * arg1, struct varlena * arg2); +extern bool textne(struct varlena * arg1, struct varlena * arg2); +extern bool text_lt(struct varlena * arg1, struct varlena * arg2); +extern bool text_le(struct varlena * arg1, struct varlena * arg2); +extern bool text_gt(struct varlena * arg1, struct varlena * arg2); +extern bool text_ge(struct varlena * arg1, struct varlena * arg2); +extern int32 textpos(text * t1, text * t2); +extern int32 byteaGetSize(struct varlena * v); +extern int32 byteaGetByte(struct varlena * v, int32 n); +extern int32 byteaGetBit(struct varlena * v, int32 n); extern struct varlena *byteaSetByte(struct varlena * v, int32 n, int32 newByte); extern struct varlena *byteaSetBit(struct varlena * v, int32 n, int32 newBit); /* datetime.c */ -extern DateADT date_in(char *datestr); -extern char *date_out(DateADT dateVal); -extern bool date_eq(DateADT dateVal1, DateADT dateVal2); -extern bool date_ne(DateADT dateVal1, DateADT dateVal2); -extern bool date_lt(DateADT dateVal1, DateADT dateVal2); -extern bool date_le(DateADT dateVal1, DateADT dateVal2); -extern bool date_gt(DateADT dateVal1, DateADT dateVal2); -extern bool date_ge(DateADT dateVal1, DateADT dateVal2); -extern int date_cmp(DateADT dateVal1, DateADT dateVal2); -extern DateADT date_larger(DateADT dateVal1, DateADT dateVal2); -extern DateADT date_smaller(DateADT dateVal1, DateADT dateVal2); -extern int32 date_mi(DateADT dateVal1, DateADT dateVal2); -extern DateADT date_pli(DateADT dateVal, int32 days); -extern DateADT date_mii(DateADT dateVal, int32 days); +extern DateADT date_in(char *datestr); +extern char *date_out(DateADT dateVal); +extern bool date_eq(DateADT dateVal1, DateADT dateVal2); +extern bool date_ne(DateADT dateVal1, DateADT dateVal2); +extern bool date_lt(DateADT dateVal1, DateADT dateVal2); +extern bool date_le(DateADT dateVal1, DateADT dateVal2); +extern bool date_gt(DateADT dateVal1, DateADT dateVal2); +extern bool date_ge(DateADT dateVal1, DateADT dateVal2); +extern int date_cmp(DateADT dateVal1, DateADT dateVal2); +extern DateADT date_larger(DateADT dateVal1, DateADT dateVal2); +extern DateADT date_smaller(DateADT dateVal1, DateADT dateVal2); +extern int32 date_mi(DateADT dateVal1, DateADT dateVal2); +extern DateADT date_pli(DateADT dateVal, int32 days); +extern DateADT date_mii(DateADT dateVal, int32 days); extern DateTime *date_datetime(DateADT date); -extern DateADT datetime_date(DateTime * datetime); +extern DateADT datetime_date(DateTime * datetime); extern DateTime *datetime_datetime(DateADT date, TimeADT * time); -extern DateADT abstime_date(AbsoluteTime abstime); +extern DateADT abstime_date(AbsoluteTime abstime); extern TimeADT *time_in(char *timestr); -extern char *time_out(TimeADT * time); -extern bool time_eq(TimeADT * time1, TimeADT * time2); -extern bool time_ne(TimeADT * time1, TimeADT * time2); -extern bool time_lt(TimeADT * time1, TimeADT * time2); -extern bool time_le(TimeADT * time1, TimeADT * time2); -extern bool time_gt(TimeADT * time1, TimeADT * time2); -extern bool time_ge(TimeADT * time1, TimeADT * time2); -extern int time_cmp(TimeADT * time1, TimeADT * time2); -extern int32 int42reltime(int32 timevalue); +extern char *time_out(TimeADT * time); +extern bool time_eq(TimeADT * time1, TimeADT * time2); +extern bool time_ne(TimeADT * time1, TimeADT * time2); +extern bool time_lt(TimeADT * time1, TimeADT * time2); +extern bool time_le(TimeADT * time1, TimeADT * time2); +extern bool time_gt(TimeADT * time1, TimeADT * time2); +extern bool time_ge(TimeADT * time1, TimeADT * time2); +extern int time_cmp(TimeADT * time1, TimeADT * time2); +extern int32 int42reltime(int32 timevalue); /* like.c */ -extern bool char2like(uint16 arg1, struct varlena * p); -extern bool char2nlike(uint16 arg1, struct varlena * p); -extern bool char4like(uint32 arg1, struct varlena * p); -extern bool char4nlike(uint32 arg1, struct varlena * p); -extern bool char8like(char *s, struct varlena * p); -extern bool char8nlike(char *s, struct varlena * p); -extern bool char16like(char *s, struct varlena * p); -extern bool char16nlike(char *s, struct varlena * p); -extern bool namelike(NameData * n, struct varlena * p); -extern bool namenlike(NameData * s, struct varlena * p); -extern bool textlike(struct varlena * s, struct varlena * p); -extern bool textnlike(struct varlena * s, struct varlena * p); +extern bool char2like(uint16 arg1, struct varlena * p); +extern bool char2nlike(uint16 arg1, struct varlena * p); +extern bool char4like(uint32 arg1, struct varlena * p); +extern bool char4nlike(uint32 arg1, struct varlena * p); +extern bool char8like(char *s, struct varlena * p); +extern bool char8nlike(char *s, struct varlena * p); +extern bool char16like(char *s, struct varlena * p); +extern bool char16nlike(char *s, struct varlena * p); +extern bool namelike(NameData * n, struct varlena * p); +extern bool namenlike(NameData * s, struct varlena * p); +extern bool textlike(struct varlena * s, struct varlena * p); +extern bool textnlike(struct varlena * s, struct varlena * p); /* oracle_compat.c */ -extern text *lower(text * string); -extern text *upper(text * string); -extern text *initcap(text * string); -extern text *lpad(text * string1, int4 len, text * string2); -extern text *rpad(text * string1, int4 len, text * string2); -extern text *ltrim(text * string, text * set); -extern text *rtrim(text * string, text * set); -extern text *substr(text * string, int4 m, int4 n); -extern text *translate(text * string, char from, char to); +extern text *lower(text * string); +extern text *upper(text * string); +extern text *initcap(text * string); +extern text *lpad(text * string1, int4 len, text * string2); +extern text *rpad(text * string1, int4 len, text * string2); +extern text *ltrim(text * string, text * set); +extern text *rtrim(text * string, text * set); +extern text *substr(text * string, int4 m, int4 n); +extern text *translate(text * string, char from, char to); /* acl.c */ diff --git a/src/include/utils/cash.h b/src/include/utils/cash.h index 2e5f82c093b..4a88219090e 100644 --- a/src/include/utils/cash.h +++ b/src/include/utils/cash.h @@ -13,22 +13,22 @@ typedef signed int Cash; extern const char *cash_out(Cash * value); -extern Cash *cash_in(const char *str); - -extern bool cash_eq(Cash * c1, Cash * c2); -extern bool cash_ne(Cash * c1, Cash * c2); -extern bool cash_lt(Cash * c1, Cash * c2); -extern bool cash_le(Cash * c1, Cash * c2); -extern bool cash_gt(Cash * c1, Cash * c2); -extern bool cash_ge(Cash * c1, Cash * c2); - -extern Cash *cash_pl(Cash * c1, Cash * c2); -extern Cash *cash_mi(Cash * c1, Cash * c2); -extern Cash *cash_mul(Cash * c, float8 * f); -extern Cash *cash_div(Cash * c, float8 * f); - -extern Cash *cashlarger(Cash * c1, Cash * c2); -extern Cash *cashsmaller(Cash * c1, Cash * c2); +extern Cash *cash_in(const char *str); + +extern bool cash_eq(Cash * c1, Cash * c2); +extern bool cash_ne(Cash * c1, Cash * c2); +extern bool cash_lt(Cash * c1, Cash * c2); +extern bool cash_le(Cash * c1, Cash * c2); +extern bool cash_gt(Cash * c1, Cash * c2); +extern bool cash_ge(Cash * c1, Cash * c2); + +extern Cash *cash_pl(Cash * c1, Cash * c2); +extern Cash *cash_mi(Cash * c1, Cash * c2); +extern Cash *cash_mul(Cash * c, float8 * f); +extern Cash *cash_div(Cash * c, float8 * f); + +extern Cash *cashlarger(Cash * c1, Cash * c2); +extern Cash *cashsmaller(Cash * c1, Cash * c2); extern const char *cash_words_out(Cash * value); diff --git a/src/include/utils/catcache.h b/src/include/utils/catcache.h index 6b33ef89b11..c7dc6283445 100644 --- a/src/include/utils/catcache.h +++ b/src/include/utils/catcache.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: catcache.h,v 1.6 1997/09/07 05:02:14 momjian Exp $ + * $Id: catcache.h,v 1.7 1997/09/08 02:39:34 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -27,11 +27,11 @@ typedef struct catctup { - HeapTuple ct_tup; /* A pointer to a tuple */ - Dlelem *ct_node; /* points to LRU list is the CatCTup is in + HeapTuple ct_tup; /* A pointer to a tuple */ + Dlelem *ct_node; /* points to LRU list is the CatCTup is in * the cache, else, points to the cache if * the CatCTup is in LRU list */ -} CatCTup; +} CatCTup; /* voodoo constants */ #define NCCBUCK 500 /* CatCache buckets */ @@ -39,24 +39,24 @@ typedef struct catctup typedef struct catcache { - Oid relationId; - Oid indexId; - char *cc_relname; /* relation name for defered open */ - char *cc_indname; /* index name for defered open */ - HeapTuple(*cc_iscanfunc) (); /* index scanfunction */ - TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */ - int id; /* XXX could be improved -hirohama */ - short cc_ntup; /* # of tuples in this cache */ - short cc_maxtup; /* max # of tuples allowed (LRU) */ - short cc_nkeys; - short cc_size; - short cc_key[4]; - short cc_klen[4]; - ScanKeyData cc_skey[4]; + Oid relationId; + Oid indexId; + char *cc_relname; /* relation name for defered open */ + char *cc_indname; /* index name for defered open */ + HeapTuple(*cc_iscanfunc) (); /* index scanfunction */ + TupleDesc cc_tupdesc; /* tuple descriptor from reldesc */ + int id; /* XXX could be improved -hirohama */ + short cc_ntup; /* # of tuples in this cache */ + short cc_maxtup; /* max # of tuples allowed (LRU) */ + short cc_nkeys; + short cc_size; + short cc_key[4]; + short cc_klen[4]; + ScanKeyData cc_skey[4]; struct catcache *cc_next; - Dllist *cc_lrulist; /* LRU list, most recent first */ - Dllist *cc_cache[NCCBUCK + 1]; -} CatCache; + Dllist *cc_lrulist; /* LRU list, most recent first */ + Dllist *cc_cache[NCCBUCK + 1]; +} CatCache; #define InvalidCatalogCacheId (-1) @@ -66,11 +66,11 @@ extern GlobalMemory CacheCxt; extern void CatalogCacheIdInvalidate(int cacheId, Index hashIndex, ItemPointer pointer); -extern void ResetSystemCache(void); +extern void ResetSystemCache(void); extern CatCache * InitSysCache(char *relname, char *indname, int id, int nkeys, int key[], HeapTuple(*iScanfuncP) ()); -extern HeapTuple +extern HeapTuple SearchSysCache(struct catcache * cache, Datum v1, Datum v2, Datum v3, Datum v4); extern void diff --git a/src/include/utils/datetime.h b/src/include/utils/datetime.h index 79e6fb7ff57..4c0cefce8fc 100644 --- a/src/include/utils/datetime.h +++ b/src/include/utils/datetime.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: datetime.h,v 1.4 1997/09/07 05:02:16 momjian Exp $ + * $Id: datetime.h,v 1.5 1997/09/08 02:39:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,8 +15,8 @@ #include "utils/dt.h" -typedef int32 DateADT; +typedef int32 DateADT; -typedef float8 TimeADT; +typedef float8 TimeADT; #endif /* DATETIME_H */ diff --git a/src/include/utils/datum.h b/src/include/utils/datum.h index 5409c8ddfe3..8fcd2136568 100644 --- a/src/include/utils/datum.h +++ b/src/include/utils/datum.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: datum.h,v 1.3 1997/09/07 05:02:17 momjian Exp $ + * $Id: datum.h,v 1.4 1997/09/08 02:39:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,26 +38,26 @@ * datumGetSize * find the "real" length of a datum */ -extern Size datumGetSize(Datum value, Oid type, bool byVal, Size len); +extern Size datumGetSize(Datum value, Oid type, bool byVal, Size len); /*--------------- * datumCopy * make a copy of a datum. */ -extern Datum datumCopy(Datum value, Oid type, bool byVal, Size len); +extern Datum datumCopy(Datum value, Oid type, bool byVal, Size len); /*--------------- * datumFree * free space that *might* have been palloced by "datumCopy" */ -extern void datumFree(Datum value, Oid type, bool byVal, Size len); +extern void datumFree(Datum value, Oid type, bool byVal, Size len); /*--------------- * datumIsEqual * return true if thwo datums are equal, false otherwise. * XXX : See comments in the code for restrictions! */ -extern bool +extern bool datumIsEqual(Datum value1, Datum value2, Oid type, bool byVal, Size len); diff --git a/src/include/utils/dt.h b/src/include/utils/dt.h index b30e3a18627..8634b7f03c2 100644 --- a/src/include/utils/dt.h +++ b/src/include/utils/dt.h @@ -8,7 +8,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dt.h,v 1.19 1997/09/07 05:02:19 momjian Exp $ + * $Id: dt.h,v 1.20 1997/09/08 02:39:37 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,15 +28,15 @@ * consisting of a beginning and ending time, not a time span - tgl 97/03/20 */ -typedef double DateTime; +typedef double DateTime; typedef struct { - double time; /* all time units other than months and + double time; /* all time units other than months and * years */ - int4 month; /* months and years, after time for + int4 month; /* months and years, after time for * alignment */ -} TimeSpan; +} TimeSpan; /* ---------------------------------------------------------------- @@ -185,13 +185,13 @@ typedef struct typedef struct { #if defined(aix) - char *token; + char *token; #else - char token[TOKMAXLEN]; + char token[TOKMAXLEN]; #endif /* aix */ - char type; - char value; /* this may be unsigned, alas */ -} datetkn; + char type; + char value; /* this may be unsigned, alas */ +} datetkn; #ifdef NAN #define DT_INVALID (NAN) @@ -223,7 +223,7 @@ typedef struct #define DATETIME_CURRENT(j) {j = DT_CURRENT;} #if defined(linux) && defined(PPC) -extern int datetime_is_current(double j); +extern int datetime_is_current(double j); #define DATETIME_IS_CURRENT(j) datetime_is_current(j) #else @@ -232,7 +232,7 @@ extern int datetime_is_current(double j); #define DATETIME_EPOCH(j) {j = DT_EPOCH;} #if defined(linux) && defined(PPC) -extern int datetime_is_epoch(double j); +extern int datetime_is_epoch(double j); #define DATETIME_IS_EPOCH(j) datetime_is_epoch(j) #else @@ -260,38 +260,38 @@ extern int datetime_is_epoch(double j); */ extern DateTime *datetime_in(char *str); -extern char *datetime_out(DateTime * dt); -extern bool datetime_eq(DateTime * dt1, DateTime * dt2); -extern bool datetime_ne(DateTime * dt1, DateTime * dt2); -extern bool datetime_lt(DateTime * dt1, DateTime * dt2); -extern bool datetime_le(DateTime * dt1, DateTime * dt2); -extern bool datetime_ge(DateTime * dt1, DateTime * dt2); -extern bool datetime_gt(DateTime * dt1, DateTime * dt2); -extern bool datetime_finite(DateTime * datetime); -extern int datetime_cmp(DateTime * dt1, DateTime * dt2); +extern char *datetime_out(DateTime * dt); +extern bool datetime_eq(DateTime * dt1, DateTime * dt2); +extern bool datetime_ne(DateTime * dt1, DateTime * dt2); +extern bool datetime_lt(DateTime * dt1, DateTime * dt2); +extern bool datetime_le(DateTime * dt1, DateTime * dt2); +extern bool datetime_ge(DateTime * dt1, DateTime * dt2); +extern bool datetime_gt(DateTime * dt1, DateTime * dt2); +extern bool datetime_finite(DateTime * datetime); +extern int datetime_cmp(DateTime * dt1, DateTime * dt2); extern DateTime *datetime_smaller(DateTime * dt1, DateTime * dt2); extern DateTime *datetime_larger(DateTime * dt1, DateTime * dt2); extern TimeSpan *timespan_in(char *str); -extern char *timespan_out(TimeSpan * span); -extern bool timespan_eq(TimeSpan * span1, TimeSpan * span2); -extern bool timespan_ne(TimeSpan * span1, TimeSpan * span2); -extern bool timespan_lt(TimeSpan * span1, TimeSpan * span2); -extern bool timespan_le(TimeSpan * span1, TimeSpan * span2); -extern bool timespan_ge(TimeSpan * span1, TimeSpan * span2); -extern bool timespan_gt(TimeSpan * span1, TimeSpan * span2); -extern int timespan_cmp(TimeSpan * span1, TimeSpan * span2); +extern char *timespan_out(TimeSpan * span); +extern bool timespan_eq(TimeSpan * span1, TimeSpan * span2); +extern bool timespan_ne(TimeSpan * span1, TimeSpan * span2); +extern bool timespan_lt(TimeSpan * span1, TimeSpan * span2); +extern bool timespan_le(TimeSpan * span1, TimeSpan * span2); +extern bool timespan_ge(TimeSpan * span1, TimeSpan * span2); +extern bool timespan_gt(TimeSpan * span1, TimeSpan * span2); +extern int timespan_cmp(TimeSpan * span1, TimeSpan * span2); extern TimeSpan *timespan_smaller(TimeSpan * span1, TimeSpan * span2); extern TimeSpan *timespan_larger(TimeSpan * span1, TimeSpan * span2); -extern text *datetime_text(DateTime * datetime); +extern text *datetime_text(DateTime * datetime); extern DateTime *text_datetime(text * str); -extern text *timespan_text(TimeSpan * timespan); +extern text *timespan_text(TimeSpan * timespan); extern DateTime *datetime_trunc(text * units, DateTime * datetime); extern TimeSpan *timespan_trunc(text * units, TimeSpan * timespan); -extern float64 datetime_part(text * units, DateTime * datetime); -extern float64 timespan_part(text * units, TimeSpan * timespan); -extern text *datetime_zone(text * zone, DateTime * datetime); +extern float64 datetime_part(text * units, DateTime * datetime); +extern float64 timespan_part(text * units, TimeSpan * timespan); +extern text *datetime_zone(text * zone, DateTime * datetime); extern TimeSpan *timespan_um(TimeSpan * span); extern TimeSpan *timespan_pl(TimeSpan * span1, TimeSpan * span2); @@ -303,14 +303,14 @@ extern DateTime *datetime_pl_span(DateTime * dt, TimeSpan * span); extern DateTime *datetime_mi_span(DateTime * dt, TimeSpan * span); extern TimeSpan *datetime_age(DateTime * dt1, DateTime * dt2); -extern void GetCurrentTime(struct tm * tm); +extern void GetCurrentTime(struct tm * tm); extern DateTime SetDateTime(DateTime datetime); -extern int tm2datetime(struct tm * tm, double fsec, int *tzp, DateTime * dt); +extern int tm2datetime(struct tm * tm, double fsec, int *tzp, DateTime * dt); -extern void j2date(int jd, int *year, int *month, int *day); -extern int date2j(int year, int month, int day); +extern void j2date(int jd, int *year, int *month, int *day); +extern int date2j(int year, int month, int day); -extern double time2t(const int hour, const int min, const double sec); +extern double time2t(const int hour, const int min, const double sec); extern int ParseDateTime(char *timestr, char *lowstr, @@ -327,9 +327,9 @@ extern int DecodeDateDelta(char *field[], int ftype[], int nf, int *dtype, struct tm * tm, double *fsec); -extern int EncodeDateOnly(struct tm * tm, int style, char *str); -extern int EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str); -extern int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str); -extern int EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str); +extern int EncodeDateOnly(struct tm * tm, int style, char *str); +extern int EncodeTimeOnly(struct tm * tm, double fsec, int style, char *str); +extern int EncodeDateTime(struct tm * tm, double fsec, int *tzp, char **tzn, int style, char *str); +extern int EncodeTimeSpan(struct tm * tm, double fsec, int style, char *str); #endif /* DT_H */ diff --git a/src/include/utils/dynahash.h b/src/include/utils/dynahash.h index bf04ef10739..6febd293cee 100644 --- a/src/include/utils/dynahash.h +++ b/src/include/utils/dynahash.h @@ -6,13 +6,13 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dynahash.h,v 1.3 1997/09/07 05:02:20 momjian Exp $ + * $Id: dynahash.h,v 1.4 1997/09/08 02:39:38 momjian Exp $ * *------------------------------------------------------------------------- */ #ifndef DYNAHASH_H #define DYNAHASH_H -extern int my_log2(long num); +extern int my_log2(long num); #endif /* DYNAHASH_H */ diff --git a/src/include/utils/dynamic_loader.h b/src/include/utils/dynamic_loader.h index fe8e189ff35..7c8b075a90b 100644 --- a/src/include/utils/dynamic_loader.h +++ b/src/include/utils/dynamic_loader.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: dynamic_loader.h,v 1.6 1997/09/07 05:02:22 momjian Exp $ + * $Id: dynamic_loader.h,v 1.7 1997/09/08 02:39:38 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,16 +29,16 @@ typedef struct df_files { - char filename[MAXPATHLEN]; /* Full pathname of file */ - dev_t device; /* Device file is on */ - ino_t inode; /* Inode number of file */ - void *handle; /* a handle for pg_dl* functions */ + char filename[MAXPATHLEN]; /* Full pathname of file */ + dev_t device; /* Device file is on */ + ino_t inode; /* Inode number of file */ + void *handle; /* a handle for pg_dl* functions */ struct df_files *next; -} DynamicFileList; +} DynamicFileList; -extern void *pg_dlopen(char *filename); +extern void *pg_dlopen(char *filename); extern func_ptr pg_dlsym(void *handle, char *funcname); -extern void pg_dlclose(void *handle); -extern char *pg_dlerror(void); +extern void pg_dlclose(void *handle); +extern char *pg_dlerror(void); #endif /* DYNAMIC_LOADER_H */ diff --git a/src/include/utils/elog.h b/src/include/utils/elog.h index fc9305d9a0e..8fd93be9fa5 100644 --- a/src/include/utils/elog.h +++ b/src/include/utils/elog.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: elog.h,v 1.4 1997/09/07 05:02:27 momjian Exp $ + * $Id: elog.h,v 1.5 1997/09/08 02:39:39 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,10 +33,10 @@ /* uncomment the following if you want your elog's to be timestamped */ /* #define ELOG_TIMESTAMPS */ -extern void elog(int lev, const char *fmt,...); +extern void elog(int lev, const char *fmt,...); #ifndef PG_STANDALONE -int DebugFileOpen(void); +int DebugFileOpen(void); #endif diff --git a/src/include/utils/exc.h b/src/include/utils/exc.h index 5c240eeaa5d..c8b791cb6f6 100644 --- a/src/include/utils/exc.h +++ b/src/include/utils/exc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: exc.h,v 1.8 1997/09/07 05:02:28 momjian Exp $ + * $Id: exc.h,v 1.9 1997/09/08 02:39:41 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -17,8 +17,8 @@ #include "config.h" -extern char *ExcFileName; -extern Index ExcLineNumber; +extern char *ExcFileName; +extern Index ExcLineNumber; /* * ExcMessage and Exception are now defined in c.h @@ -32,18 +32,18 @@ typedef sigjmp_buf ExcContext; #endif typedef Exception *ExcId; -typedef long ExcDetail; -typedef char *ExcData; +typedef long ExcDetail; +typedef char *ExcData; typedef struct ExcFrame { struct ExcFrame *link; - ExcContext context; - ExcId id; - ExcDetail detail; - ExcData data; - ExcMessage message; -} ExcFrame; + ExcContext context; + ExcId id; + ExcDetail detail; + ExcData data; + ExcMessage message; +} ExcFrame; extern ExcFrame *ExcCurFrameP; @@ -71,13 +71,13 @@ extern ExcFrame *ExcCurFrameP; #define reraise() \ raise4(*exception.id,exception.detail,exception.data,exception.message) -typedef void ExcProc(Exception *, ExcDetail, ExcData, ExcMessage); +typedef void ExcProc(Exception *, ExcDetail, ExcData, ExcMessage); /* * prototypes for functions in exc.c */ -extern void EnableExceptionHandling(bool on); +extern void EnableExceptionHandling(bool on); extern void ExcRaise(Exception * excP, ExcDetail detail, diff --git a/src/include/utils/fcache.h b/src/include/utils/fcache.h index 27c3269b0e4..af8111676e4 100644 --- a/src/include/utils/fcache.h +++ b/src/include/utils/fcache.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fcache.h,v 1.3 1997/09/07 05:02:30 momjian Exp $ + * $Id: fcache.h,v 1.4 1997/09/08 02:39:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,39 +16,39 @@ typedef struct { - int typlen; /* length of the return type */ - int typbyval; /* true if return type is pass by value */ - func_ptr func; /* address of function to call (for c + int typlen; /* length of the return type */ + int typbyval; /* true if return type is pass by value */ + func_ptr func; /* address of function to call (for c * funcs) */ - Oid foid; /* oid of the function in pg_proc */ - Oid language; /* oid of the language in pg_language */ - int nargs; /* number of arguments */ + Oid foid; /* oid of the function in pg_proc */ + Oid language; /* oid of the language in pg_language */ + int nargs; /* number of arguments */ /* Might want to make these two arrays of size MAXFUNCARGS */ - Oid *argOidVect; /* oids of all the arguments */ - bool *nullVect; /* keep track of null arguments */ + Oid *argOidVect; /* oids of all the arguments */ + bool *nullVect; /* keep track of null arguments */ - char *src; /* source code of the function */ - char *bin; /* binary object code ?? */ - char *func_state; /* fuction_state struct for execution */ + char *src; /* source code of the function */ + char *bin; /* binary object code ?? */ + char *func_state; /* fuction_state struct for execution */ - bool oneResult; /* true we only want 1 result from the + bool oneResult; /* true we only want 1 result from the * function */ - bool hasSetArg; /* true if func is part of a nested dot + bool hasSetArg; /* true if func is part of a nested dot * expr whose argument is func returning a * set ugh! */ - Pointer funcSlot; /* if one result we need to copy it before + Pointer funcSlot; /* if one result we need to copy it before * we end execution of the function and * free stuff */ - char *setArg; /* current argument for nested dot + char *setArg; /* current argument for nested dot * execution Nested dot expressions mean * we have funcs whose argument is a set * of tuples */ - bool istrusted; /* trusted fn? */ -} FunctionCache, *FunctionCachePtr; + bool istrusted; /* trusted fn? */ +} FunctionCache, *FunctionCachePtr; #endif /* FCACHE_H */ diff --git a/src/include/utils/fcache2.h b/src/include/utils/fcache2.h index 781ff241393..bf9c7fb0c64 100644 --- a/src/include/utils/fcache2.h +++ b/src/include/utils/fcache2.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fcache2.h,v 1.3 1997/09/07 05:02:31 momjian Exp $ + * $Id: fcache2.h,v 1.4 1997/09/08 02:39:43 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,6 +16,6 @@ #include <nodes/execnodes.h> extern void - setFcache(Node * node, Oid foid, List * argList, ExprContext * econtext); + setFcache(Node * node, Oid foid, List * argList, ExprContext * econtext); #endif /* FCACHE2_H */ diff --git a/src/include/utils/fmgrtab.h b/src/include/utils/fmgrtab.h index e23f7c79266..a94e7f4811c 100644 --- a/src/include/utils/fmgrtab.h +++ b/src/include/utils/fmgrtab.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fmgrtab.h,v 1.5 1997/09/07 05:02:32 momjian Exp $ + * $Id: fmgrtab.h,v 1.6 1997/09/08 02:39:44 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,14 +16,14 @@ typedef struct { - Oid proid; - uint16 nargs; - func_ptr func; - char *funcName; -} FmgrCall; + Oid proid; + uint16 nargs; + func_ptr func; + char *funcName; +} FmgrCall; extern FmgrCall *fmgr_isbuiltin(Oid id); extern func_ptr fmgr_lookupByName(char *name); -extern void load_file(char *filename); +extern void load_file(char *filename); #endif /* FMGRTAB_H */ diff --git a/src/include/utils/geo_decls.h b/src/include/utils/geo_decls.h index 4cbbeca3b82..55b57742183 100644 --- a/src/include/utils/geo_decls.h +++ b/src/include/utils/geo_decls.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: geo_decls.h,v 1.9 1997/09/07 05:02:34 momjian Exp $ + * $Id: geo_decls.h,v 1.10 1997/09/08 02:39:46 momjian Exp $ * * NOTE * These routines do *not* use the float types from adt/. @@ -65,9 +65,9 @@ *-------------------------------------------------------------------*/ typedef struct { - double x, - y; -} Point; + double x, + y; +} Point; /*--------------------------------------------------------------------- @@ -75,10 +75,10 @@ typedef struct *-------------------------------------------------------------------*/ typedef struct { - Point p[2]; + Point p[2]; - double m; /* precomputed to save time, not in tuple */ -} LSEG; + double m; /* precomputed to save time, not in tuple */ +} LSEG; /*--------------------------------------------------------------------- @@ -86,12 +86,12 @@ typedef struct *-------------------------------------------------------------------*/ typedef struct { - int32 size; /* XXX varlena */ - int32 npts; - int32 closed; /* is this a closed polygon? */ - int32 dummy; /* padding to make it double align */ - Point p[1]; /* variable length array of POINTs */ -} PATH; + int32 size; /* XXX varlena */ + int32 npts; + int32 closed; /* is this a closed polygon? */ + int32 dummy; /* padding to make it double align */ + Point p[1]; /* variable length array of POINTs */ +} PATH; /*--------------------------------------------------------------------- @@ -104,12 +104,12 @@ typedef struct *-------------------------------------------------------------------*/ typedef struct { - double A, - B, - C; + double A, + B, + C; - double m; -} LINE; + double m; +} LINE; /*--------------------------------------------------------------------- @@ -118,9 +118,9 @@ typedef struct *-------------------------------------------------------------------*/ typedef struct { - Point high, - low; /* corner POINTs */ -} BOX; + Point high, + low; /* corner POINTs */ +} BOX; /*--------------------------------------------------------------------- * POLYGON - Specified by an array of doubles defining the points, @@ -129,178 +129,178 @@ typedef struct *-------------------------------------------------------------------*/ typedef struct { - int32 size; /* XXX varlena */ - int32 npts; - BOX boundbox; - Point p[1]; /* variable length array of POINTs */ -} POLYGON; + int32 size; /* XXX varlena */ + int32 npts; + BOX boundbox; + Point p[1]; /* variable length array of POINTs */ +} POLYGON; /*--------------------------------------------------------------------- * CIRCLE - Specified by a center point and radius. *-------------------------------------------------------------------*/ typedef struct { - Point center; - double radius; -} CIRCLE; + Point center; + double radius; +} CIRCLE; /* * in geo_ops.h */ /* public point routines */ -extern Point *point_in(char *str); -extern char *point_out(Point * pt); -extern bool point_left(Point * pt1, Point * pt2); -extern bool point_right(Point * pt1, Point * pt2); -extern bool point_above(Point * pt1, Point * pt2); -extern bool point_below(Point * pt1, Point * pt2); -extern bool point_vert(Point * pt1, Point * pt2); -extern bool point_horiz(Point * pt1, Point * pt2); -extern bool point_eq(Point * pt1, Point * pt2); -extern int32 pointdist(Point * p1, Point * p2); -extern double *point_distance(Point * pt1, Point * pt2); -extern double *point_slope(Point * pt1, Point * pt2); +extern Point *point_in(char *str); +extern char *point_out(Point * pt); +extern bool point_left(Point * pt1, Point * pt2); +extern bool point_right(Point * pt1, Point * pt2); +extern bool point_above(Point * pt1, Point * pt2); +extern bool point_below(Point * pt1, Point * pt2); +extern bool point_vert(Point * pt1, Point * pt2); +extern bool point_horiz(Point * pt1, Point * pt2); +extern bool point_eq(Point * pt1, Point * pt2); +extern int32 pointdist(Point * p1, Point * p2); +extern double *point_distance(Point * pt1, Point * pt2); +extern double *point_slope(Point * pt1, Point * pt2); /* private routines */ -extern double point_dt(Point * pt1, Point * pt2); -extern double point_sl(Point * pt1, Point * pt2); +extern double point_dt(Point * pt1, Point * pt2); +extern double point_sl(Point * pt1, Point * pt2); -extern Point *point(float8 * x, float8 * y); -extern Point *point_add(Point * p1, Point * p2); -extern Point *point_sub(Point * p1, Point * p2); -extern Point *point_mul(Point * p1, Point * p2); -extern Point *point_div(Point * p1, Point * p2); +extern Point *point(float8 * x, float8 * y); +extern Point *point_add(Point * p1, Point * p2); +extern Point *point_sub(Point * p1, Point * p2); +extern Point *point_mul(Point * p1, Point * p2); +extern Point *point_div(Point * p1, Point * p2); /* public lseg routines */ -extern LSEG *lseg_in(char *str); -extern char *lseg_out(LSEG * ls); -extern bool lseg_intersect(LSEG * l1, LSEG * l2); -extern bool lseg_parallel(LSEG * l1, LSEG * l2); -extern bool lseg_perp(LSEG * l1, LSEG * l2); -extern bool lseg_vertical(LSEG * lseg); -extern bool lseg_horizontal(LSEG * lseg); -extern bool lseg_eq(LSEG * l1, LSEG * l2); -extern double *lseg_distance(LSEG * l1, LSEG * l2); -extern Point *lseg_center(LSEG * lseg); -extern Point *lseg_interpt(LSEG * l1, LSEG * l2); -extern double *dist_pl(Point * pt, LINE * line); -extern double *dist_ps(Point * pt, LSEG * lseg); -extern double *dist_ppath(Point * pt, PATH * path); -extern double *dist_pb(Point * pt, BOX * box); -extern double *dist_sl(LSEG * lseg, LINE * line); -extern double *dist_sb(LSEG * lseg, BOX * box); -extern double *dist_lb(LINE * line, BOX * box); -extern Point *close_pl(Point * pt, LINE * line); -extern Point *close_ps(Point * pt, LSEG * lseg); -extern Point *close_pb(Point * pt, BOX * box); -extern Point *close_sl(LSEG * lseg, LINE * line); -extern Point *close_sb(LSEG * lseg, BOX * box); -extern Point *close_lb(LINE * line, BOX * box); -extern bool on_pl(Point * pt, LINE * line); -extern bool on_ps(Point * pt, LSEG * lseg); -extern bool on_pb(Point * pt, BOX * box); -extern bool on_ppath(Point * pt, PATH * path); -extern bool on_sl(LSEG * lseg, LINE * line); -extern bool on_sb(LSEG * lseg, BOX * box); -extern bool inter_sl(LSEG * lseg, LINE * line); -extern bool inter_sb(LSEG * lseg, BOX * box); -extern bool inter_lb(LINE * line, BOX * box); +extern LSEG *lseg_in(char *str); +extern char *lseg_out(LSEG * ls); +extern bool lseg_intersect(LSEG * l1, LSEG * l2); +extern bool lseg_parallel(LSEG * l1, LSEG * l2); +extern bool lseg_perp(LSEG * l1, LSEG * l2); +extern bool lseg_vertical(LSEG * lseg); +extern bool lseg_horizontal(LSEG * lseg); +extern bool lseg_eq(LSEG * l1, LSEG * l2); +extern double *lseg_distance(LSEG * l1, LSEG * l2); +extern Point *lseg_center(LSEG * lseg); +extern Point *lseg_interpt(LSEG * l1, LSEG * l2); +extern double *dist_pl(Point * pt, LINE * line); +extern double *dist_ps(Point * pt, LSEG * lseg); +extern double *dist_ppath(Point * pt, PATH * path); +extern double *dist_pb(Point * pt, BOX * box); +extern double *dist_sl(LSEG * lseg, LINE * line); +extern double *dist_sb(LSEG * lseg, BOX * box); +extern double *dist_lb(LINE * line, BOX * box); +extern Point *close_pl(Point * pt, LINE * line); +extern Point *close_ps(Point * pt, LSEG * lseg); +extern Point *close_pb(Point * pt, BOX * box); +extern Point *close_sl(LSEG * lseg, LINE * line); +extern Point *close_sb(LSEG * lseg, BOX * box); +extern Point *close_lb(LINE * line, BOX * box); +extern bool on_pl(Point * pt, LINE * line); +extern bool on_ps(Point * pt, LSEG * lseg); +extern bool on_pb(Point * pt, BOX * box); +extern bool on_ppath(Point * pt, PATH * path); +extern bool on_sl(LSEG * lseg, LINE * line); +extern bool on_sb(LSEG * lseg, BOX * box); +extern bool inter_sl(LSEG * lseg, LINE * line); +extern bool inter_sb(LSEG * lseg, BOX * box); +extern bool inter_lb(LINE * line, BOX * box); /* private routines */ -extern LSEG *lseg_construct(Point * pt1, Point * pt2); +extern LSEG *lseg_construct(Point * pt1, Point * pt2); /* public box routines */ -extern BOX *box_in(char *str); -extern char *box_out(BOX * box); -extern bool box_same(BOX * box1, BOX * box2); -extern bool box_overlap(BOX * box1, BOX * box2); -extern bool box_overleft(BOX * box1, BOX * box2); -extern bool box_left(BOX * box1, BOX * box2); -extern bool box_right(BOX * box1, BOX * box2); -extern bool box_overright(BOX * box1, BOX * box2); -extern bool box_contained(BOX * box1, BOX * box2); -extern bool box_contain(BOX * box1, BOX * box2); -extern bool box_below(BOX * box1, BOX * box2); -extern bool box_above(BOX * box1, BOX * box2); -extern bool box_lt(BOX * box1, BOX * box2); -extern bool box_gt(BOX * box1, BOX * box2); -extern bool box_eq(BOX * box1, BOX * box2); -extern bool box_le(BOX * box1, BOX * box2); -extern bool box_ge(BOX * box1, BOX * box2); -extern Point *box_center(BOX * box); -extern double *box_area(BOX * box); -extern double *box_width(BOX * box); -extern double *box_height(BOX * box); -extern double *box_distance(BOX * box1, BOX * box2); -extern Point *box_center(BOX * box); -extern BOX *box_intersect(BOX * box1, BOX * box2); -extern LSEG *box_diagonal(BOX * box); +extern BOX *box_in(char *str); +extern char *box_out(BOX * box); +extern bool box_same(BOX * box1, BOX * box2); +extern bool box_overlap(BOX * box1, BOX * box2); +extern bool box_overleft(BOX * box1, BOX * box2); +extern bool box_left(BOX * box1, BOX * box2); +extern bool box_right(BOX * box1, BOX * box2); +extern bool box_overright(BOX * box1, BOX * box2); +extern bool box_contained(BOX * box1, BOX * box2); +extern bool box_contain(BOX * box1, BOX * box2); +extern bool box_below(BOX * box1, BOX * box2); +extern bool box_above(BOX * box1, BOX * box2); +extern bool box_lt(BOX * box1, BOX * box2); +extern bool box_gt(BOX * box1, BOX * box2); +extern bool box_eq(BOX * box1, BOX * box2); +extern bool box_le(BOX * box1, BOX * box2); +extern bool box_ge(BOX * box1, BOX * box2); +extern Point *box_center(BOX * box); +extern double *box_area(BOX * box); +extern double *box_width(BOX * box); +extern double *box_height(BOX * box); +extern double *box_distance(BOX * box1, BOX * box2); +extern Point *box_center(BOX * box); +extern BOX *box_intersect(BOX * box1, BOX * box2); +extern LSEG *box_diagonal(BOX * box); /* private routines */ -extern double box_dt(BOX * box1, BOX * box2); +extern double box_dt(BOX * box1, BOX * box2); -extern BOX *box(Point * p1, Point * p2); -extern BOX *box_add(BOX * box, Point * p); -extern BOX *box_sub(BOX * box, Point * p); -extern BOX *box_mul(BOX * box, Point * p); -extern BOX *box_div(BOX * box, Point * p); +extern BOX *box(Point * p1, Point * p2); +extern BOX *box_add(BOX * box, Point * p); +extern BOX *box_sub(BOX * box, Point * p); +extern BOX *box_mul(BOX * box, Point * p); +extern BOX *box_div(BOX * box, Point * p); /* private line routines */ -extern double *line_distance(LINE * l1, LINE * l2); +extern double *line_distance(LINE * l1, LINE * l2); /* public path routines */ -extern PATH *path_in(char *str); -extern char *path_out(PATH * path); -extern bool path_n_lt(PATH * p1, PATH * p2); -extern bool path_n_gt(PATH * p1, PATH * p2); -extern bool path_n_eq(PATH * p1, PATH * p2); -extern bool path_n_le(PATH * p1, PATH * p2); -extern bool path_n_ge(PATH * p1, PATH * p2); -extern bool path_inter(PATH * p1, PATH * p2); -extern double *path_distance(PATH * p1, PATH * p2); -extern double *path_length(PATH * path); - -extern bool path_isclosed(PATH * path); -extern bool path_isopen(PATH * path); -extern int4 path_npoints(PATH * path); - -extern PATH *path_close(PATH * path); -extern PATH *path_open(PATH * path); -extern PATH *path_add(PATH * p1, PATH * p2); -extern PATH *path_add_pt(PATH * path, Point * point); -extern PATH *path_sub_pt(PATH * path, Point * point); -extern PATH *path_mul_pt(PATH * path, Point * point); -extern PATH *path_div_pt(PATH * path, Point * point); -extern bool path_contain_pt(PATH * path, Point * p); -extern bool pt_contained_path(Point * p, PATH * path); - -extern Point *path_center(PATH * path); +extern PATH *path_in(char *str); +extern char *path_out(PATH * path); +extern bool path_n_lt(PATH * p1, PATH * p2); +extern bool path_n_gt(PATH * p1, PATH * p2); +extern bool path_n_eq(PATH * p1, PATH * p2); +extern bool path_n_le(PATH * p1, PATH * p2); +extern bool path_n_ge(PATH * p1, PATH * p2); +extern bool path_inter(PATH * p1, PATH * p2); +extern double *path_distance(PATH * p1, PATH * p2); +extern double *path_length(PATH * path); + +extern bool path_isclosed(PATH * path); +extern bool path_isopen(PATH * path); +extern int4 path_npoints(PATH * path); + +extern PATH *path_close(PATH * path); +extern PATH *path_open(PATH * path); +extern PATH *path_add(PATH * p1, PATH * p2); +extern PATH *path_add_pt(PATH * path, Point * point); +extern PATH *path_sub_pt(PATH * path, Point * point); +extern PATH *path_mul_pt(PATH * path, Point * point); +extern PATH *path_div_pt(PATH * path, Point * point); +extern bool path_contain_pt(PATH * path, Point * p); +extern bool pt_contained_path(Point * p, PATH * path); + +extern Point *path_center(PATH * path); extern POLYGON *path_poly(PATH * path); -extern PATH *upgradepath(PATH * path); -extern bool isoldpath(PATH * path); +extern PATH *upgradepath(PATH * path); +extern bool isoldpath(PATH * path); /* public polygon routines */ extern POLYGON *poly_in(char *s); -extern char *poly_out(POLYGON * poly); -extern bool poly_left(POLYGON * polya, POLYGON * polyb); -extern bool poly_overleft(POLYGON * polya, POLYGON * polyb); -extern bool poly_right(POLYGON * polya, POLYGON * polyb); -extern bool poly_overright(POLYGON * polya, POLYGON * polyb); -extern bool poly_same(POLYGON * polya, POLYGON * polyb); -extern bool poly_overlap(POLYGON * polya, POLYGON * polyb); -extern bool poly_contain(POLYGON * polya, POLYGON * polyb); -extern bool poly_contained(POLYGON * polya, POLYGON * polyb); -extern bool poly_contain_pt(POLYGON * poly, Point * p); -extern bool pt_contained_poly(Point * p, POLYGON * poly); - -extern double *poly_distance(POLYGON * polya, POLYGON * polyb); -extern int4 poly_npoints(POLYGON * poly); -extern Point *poly_center(POLYGON * poly); -extern BOX *poly_box(POLYGON * poly); -extern PATH *poly_path(POLYGON * poly); +extern char *poly_out(POLYGON * poly); +extern bool poly_left(POLYGON * polya, POLYGON * polyb); +extern bool poly_overleft(POLYGON * polya, POLYGON * polyb); +extern bool poly_right(POLYGON * polya, POLYGON * polyb); +extern bool poly_overright(POLYGON * polya, POLYGON * polyb); +extern bool poly_same(POLYGON * polya, POLYGON * polyb); +extern bool poly_overlap(POLYGON * polya, POLYGON * polyb); +extern bool poly_contain(POLYGON * polya, POLYGON * polyb); +extern bool poly_contained(POLYGON * polya, POLYGON * polyb); +extern bool poly_contain_pt(POLYGON * poly, Point * p); +extern bool pt_contained_poly(Point * p, POLYGON * poly); + +extern double *poly_distance(POLYGON * polya, POLYGON * polyb); +extern int4 poly_npoints(POLYGON * poly); +extern Point *poly_center(POLYGON * poly); +extern BOX *poly_box(POLYGON * poly); +extern PATH *poly_path(POLYGON * poly); extern POLYGON *box_poly(BOX * box); extern POLYGON *upgradepoly(POLYGON * poly); @@ -309,52 +309,52 @@ extern POLYGON *revertpoly(POLYGON * poly); /* private polygon routines */ /* public circle routines */ -extern CIRCLE *circle_in(char *str); -extern char *circle_out(CIRCLE * circle); -extern bool circle_same(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_overlap(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_overleft(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_left(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_right(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_overright(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_contained(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_contain(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_below(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_above(CIRCLE * circle1, CIRCLE * circle2); - -extern bool circle_eq(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_ne(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_lt(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_gt(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_le(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_ge(CIRCLE * circle1, CIRCLE * circle2); -extern bool circle_contain_pt(CIRCLE * circle, Point * point); -extern bool pt_contained_circle(Point * point, CIRCLE * circle); -extern CIRCLE *circle_add_pt(CIRCLE * circle, Point * point); -extern CIRCLE *circle_sub_pt(CIRCLE * circle, Point * point); -extern CIRCLE *circle_mul_pt(CIRCLE * circle, Point * point); -extern CIRCLE *circle_div_pt(CIRCLE * circle, Point * point); -extern double *circle_diameter(CIRCLE * circle); -extern double *circle_radius(CIRCLE * circle); -extern double *circle_distance(CIRCLE * circle1, CIRCLE * circle2); -extern double *dist_pc(Point * point, CIRCLE * circle); -extern double *dist_cpoly(CIRCLE * circle, POLYGON * poly); -extern Point *circle_center(CIRCLE * circle); -extern CIRCLE *circle(Point * center, float8 * radius); -extern CIRCLE *box_circle(BOX * box); -extern BOX *circle_box(CIRCLE * circle); -extern CIRCLE *poly_circle(POLYGON * poly); +extern CIRCLE *circle_in(char *str); +extern char *circle_out(CIRCLE * circle); +extern bool circle_same(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_overlap(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_overleft(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_left(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_right(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_overright(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_contained(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_contain(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_below(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_above(CIRCLE * circle1, CIRCLE * circle2); + +extern bool circle_eq(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_ne(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_lt(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_gt(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_le(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_ge(CIRCLE * circle1, CIRCLE * circle2); +extern bool circle_contain_pt(CIRCLE * circle, Point * point); +extern bool pt_contained_circle(Point * point, CIRCLE * circle); +extern CIRCLE *circle_add_pt(CIRCLE * circle, Point * point); +extern CIRCLE *circle_sub_pt(CIRCLE * circle, Point * point); +extern CIRCLE *circle_mul_pt(CIRCLE * circle, Point * point); +extern CIRCLE *circle_div_pt(CIRCLE * circle, Point * point); +extern double *circle_diameter(CIRCLE * circle); +extern double *circle_radius(CIRCLE * circle); +extern double *circle_distance(CIRCLE * circle1, CIRCLE * circle2); +extern double *dist_pc(Point * point, CIRCLE * circle); +extern double *dist_cpoly(CIRCLE * circle, POLYGON * poly); +extern Point *circle_center(CIRCLE * circle); +extern CIRCLE *circle(Point * center, float8 * radius); +extern CIRCLE *box_circle(BOX * box); +extern BOX *circle_box(CIRCLE * circle); +extern CIRCLE *poly_circle(POLYGON * poly); extern POLYGON *circle_poly(int npts, CIRCLE * circle); /* private routines */ -extern double *circle_area(CIRCLE * circle); -extern double circle_dt(CIRCLE * circle1, CIRCLE * circle2); +extern double *circle_area(CIRCLE * circle); +extern double circle_dt(CIRCLE * circle1, CIRCLE * circle2); /* geo_selfuncs.c */ -extern float64 +extern float64 areasel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); -extern float64 +extern float64 areajoinsel(Oid opid, Oid relid, AttrNumber attno, char *value, int32 flag); diff --git a/src/include/utils/hsearch.h b/src/include/utils/hsearch.h index 577e6edfcdc..7cc6894c92a 100644 --- a/src/include/utils/hsearch.h +++ b/src/include/utils/hsearch.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: hsearch.h,v 1.4 1997/09/07 05:02:35 momjian Exp $ + * $Id: hsearch.h,v 1.5 1997/09/08 02:39:47 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ */ typedef struct element { - unsigned long next; /* secret from user */ - long key; -} ELEMENT; + unsigned long next; /* secret from user */ + long key; +} ELEMENT; typedef unsigned long BUCKET_INDEX; @@ -46,58 +46,58 @@ typedef unsigned long SEG_OFFSET; typedef struct hashhdr { - long bsize; /* Bucket/Page Size */ - long bshift; /* Bucket shift */ - long dsize; /* Directory Size */ - long ssize; /* Segment Size */ - long sshift; /* Segment shift */ - long max_bucket; /* ID of Maximum bucket in use */ - long high_mask; /* Mask to modulo into entire table */ - long low_mask; /* Mask to modulo into lower half of table */ - long ffactor; /* Fill factor */ - long nkeys; /* Number of keys in hash table */ - long nsegs; /* Number of allocated segments */ - long keysize; /* hash key length in bytes */ - long datasize; /* elem data length in bytes */ - long max_dsize; /* 'dsize' limit if directory is fixed + long bsize; /* Bucket/Page Size */ + long bshift; /* Bucket shift */ + long dsize; /* Directory Size */ + long ssize; /* Segment Size */ + long sshift; /* Segment shift */ + long max_bucket; /* ID of Maximum bucket in use */ + long high_mask; /* Mask to modulo into entire table */ + long low_mask; /* Mask to modulo into lower half of table */ + long ffactor; /* Fill factor */ + long nkeys; /* Number of keys in hash table */ + long nsegs; /* Number of allocated segments */ + long keysize; /* hash key length in bytes */ + long datasize; /* elem data length in bytes */ + long max_dsize; /* 'dsize' limit if directory is fixed * size */ - BUCKET_INDEX freeBucketIndex; + BUCKET_INDEX freeBucketIndex; /* index of first free bucket */ #ifdef HASH_STATISTICS - long accesses; - long collisions; + long accesses; + long collisions; #endif -} HHDR; +} HHDR; typedef struct htab { - HHDR *hctl; /* shared control information */ - long (*hash) (); /* Hash Function */ - char *segbase; /* segment base address for calculating + HHDR *hctl; /* shared control information */ + long (*hash) (); /* Hash Function */ + char *segbase; /* segment base address for calculating * pointer values */ - SEG_OFFSET *dir; /* 'directory' of segm starts */ - long *(*alloc) ();/* memory allocator (long * for alignment + SEG_OFFSET *dir; /* 'directory' of segm starts */ + long *(*alloc) (); /* memory allocator (long * for alignment * reasons) */ -} HTAB; +} HTAB; typedef struct hashctl { - long bsize; /* Bucket Size */ - long ssize; /* Segment Size */ - long dsize; /* Dirsize Size */ - long ffactor; /* Fill factor */ - long (*hash) (); /* Hash Function */ - long keysize; /* hash key length in bytes */ - long datasize; /* elem data length in bytes */ - long max_size; /* limit to dsize if directory size is + long bsize; /* Bucket Size */ + long ssize; /* Segment Size */ + long dsize; /* Dirsize Size */ + long ffactor; /* Fill factor */ + long (*hash) (); /* Hash Function */ + long keysize; /* hash key length in bytes */ + long datasize; /* elem data length in bytes */ + long max_size; /* limit to dsize if directory size is * limited */ - long *segbase; /* base for calculating bucket + seg ptrs */ - long *(*alloc) ();/* memory allocation function */ - long *dir; /* directory if allocated already */ - long *hctl; /* location of header information in shd + long *segbase; /* base for calculating bucket + seg ptrs */ + long *(*alloc) (); /* memory allocation function */ + long *dir; /* directory if allocated already */ + long *hctl; /* location of header information in shd * mem */ -} HASHCTL; +} HASHCTL; /* Flags to indicate action for hctl */ #define HASH_BUCKET 0x001 /* Setting bucket size */ @@ -125,23 +125,23 @@ typedef enum HASH_REMOVE, HASH_FIND_SAVE, HASH_REMOVE_SAVED -} HASHACTION; +} HASHACTION; /* * prototypes from functions in dynahash.c */ -extern HTAB *hash_create(int nelem, HASHCTL * info, int flags); -extern void hash_destroy(HTAB * hashp); -extern void hash_stats(char *where, HTAB * hashp); -extern long * +extern HTAB *hash_create(int nelem, HASHCTL * info, int flags); +extern void hash_destroy(HTAB * hashp); +extern void hash_stats(char *where, HTAB * hashp); +extern long * hash_search(HTAB * hashp, char *keyPtr, HASHACTION action, bool * foundPtr); -extern long *hash_seq(HTAB * hashp); +extern long *hash_seq(HTAB * hashp); /* * prototypes from functions in hashfn.c */ -extern long string_hash(char *key, int keysize); -extern long tag_hash(int *key, int keysize); +extern long string_hash(char *key, int keysize); +extern long tag_hash(int *key, int keysize); #endif /* HSEARCH_H */ diff --git a/src/include/utils/inval.h b/src/include/utils/inval.h index 21ea8eefb6b..ada1cf32d12 100644 --- a/src/include/utils/inval.h +++ b/src/include/utils/inval.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: inval.h,v 1.5 1997/09/07 05:02:36 momjian Exp $ + * $Id: inval.h,v 1.6 1997/09/08 02:39:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,13 +16,13 @@ #include <access/htup.h> #include <utils/rel.h> -extern void DiscardInvalid(void); +extern void DiscardInvalid(void); -extern void RegisterInvalid(bool send); +extern void RegisterInvalid(bool send); -extern void SetRefreshWhenInvalidate(bool on); +extern void SetRefreshWhenInvalidate(bool on); -extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple); +extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple); /* * POSTGRES local cache invalidation definitions. (originates from linval.h) @@ -30,13 +30,13 @@ extern void RelationInvalidateHeapTuple(Relation relation, HeapTuple tuple); typedef struct InvalidationUserData { struct InvalidationUserData *dataP[1]; /* VARIABLE LENGTH */ -} InvalidationUserData; /* VARIABLE LENGTH STRUCTURE */ +} InvalidationUserData; /* VARIABLE LENGTH STRUCTURE */ typedef struct InvalidationEntryData { InvalidationUserData *nextP; InvalidationUserData userData; /* VARIABLE LENGTH ARRAY */ -} InvalidationEntryData; /* VARIABLE LENGTH STRUCTURE */ +} InvalidationEntryData; /* VARIABLE LENGTH STRUCTURE */ typedef Pointer InvalidationEntry; diff --git a/src/include/utils/lselect.h b/src/include/utils/lselect.h index d5498df779a..f31fa5583d2 100644 --- a/src/include/utils/lselect.h +++ b/src/include/utils/lselect.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: lselect.h,v 1.5 1997/09/07 05:02:38 momjian Exp $ + * $Id: lselect.h,v 1.6 1997/09/08 02:39:48 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,9 +18,9 @@ struct leftist { - short lt_dist; /* distance to leaf/empty node */ - short lt_devnum; /* device number of tuple */ - HeapTuple lt_tuple; + short lt_dist; /* distance to leaf/empty node */ + short lt_devnum; /* device number of tuple */ + HeapTuple lt_tuple; struct leftist *lt_left; struct leftist *lt_right; }; @@ -28,27 +28,27 @@ struct leftist /* replaces global variables in lselect.c to make it reentrant */ typedef struct { - TupleDesc tupDesc; - int nKeys; - ScanKey scanKeys; - int sortMem; /* needed for psort */ -} LeftistContextData; + TupleDesc tupDesc; + int nKeys; + ScanKey scanKeys; + int sortMem; /* needed for psort */ +} LeftistContextData; typedef LeftistContextData *LeftistContext; extern struct leftist * lmerge(struct leftist * pt, struct leftist * qt, LeftistContext context); -extern HeapTuple +extern HeapTuple gettuple(struct leftist ** treep, short *devnum, LeftistContext context); extern void puttuple(struct leftist ** treep, HeapTuple newtuple, short devnum, LeftistContext context); -extern int tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context); +extern int tuplecmp(HeapTuple ltup, HeapTuple rtup, LeftistContext context); #ifdef EBUG -extern void checktree(struct leftist * tree, LeftistContext context); -extern int checktreer(struct leftist * tree, int level, LeftistContext context); +extern void checktree(struct leftist * tree, LeftistContext context); +extern int checktreer(struct leftist * tree, int level, LeftistContext context); #endif /* EBUG */ diff --git a/src/include/utils/lsyscache.h b/src/include/utils/lsyscache.h index 5abc26912cd..cad6ecfbfa4 100644 --- a/src/include/utils/lsyscache.h +++ b/src/include/utils/lsyscache.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: lsyscache.h,v 1.4 1997/09/07 05:02:39 momjian Exp $ + * $Id: lsyscache.h,v 1.5 1997/09/08 02:39:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,29 +16,29 @@ #include <access/attnum.h> #include <access/htup.h> -extern bool op_class(Oid opid, int32 opclass, Oid amopid); -extern char *get_attname(Oid relid, AttrNumber attnum); +extern bool op_class(Oid opid, int32 opclass, Oid amopid); +extern char *get_attname(Oid relid, AttrNumber attnum); extern AttrNumber get_attnum(Oid relid, char *attname); -extern Oid get_atttype(Oid relid, AttrNumber attnum); -extern bool get_attisset(Oid relid, char *attname); +extern Oid get_atttype(Oid relid, AttrNumber attnum); +extern bool get_attisset(Oid relid, char *attname); extern RegProcedure get_opcode(Oid opid); -extern char *get_opname(Oid opid); -extern bool +extern char *get_opname(Oid opid); +extern bool op_mergesortable(Oid opid, Oid ltype, Oid rtype, Oid * leftOp, Oid * rightOp); -extern Oid op_hashjoinable(Oid opid, Oid ltype, Oid rtype); -extern Oid get_commutator(Oid opid); +extern Oid op_hashjoinable(Oid opid, Oid ltype, Oid rtype); +extern Oid get_commutator(Oid opid); extern HeapTuple get_operator_tuple(Oid opno); -extern Oid get_negator(Oid opid); +extern Oid get_negator(Oid opid); extern RegProcedure get_oprrest(Oid opid); extern RegProcedure get_oprjoin(Oid opid); -extern int get_relnatts(Oid relid); -extern char *get_rel_name(Oid relid); +extern int get_relnatts(Oid relid); +extern char *get_rel_name(Oid relid); extern struct varlena *get_relstub(Oid relid, int no, bool * islast); -extern Oid get_ruleid(char *rulename); -extern Oid get_eventrelid(Oid ruleid); -extern int16 get_typlen(Oid typid); -extern bool get_typbyval(Oid typid); +extern Oid get_ruleid(char *rulename); +extern Oid get_eventrelid(Oid ruleid); +extern int16 get_typlen(Oid typid); +extern bool get_typbyval(Oid typid); extern struct varlena *get_typdefault(Oid typid); #endif /* LSYSCACHE_H */ diff --git a/src/include/utils/mcxt.h b/src/include/utils/mcxt.h index b7dfcc7cda6..4c37d33187c 100644 --- a/src/include/utils/mcxt.h +++ b/src/include/utils/mcxt.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: mcxt.h,v 1.6 1997/09/07 05:02:40 momjian Exp $ + * $Id: mcxt.h,v 1.7 1997/09/08 02:39:49 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,16 +37,16 @@ extern MemoryContext TopMemoryContext; /* * prototypes for functions in mcxt.c */ -extern void EnableMemoryContext(bool on); -extern Pointer MemoryContextAlloc(MemoryContext context, Size size); -extern Pointer +extern void EnableMemoryContext(bool on); +extern Pointer MemoryContextAlloc(MemoryContext context, Size size); +extern Pointer MemoryContextRealloc(MemoryContext context, Pointer pointer, Size size); -extern void MemoryContextFree(MemoryContext context, Pointer pointer); +extern void MemoryContextFree(MemoryContext context, Pointer pointer); extern MemoryContext MemoryContextSwitchTo(MemoryContext context); extern GlobalMemory CreateGlobalMemory(char *name); -extern void GlobalMemoryDestroy(GlobalMemory context); +extern void GlobalMemoryDestroy(GlobalMemory context); #endif /* MCXT_H */ diff --git a/src/include/utils/memutils.h b/src/include/utils/memutils.h index b87c331a1d7..8e9c184b9c6 100644 --- a/src/include/utils/memutils.h +++ b/src/include/utils/memutils.h @@ -15,7 +15,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: memutils.h,v 1.9 1997/09/07 05:02:42 momjian Exp $ + * $Id: memutils.h,v 1.10 1997/09/08 02:39:50 momjian Exp $ * * NOTES * some of the information in this file will be moved to @@ -107,27 +107,27 @@ typedef OrderedSetData *OrderedSet; struct OrderedElemData { - OrderedElem next; /* Next elem or &this->set->dummy */ - OrderedElem prev; /* Previous elem or &this->set->head */ - OrderedSet set; /* Parent set */ + OrderedElem next; /* Next elem or &this->set->dummy */ + OrderedElem prev; /* Previous elem or &this->set->head */ + OrderedSet set; /* Parent set */ }; struct OrderedSetData { - OrderedElem head; /* First elem or &this->dummy */ - OrderedElem dummy; /* (hack) Terminator == NULL */ - OrderedElem tail; /* Last elem or &this->head */ - Offset offset; /* Offset from struct base to elem */ + OrderedElem head; /* First elem or &this->dummy */ + OrderedElem dummy; /* (hack) Terminator == NULL */ + OrderedElem tail; /* Last elem or &this->head */ + Offset offset; /* Offset from struct base to elem */ /* this could be signed short int! */ }; -extern void OrderedSetInit(OrderedSet set, Offset offset); -extern bool OrderedSetContains(OrderedSet set, OrderedElem elem); -extern Pointer OrderedSetGetHead(OrderedSet set); -extern Pointer OrderedElemGetPredecessor(OrderedElem elem); -extern Pointer OrderedElemGetSuccessor(OrderedElem elem); -extern void OrderedElemPop(OrderedElem elem); -extern void OrderedElemPushInto(OrderedElem elem, OrderedSet Set); +extern void OrderedSetInit(OrderedSet set, Offset offset); +extern bool OrderedSetContains(OrderedSet set, OrderedElem elem); +extern Pointer OrderedSetGetHead(OrderedSet set); +extern Pointer OrderedElemGetPredecessor(OrderedElem elem); +extern Pointer OrderedElemGetSuccessor(OrderedElem elem); +extern void OrderedElemPop(OrderedElem elem); +extern void OrderedElemPushInto(OrderedElem elem, OrderedSet Set); /***************************************************************************** * aset.h -- Allocation set definitions. * @@ -193,7 +193,7 @@ typedef enum AllocMode StaticAllocMode, /* always "statically" allocate */ TunableAllocMode, /* allocations are "tuned" */ BoundedAllocMode /* allocations bounded to fixed usage */ -} AllocMode; +} AllocMode; #define DefaultAllocMode DynamicAllocMode @@ -203,9 +203,9 @@ typedef enum AllocMode */ typedef struct AllocSetData { - OrderedSetData setData; + OrderedSetData setData; /* Note: this will change in the future to support other modes */ -} AllocSetData; +} AllocSetData; typedef AllocSetData *AllocSet; @@ -221,18 +221,18 @@ typedef AllocSetData *AllocSet; */ #define AllocSetIsValid(set) PointerIsValid(set) -extern void AllocSetInit(AllocSet set, AllocMode mode, Size limit); +extern void AllocSetInit(AllocSet set, AllocMode mode, Size limit); -extern void AllocSetReset(AllocSet set); +extern void AllocSetReset(AllocSet set); -extern bool AllocSetContains(AllocSet set, AllocPointer pointer); +extern bool AllocSetContains(AllocSet set, AllocPointer pointer); extern AllocPointer AllocSetAlloc(AllocSet set, Size size); -extern void AllocSetFree(AllocSet set, AllocPointer pointer); -extern AllocPointer +extern void AllocSetFree(AllocSet set, AllocPointer pointer); +extern AllocPointer AllocSetRealloc(AllocSet set, AllocPointer pointer, Size size); -extern void AllocSetDump(AllocSet set); +extern void AllocSetDump(AllocSet set); /***************************************************************************** * clib.h -- Standard C library definitions * @@ -247,7 +247,7 @@ extern void AllocSetDump(AllocSet set); * LibCCopyLength is only used within this file. -cim 6/12/90 * */ -typedef int LibCCopyLength; +typedef int LibCCopyLength; /* * MemoryCopy -- @@ -262,7 +262,7 @@ typedef int LibCCopyLength; #define MaxBitsPerByte 8 -typedef uint32 AttributeSize; /* XXX should be defined elsewhere */ +typedef uint32 AttributeSize; /* XXX should be defined elsewhere */ #define MaxHeapTupleSize 0x7fffffff #define MaxAttributeSize 0x7fffffff diff --git a/src/include/utils/module.h b/src/include/utils/module.h index cadff1aa6c3..2b528fed8ff 100644 --- a/src/include/utils/module.h +++ b/src/include/utils/module.h @@ -10,7 +10,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: module.h,v 1.2 1997/09/07 05:02:44 momjian Exp $ + * $Id: module.h,v 1.3 1997/09/08 02:39:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,6 +20,6 @@ /* * prototypes for functions in init/enbl.c */ -extern bool BypassEnable(int *enableCountInOutP, bool on); +extern bool BypassEnable(int *enableCountInOutP, bool on); #endif /* MODULE_H */ diff --git a/src/include/utils/nabstime.h b/src/include/utils/nabstime.h index 5372501bcb0..f1a065caf4a 100644 --- a/src/include/utils/nabstime.h +++ b/src/include/utils/nabstime.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: nabstime.h,v 1.11 1997/09/07 05:02:46 momjian Exp $ + * $Id: nabstime.h,v 1.12 1997/09/08 02:39:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,14 +23,14 @@ * * ---------------------------------------------------------------- */ -typedef int32 AbsoluteTime; -typedef int32 RelativeTime; +typedef int32 AbsoluteTime; +typedef int32 RelativeTime; typedef struct { - int32 status; - AbsoluteTime data[2]; -} TimeIntervalData; + int32 status; + AbsoluteTime data[2]; +} TimeIntervalData; typedef TimeIntervalData *TimeInterval; /* @@ -102,22 +102,22 @@ extern AbsoluteTime GetCurrentAbsoluteTime(void); * nabstime.c prototypes */ extern AbsoluteTime nabstimein(char *timestr); -extern char *nabstimeout(AbsoluteTime time); +extern char *nabstimeout(AbsoluteTime time); -extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2); -extern bool abstime_finite(AbsoluteTime time); +extern bool abstimeeq(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimene(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimelt(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimegt(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimele(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstimege(AbsoluteTime t1, AbsoluteTime t2); +extern bool abstime_finite(AbsoluteTime time); extern AbsoluteTime datetime_abstime(DateTime * datetime); extern DateTime *abstime_datetime(AbsoluteTime abstime); -extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2); -extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2); +extern bool AbsoluteTimeIsBefore(AbsoluteTime time1, AbsoluteTime time2); +extern bool AbsoluteTimeIsAfter(AbsoluteTime time1, AbsoluteTime time2); -extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn); +extern void abstime2tm(AbsoluteTime time, int *tzp, struct tm * tm, char *tzn); #endif /* NABSTIME_H */ diff --git a/src/include/utils/oidcompos.h b/src/include/utils/oidcompos.h index f4980051f05..118078de85e 100644 --- a/src/include/utils/oidcompos.h +++ b/src/include/utils/oidcompos.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: oidcompos.h,v 1.2 1997/09/07 05:02:47 momjian Exp $ + * $Id: oidcompos.h,v 1.3 1997/09/08 02:39:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -14,39 +14,39 @@ #define OIDCOMPOS_H /* oidint4.c */ -OidInt4 oidint4in(char *o); -char *oidint4out(OidInt4 o); -bool oidint4lt(OidInt4 o1, OidInt4 o2); -bool oidint4le(OidInt4 o1, OidInt4 o2); -bool oidint4eq(OidInt4 o1, OidInt4 o2); -bool oidint4ge(OidInt4 o1, OidInt4 o2); -bool oidint4gt(OidInt4 o1, OidInt4 o2); -bool oidint4ne(OidInt4 o1, OidInt4 o2); -int oidint4cmp(OidInt4 o1, OidInt4 o2); -OidInt4 mkoidint4(Oid v_oid, uint32 v_int4); +OidInt4 oidint4in(char *o); +char *oidint4out(OidInt4 o); +bool oidint4lt(OidInt4 o1, OidInt4 o2); +bool oidint4le(OidInt4 o1, OidInt4 o2); +bool oidint4eq(OidInt4 o1, OidInt4 o2); +bool oidint4ge(OidInt4 o1, OidInt4 o2); +bool oidint4gt(OidInt4 o1, OidInt4 o2); +bool oidint4ne(OidInt4 o1, OidInt4 o2); +int oidint4cmp(OidInt4 o1, OidInt4 o2); +OidInt4 mkoidint4(Oid v_oid, uint32 v_int4); /* oidint2.c */ -OidInt2 oidint2in(char *o); -char *oidint2out(OidInt2 o); -bool oidint2lt(OidInt2 o1, OidInt2 o2); -bool oidint2le(OidInt2 o1, OidInt2 o2); -bool oidint2eq(OidInt2 o1, OidInt2 o2); -bool oidint2ge(OidInt2 o1, OidInt2 o2); -bool oidint2gt(OidInt2 o1, OidInt2 o2); -bool oidint2ne(OidInt2 o1, OidInt2 o2); -int oidint2cmp(OidInt2 o1, OidInt2 o2); -OidInt2 mkoidint2(Oid v_oid, uint16 v_int2); +OidInt2 oidint2in(char *o); +char *oidint2out(OidInt2 o); +bool oidint2lt(OidInt2 o1, OidInt2 o2); +bool oidint2le(OidInt2 o1, OidInt2 o2); +bool oidint2eq(OidInt2 o1, OidInt2 o2); +bool oidint2ge(OidInt2 o1, OidInt2 o2); +bool oidint2gt(OidInt2 o1, OidInt2 o2); +bool oidint2ne(OidInt2 o1, OidInt2 o2); +int oidint2cmp(OidInt2 o1, OidInt2 o2); +OidInt2 mkoidint2(Oid v_oid, uint16 v_int2); /* oidname.c */ -OidName oidnamein(char *inStr); -char *oidnameout(OidName oidname); -bool oidnamelt(OidName o1, OidName o2); -bool oidnamele(OidName o1, OidName o2); -bool oidnameeq(OidName o1, OidName o2); -bool oidnamene(OidName o1, OidName o2); -bool oidnamege(OidName o1, OidName o2); -bool oidnamegt(OidName o1, OidName o2); -int oidnamecmp(OidName o1, OidName o2); -OidName mkoidname(Oid id, char *name); +OidName oidnamein(char *inStr); +char *oidnameout(OidName oidname); +bool oidnamelt(OidName o1, OidName o2); +bool oidnamele(OidName o1, OidName o2); +bool oidnameeq(OidName o1, OidName o2); +bool oidnamene(OidName o1, OidName o2); +bool oidnamege(OidName o1, OidName o2); +bool oidnamegt(OidName o1, OidName o2); +int oidnamecmp(OidName o1, OidName o2); +OidName mkoidname(Oid id, char *name); #endif /* OIDCOMPOS_H */ diff --git a/src/include/utils/palloc.h b/src/include/utils/palloc.h index b4a35db9795..b6f32c4f01b 100644 --- a/src/include/utils/palloc.h +++ b/src/include/utils/palloc.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: palloc.h,v 1.4 1997/09/07 05:02:49 momjian Exp $ + * $Id: palloc.h,v 1.5 1997/09/08 02:39:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,11 +15,11 @@ #include <c.h> -extern void *palloc(Size size); -extern void pfree(void *pointer); -extern void *repalloc(void *pointer, Size size); +extern void *palloc(Size size); +extern void pfree(void *pointer); +extern void *repalloc(void *pointer, Size size); /* like strdup except uses palloc */ -extern char *pstrdup(char *pointer); +extern char *pstrdup(char *pointer); #endif /* PALLOC_H */ diff --git a/src/include/utils/portal.h b/src/include/utils/portal.h index 07edce974ef..84a5d539af4 100644 --- a/src/include/utils/portal.h +++ b/src/include/utils/portal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: portal.h,v 1.5 1997/09/07 05:02:51 momjian Exp $ + * $Id: portal.h,v 1.6 1997/09/08 02:39:53 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,9 +32,9 @@ typedef struct PortalBlockData { - AllocSetData setData; - FixedItemData itemData; -} PortalBlockData; + AllocSetData setData; + FixedItemData itemData; +} PortalBlockData; typedef PortalBlockData *PortalBlock; @@ -43,13 +43,13 @@ typedef PortalD *Portal; struct PortalD { - char *name; /* XXX PortalName */ + char *name; /* XXX PortalName */ struct PortalVariableMemory variable; struct PortalHeapMemory heap; - QueryDesc *queryDesc; - TupleDesc attinfo; - EState *state; - void (*cleanup) (Portal); + QueryDesc *queryDesc; + TupleDesc attinfo; + EState *state; + void (*cleanup) (Portal); }; /* @@ -63,21 +63,21 @@ struct PortalD */ #define VACPNAME "<vacuum>" -extern bool PortalNameIsSpecial(char *pname); -extern void AtEOXact_portals(void); -extern void EnablePortalManager(bool on); -extern Portal GetPortalByName(char *name); -extern Portal BlankPortalAssignName(char *name); +extern bool PortalNameIsSpecial(char *pname); +extern void AtEOXact_portals(void); +extern void EnablePortalManager(bool on); +extern Portal GetPortalByName(char *name); +extern Portal BlankPortalAssignName(char *name); extern void PortalSetQuery(Portal portal, QueryDesc * queryDesc, TupleDesc attinfo, EState * state, void (*cleanup) (Portal portal)); extern QueryDesc *PortalGetQueryDesc(Portal portal); -extern EState *PortalGetState(Portal portal); -extern Portal CreatePortal(char *name); -extern void PortalDestroy(Portal * portalP); -extern void StartPortalAllocMode(AllocMode mode, Size limit); -extern void EndPortalAllocMode(void); +extern EState *PortalGetState(Portal portal); +extern Portal CreatePortal(char *name); +extern void PortalDestroy(Portal * portalP); +extern void StartPortalAllocMode(AllocMode mode, Size limit); +extern void EndPortalAllocMode(void); extern PortalVariableMemory PortalGetVariableMemory(Portal portal); extern PortalHeapMemory PortalGetHeapMemory(Portal portal); diff --git a/src/include/utils/psort.h b/src/include/utils/psort.h index fe5e0b2f357..01fa4153c1e 100644 --- a/src/include/utils/psort.h +++ b/src/include/utils/psort.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: psort.h,v 1.8 1997/09/07 05:02:53 momjian Exp $ + * $Id: psort.h,v 1.9 1997/09/08 02:39:54 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -24,17 +24,17 @@ struct tape { - int tp_dummy; /* (D) */ - int tp_fib; /* (A) */ - FILE *tp_file; /* (TAPE) */ - struct tape *tp_prev; + int tp_dummy; /* (D) */ + int tp_fib; /* (A) */ + FILE *tp_file; /* (TAPE) */ + struct tape *tp_prev; }; struct cmplist { - int cp_attn; /* attribute number */ - int cp_num; /* comparison function code */ - int cp_rev; /* invert comparison flag */ + int cp_attn; /* attribute number */ + int cp_num; /* comparison function code */ + int cp_rev; /* invert comparison flag */ struct cmplist *cp_next; /* next in chain */ }; @@ -47,25 +47,24 @@ typedef struct Psortstate { LeftistContextData treeContext; - int TapeRange; - int Level; - int TotalDummy; - struct tape Tape[MAXTAPES]; + int TapeRange; + int Level; + int TotalDummy; + struct tape Tape[MAXTAPES]; - int BytesRead; - int BytesWritten; - int tupcount; + int BytesRead; + int BytesWritten; + int tupcount; struct leftist *Tuples; - FILE *psort_grab_file; - long psort_current; /* could be file offset, or array - * index */ - long psort_saved;/* could be file offset, or array index */ - bool using_tape_files; + FILE *psort_grab_file; + long psort_current; /* could be file offset, or array index */ + long psort_saved; /* could be file offset, or array index */ + bool using_tape_files; - HeapTuple *memtuples; -} Psortstate; + HeapTuple *memtuples; +} Psortstate; #ifdef EBUG #include <stdio.h> @@ -99,10 +98,10 @@ if (1) CODE; else #endif /* psort.c */ -extern bool psort_begin(Sort * node, int nkeys, ScanKey key); +extern bool psort_begin(Sort * node, int nkeys, ScanKey key); extern HeapTuple psort_grabtuple(Sort * node); -extern void psort_markpos(Sort * node); -extern void psort_restorepos(Sort * node); -extern void psort_end(Sort * node); +extern void psort_markpos(Sort * node); +extern void psort_restorepos(Sort * node); +extern void psort_end(Sort * node); #endif /* PSORT_H */ diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index 31dcb7401ab..9fe943c58d6 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: rel.h,v 1.10 1997/09/07 05:02:54 momjian Exp $ + * $Id: rel.h,v 1.11 1997/09/08 02:39:55 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,47 +22,47 @@ typedef struct Trigger { - char *tgname; - Oid tgfoid; - func_ptr tgfunc; - int16 tgtype; - int16 tgnargs; - int16 tgattr[8]; - char **tgargs; -} Trigger; + char *tgname; + Oid tgfoid; + func_ptr tgfunc; + int16 tgtype; + int16 tgnargs; + int16 tgattr[8]; + char **tgargs; +} Trigger; typedef struct TriggerDesc { - uint16 n_before_statement[4]; - uint16 n_before_row[4]; - uint16 n_after_row[4]; - uint16 n_after_statement[4]; - Trigger **tg_before_statement[4]; - Trigger **tg_before_row[4]; - Trigger **tg_after_row[4]; - Trigger **tg_after_statement[4]; - Trigger *triggers; -} TriggerDesc; + uint16 n_before_statement[4]; + uint16 n_before_row[4]; + uint16 n_after_row[4]; + uint16 n_after_statement[4]; + Trigger **tg_before_statement[4]; + Trigger **tg_before_row[4]; + Trigger **tg_after_row[4]; + Trigger **tg_after_statement[4]; + Trigger *triggers; +} TriggerDesc; typedef struct RelationData { - File rd_fd; /* open file descriptor */ - int rd_nblocks; /* number of blocks in rel */ - uint16 rd_refcnt; /* reference count */ - bool rd_islocal; /* uses the local buffer mgr */ - bool rd_isnailed;/* rel is nailed in cache */ - bool rd_istemp; /* rel is a temp rel */ - bool rd_tmpunlinked; /* temp rel already unlinked */ - Form_pg_am rd_am; /* AM tuple */ - Form_pg_class rd_rel; /* RELATION tuple */ - Oid rd_id; /* relations's object id */ - Pointer lockInfo; /* ptr. to misc. info. */ - TupleDesc rd_att; /* tuple desciptor */ - RuleLock *rd_rules; /* rewrite rules */ - IndexStrategy rd_istrat; - RegProcedure *rd_support; - TriggerDesc *trigdesc; -} RelationData; + File rd_fd; /* open file descriptor */ + int rd_nblocks; /* number of blocks in rel */ + uint16 rd_refcnt; /* reference count */ + bool rd_islocal; /* uses the local buffer mgr */ + bool rd_isnailed; /* rel is nailed in cache */ + bool rd_istemp; /* rel is a temp rel */ + bool rd_tmpunlinked; /* temp rel already unlinked */ + Form_pg_am rd_am; /* AM tuple */ + Form_pg_class rd_rel; /* RELATION tuple */ + Oid rd_id; /* relations's object id */ + Pointer lockInfo; /* ptr. to misc. info. */ + TupleDesc rd_att; /* tuple desciptor */ + RuleLock *rd_rules; /* rewrite rules */ + IndexStrategy rd_istrat; + RegProcedure *rd_support; + TriggerDesc *trigdesc; +} RelationData; typedef RelationData *Relation; @@ -76,7 +76,7 @@ typedef Relation *RelationPtr; #define InvalidRelation ((Relation)NULL) -typedef char ArchiveMode; +typedef char ArchiveMode; /* * RelationIsValid -- diff --git a/src/include/utils/relcache.h b/src/include/utils/relcache.h index 984d0cc63ae..00e6c8c3436 100644 --- a/src/include/utils/relcache.h +++ b/src/include/utils/relcache.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: relcache.h,v 1.7 1997/09/07 05:03:00 momjian Exp $ + * $Id: relcache.h,v 1.8 1997/09/08 02:39:56 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,17 +22,17 @@ extern Relation RelationIdCacheGetRelation(Oid relationId); extern Relation RelationIdGetRelation(Oid relationId); extern Relation RelationNameGetRelation(char *relationName); -extern void RelationClose(Relation relation); -extern void RelationForgetRelation(Oid rid); -extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId); +extern void RelationClose(Relation relation); +extern void RelationForgetRelation(Oid rid); +extern void RelationIdInvalidateRelationCacheByRelationId(Oid relationId); extern void - RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId); + RelationIdInvalidateRelationCacheByAccessMethodId(Oid accessMethodId); -extern void RelationCacheInvalidate(bool onlyFlushReferenceCountZero); +extern void RelationCacheInvalidate(bool onlyFlushReferenceCountZero); -extern void RelationRegisterRelation(Relation relation); -extern void RelationPurgeLocalRelation(bool xactComitted); -extern void RelationInitialize(void); +extern void RelationRegisterRelation(Relation relation); +extern void RelationPurgeLocalRelation(bool xactComitted); +extern void RelationInitialize(void); #endif /* RELCACHE_H */ diff --git a/src/include/utils/sets.h b/src/include/utils/sets.h index 717989bdfe3..f928b4012b5 100644 --- a/src/include/utils/sets.h +++ b/src/include/utils/sets.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: sets.h,v 1.2 1997/09/07 05:03:01 momjian Exp $ + * $Id: sets.h,v 1.3 1997/09/08 02:39:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ /* Temporary name of set, before SetDefine changes it. */ #define GENERICSETNAME "zyxset" -extern Oid SetDefine(char *querystr, char *typename); -extern int seteval(Oid funcoid); +extern Oid SetDefine(char *querystr, char *typename); +extern int seteval(Oid funcoid); #endif /* SETS_H */ diff --git a/src/include/utils/syscache.h b/src/include/utils/syscache.h index db830e3cd2f..627356e29a3 100644 --- a/src/include/utils/syscache.h +++ b/src/include/utils/syscache.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: syscache.h,v 1.5 1997/09/07 05:03:02 momjian Exp $ + * $Id: syscache.h,v 1.6 1997/09/08 02:39:58 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include <access/attnum.h> #include <access/htup.h> - /*#define CACHEDEBUG*//* turns DEBUG elogs on */ + /* #define CACHEDEBUG *//* turns DEBUG elogs on */ /* @@ -66,32 +66,32 @@ */ struct cachedesc { - char *name; /* this is Name * so that we can + char *name; /* this is Name * so that we can * initialize it */ - int nkeys; - int key[4]; - int size; /* sizeof(appropriate struct) */ - char *indname; /* index relation for this cache, if + int nkeys; + int key[4]; + int size; /* sizeof(appropriate struct) */ + char *indname; /* index relation for this cache, if * exists */ - HeapTuple(*iScanFunc) (); /* function to handle + HeapTuple(*iScanFunc) (); /* function to handle * index scans */ }; -extern void zerocaches(void); -extern void InitCatalogCache(void); -extern HeapTuple +extern void zerocaches(void); +extern void InitCatalogCache(void); +extern HeapTuple SearchSysCacheTuple(int cacheId, Datum key1, Datum key2, Datum key3, Datum key4); -extern int32 +extern int32 SearchSysCacheStruct(int cacheId, char *returnStruct, Datum key1, Datum key2, Datum key3, Datum key4); -extern void * +extern void * SearchSysCacheGetAttribute(int cacheId, AttrNumber attributeNumber, Datum key1, Datum key2, Datum key3, Datum key4); -extern void *TypeDefaultRetrieve(Oid typId); +extern void *TypeDefaultRetrieve(Oid typId); #endif /* SYSCACHE_H */ diff --git a/src/include/utils/tqual.h b/src/include/utils/tqual.h index a32ccb2ab13..579c6e9525e 100644 --- a/src/include/utils/tqual.h +++ b/src/include/utils/tqual.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: tqual.h,v 1.7 1997/09/07 05:03:03 momjian Exp $ + * $Id: tqual.h,v 1.8 1997/09/08 02:39:59 momjian Exp $ * * NOTE * It may be desirable to allow time qualifications to indicate @@ -21,8 +21,8 @@ typedef struct TimeQualSpace { - char data[12]; -} TimeQualSpace; + char data[12]; +} TimeQualSpace; typedef Pointer TimeQual; @@ -32,14 +32,14 @@ typedef Pointer TimeQual; /* As above, plus updates in this command */ extern TimeQual SelfTimeQual; -extern void setheapoverride(bool on); -extern bool heapisoverride(void); +extern void setheapoverride(bool on); +extern bool heapisoverride(void); extern TimeQual TimeFormSnapshotTimeQual(AbsoluteTime time); -extern TimeQual +extern TimeQual TimeFormRangedTimeQual(AbsoluteTime startTime, AbsoluteTime endTime); -extern bool HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual); +extern bool HeapTupleSatisfiesTimeQual(HeapTuple tuple, TimeQual qual); #endif /* TQUAL_H */ diff --git a/src/include/version.h b/src/include/version.h index 14920ffd378..3c4c4e14e6e 100644 --- a/src/include/version.h +++ b/src/include/version.h @@ -4,7 +4,7 @@ * this file contains the interface to version.c. * Also some parameters. * - * $Id: version.h,v 1.3 1997/09/07 04:55:43 momjian Exp $ + * $Id: version.h,v 1.4 1997/09/08 02:33:57 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -12,10 +12,10 @@ #define VERSION_H void - ValidatePgVersion(const char *path, char **reason_p); + ValidatePgVersion(const char *path, char **reason_p); void - SetPgVersion(const char *path, char **reason_p); + SetPgVersion(const char *path, char **reason_p); #define PG_RELEASE 6 #define PG_VERSION 1 diff --git a/src/interfaces/libpgtcl/libpgtcl.h b/src/interfaces/libpgtcl/libpgtcl.h index 4ee2848c991..7dfec8f5811 100644 --- a/src/interfaces/libpgtcl/libpgtcl.h +++ b/src/interfaces/libpgtcl/libpgtcl.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpgtcl.h,v 1.3 1997/09/07 05:03:06 momjian Exp $ + * $Id: libpgtcl.h,v 1.4 1997/09/08 02:40:03 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -16,7 +16,7 @@ #include "tcl.h" -extern int Pgtcl_Init(Tcl_Interp * interp); -extern int Pgtcl_SafeInit(Tcl_Interp * interp); +extern int Pgtcl_Init(Tcl_Interp * interp); +extern int Pgtcl_SafeInit(Tcl_Interp * interp); #endif /* LIBPGTCL_H */ diff --git a/src/interfaces/libpgtcl/pgtcl.c b/src/interfaces/libpgtcl/pgtcl.c index 75c8ec5ddad..e8502da5c24 100644 --- a/src/interfaces/libpgtcl/pgtcl.c +++ b/src/interfaces/libpgtcl/pgtcl.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.8 1997/09/07 05:03:09 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtcl.c,v 1.9 1997/09/08 02:40:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,11 +34,11 @@ static void Pgtcl_AtExit(ClientData cData) { - Pg_clientData *cd = (Pg_clientData *) cData; - Tcl_HashEntry *hent; - Tcl_HashSearch hsearch; + Pg_clientData *cd = (Pg_clientData *) cData; + Tcl_HashEntry *hent; + Tcl_HashSearch hsearch; Pg_ConnectionId *connid; - PGconn *conn; + PGconn *conn; while ((hent = Tcl_FirstHashEntry(&(cd->dbh_hash), &hsearch)) != NULL) { @@ -67,7 +67,7 @@ Pgtcl_Shutdown(ClientData cData, Tcl_Interp * interp) int Pgtcl_Init(Tcl_Interp * interp) { - Pg_clientData *cd; + Pg_clientData *cd; /* Create and initialize the client data area */ cd = (Pg_clientData *) ckalloc(sizeof(Pg_clientData)); diff --git a/src/interfaces/libpgtcl/pgtclCmds.c b/src/interfaces/libpgtcl/pgtclCmds.c index 834938487d4..c26b3ebdc35 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.c +++ b/src/interfaces/libpgtcl/pgtclCmds.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.14 1997/09/07 05:03:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclCmds.c,v 1.15 1997/09/08 02:40:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,9 +41,9 @@ static inline char * translate_escape(char *p, int isArray) { - register char c, - *q, - *s; + register char c, + *q, + *s; #ifdef TCL_ARRAYS_DEBUG_ESCAPE printf(" escape = '%s'\n", p); @@ -52,81 +52,82 @@ translate_escape(char *p, int isArray) s = p + 2; switch (c = *(p + 1)) { - case '0': - case '1': - case '2': - case '3': - case '4': - case '5': - case '6': - case '7': - c = DIGIT(c); - if (ISOCTAL(*s)) - { - c = (c << 3) + DIGIT(*s++); - } - if (ISOCTAL(*s)) - { - c = (c << 3) + DIGIT(*s++); - } - *p = c; - break; - case 'b': - *p = '\b'; - break; - case 'f': - *p = '\f'; - break; - case 'n': - *p = '\n'; - break; - case 'r': - *p = '\r'; - break; - case 't': - *p = '\t'; - break; - case 'v': - *p = '\v'; - break; - case '\\': - case '{': - case '}': - case '"': - - /* - * Backslahes, curly braces and double-quotes are left escaped if - * they appear inside an array. They will be unescaped by Tcl in - * Tcl_AppendElement. The buffer position is advanced by 1 so that - * the this character is not processed again by the caller. - */ - if (isArray) - { - return p + 1; - } - else - { + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + c = DIGIT(c); + if (ISOCTAL(*s)) + { + c = (c << 3) + DIGIT(*s++); + } + if (ISOCTAL(*s)) + { + c = (c << 3) + DIGIT(*s++); + } *p = c; - } - break; - case '\0': - - /* - * This means a backslash at the end of the string. It should - * never happen but in that case replace the \ with a \0 but don't - * shift the rest of the buffer so that the caller can see the end - * of the string and terminate. - */ - *p = c; - return p; - break; - default: + break; + case 'b': + *p = '\b'; + break; + case 'f': + *p = '\f'; + break; + case 'n': + *p = '\n'; + break; + case 'r': + *p = '\r'; + break; + case 't': + *p = '\t'; + break; + case 'v': + *p = '\v'; + break; + case '\\': + case '{': + case '}': + case '"': + + /* + * Backslahes, curly braces and double-quotes are left escaped + * if they appear inside an array. They will be unescaped by + * Tcl in Tcl_AppendElement. The buffer position is advanced + * by 1 so that the this character is not processed again by + * the caller. + */ + if (isArray) + { + return p + 1; + } + else + { + *p = c; + } + break; + case '\0': + + /* + * This means a backslash at the end of the string. It should + * never happen but in that case replace the \ with a \0 but + * don't shift the rest of the buffer so that the caller can + * see the end of the string and terminate. + */ + *p = c; + return p; + break; + default: - /* - * Default case, store the escaped character over the backslash - * and shift the buffer over itself. - */ - *p = c; + /* + * Default case, store the escaped character over the + * backslash and shift the buffer over itself. + */ + *p = c; } /* Shift the rest of the buffer over itself after the current char */ q = p + 1; @@ -149,12 +150,12 @@ translate_escape(char *p, int isArray) * representation of a postgres array. */ -static char * +static char * tcl_value(char *value) { - int literal, - last; - register char *p; + int literal, + last; + register char *p; if (!value) { @@ -179,12 +180,12 @@ tcl_value(char *value) /* We are at the list level, look for ',' and '"' */ switch (*p) { - case '"': /* beginning of literal */ - literal = 1; - break; - case ',': /* replace the ',' with space */ - *p = ' '; - break; + case '"': /* beginning of literal */ + literal = 1; + break; + case ',': /* replace the ',' with space */ + *p = ' '; + break; } } else @@ -192,16 +193,16 @@ tcl_value(char *value) /* We are inside a C string */ switch (*p) { - case '"': /* end of literal */ - literal = 0; - break; - case '\\': - - /* - * escape sequence, translate it - */ - p = translate_escape(p, 1); - break; + case '"': /* end of literal */ + literal = 0; + break; + case '\\': + + /* + * escape sequence, translate it + */ + p = translate_escape(p, 1); + break; } } if (!*p) @@ -255,7 +256,7 @@ int Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv) { PQconninfoOption *option; - char buf[8192]; + char buf[8192]; Tcl_ResetResult(interp); for (option = PQconndefaults(); option->keyword != NULL; option++) @@ -292,14 +293,14 @@ Pg_conndefaults(ClientData cData, Tcl_Interp * interp, int argc, char **argv) int Pg_connect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - char *pghost = NULL; - char *pgtty = NULL; - char *pgport = NULL; - char *pgoptions = NULL; - char *dbName; - int i; - PGconn *conn; + Pg_clientData *cd = (Pg_clientData *) cData; + char *pghost = NULL; + char *pgtty = NULL; + char *pgport = NULL; + char *pgoptions = NULL; + char *dbName; + int i; + PGconn *conn; if (argc == 1) { @@ -404,8 +405,8 @@ Pg_connect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_disconnect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; if (argc != 2) { @@ -439,9 +440,9 @@ Pg_disconnect(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - PGresult *result; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + PGresult *result; if (argc != 3) { @@ -507,15 +508,15 @@ Pg_exec(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGresult *result; - char *opt; - int i; - int tupno; - char prearrayInd[MAX_MESSAGE_LEN]; - char arrayInd[MAX_MESSAGE_LEN]; - char *appendstr; - char *arrVar; + Pg_clientData *cd = (Pg_clientData *) cData; + PGresult *result; + char *opt; + int i; + int tupno; + char prearrayInd[MAX_MESSAGE_LEN]; + char arrayInd[MAX_MESSAGE_LEN]; + char *appendstr; + char *arrVar; if (argc != 3 && argc != 4 && argc != 5) { @@ -669,7 +670,7 @@ Pg_result(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } else if (strcmp(opt, "-lAttributes") == 0) { - char buf[512]; + char buf[512]; Tcl_ResetResult(interp); for (i = 0; i < PQnfields(result); i++) @@ -726,11 +727,11 @@ Pg_result_errReturn: int Pg_lo_open(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int lobjId; - int mode; - int fd; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int lobjId; + int mode; + int fd; if (argc != 4) { @@ -755,33 +756,33 @@ Pg_lo_open(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) } switch (argv[3][0]) { - case 'r': - case 'R': - mode = INV_READ; - break; - case 'w': - case 'W': - mode = INV_WRITE; - break; - default: - Tcl_AppendResult(interp, "mode argument must be 'r', 'w', or 'rw'", 0); - return TCL_ERROR; + case 'r': + case 'R': + mode = INV_READ; + break; + case 'w': + case 'W': + mode = INV_WRITE; + break; + default: + Tcl_AppendResult(interp, "mode argument must be 'r', 'w', or 'rw'", 0); + return TCL_ERROR; } switch (argv[3][1]) { - case '\0': - break; - case 'r': - case 'R': - mode = mode & INV_READ; - break; - case 'w': - case 'W': - mode = mode & INV_WRITE; - break; - default: - Tcl_AppendResult(interp, "mode argument must be 'r', 'w', or 'rw'", 0); - return TCL_ERROR; + case '\0': + break; + case 'r': + case 'R': + mode = mode & INV_READ; + break; + case 'w': + case 'W': + mode = mode & INV_WRITE; + break; + default: + Tcl_AppendResult(interp, "mode argument must be 'r', 'w', or 'rw'", 0); + return TCL_ERROR; } fd = lo_open(conn, lobjId, mode); @@ -800,9 +801,9 @@ Pg_lo_open(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_lo_close(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int fd; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int fd; if (argc != 3) { @@ -837,13 +838,13 @@ Pg_lo_close(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_lo_read(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int fd; - int nbytes = 0; - char *buf; - char *bufVar; - int len; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int fd; + int nbytes = 0; + char *buf; + char *bufVar; + int len; if (argc != 5) { @@ -892,12 +893,12 @@ Pg_lo_write int Pg_lo_write(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - char *buf; - int fd; - int nbytes = 0; - int len; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + char *buf; + int fd; + int nbytes = 0; + int len; if (argc != 5) { @@ -943,12 +944,12 @@ whence can be either int Pg_lo_lseek(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int fd; - char *whenceStr; - int offset, - whence; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int fd; + char *whenceStr; + int offset, + whence; if (argc != 5) { @@ -1006,11 +1007,11 @@ for now, we don't support any additional storage managers. int Pg_lo_creat(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - char *modeStr; - char *modeWord; - int mode; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + char *modeStr; + char *modeWord; + int mode; if (argc != 3) { @@ -1086,9 +1087,9 @@ Pg_lo_tell int Pg_lo_tell(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int fd; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int fd; if (argc != 3) { @@ -1123,10 +1124,10 @@ Pg_lo_unlink int Pg_lo_unlink(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - int lobjId; - int retval; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + int lobjId; + int retval; if (argc != 3) { @@ -1169,10 +1170,10 @@ Pg_lo_import int Pg_lo_import(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - char *filename; - Oid lobjId; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + char *filename; + Oid lobjId; if (argc != 3) { @@ -1212,11 +1213,11 @@ Pg_lo_export int Pg_lo_export(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - char *filename; - Oid lobjId; - int retval; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + char *filename; + Oid lobjId; + int retval; if (argc != 4) { @@ -1268,20 +1269,20 @@ Pg_lo_export(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv) { - Pg_clientData *cd = (Pg_clientData *) cData; - PGconn *conn; - PGresult *result; - int r; - size_t tupno, - column, - ncols; - Tcl_DString headers; - char buffer[2048]; + Pg_clientData *cd = (Pg_clientData *) cData; + PGconn *conn; + PGresult *result; + int r; + size_t tupno, + column, + ncols; + Tcl_DString headers; + char buffer[2048]; struct { - char *cname; - int change; - } *info; + char *cname; + int change; + } *info; if (argc != 5) { @@ -1343,7 +1344,7 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv) if (r == TCL_ERROR) { - char msg[60]; + char msg[60]; sprintf(msg, "\n (\"pg_select\" body line %d)", interp->errorLine); @@ -1363,13 +1364,13 @@ Pg_select(ClientData cData, Tcl_Interp * interp, int argc, char **argv) int Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - int new; - char *relname; - char *callback = NULL; - Tcl_HashEntry *entry; - PGconn *conn; - PGresult *result; + Pg_clientData *cd = (Pg_clientData *) cData; + int new; + char *relname; + char *callback = NULL; + Tcl_HashEntry *entry; + PGconn *conn; + PGresult *result; if ((argc < 3) || (argc > 4)) { @@ -1404,7 +1405,7 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) if (new) { /* New callback, execute a listen command on the relation */ - char *cmd = (char *) ckalloc((unsigned) (strlen(argv[2]) + 8)); + char *cmd = (char *) ckalloc((unsigned) (strlen(argv[2]) + 8)); sprintf(cmd, "LISTEN %s", relname); result = PQexec(conn, cmd); @@ -1452,14 +1453,14 @@ Pg_listen(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) int Pg_notifies(ClientData cData, Tcl_Interp * interp, int argc, char *argv[]) { - Pg_clientData *cd = (Pg_clientData *) cData; - int count; - char buff[12]; - char *callback; - Tcl_HashEntry *entry; - PGconn *conn; - PGresult *result; - PGnotify *notify; + Pg_clientData *cd = (Pg_clientData *) cData; + int count; + char buff[12]; + char *callback; + Tcl_HashEntry *entry; + PGconn *conn; + PGresult *result; + PGnotify *notify; if (argc != 2) { diff --git a/src/interfaces/libpgtcl/pgtclCmds.h b/src/interfaces/libpgtcl/pgtclCmds.h index f1e5755641f..6def84d97ff 100644 --- a/src/interfaces/libpgtcl/pgtclCmds.h +++ b/src/interfaces/libpgtcl/pgtclCmds.h @@ -5,7 +5,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclCmds.h,v 1.7 1997/09/07 05:03:12 momjian Exp $ + * $Id: pgtclCmds.h,v 1.8 1997/09/08 02:40:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -20,28 +20,28 @@ typedef struct Pg_clientData_s { - Tcl_HashTable dbh_hash; - Tcl_HashTable res_hash; - Tcl_HashTable notify_hash; - long dbh_count; - long res_count; -} Pg_clientData; + Tcl_HashTable dbh_hash; + Tcl_HashTable res_hash; + Tcl_HashTable notify_hash; + long dbh_count; + long res_count; +} Pg_clientData; typedef struct Pg_ConnectionId_s { - char id[32]; - PGconn *conn; - Tcl_HashTable res_hash; -} Pg_ConnectionId; + char id[32]; + PGconn *conn; + Tcl_HashTable res_hash; +} Pg_ConnectionId; typedef struct Pg_ResultId_s { - char id[32]; - PGresult *result; + char id[32]; + PGresult *result; Pg_ConnectionId *connection; -} Pg_ResultId; +} Pg_ResultId; /* **************************/ diff --git a/src/interfaces/libpgtcl/pgtclId.c b/src/interfaces/libpgtcl/pgtclId.c index d6265974b43..fb43616a8ea 100644 --- a/src/interfaces/libpgtcl/pgtclId.c +++ b/src/interfaces/libpgtcl/pgtclId.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.4 1997/09/07 05:03:13 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpgtcl/Attic/pgtclId.c,v 1.5 1997/09/08 02:40:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,9 +31,9 @@ void PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn) { - Tcl_HashEntry *hent; + Tcl_HashEntry *hent; Pg_ConnectionId *connid; - int hnew; + int hnew; connid = (Pg_ConnectionId *) ckalloc(sizeof(Pg_ConnectionId)); connid->conn = conn; @@ -49,10 +49,10 @@ PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn) /* * Get back the connection from the Id */ -PGconn * +PGconn * PgGetConnectionId(Pg_clientData * cd, char *id) { - Tcl_HashEntry *hent; + Tcl_HashEntry *hent; Pg_ConnectionId *connid; hent = Tcl_FindHashEntry(&(cd->dbh_hash), id); @@ -73,12 +73,12 @@ PgGetConnectionId(Pg_clientData * cd, char *id) void PgDelConnectionId(Pg_clientData * cd, char *id) { - Tcl_HashEntry *hent; - Tcl_HashEntry *hent2; - Tcl_HashEntry *hent3; - Tcl_HashSearch hsearch; + Tcl_HashEntry *hent; + Tcl_HashEntry *hent2; + Tcl_HashEntry *hent3; + Tcl_HashSearch hsearch; Pg_ConnectionId *connid; - Pg_ResultId *resid; + Pg_ResultId *resid; hent = Tcl_FindHashEntry(&(cd->dbh_hash), id); if (hent == NULL) @@ -113,10 +113,10 @@ PgDelConnectionId(Pg_clientData * cd, char *id) void PgSetResultId(Pg_clientData * cd, char *id, char *connid_c, PGresult * res) { - Tcl_HashEntry *hent; + Tcl_HashEntry *hent; Pg_ConnectionId *connid; - Pg_ResultId *resid; - int hnew; + Pg_ResultId *resid; + int hnew; hent = Tcl_FindHashEntry(&(cd->dbh_hash), connid_c); if (hent == NULL) @@ -148,11 +148,11 @@ PgSetResultId(Pg_clientData * cd, char *id, char *connid_c, PGresult * res) /* * Get back the result pointer from the Id */ -PGresult * +PGresult * PgGetResultId(Pg_clientData * cd, char *id) { - Tcl_HashEntry *hent; - Pg_ResultId *resid; + Tcl_HashEntry *hent; + Pg_ResultId *resid; hent = Tcl_FindHashEntry(&(cd->res_hash), id); if (hent == NULL) @@ -171,9 +171,9 @@ PgGetResultId(Pg_clientData * cd, char *id) void PgDelResultId(Pg_clientData * cd, char *id) { - Tcl_HashEntry *hent; - Tcl_HashEntry *hent2; - Pg_ResultId *resid; + Tcl_HashEntry *hent; + Tcl_HashEntry *hent2; + Pg_ResultId *resid; hent = Tcl_FindHashEntry(&(cd->res_hash), id); if (hent == NULL) @@ -202,8 +202,8 @@ PgDelResultId(Pg_clientData * cd, char *id) void PgGetConnByResultId(Pg_clientData * cd, char *id, char *resid_c) { - Tcl_HashEntry *hent; - Pg_ResultId *resid; + Tcl_HashEntry *hent; + Pg_ResultId *resid; hent = Tcl_FindHashEntry(&(cd->res_hash), id); if (hent == NULL) diff --git a/src/interfaces/libpgtcl/pgtclId.h b/src/interfaces/libpgtcl/pgtclId.h index 03856434d6b..22d44c5b9fa 100644 --- a/src/interfaces/libpgtcl/pgtclId.h +++ b/src/interfaces/libpgtcl/pgtclId.h @@ -8,15 +8,15 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pgtclId.h,v 1.3 1997/09/07 05:03:14 momjian Exp $ + * $Id: pgtclId.h,v 1.4 1997/09/08 02:40:17 momjian Exp $ * *------------------------------------------------------------------------- */ -extern void PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn); -extern PGconn *PgGetConnectionId(Pg_clientData * cd, char *id); -extern void PgDelConnectionId(Pg_clientData * cd, char *id); -extern void PgSetResultId(Pg_clientData * cd, char *id, char *connid, PGresult * res); +extern void PgSetConnectionId(Pg_clientData * cd, char *id, PGconn * conn); +extern PGconn *PgGetConnectionId(Pg_clientData * cd, char *id); +extern void PgDelConnectionId(Pg_clientData * cd, char *id); +extern void PgSetResultId(Pg_clientData * cd, char *id, char *connid, PGresult * res); extern PGresult *PgGetResultId(Pg_clientData * cd, char *id); -extern void PgDelResultId(Pg_clientData * cd, char *id); -extern void PgGetConnByResultId(Pg_clientData * cd, char *id, char *resid); +extern void PgDelResultId(Pg_clientData * cd, char *id); +extern void PgGetConnByResultId(Pg_clientData * cd, char *id, char *resid); diff --git a/src/interfaces/libpq/fe-auth.c b/src/interfaces/libpq/fe-auth.c index 433cc65ded7..0b4a697f859 100644 --- a/src/interfaces/libpq/fe-auth.c +++ b/src/interfaces/libpq/fe-auth.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.9 1997/09/07 05:03:17 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-auth.c,v 1.10 1997/09/08 02:40:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -49,9 +49,9 @@ struct authsvc { - char name[16]; /* service nickname (for command line) */ - MsgType msgtype; /* startup packet header type */ - int allowed; /* initially allowed (before command line + char name[16]; /* service nickname (for command line) */ + MsgType msgtype; /* startup packet header type */ + int allowed; /* initially allowed (before command line * option parsing)? */ }; @@ -84,7 +84,7 @@ static struct authsvc authsvcs[] = { {"password", STARTUP_PASSWORD_MSG, 0} }; -static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); +static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); #ifdef KRB4 /*---------------------------------------------------------------- @@ -95,7 +95,7 @@ static n_authsvcs = sizeof(authsvcs) / sizeof(struct authsvc); #include "krb.h" /* for some reason, this is not defined in krb.h ... */ -extern char *tkt_string(void); +extern char *tkt_string(void); /* * pg_krb4_init -- initialization performed before any Kerberos calls are made @@ -107,8 +107,8 @@ extern char *tkt_string(void); static void pg_krb4_init() { - char *realm; - static init_done = 0; + char *realm; + static init_done = 0; if (init_done) return; @@ -120,7 +120,7 @@ pg_krb4_init() */ if (realm = getenv("PGREALM")) { - char tktbuf[MAXPATHLEN]; + char tktbuf[MAXPATHLEN]; (void) sprintf(tktbuf, "%s@%s", tkt_string(), realm); krb_set_tkt_string(tktbuf); @@ -133,13 +133,13 @@ pg_krb4_init() * * We obtain this information by digging around in the ticket file. */ -static char * +static char * pg_krb4_authname(char *PQerrormsg) { - char instance[INST_SZ]; - char realm[REALM_SZ]; - int status; - static char name[SNAME_SZ + 1] = ""; + char instance[INST_SZ]; + char realm[REALM_SZ]; + int status; + static char name[SNAME_SZ + 1] = ""; if (name[0]) return (name); @@ -178,11 +178,11 @@ pg_krb4_sendauth(const char *PQerrormsg, int sock, struct sockaddr_in * raddr, const char *hostname) { - long krbopts = 0;/* one-way authentication */ - KTEXT_ST clttkt; - int status; - char hostbuf[MAXHOSTNAMELEN]; - const char *realm = getenv("PGREALM"); /* NULL == current realm */ + long krbopts = 0; /* one-way authentication */ + KTEXT_ST clttkt; + int status; + char hostbuf[MAXHOSTNAMELEN]; + const char *realm = getenv("PGREALM"); /* NULL == current realm */ if (!hostname || !(*hostname)) { @@ -239,10 +239,10 @@ pg_krb4_sendauth(const char *PQerrormsg, int sock, * krb5_an_to_ln, except that it punts if multiple components are found, * and we can't afford to punt. */ -static char * +static char * pg_an_to_ln(const char *aname) { - char *p; + char *p; if ((p = strchr(aname, '/')) || (p = strchr(aname, '@'))) *p = '\0'; @@ -259,13 +259,13 @@ pg_an_to_ln(const char *aname) * */ static int -krb5_ccache + krb5_ccache pg_krb5_init(void) { krb5_error_code code; - char *realm, - *defname; - char tktbuf[MAXPATHLEN]; + char *realm, + *defname; + char tktbuf[MAXPATHLEN]; static krb5_ccache ccache = (krb5_ccache) NULL; if (ccache) @@ -308,10 +308,10 @@ pg_krb5_init(void) static const char * pg_krb5_authname(const char *PQerrormsg) { - krb5_ccache ccache; - krb5_principal principal; + krb5_ccache ccache; + krb5_principal principal; krb5_error_code code; - static char *authname = (char *) NULL; + static char *authname = (char *) NULL; if (authname) return (authname); @@ -360,15 +360,15 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock, struct sockaddr_in * raddr, const char *hostname) { - char servbuf[MAXHOSTNAMELEN + 1 + - sizeof(PG_KRB_SRVNAM)]; - const char *hostp; - const char *realm; + char servbuf[MAXHOSTNAMELEN + 1 + + sizeof(PG_KRB_SRVNAM)]; + const char *hostp; + const char *realm; krb5_error_code code; - krb5_principal client, - server; - krb5_ccache ccache; - krb5_error *error = (krb5_error *) NULL; + krb5_principal client, + server; + krb5_ccache ccache; + krb5_error *error = (krb5_error *) NULL; ccache = pg_krb5_init(); /* don't free this */ @@ -459,8 +459,8 @@ pg_krb5_sendauth(const char *PQerrormsg, int sock, static int pg_password_sendauth(Port * port, const char *user, const char *password) { - PacketBuf buf; - char *tmp; + PacketBuf buf; + char *tmp; buf.len = htonl(sizeof(PacketBuf)); buf.msgtype = STARTUP_PASSWORD_MSG; @@ -484,36 +484,36 @@ fe_sendauth(MsgType msgtype, Port * port, const char *hostname, switch (msgtype) { #ifdef KRB4 - case STARTUP_KRB4_MSG: - if (pg_krb4_sendauth(PQerrormsg, port->sock, &port->laddr, - &port->raddr, - hostname) != STATUS_OK) - { - (void) sprintf(PQerrormsg, - "fe_sendauth: krb4 authentication failed\n"); + case STARTUP_KRB4_MSG: + if (pg_krb4_sendauth(PQerrormsg, port->sock, &port->laddr, + &port->raddr, + hostname) != STATUS_OK) + { + (void) sprintf(PQerrormsg, + "fe_sendauth: krb4 authentication failed\n"); /* fputs(PQerrormsg, stderr); */ - return (STATUS_ERROR); - } - break; + return (STATUS_ERROR); + } + break; #endif #ifdef KRB5 - case STARTUP_KRB5_MSG: - if (pg_krb5_sendauth(PQerrormsg, port->sock, &port->laddr, - &port->raddr, - hostname) != STATUS_OK) - { - (void) sprintf(PQerrormsg, - "fe_sendauth: krb5 authentication failed\n"); - return (STATUS_ERROR); - } - break; + case STARTUP_KRB5_MSG: + if (pg_krb5_sendauth(PQerrormsg, port->sock, &port->laddr, + &port->raddr, + hostname) != STATUS_OK) + { + (void) sprintf(PQerrormsg, + "fe_sendauth: krb5 authentication failed\n"); + return (STATUS_ERROR); + } + break; #endif - case STARTUP_MSG: - break; - case STARTUP_PASSWORD_MSG: - pg_password_sendauth(port, user, password); - default: - break; + case STARTUP_MSG: + break; + case STARTUP_PASSWORD_MSG: + pg_password_sendauth(port, user, password); + default: + break; } return (STATUS_OK); } @@ -525,12 +525,12 @@ fe_sendauth(MsgType msgtype, Port * port, const char *hostname, * Set/return the authentication service currently selected for use by the * frontend. (You can only use one in the frontend, obviously.) */ -static pg_authsvc = -1; +static pg_authsvc = -1; void fe_setauthsvc(const char *name, char *PQerrormsg) { - int i; + int i; for (i = 0; i < n_authsvcs; ++i) if (!strcmp(name, authsvcs[i].name)) @@ -560,39 +560,39 @@ fe_getauthsvc(char *PQerrormsg) * name the user has authenticated to the system * if there is an error, return the error message in PQerrormsg */ -char * +char * fe_getauthname(char *PQerrormsg) { - char *name = (char *) NULL; - char *authn = (char *) NULL; - MsgType authsvc; + char *name = (char *) NULL; + char *authn = (char *) NULL; + MsgType authsvc; authsvc = fe_getauthsvc(PQerrormsg); switch ((int) authsvc) { #ifdef KRB4 - case STARTUP_KRB4_MSG: - name = pg_krb4_authname(PQerrormsg); - break; + case STARTUP_KRB4_MSG: + name = pg_krb4_authname(PQerrormsg); + break; #endif #ifdef KRB5 - case STARTUP_KRB5_MSG: - name = pg_krb5_authname(PQerrormsg); - break; + case STARTUP_KRB5_MSG: + name = pg_krb5_authname(PQerrormsg); + break; #endif - case STARTUP_MSG: - { - struct passwd *pw = getpwuid(geteuid()); + case STARTUP_MSG: + { + struct passwd *pw = getpwuid(geteuid()); - if (pw) - name = pw->pw_name; - } - break; - default: - (void) sprintf(PQerrormsg, + if (pw) + name = pw->pw_name; + } + break; + default: + (void) sprintf(PQerrormsg, "fe_getauthname: invalid authentication system: %d\n", - authsvc); - break; + authsvc); + break; } if (name && (authn = (char *) malloc(strlen(name) + 1))) diff --git a/src/interfaces/libpq/fe-auth.h b/src/interfaces/libpq/fe-auth.h index 6ca83fe4e89..6bd4530a285 100644 --- a/src/interfaces/libpq/fe-auth.h +++ b/src/interfaces/libpq/fe-auth.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fe-auth.h,v 1.4 1997/09/07 05:03:21 momjian Exp $ + * $Id: fe-auth.h,v 1.5 1997/09/08 02:40:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ extern int fe_sendauth(MsgType msgtype, Port * port, const char *hostname, const char *user, const char *password, const char *PQerromsg); -extern void fe_setauthsvc(const char *name, char *PQerrormsg); +extern void fe_setauthsvc(const char *name, char *PQerrormsg); #define PG_KRB4_VERSION "PGVER4.1" /* at most KRB_SENDAUTH_VLEN chars */ #define PG_KRB5_VERSION "PGVER5.1" diff --git a/src/interfaces/libpq/fe-connect.c b/src/interfaces/libpq/fe-connect.c index 1b6a1c1243d..c338f49ca3e 100644 --- a/src/interfaces/libpq/fe-connect.c +++ b/src/interfaces/libpq/fe-connect.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.39 1997/09/07 05:03:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-connect.c,v 1.40 1997/09/08 02:40:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,12 +41,12 @@ /* use a local version instead of the one found in pqpacket.c */ static ConnStatusType connectDB(PGconn * conn); -static void startup2PacketBuf(StartupInfo * s, PacketBuf * res); -static void freePGconn(PGconn * conn); -static void closePGconn(PGconn * conn); -static int conninfo_parse(const char *conninfo, char *errorMessage); -static char *conninfo_getval(char *keyword); -static void conninfo_free(void); +static void startup2PacketBuf(StartupInfo * s, PacketBuf * res); +static void freePGconn(PGconn * conn); +static void closePGconn(PGconn * conn); +static int conninfo_parse(const char *conninfo, char *errorMessage); +static char *conninfo_getval(char *keyword); +static void conninfo_free(void); #define NOTIFYLIST_INITIAL_SIZE 10 #define NOTIFYLIST_GROWBY 10 @@ -104,9 +104,9 @@ static PQconninfoOption PQconninfoOptions[] = { struct EnvironmentOptions { - const char *envName, - *pgName; -} EnvironmentOptions[] = + const char *envName, + *pgName; +} EnvironmentOptions[] = { { @@ -136,12 +136,12 @@ struct EnvironmentOptions * then some fields may be null'ed out instead of having valid values * ---------------- */ -PGconn * +PGconn * PQconnectdb(const char *conninfo) { - PGconn *conn; + PGconn *conn; PQconninfoOption *option; - char errorMessage[ERROR_MSG_LENGTH]; + char errorMessage[ERROR_MSG_LENGTH]; /* ---------- * Allocate memory for the conn structure @@ -240,7 +240,7 @@ PQconnectdb(const char *conninfo) conn->status = connectDB(conn); if (conn->status == CONNECTION_OK) { - PGresult *res; + PGresult *res; /* * Send a blank query to make sure everything works; in @@ -270,7 +270,7 @@ PQconnectdb(const char *conninfo) PQconninfoOption * PQconndefaults(void) { - char errorMessage[ERROR_MSG_LENGTH]; + char errorMessage[ERROR_MSG_LENGTH]; conninfo_parse("", errorMessage); return PQconninfoOptions; @@ -311,18 +311,18 @@ PQconndefaults(void) * * ---------------- */ -PGconn * +PGconn * PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName) { - PGconn *conn; - char *tmp; - char errorMessage[ERROR_MSG_LENGTH]; + PGconn *conn; + char *tmp; + char errorMessage[ERROR_MSG_LENGTH]; /* An error message from some service we call. */ - bool error; + bool error; /* We encountered an error that prevents successful completion */ - int i; + int i; conn = (PGconn *) malloc(sizeof(PGconn)); @@ -436,7 +436,7 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha /* Puts message in conn->errorMessage */ if (conn->status == CONNECTION_OK) { - PGresult *res; + PGresult *res; /* * Send a blank query to make sure everything works; in @@ -462,18 +462,18 @@ PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const cha * return CONNECTION_OK if successful, CONNECTION_BAD if not. * */ -static ConnStatusType +static ConnStatusType connectDB(PGconn * conn) { struct hostent *hp; - StartupInfo startup; - PacketBuf pacBuf; - int status; - MsgType msgtype; - int laddrlen = sizeof(struct sockaddr); - Port *port = conn->port; - int portno; + StartupInfo startup; + PacketBuf pacBuf; + int status; + MsgType msgtype; + int laddrlen = sizeof(struct sockaddr); + Port *port = conn->port; + int portno; /* * Initialize the startup packet. @@ -534,7 +534,7 @@ connectDB(PGconn * conn) } { struct protoent *pe; - int on = 1; + int on = 1; pe = getprotobyname("TCP"); if (pe == NULL) @@ -609,15 +609,15 @@ connectDB(PGconn * conn) { struct EnvironmentOptions *eo; - char setQuery[80]; /* mjl: size okay? XXX */ + char setQuery[80]; /* mjl: size okay? XXX */ for (eo = EnvironmentOptions; eo->envName; eo++) { - const char *val; + const char *val; if ((val = getenv(eo->envName))) { - PGresult *res; + PGresult *res; sprintf(setQuery, "SET %s TO '%.60s'", eo->pgName, val); res = PQexec(conn, setQuery); @@ -699,7 +699,7 @@ closePGconn(PGconn * conn) fflush(conn->Pfout); sigaction(SIGPIPE, &oldaction, NULL); #else - signal(SIGPIPE, SIG_IGN); + signal(SIGPIPE, SIG_IGN); fputs("X\0", conn->Pfout); fflush(conn->Pfout); signal(SIGPIPE, SIG_DFL); @@ -773,8 +773,8 @@ packetSend(Port * port, PacketLen len, bool nonBlocking) { - PacketLen totalLen; - int addrLen = sizeof(struct sockaddr_in); + PacketLen totalLen; + int addrLen = sizeof(struct sockaddr_in); totalLen = len; @@ -800,7 +800,7 @@ packetSend(Port * port, static void startup2PacketBuf(StartupInfo * s, PacketBuf * res) { - char *tmp; + char *tmp; /* res = (PacketBuf*)malloc(sizeof(PacketBuf)); */ res->len = htonl(sizeof(PacketBuf)); @@ -827,14 +827,14 @@ startup2PacketBuf(StartupInfo * s, PacketBuf * res) static int conninfo_parse(const char *conninfo, char *errorMessage) { - char *pname; - char *pval; - char *buf; - char *tmp; - char *cp; - char *cp2; + char *pname; + char *pval; + char *buf; + char *tmp; + char *cp; + char *cp2; PQconninfoOption *option; - char errortmp[ERROR_MSG_LENGTH]; + char errortmp[ERROR_MSG_LENGTH]; conninfo_free(); @@ -1054,7 +1054,7 @@ conninfo_parse(const char *conninfo, char *errorMessage) } -static char * +static char * conninfo_getval(char *keyword) { PQconninfoOption *option; @@ -1087,7 +1087,7 @@ conninfo_free() } /* =========== accessor functions for PGconn ========= */ -char * +char * PQdb(PGconn * conn) { if (!conn) @@ -1098,7 +1098,7 @@ PQdb(PGconn * conn) return conn->dbName; } -char * +char * PQuser(PGconn * conn) { if (!conn) @@ -1109,7 +1109,7 @@ PQuser(PGconn * conn) return conn->pguser; } -char * +char * PQhost(PGconn * conn) { if (!conn) @@ -1121,7 +1121,7 @@ PQhost(PGconn * conn) return conn->pghost; } -char * +char * PQoptions(PGconn * conn) { if (!conn) @@ -1132,7 +1132,7 @@ PQoptions(PGconn * conn) return conn->pgoptions; } -char * +char * PQtty(PGconn * conn) { if (!conn) @@ -1143,7 +1143,7 @@ PQtty(PGconn * conn) return conn->pgtty; } -char * +char * PQport(PGconn * conn) { if (!conn) @@ -1165,7 +1165,7 @@ PQstatus(PGconn * conn) return conn->status; } -char * +char * PQerrorMessage(PGconn * conn) { if (!conn) diff --git a/src/interfaces/libpq/fe-connect.h b/src/interfaces/libpq/fe-connect.h index 5bd38084488..bf4c5cdf35d 100644 --- a/src/interfaces/libpq/fe-connect.h +++ b/src/interfaces/libpq/fe-connect.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: fe-connect.h,v 1.2 1997/09/07 05:03:26 momjian Exp $ + * $Id: fe-connect.h,v 1.3 1997/09/08 02:40:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -18,12 +18,12 @@ *---------------------------------------------------------------- */ -extern int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking); +extern int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking); #endif /* FE_CONNECT_H */ #ifndef FE_CONNECT_H #define FE_CONNECT_H -int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking); +int packetSend(Port * port, PacketBuf * buf, PacketLen len, bool nonBlocking); #endif diff --git a/src/interfaces/libpq/fe-exec.c b/src/interfaces/libpq/fe-exec.c index be8913e7bf7..454555bfda3 100644 --- a/src/interfaces/libpq/fe-exec.c +++ b/src/interfaces/libpq/fe-exec.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.36 1997/09/07 05:03:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-exec.c,v 1.37 1997/09/08 02:40:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,14 +30,14 @@ #ifdef TIOCGWINSZ -struct winsize screen_size; +struct winsize screen_size; #else struct winsize { - int ws_row; - int ws_col; -} screen_size; + int ws_row; + int ws_col; +} screen_size; #endif @@ -46,7 +46,7 @@ struct winsize #define TUPARR_GROW_BY 100 /* keep this in same order as ExecStatusType in pgtclCmds.h */ -const char *pgresStatus[] = { +const char *pgresStatus[] = { "PGRES_EMPTY_QUERY", "PGRES_COMMAND_OK", "PGRES_TUPLES_OK", @@ -57,11 +57,11 @@ const char *pgresStatus[] = { static PGresult *makePGresult(PGconn * conn, char *pname); -static void addTuple(PGresult * res, PGresAttValue * tup); +static void addTuple(PGresult * res, PGresAttValue * tup); static PGresAttValue *getTuple(PGconn * conn, PGresult * res, int binary); static PGresult *makeEmptyPGresult(PGconn * conn, ExecStatusType status); -static void fill(int length, int max, char filler, FILE * fp); -static char * +static void fill(int length, int max, char filler, FILE * fp); +static char * do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[], char *fieldNames[], unsigned char fieldNotNum[], const int fs_len, PGresult * res); @@ -74,8 +74,8 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, void PQclear(PGresult * res) { - int i, - j; + int i, + j; if (!res) return; @@ -116,7 +116,7 @@ PQclear(PGresult * res) static PGresult * makeEmptyPGresult(PGconn * conn, ExecStatusType status) { - PGresult *result; + PGresult *result; result = (PGresult *) malloc(sizeof(PGresult)); @@ -142,22 +142,22 @@ makeEmptyPGresult(PGconn * conn, ExecStatusType status) static PGresAttValue * getTuple(PGconn * conn, PGresult * result, int binary) { - char bitmap[MAX_FIELDS]; /* the backend sends us a bitmap + char bitmap[MAX_FIELDS]; /* the backend sends us a bitmap * of */ /* which attributes are null */ - int bitmap_index = 0; - int i; - int nbytes; /* the number of bytes in bitmap */ - char bmap; /* One byte of the bitmap */ - int bitcnt = 0; /* number of bits examined in current byte */ - int vlen; /* length of the current field value */ - FILE *pfin = conn->Pfin; - FILE *pfdebug = conn->Pfdebug; + int bitmap_index = 0; + int i; + int nbytes; /* the number of bytes in bitmap */ + char bmap; /* One byte of the bitmap */ + int bitcnt = 0; /* number of bits examined in current byte */ + int vlen; /* length of the current field value */ + FILE *pfin = conn->Pfin; + FILE *pfdebug = conn->Pfdebug; - PGresAttValue *tup; + PGresAttValue *tup; - int nfields = result->numAttributes; + int nfields = result->numAttributes; result->binary = binary; @@ -264,16 +264,16 @@ addTuple(PGresult * res, PGresAttValue * tup) static PGresult * makePGresult(PGconn * conn, char *pname) { - PGresult *result; - int id; - int nfields; - int i; - int done = 0; + PGresult *result; + int id; + int nfields; + int i; + int done = 0; - PGresAttValue *newTup; + PGresAttValue *newTup; - FILE *pfin = conn->Pfin; - FILE *pfdebug = conn->Pfdebug; + FILE *pfin = conn->Pfin; + FILE *pfdebug = conn->Pfdebug; result = makeEmptyPGresult(conn, PGRES_TUPLES_OK); @@ -299,9 +299,9 @@ makePGresult(PGconn * conn, char *pname) /* get type info */ for (i = 0; i < nfields; i++) { - char typName[MAX_MESSAGE_LEN]; - int adtid; - int adtsize; + char typName[MAX_MESSAGE_LEN]; + int adtid; + int adtsize; if (pqGets(typName, MAX_MESSAGE_LEN, pfin, pfdebug) || pqGetInt(&adtid, 4, pfin, pfdebug) || @@ -325,57 +325,57 @@ makePGresult(PGconn * conn, char *pname) { switch (id) { - case 'T': /* a new row group */ - sprintf(conn->errorMessage, - "makePGresult() -- " - "is not equipped to handle multiple row groups.\n"); - goto makePGresult_badResponse_return; - case 'B': /* a row in binary format */ - case 'D': /* a row in ASCII format */ - newTup = getTuple(conn, result, (id == 'B')); - if (newTup == NULL) + case 'T': /* a new row group */ + sprintf(conn->errorMessage, + "makePGresult() -- " + "is not equipped to handle multiple row groups.\n"); goto makePGresult_badResponse_return; - addTuple(result, newTup); - break; - case 'C': /* end of portal row stream */ - { - char command[MAX_MESSAGE_LEN]; + case 'B': /* a row in binary format */ + case 'D': /* a row in ASCII format */ + newTup = getTuple(conn, result, (id == 'B')); + if (newTup == NULL) + goto makePGresult_badResponse_return; + addTuple(result, newTup); + break; + case 'C': /* end of portal row stream */ + { + char command[MAX_MESSAGE_LEN]; - pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */ - done = 1; - } - break; - case 'E': /* errors */ - if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) - { - sprintf(conn->errorMessage, - "Error return detected from backend, " - "but error message cannot be read"); - } - result->resultStatus = PGRES_FATAL_ERROR; - return result; - break; - case 'N': /* notices from the backend */ - if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) - { - sprintf(conn->errorMessage, - "Notice return detected from backend, " - "but error message cannot be read"); - } - else - /* XXXX send Notices to stderr for now */ - fprintf(stderr, "%s\n", conn->errorMessage); - break; - default: /* uh-oh this should never happen but + pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */ + done = 1; + } + break; + case 'E': /* errors */ + if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) + { + sprintf(conn->errorMessage, + "Error return detected from backend, " + "but error message cannot be read"); + } + result->resultStatus = PGRES_FATAL_ERROR; + return result; + break; + case 'N': /* notices from the backend */ + if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) + { + sprintf(conn->errorMessage, + "Notice return detected from backend, " + "but error message cannot be read"); + } + else + /* XXXX send Notices to stderr for now */ + fprintf(stderr, "%s\n", conn->errorMessage); + break; + default: /* uh-oh this should never happen but * frequently does when the backend dumps * core */ - sprintf(conn->errorMessage, - "FATAL: unrecognized data from the backend. " - "It probably dumped core.\n"); - fprintf(stderr, conn->errorMessage); - result->resultStatus = PGRES_FATAL_ERROR; - return result; - break; + sprintf(conn->errorMessage, + "FATAL: unrecognized data from the backend. " + "It probably dumped core.\n"); + fprintf(stderr, conn->errorMessage); + result->resultStatus = PGRES_FATAL_ERROR; + return result; + break; } if (!done) id = getc(pfin); @@ -411,32 +411,32 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug, PGresult ** result_p, char *const reason) { - int id; + int id; /* * The protocol character received from the backend. The protocol * character is the first character in the backend's response to our * query. It defines the nature of the response. */ - PGnotify *newNotify; - bool done; + PGnotify *newNotify; + bool done; /* We're all done with the query and ready to return the result. */ - int emptiesSent; + int emptiesSent; /* * Number of empty queries we have sent in order to flush out multiple * responses, less the number of corresponding responses we have * received. */ - int errors; + int errors; /* * If an error is received, we must still drain out the empty queries * sent. So we need another flag. */ - char cmdStatus[MAX_MESSAGE_LEN]; - char pname[MAX_MESSAGE_LEN]; /* portal name */ + char cmdStatus[MAX_MESSAGE_LEN]; + char pname[MAX_MESSAGE_LEN]; /* portal name */ /* * loop because multiple messages, especially NOTICES, can come back @@ -470,82 +470,95 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug, { switch (id) { - case 'A': - newNotify = (PGnotify *) malloc(sizeof(PGnotify)); - pqGetInt(&(newNotify->be_pid), 4, pfin, pfdebug); - pqGets(newNotify->relname, NAMEDATALEN, pfin, pfdebug); - DLAddTail(conn->notifyList, DLNewElem(newNotify)); - - /* - * async messages are piggy'ed back on other messages, so - * we stay in the while loop for other messages - */ - break; - case 'C': /* portal query command, no rows returned */ - if (pqGets(cmdStatus, MAX_MESSAGE_LEN, pfin, pfdebug) == 1) - { - sprintf(reason, - "PQexec() -- query command completed, " - "but return message from backend cannot be read."); - *result_p = (PGresult *) NULL; - done = true; - } - else - { + case 'A': + newNotify = (PGnotify *) malloc(sizeof(PGnotify)); + pqGetInt(&(newNotify->be_pid), 4, pfin, pfdebug); + pqGets(newNotify->relname, NAMEDATALEN, pfin, pfdebug); + DLAddTail(conn->notifyList, DLNewElem(newNotify)); /* - * since backend may produce more than one result for - * some commands need to poll until clear send an - * empty query down, and keep reading out of the pipe - * until an 'I' is received. + * async messages are piggy'ed back on other messages, + * so we stay in the while loop for other messages */ - pqPuts("Q ", pfout, pfdebug); /* send an empty query */ - - /* - * Increment a flag and process messages in the usual - * way because there may be async notifications - * pending. DZ - 31-8-1996 - */ - emptiesSent++; - } - break; - case 'E': /* error return */ - if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) - { - (void) sprintf(reason, - "PQexec() -- error return detected from backend, " - "but attempt to read the error message failed."); - } - *result_p = (PGresult *) NULL; - errors++; - if (emptiesSent == 0) - { - done = true; - } - break; - case 'I': - { /* empty query */ - /* read and throw away the closing '\0' */ - int c; + break; + case 'C': /* portal query command, no rows returned */ + if (pqGets(cmdStatus, MAX_MESSAGE_LEN, pfin, pfdebug) == 1) + { + sprintf(reason, + "PQexec() -- query command completed, " + "but return message from backend cannot be read."); + *result_p = (PGresult *) NULL; + done = true; + } + else + { - if ((c = pqGetc(pfin, pfdebug)) != '\0') + /* + * since backend may produce more than one result + * for some commands need to poll until clear send + * an empty query down, and keep reading out of + * the pipe until an 'I' is received. + */ + pqPuts("Q ", pfout, pfdebug); /* send an empty query */ + + /* + * Increment a flag and process messages in the + * usual way because there may be async + * notifications pending. DZ - 31-8-1996 + */ + emptiesSent++; + } + break; + case 'E': /* error return */ + if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) { - fprintf(stderr, "error!, unexpected character %c following 'I'\n", c); + (void) sprintf(reason, + "PQexec() -- error return detected from backend, " + "but attempt to read the error message failed."); } - if (emptiesSent) + *result_p = (PGresult *) NULL; + errors++; + if (emptiesSent == 0) { - if (--emptiesSent == 0) - { /* is this the last one? */ - - /* - * If this is the result of a portal query - * command set the command status and message - * accordingly. DZ - 31-8-1996 - */ + done = true; + } + break; + case 'I': + { /* empty query */ + /* read and throw away the closing '\0' */ + int c; + + if ((c = pqGetc(pfin, pfdebug)) != '\0') + { + fprintf(stderr, "error!, unexpected character %c following 'I'\n", c); + } + if (emptiesSent) + { + if (--emptiesSent == 0) + { /* is this the last one? */ + + /* + * If this is the result of a portal query + * command set the command status and + * message accordingly. DZ - 31-8-1996 + */ + if (!errors) + { + *result_p = makeEmptyPGresult(conn, PGRES_COMMAND_OK); + strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN - 1); + } + else + { + *result_p = (PGresult *) NULL; + } + done = true; + } + } + else + { if (!errors) { - *result_p = makeEmptyPGresult(conn, PGRES_COMMAND_OK); - strncpy((*result_p)->cmdStatus, cmdStatus, CMDSTATUS_LEN - 1); + *result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY); } else { @@ -554,62 +567,50 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug, done = true; } } - else + break; + case 'N': /* notices from the backend */ + if (pqGets(reason, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) { - if (!errors) - { - *result_p = makeEmptyPGresult(conn, PGRES_EMPTY_QUERY); - } - else - { - *result_p = (PGresult *) NULL; - } + sprintf(reason, + "PQexec() -- Notice detected from backend, " + "but attempt to read the notice failed."); + *result_p = (PGresult *) NULL; done = true; } - } - break; - case 'N': /* notices from the backend */ - if (pqGets(reason, ERROR_MSG_LENGTH, pfin, pfdebug) == 1) - { + else + + /* + * Should we really be doing this? These notices + * are not important enough for us to presume to + * put them on stderr. Maybe the caller should + * decide whether to put them on stderr or not. + * BJH 96.12.27 + */ + fprintf(stderr, "%s", reason); + break; + case 'P': /* synchronous (normal) portal */ + pqGets(pname, MAX_MESSAGE_LEN, pfin, pfdebug); /* read in portal name */ + break; + case 'T': /* actual row results: */ + *result_p = makePGresult(conn, pname); + done = true; + break; + case 'D': /* copy command began successfully */ + *result_p = makeEmptyPGresult(conn, PGRES_COPY_IN); + done = true; + break; + case 'B': /* copy command began successfully */ + *result_p = makeEmptyPGresult(conn, PGRES_COPY_OUT); + done = true; + break; + default: sprintf(reason, - "PQexec() -- Notice detected from backend, " - "but attempt to read the notice failed."); + "unknown protocol character '%c' read from backend. " + "(The protocol character is the first character the " + "backend sends in response to a query it receives).\n", + id); *result_p = (PGresult *) NULL; done = true; - } - else - - /* - * Should we really be doing this? These notices are - * not important enough for us to presume to put them - * on stderr. Maybe the caller should decide whether - * to put them on stderr or not. BJH 96.12.27 - */ - fprintf(stderr, "%s", reason); - break; - case 'P': /* synchronous (normal) portal */ - pqGets(pname, MAX_MESSAGE_LEN, pfin, pfdebug); /* read in portal name */ - break; - case 'T': /* actual row results: */ - *result_p = makePGresult(conn, pname); - done = true; - break; - case 'D': /* copy command began successfully */ - *result_p = makeEmptyPGresult(conn, PGRES_COPY_IN); - done = true; - break; - case 'B': /* copy command began successfully */ - *result_p = makeEmptyPGresult(conn, PGRES_COPY_OUT); - done = true; - break; - default: - sprintf(reason, - "unknown protocol character '%c' read from backend. " - "(The protocol character is the first character the " - "backend sends in response to a query it receives).\n", - id); - *result_p = (PGresult *) NULL; - done = true; } /* switch on protocol character */ } /* if character was received */ } /* while not done */ @@ -628,11 +629,11 @@ process_response_from_backend(FILE * pfin, FILE * pfout, FILE * pfdebug, * */ -PGresult * +PGresult * PQexec(PGconn * conn, const char *query) { - PGresult *result; - char buffer[MAX_MESSAGE_LEN]; + PGresult *result; + char buffer[MAX_MESSAGE_LEN]; if (!conn) return NULL; @@ -690,10 +691,10 @@ PQexec(PGconn * conn, const char *query) * the CALLER is responsible for FREE'ing the structure returned */ -PGnotify * +PGnotify * PQnotifies(PGconn * conn) { - Dlelem *e; + Dlelem *e; if (!conn) return NULL; @@ -728,7 +729,7 @@ PQnotifies(PGconn * conn) int PQgetline(PGconn * conn, char *s, int maxlen) { - int c = '\0'; + int c = '\0'; if (!conn) return EOF; @@ -784,9 +785,9 @@ PQputline(PGconn * conn, const char *s) int PQendcopy(PGconn * conn) { - FILE *pfin, - *pfdebug; - bool valid = true; + FILE *pfin, + *pfdebug; + bool valid = true; if (!conn) return (int) NULL; @@ -796,7 +797,7 @@ PQendcopy(PGconn * conn) if (pqGetc(pfin, pfdebug) == 'C') { - char command[MAX_MESSAGE_LEN]; + char command[MAX_MESSAGE_LEN]; pqGets(command, MAX_MESSAGE_LEN, pfin, pfdebug); /* read command tag */ } @@ -820,8 +821,8 @@ PQendcopy(PGconn * conn) static void fill(int length, int max, char filler, FILE * fp) { - int count; - char filltmp[2]; + int count; + char filltmp[2]; filltmp[0] = filler; filltmp[1] = 0; @@ -847,11 +848,11 @@ PQdisplayTuples(PGresult * res, { #define DEFAULT_FIELD_SEP " " - int i, - j; - int nFields; - int nTuples; - int fLength[MAX_FIELDS]; + int i, + j; + int nFields; + int nTuples; + int fLength[MAX_FIELDS]; if (fieldSep == NULL) fieldSep = DEFAULT_FIELD_SEP; @@ -941,13 +942,13 @@ PQprintTuples(PGresult * res, * width */ ) { - int nFields; - int nTups; - int i, - j; - char formatString[80]; + int nFields; + int nTups; + int i, + j; + char formatString[80]; - char *tborder = NULL; + char *tborder = NULL; nFields = PQnfields(res); nTups = PQntuples(res); @@ -964,7 +965,7 @@ PQprintTuples(PGresult * res, if (!TerseOutput) { - int width; + int width; width = nFields * 14; tborder = malloc(width + 1); @@ -996,7 +997,7 @@ PQprintTuples(PGresult * res, { for (j = 0; j < nFields; j++) { - char *pval = PQgetvalue(res, i, j); + char *pval = PQgetvalue(res, i, j); fprintf(fout, formatString, TerseOutput ? "" : "|", @@ -1022,11 +1023,11 @@ do_field(PQprintOpt * po, PGresult * res, ) { - char *pval, - *p, - *o; - int plen; - bool skipit; + char *pval, + *p, + *o; + int plen; + bool skipit; plen = PQgetlength(res, i, j); pval = PQgetvalue(res, i, j); @@ -1062,7 +1063,7 @@ do_field(PQprintOpt * po, PGresult * res, *o = '\0'; if (!po->expanded && (po->align || po->html3)) { - int n = strlen(buf); + int n = strlen(buf); if (n > fieldMax[j]) fieldMax[j] = n; @@ -1112,23 +1113,23 @@ do_field(PQprintOpt * po, PGresult * res, } -static char * +static char * do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[], char *fieldNames[], unsigned char fieldNotNum[], const int fs_len, PGresult * res) { - int j; /* for loop index */ - char *border = NULL; + int j; /* for loop index */ + char *border = NULL; if (po->html3) fputs("<tr>", fout); else { - int j; /* for loop index */ - int tot = 0; - int n = 0; - char *p = NULL; + int j; /* for loop index */ + int tot = 0; + int n = 0; + char *p = NULL; for (; n < nFields; n++) tot += fieldMax[n] + fs_len + (po->standard ? 2 : 0); @@ -1143,19 +1144,19 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[], p = border; if (po->standard) { - char *fs = po->fieldSep; + char *fs = po->fieldSep; while (*fs++) *p++ = '+'; } for (j = 0; j < nFields; j++) { - int len; + int len; for (len = fieldMax[j] + (po->standard ? 2 : 0); len--; *p++ = '-'); if (po->standard || (j + 1) < nFields) { - char *fs = po->fieldSep; + char *fs = po->fieldSep; while (*fs++) *p++ = '+'; @@ -1169,7 +1170,7 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[], fputs(po->fieldSep, fout); for (j = 0; j < nFields; j++) { - char *s = PQfname(res, j); + char *s = PQfname(res, j); if (po->html3) { @@ -1178,7 +1179,7 @@ do_header(FILE * fout, PQprintOpt * po, const int nFields, int fieldMax[], } else { - int n = strlen(s); + int n = strlen(s); if (n > fieldMax[j]) fieldMax[j] = n; @@ -1206,7 +1207,7 @@ output_row(FILE * fout, PQprintOpt * po, const int nFields, char *fields[], const int row_index) { - int field_index;/* for loop index */ + int field_index; /* for loop index */ if (po->html3) fputs("<tr>", fout); @@ -1214,7 +1215,7 @@ output_row(FILE * fout, PQprintOpt * po, const int nFields, char *fields[], fputs(po->fieldSep, fout); for (field_index = 0; field_index < nFields; field_index++) { - char *p = fields[row_index * nFields + field_index]; + char *p = fields[row_index * nFields + field_index]; if (po->html3) fprintf(fout, "<td align=%s>%s</td>", @@ -1261,28 +1262,27 @@ PQprint(FILE * fout, PQprintOpt * po ) { - int nFields; + int nFields; nFields = PQnfields(res); if (nFields > 0) { /* only print rows with at least 1 field. */ - int i, - j; - int nTups; - int *fieldMax = NULL; /* in case we don't use - * them */ - unsigned char *fieldNotNum = NULL; - char *border = NULL; - char **fields = NULL; - char **fieldNames; - int fieldMaxLen = 0; - int numFieldName; - int fs_len = strlen(po->fieldSep); - int total_line_length = 0; - int usePipe = 0; - char *pagerenv; - char buf[8192 * 2 + 1]; + int i, + j; + int nTups; + int *fieldMax = NULL; /* in case we don't use them */ + unsigned char *fieldNotNum = NULL; + char *border = NULL; + char **fields = NULL; + char **fieldNames; + int fieldMaxLen = 0; + int numFieldName; + int fs_len = strlen(po->fieldSep); + int total_line_length = 0; + int usePipe = 0; + char *pagerenv; + char buf[8192 * 2 + 1]; nTups = PQntuples(res); if (!(fieldNames = (char **) calloc(nFields, sizeof(char *)))) @@ -1306,8 +1306,8 @@ PQprint(FILE * fout, ; for (j = 0; j < nFields; j++) { - int len; - char *s = + int len; + char *s = (j < numFieldName && po->fieldName[j][0]) ? po->fieldName[j] : PQfname(res, j); @@ -1386,11 +1386,11 @@ PQprint(FILE * fout, } else { - int len = 0; + int len = 0; for (j = 0; j < nFields; j++) { - char *s = fieldNames[j]; + char *s = fieldNames[j]; fputs(s, fout); len += strlen(s) + fs_len; @@ -1501,7 +1501,7 @@ PQprint(FILE * fout, * ---------------- */ -PGresult * +PGresult * PQfn(PGconn * conn, int fnid, int *result_buf, @@ -1510,11 +1510,11 @@ PQfn(PGconn * conn, PQArgBlock * args, int nargs) { - FILE *pfin, - *pfout, - *pfdebug; - int id; - int i; + FILE *pfin, + *pfout, + *pfdebug; + int id; + int i; if (!conn) return NULL; @@ -1561,47 +1561,47 @@ PQfn(PGconn * conn, id = pqGetc(pfin, pfdebug); for (;;) { - int c; + int c; switch (id) { - case 'G': /* function returned properly */ - pqGetInt(actual_result_len, 4, pfin, pfdebug); - if (result_is_int) - { - pqGetInt(result_buf, 4, pfin, pfdebug); - } - else - { - pqGetnchar((char *) result_buf, *actual_result_len, - pfin, pfdebug); - } - c = pqGetc(pfin, pfdebug); /* get the last '0' */ - return makeEmptyPGresult(conn, PGRES_COMMAND_OK); - case 'E': - sprintf(conn->errorMessage, - "PQfn: returned an error"); - return makeEmptyPGresult(conn, PGRES_FATAL_ERROR); - case 'N': - /* print notice and go back to processing return values */ - if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) - == 1) - { + case 'G': /* function returned properly */ + pqGetInt(actual_result_len, 4, pfin, pfdebug); + if (result_is_int) + { + pqGetInt(result_buf, 4, pfin, pfdebug); + } + else + { + pqGetnchar((char *) result_buf, *actual_result_len, + pfin, pfdebug); + } + c = pqGetc(pfin, pfdebug); /* get the last '0' */ + return makeEmptyPGresult(conn, PGRES_COMMAND_OK); + case 'E': sprintf(conn->errorMessage, + "PQfn: returned an error"); + return makeEmptyPGresult(conn, PGRES_FATAL_ERROR); + case 'N': + /* print notice and go back to processing return values */ + if (pqGets(conn->errorMessage, ERROR_MSG_LENGTH, pfin, pfdebug) + == 1) + { + sprintf(conn->errorMessage, "Notice return detected from backend, but message " - "cannot be read"); - } - else - fprintf(stderr, "%s\n", conn->errorMessage); - /* keep iterating */ - break; - case '0': /* no return value */ - return makeEmptyPGresult(conn, PGRES_COMMAND_OK); - default: - /* The backend violates the protocol. */ - sprintf(conn->errorMessage, - "FATAL: PQfn: protocol error: id=%x\n", id); - return makeEmptyPGresult(conn, PGRES_FATAL_ERROR); + "cannot be read"); + } + else + fprintf(stderr, "%s\n", conn->errorMessage); + /* keep iterating */ + break; + case '0': /* no return value */ + return makeEmptyPGresult(conn, PGRES_COMMAND_OK); + default: + /* The backend violates the protocol. */ + sprintf(conn->errorMessage, + "FATAL: PQfn: protocol error: id=%x\n", id); + return makeEmptyPGresult(conn, PGRES_FATAL_ERROR); } } } @@ -1645,7 +1645,7 @@ PQnfields(PGresult * res) /* returns NULL if the field_num is invalid */ -char * +char * PQfname(PGresult * res, int field_num) { if (!res) @@ -1675,7 +1675,7 @@ PQfname(PGresult * res, int field_num) int PQfnumber(PGresult * res, const char *field_name) { - int i; + int i; if (!res) { @@ -1743,7 +1743,7 @@ PQfsize(PGresult * res, int field_num) return 0; } -char * +char * PQcmdStatus(PGresult * res) { if (!res) @@ -1759,8 +1759,8 @@ PQcmdStatus(PGresult * res) if the last command was an INSERT, return the oid string if not, return "" */ -static char oidStatus[32] = {0}; -const char * +static char oidStatus[32] = {0}; +const char * PQoidStatus(PGresult * res) { if (!res) @@ -1775,8 +1775,8 @@ PQoidStatus(PGresult * res) if (strncmp(res->cmdStatus, "INSERT", 6) == 0) { - char *p = res->cmdStatus + 7; - char *e; + char *p = res->cmdStatus + 7; + char *e; for (e = p; *e != ' ' && *e;) e++; @@ -1790,7 +1790,7 @@ PQoidStatus(PGresult * res) if the last command was an INSERT/UPDATE/DELETE, return number of inserted/affected tuples, if not, return "" */ -const char * +const char * PQcmdTuples(PGresult * res) { if (!res) @@ -1806,7 +1806,7 @@ PQcmdTuples(PGresult * res) strncmp(res->cmdStatus, "DELETE", 6) == 0 || strncmp(res->cmdStatus, "UPDATE", 6) == 0) { - char *p = res->cmdStatus + 6; + char *p = res->cmdStatus + 6; if (*p == 0) { @@ -1840,7 +1840,7 @@ PQcmdTuples(PGresult * res) if res is not binary, a null-terminated ASCII string is returned. */ -char * +char * PQgetvalue(PGresult * res, int tup_num, int field_num) { if (!res) diff --git a/src/interfaces/libpq/fe-lobj.c b/src/interfaces/libpq/fe-lobj.c index 1636edc7f42..6e97e6465d9 100644 --- a/src/interfaces/libpq/fe-lobj.c +++ b/src/interfaces/libpq/fe-lobj.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.8 1997/09/07 05:03:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-lobj.c,v 1.9 1997/09/08 02:40:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ #define LO_BUFSIZE 1024 -static int lo_initialize(PGconn * conn); +static int lo_initialize(PGconn * conn); /* * lo_open @@ -35,10 +35,10 @@ static int lo_initialize(PGconn * conn); int lo_open(PGconn * conn, Oid lobjId, int mode) { - int fd; - int result_len; - PQArgBlock argv[2]; - PGresult *res; + int fd; + int result_len; + PQArgBlock argv[2]; + PGresult *res; argv[0].isint = 1; argv[0].len = 4; @@ -81,10 +81,10 @@ lo_open(PGconn * conn, Oid lobjId, int mode) int lo_close(PGconn * conn, int fd) { - PQArgBlock argv[1]; - PGresult *res; - int retval; - int result_len; + PQArgBlock argv[1]; + PGresult *res; + int retval; + int result_len; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -119,9 +119,9 @@ lo_close(PGconn * conn, int fd) int lo_read(PGconn * conn, int fd, char *buf, int len) { - PQArgBlock argv[2]; - PGresult *res; - int result_len; + PQArgBlock argv[2]; + PGresult *res; + int result_len; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -158,10 +158,10 @@ lo_read(PGconn * conn, int fd, char *buf, int len) int lo_write(PGconn * conn, int fd, char *buf, int len) { - PQArgBlock argv[2]; - PGresult *res; - int result_len; - int retval; + PQArgBlock argv[2]; + PGresult *res; + int result_len; + int retval; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -203,10 +203,10 @@ lo_write(PGconn * conn, int fd, char *buf, int len) int lo_lseek(PGconn * conn, int fd, int offset, int whence) { - PQArgBlock argv[3]; - PGresult *res; - int retval; - int result_len; + PQArgBlock argv[3]; + PGresult *res; + int retval; + int result_len; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -251,10 +251,10 @@ lo_lseek(PGconn * conn, int fd, int offset, int whence) Oid lo_creat(PGconn * conn, int mode) { - PQArgBlock argv[1]; - PGresult *res; - int retval; - int result_len; + PQArgBlock argv[1]; + PGresult *res; + int retval; + int result_len; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -288,10 +288,10 @@ lo_creat(PGconn * conn, int mode) int lo_tell(PGconn * conn, int fd) { - int retval; - PQArgBlock argv[1]; - PGresult *res; - int result_len; + int retval; + PQArgBlock argv[1]; + PGresult *res; + int result_len; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -325,10 +325,10 @@ lo_tell(PGconn * conn, int fd) int lo_unlink(PGconn * conn, Oid lobjId) { - PQArgBlock argv[1]; - PGresult *res; - int result_len; - int retval; + PQArgBlock argv[1]; + PGresult *res; + int result_len; + int retval; if (conn->lobjfuncs == (PGlobjfuncs *) NULL) { @@ -364,12 +364,12 @@ lo_unlink(PGconn * conn, Oid lobjId) Oid lo_import(PGconn * conn, char *filename) { - int fd; - int nbytes, - tmp; - char buf[LO_BUFSIZE]; - Oid lobjOid; - int lobj; + int fd; + int nbytes, + tmp; + char buf[LO_BUFSIZE]; + Oid lobjOid; + int lobj; /* * open the file to be read in @@ -429,11 +429,11 @@ lo_import(PGconn * conn, char *filename) int lo_export(PGconn * conn, Oid lobjId, char *filename) { - int fd; - int nbytes, - tmp; - char buf[LO_BUFSIZE]; - int lobj; + int fd; + int nbytes, + tmp; + char buf[LO_BUFSIZE]; + int lobj; /* * create an inversion "object" @@ -490,11 +490,11 @@ lo_export(PGconn * conn, Oid lobjId, char *filename) static int lo_initialize(PGconn * conn) { - PGresult *res; - PGlobjfuncs *lobjfuncs; - int n; - char *fname; - Oid foid; + PGresult *res; + PGlobjfuncs *lobjfuncs; + int n; + char *fname; + Oid foid; /* ---------------- * Allocate the structure to hold the functions OID's diff --git a/src/interfaces/libpq/fe-misc.c b/src/interfaces/libpq/fe-misc.c index b7e8a1b1c69..23d1e42955f 100644 --- a/src/interfaces/libpq/fe-misc.c +++ b/src/interfaces/libpq/fe-misc.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.6 1997/09/07 05:03:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/fe-misc.c,v 1.7 1997/09/08 02:40:35 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -32,7 +32,7 @@ int pqGetc(FILE * fin, FILE * debug) { - int c; + int c; c = getc(fin); @@ -70,7 +70,7 @@ pqPutnchar(const char *s, int len, FILE * f, FILE * debug) int pqGetnchar(char *s, int len, FILE * f, FILE * debug) { - int cnt; + int cnt; if (f == NULL) return 1; @@ -92,8 +92,8 @@ pqGetnchar(char *s, int len, FILE * f, FILE * debug) int pqGets(char *s, int len, FILE * f, FILE * debug) { - int c; - const char *str = s; + int c; + const char *str = s; if (f == NULL) return 1; @@ -118,19 +118,19 @@ pqGets(char *s, int len, FILE * f, FILE * debug) int pqPutInt(const int integer, int bytes, FILE * f, FILE * debug) { - int retval = 0; + int retval = 0; switch (bytes) { - case 2: - retval = pqPutShort(integer, f); - break; - case 4: - retval = pqPutLong(integer, f); - break; - default: - fprintf(stderr, "** int size %d not supported\n", bytes); - retval = 1; + case 2: + retval = pqPutShort(integer, f); + break; + case 4: + retval = pqPutLong(integer, f); + break; + default: + fprintf(stderr, "** int size %d not supported\n", bytes); + retval = 1; } if (debug) @@ -148,19 +148,19 @@ pqPutInt(const int integer, int bytes, FILE * f, FILE * debug) int pqGetInt(int *result, int bytes, FILE * f, FILE * debug) { - int retval = 0; + int retval = 0; switch (bytes) { - case 2: - retval = pqGetShort(result, f); - break; - case 4: - retval = pqGetLong(result, f); - break; - default: - fprintf(stderr, "** int size %d not supported\n", bytes); - retval = 1; + case 2: + retval = pqGetShort(result, f); + break; + case 4: + retval = pqGetLong(result, f); + break; + default: + fprintf(stderr, "** int size %d not supported\n", bytes); + retval = 1; } if (debug) diff --git a/src/interfaces/libpq/libpq-fe.h b/src/interfaces/libpq/libpq-fe.h index 3013d5a2bfc..397630ad5d9 100644 --- a/src/interfaces/libpq/libpq-fe.h +++ b/src/interfaces/libpq/libpq-fe.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: libpq-fe.h,v 1.21 1997/09/07 05:03:36 momjian Exp $ + * $Id: libpq-fe.h,v 1.22 1997/09/08 02:40:36 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,7 +15,7 @@ #define LIBPQ_FE_H #ifdef __cplusplus -extern "C" +extern "C" { #endif @@ -32,7 +32,7 @@ extern "C" { CONNECTION_OK, CONNECTION_BAD - } ConnStatusType; + } ConnStatusType; typedef enum { @@ -49,7 +49,7 @@ extern "C" PGRES_NONFATAL_ERROR, PGRES_FATAL_ERROR - } ExecStatusType; + } ExecStatusType; /* string descriptions of the ExecStatusTypes */ extern const char *pgresStatus[]; @@ -72,21 +72,21 @@ extern "C" */ typedef struct { - int len; - int isint; + int len; + int isint; union { - int *ptr;/* can't use void (dec compiler barfs) */ - int integer; - } u; - } PQArgBlock; + int *ptr; /* can't use void (dec compiler barfs) */ + int integer; + } u; + } PQArgBlock; typedef struct pgresAttDesc { - char *name; /* type name */ - Oid adtid; /* type id */ - short adtsize;/* type size */ - } PGresAttDesc; + char *name; /* type name */ + Oid adtid; /* type id */ + short adtsize; /* type size */ + } PGresAttDesc; /* use char* for Attribute values, ASCII tuples are guaranteed to be null-terminated @@ -98,60 +98,56 @@ extern "C" typedef struct pgresAttValue { - int len; /* length in bytes of the value */ - char *value; /* actual value */ - } PGresAttValue; + int len; /* length in bytes of the value */ + char *value; /* actual value */ + } PGresAttValue; typedef struct pgNotify { - char relname[NAMEDATALEN]; /* name of relation + char relname[NAMEDATALEN]; /* name of relation * containing data */ - int be_pid; /* process id of backend */ - } PGnotify; + int be_pid; /* process id of backend */ + } PGnotify; typedef struct pgLobjfuncs { - Oid fn_lo_open; /* OID of backend function lo_open */ - Oid fn_lo_close; /* OID of backend function - * lo_close */ - Oid fn_lo_creat; /* OID of backend function - * lo_creat */ - Oid fn_lo_unlink; /* OID of backend function + Oid fn_lo_open; /* OID of backend function lo_open */ + Oid fn_lo_close;/* OID of backend function lo_close */ + Oid fn_lo_creat;/* OID of backend function lo_creat */ + Oid fn_lo_unlink; /* OID of backend function * lo_unlink */ - Oid fn_lo_lseek; /* OID of backend function - * lo_lseek */ - Oid fn_lo_tell; /* OID of backend function lo_tell */ - Oid fn_lo_read; /* OID of backend function LOread */ - Oid fn_lo_write; /* OID of backend function LOwrite */ - } PGlobjfuncs; + Oid fn_lo_lseek;/* OID of backend function lo_lseek */ + Oid fn_lo_tell; /* OID of backend function lo_tell */ + Oid fn_lo_read; /* OID of backend function LOread */ + Oid fn_lo_write;/* OID of backend function LOwrite */ + } PGlobjfuncs; /* PGconn encapsulates a connection to the backend */ typedef struct pg_conn { - char *pghost; /* the machine on which the server is + char *pghost; /* the machine on which the server is * running */ - char *pgtty; /* tty on which the backend messages is + char *pgtty; /* tty on which the backend messages is * displayed */ - char *pgport; /* the communication port with the backend */ - char *pgoptions; /* options to start the backend - * with */ - char *dbName; /* database name */ - ConnStatusType status; - char errorMessage[ERROR_MSG_LENGTH]; + char *pgport; /* the communication port with the backend */ + char *pgoptions; /* options to start the backend with */ + char *dbName; /* database name */ + ConnStatusType status; + char errorMessage[ERROR_MSG_LENGTH]; /* pipes for be/fe communication */ - FILE *Pfin; - FILE *Pfout; - FILE *Pfdebug; - void *port; /* really a Port* */ - int asyncNotifyWaiting; - Dllist *notifyList; - char *pguser; /* Postgres username of user who is + FILE *Pfin; + FILE *Pfout; + FILE *Pfdebug; + void *port; /* really a Port* */ + int asyncNotifyWaiting; + Dllist *notifyList; + char *pguser; /* Postgres username of user who is * connected */ - char *pgpass; - char *pgauth; - PGlobjfuncs *lobjfuncs; /* Backend function OID's for - * large object access */ - } PGconn; + char *pgpass; + char *pgauth; + PGlobjfuncs *lobjfuncs; /* Backend function OID's for large object + * access */ + } PGconn; #define CMDSTATUS_LEN 40 @@ -159,21 +155,21 @@ extern "C" /* unlike the old libpq, we assume that queries only return in one group */ typedef struct pg_result { - int ntups; - int numAttributes; - PGresAttDesc *attDescs; - PGresAttValue **tuples;/* each PGresTuple is an array of + int ntups; + int numAttributes; + PGresAttDesc *attDescs; + PGresAttValue **tuples; /* each PGresTuple is an array of * PGresAttValue's */ - int tupArrSize; /* size of tuples array allocated */ - ExecStatusType resultStatus; - char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the - * last insert query */ - int binary; /* binary tuple values if binary == 1, + int tupArrSize; /* size of tuples array allocated */ + ExecStatusType resultStatus; + char cmdStatus[CMDSTATUS_LEN]; /* cmd status from the + * last insert query */ + int binary; /* binary tuple values if binary == 1, * otherwise ASCII */ - PGconn *conn; - } PGresult; + PGconn *conn; + } PGresult; - typedef char pqbool; + typedef char pqbool; /* * We can't use the conventional "bool", because we are designed to be @@ -183,18 +179,18 @@ extern "C" struct _PQprintOpt { - pqbool header; /* print output field headings and row + pqbool header; /* print output field headings and row * count */ - pqbool align; /* fill align the fields */ - pqbool standard; /* old brain dead format */ - pqbool html3; /* output html tables */ - pqbool expanded; /* expand tables */ - pqbool pager; /* use pager for output if needed */ - char *fieldSep; /* field separator */ - char *tableOpt; /* insert to HTML <table ...> */ - char *caption;/* HTML <caption> */ - char **fieldName; /* null terminated array of - * repalcement field names */ + pqbool align; /* fill align the fields */ + pqbool standard; /* old brain dead format */ + pqbool html3; /* output html tables */ + pqbool expanded; /* expand tables */ + pqbool pager; /* use pager for output if needed */ + char *fieldSep; /* field separator */ + char *tableOpt; /* insert to HTML <table ...> */ + char *caption; /* HTML <caption> */ + char **fieldName; /* null terminated array of repalcement + * field names */ }; typedef struct _PQprintOpt PQprintOpt; @@ -205,134 +201,131 @@ extern "C" */ struct _PQconninfoOption { - char *keyword;/* The keyword of the option */ - char *environ;/* Fallback environment variable name */ - char *compiled; /* Fallback compiled in default - * value */ - char *val; /* Options value */ - char *label; /* Label for field in connect dialog */ - char *dispchar; /* Character to display for this - * field */ + char *keyword; /* The keyword of the option */ + char *environ; /* Fallback environment variable name */ + char *compiled; /* Fallback compiled in default value */ + char *val; /* Options value */ + char *label; /* Label for field in connect dialog */ + char *dispchar; /* Character to display for this field */ /* in a connect dialog. Values are: */ /* "" Display entered value as is */ /* "*" Password field - hide value */ /* "D" Debug options - don't */ /* create a field by default */ - int dispsize; /* Field size in characters for - * dialog */ + int dispsize; /* Field size in characters for dialog */ }; typedef struct _PQconninfoOption PQconninfoOption; /* === in fe-connect.c === */ /* make a new client connection to the backend */ - extern PGconn *PQconnectdb(const char *conninfo); + extern PGconn *PQconnectdb(const char *conninfo); extern PQconninfoOption *PQconndefaults(void); - extern PGconn *PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, + extern PGconn *PQsetdb(const char *pghost, const char *pgport, const char *pgoptions, const char *pgtty, const char *dbName); /* close the current connection and free the PGconn data structure */ - extern void PQfinish(PGconn * conn); + extern void PQfinish(PGconn * conn); /* * close the current connection and restablish a new one with the same * parameters */ - extern void PQreset(PGconn * conn); - - extern char *PQdb(PGconn * conn); - extern char *PQuser(PGconn * conn); - extern char *PQhost(PGconn * conn); - extern char *PQoptions(PGconn * conn); - extern char *PQport(PGconn * conn); - extern char *PQtty(PGconn * conn); + extern void PQreset(PGconn * conn); + + extern char *PQdb(PGconn * conn); + extern char *PQuser(PGconn * conn); + extern char *PQhost(PGconn * conn); + extern char *PQoptions(PGconn * conn); + extern char *PQport(PGconn * conn); + extern char *PQtty(PGconn * conn); extern ConnStatusType PQstatus(PGconn * conn); - extern char *PQerrorMessage(PGconn * conn); - extern void PQtrace(PGconn * conn, FILE * debug_port); - extern void PQuntrace(PGconn * conn); + extern char *PQerrorMessage(PGconn * conn); + extern void PQtrace(PGconn * conn, FILE * debug_port); + extern void PQuntrace(PGconn * conn); /* === in fe-exec.c === */ extern PGresult *PQexec(PGconn * conn, const char *query); - extern int PQgetline(PGconn * conn, char *string, int length); - extern int PQendcopy(PGconn * conn); - extern void PQputline(PGconn * conn, const char *string); + extern int PQgetline(PGconn * conn, char *string, int length); + extern int PQendcopy(PGconn * conn); + extern void PQputline(PGconn * conn, const char *string); extern ExecStatusType PQresultStatus(PGresult * res); - extern int PQntuples(PGresult * res); - extern int PQnfields(PGresult * res); - extern char *PQfname(PGresult * res, int field_num); - extern int PQfnumber(PGresult * res, const char *field_name); - extern Oid PQftype(PGresult * res, int field_num); - extern short PQfsize(PGresult * res, int field_num); - extern char *PQcmdStatus(PGresult * res); + extern int PQntuples(PGresult * res); + extern int PQnfields(PGresult * res); + extern char *PQfname(PGresult * res, int field_num); + extern int PQfnumber(PGresult * res, const char *field_name); + extern Oid PQftype(PGresult * res, int field_num); + extern short PQfsize(PGresult * res, int field_num); + extern char *PQcmdStatus(PGresult * res); extern const char *PQoidStatus(PGresult * res); extern const char *PQcmdTuples(PGresult * res); - extern char *PQgetvalue(PGresult * res, int tup_num, int field_num); - extern int PQgetlength(PGresult * res, int tup_num, int field_num); - extern int PQgetisnull(PGresult * res, int tup_num, int field_num); - extern void PQclear(PGresult * res); + extern char *PQgetvalue(PGresult * res, int tup_num, int field_num); + extern int PQgetlength(PGresult * res, int tup_num, int field_num); + extern int PQgetisnull(PGresult * res, int tup_num, int field_num); + extern void PQclear(PGresult * res); /* PQdisplayTuples() is a better version of PQprintTuples() */ - extern void PQdisplayTuples(PGresult * res, - FILE * fp, /* where to send the - * output */ - int fillAlign, /* pad the fields with - * spaces */ - const char *fieldSep, /* field separator */ - int printHeader, /* display headers? */ - int quiet); - extern void PQprintTuples(PGresult * res, - FILE * fout, /* output stream */ - int printAttName, /* print attribute names - * or not */ - int terseOutput, /* delimiter bars or - * not? */ - int width /* width of column, if - * 0, use variable width */ + extern void PQdisplayTuples(PGresult * res, + FILE * fp, /* where to send the + * output */ + int fillAlign, /* pad the fields with + * spaces */ + const char *fieldSep, /* field separator */ + int printHeader, /* display headers? */ + int quiet); + extern void PQprintTuples(PGresult * res, + FILE * fout, /* output stream */ + int printAttName, /* print attribute names + * or not */ + int terseOutput, /* delimiter bars or + * not? */ + int width /* width of column, if + * 0, use variable width */ ); - extern void PQprint(FILE * fout, /* output stream */ - PGresult * res, - PQprintOpt * ps /* option structure */ + extern void PQprint(FILE * fout, /* output stream */ + PGresult * res, + PQprintOpt * ps /* option structure */ ); extern PGnotify *PQnotifies(PGconn * conn); extern PGresult *PQfn(PGconn * conn, - int fnid, - int *result_buf, - int *result_len, - int result_is_int, - PQArgBlock * args, - int nargs); + int fnid, + int *result_buf, + int *result_len, + int result_is_int, + PQArgBlock * args, + int nargs); /* === in fe-auth.c === */ - extern MsgType fe_getauthsvc(char *PQerrormsg); - extern void fe_setauthsvc(const char *name, char *PQerrormsg); - extern char *fe_getauthname(char *PQerrormsg); + extern MsgType fe_getauthsvc(char *PQerrormsg); + extern void fe_setauthsvc(const char *name, char *PQerrormsg); + extern char *fe_getauthname(char *PQerrormsg); /* === in fe-misc.c === */ /* pqGets and pqPuts gets and sends strings to the file stream returns 0 if successful if debug is non-null, debugging output is sent to that stream */ - extern int pqGets(char *s, int maxlen, FILE * stream, FILE * debug); - extern int pqGetnchar(char *s, int maxlen, FILE * stream, FILE * debug); - extern int pqPutnchar(const char *s, int maxlen, FILE * stream, FILE * debug); - extern int pqPuts(const char *s, FILE * stream, FILE * debug); - extern int pqGetc(FILE * stream, FILE * debug); + extern int pqGets(char *s, int maxlen, FILE * stream, FILE * debug); + extern int pqGetnchar(char *s, int maxlen, FILE * stream, FILE * debug); + extern int pqPutnchar(const char *s, int maxlen, FILE * stream, FILE * debug); + extern int pqPuts(const char *s, FILE * stream, FILE * debug); + extern int pqGetc(FILE * stream, FILE * debug); /* get a n-byte integer from the stream into result */ /* returns 0 if successful */ - extern int pqGetInt(int *result, int bytes, FILE * stream, FILE * debug); + extern int pqGetInt(int *result, int bytes, FILE * stream, FILE * debug); /* put a n-byte integer into the stream */ /* returns 0 if successful */ - extern int pqPutInt(const int n, int bytes, FILE * stream, FILE * debug); - extern void pqFlush(FILE * stream, FILE * debug); + extern int pqPutInt(const int n, int bytes, FILE * stream, FILE * debug); + extern void pqFlush(FILE * stream, FILE * debug); /* === in fe-lobj.c === */ - int lo_open(PGconn * conn, Oid lobjId, int mode); - int lo_close(PGconn * conn, int fd); - int lo_read(PGconn * conn, int fd, char *buf, int len); - int lo_write(PGconn * conn, int fd, char *buf, int len); - int lo_lseek(PGconn * conn, int fd, int offset, int whence); - Oid lo_creat(PGconn * conn, int mode); - int lo_tell(PGconn * conn, int fd); - int lo_unlink(PGconn * conn, Oid lobjId); - Oid lo_import(PGconn * conn, char *filename); - int lo_export(PGconn * conn, Oid lobjId, char *filename); + int lo_open(PGconn * conn, Oid lobjId, int mode); + int lo_close(PGconn * conn, int fd); + int lo_read(PGconn * conn, int fd, char *buf, int len); + int lo_write(PGconn * conn, int fd, char *buf, int len); + int lo_lseek(PGconn * conn, int fd, int offset, int whence); + Oid lo_creat(PGconn * conn, int mode); + int lo_tell(PGconn * conn, int fd); + int lo_unlink(PGconn * conn, Oid lobjId); + Oid lo_import(PGconn * conn, char *filename); + int lo_export(PGconn * conn, Oid lobjId, char *filename); /* max length of message to send */ #define MAX_MESSAGE_LEN 8193 @@ -349,12 +342,12 @@ extern "C" #define DefaultPassword "" - typedef void *TUPLE; + typedef void *TUPLE; #define palloc malloc #define pfree free #if defined(sunos4) - extern char *sys_errlist[]; + extern char *sys_errlist[]; #define strerror(A) (sys_errlist[(A)]) #endif /* sunos4 */ diff --git a/src/interfaces/libpq/pqsignal.c b/src/interfaces/libpq/pqsignal.c index c004704ba45..3a43271be0d 100644 --- a/src/interfaces/libpq/pqsignal.c +++ b/src/interfaces/libpq/pqsignal.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.4 1997/09/07 05:03:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/interfaces/libpq/pqsignal.c,v 1.5 1997/09/08 02:40:37 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -29,7 +29,7 @@ pqsignal(int signo, pqsigfunc func) return signal(signo, func); #else struct sigaction act, - oact; + oact; act.sa_handler = func; sigemptyset(&act.sa_mask); diff --git a/src/interfaces/libpq/pqsignal.h b/src/interfaces/libpq/pqsignal.h index e2f6d7a973b..4c34a37ebef 100644 --- a/src/interfaces/libpq/pqsignal.h +++ b/src/interfaces/libpq/pqsignal.h @@ -6,7 +6,7 @@ * * Copyright (c) 1994, Regents of the University of California * - * $Id: pqsignal.h,v 1.3 1997/09/07 05:03:39 momjian Exp $ + * $Id: pqsignal.h,v 1.4 1997/09/08 02:40:38 momjian Exp $ * * NOTES * This shouldn't be in libpq, but the monitor and some other @@ -19,7 +19,7 @@ #include "c.h" -typedef void (*pqsigfunc) (int); +typedef void (*pqsigfunc) (int); extern pqsigfunc pqsignal(int signo, pqsigfunc func); diff --git a/src/test/examples/testlibpq.c b/src/test/examples/testlibpq.c index 97c1a1043e7..9cc3f463268 100644 --- a/src/test/examples/testlibpq.c +++ b/src/test/examples/testlibpq.c @@ -16,22 +16,22 @@ exit_nicely(PGconn * conn) main() { - char *pghost, - *pgport, - *pgoptions, - *pgtty; - char *dbName; - int nFields; - int i, - j; + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + int nFields; + int i, + j; #ifdef DEBUG - FILE *debug; + FILE *debug; #endif /* DEBUG */ - PGconn *conn; - PGresult *res; + PGconn *conn; + PGresult *res; /* * begin, by setting the parameters for a backend connection if the diff --git a/src/test/examples/testlibpq2.c b/src/test/examples/testlibpq2.c index d38ea1e906e..7ee09a7e024 100644 --- a/src/test/examples/testlibpq2.c +++ b/src/test/examples/testlibpq2.c @@ -30,18 +30,18 @@ exit_nicely(PGconn * conn) main() { - char *pghost, - *pgport, - *pgoptions, - *pgtty; - char *dbName; - int nFields; - int i, - j; - - PGconn *conn; - PGresult *res; - PGnotify *notify; + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + int nFields; + int i, + j; + + PGconn *conn; + PGresult *res; + PGnotify *notify; /* * begin, by setting the parameters for a backend connection if the diff --git a/src/test/examples/testlibpq3.c b/src/test/examples/testlibpq3.c index 16035585fed..4b75763b5f0 100644 --- a/src/test/examples/testlibpq3.c +++ b/src/test/examples/testlibpq3.c @@ -39,20 +39,20 @@ exit_nicely(PGconn * conn) main() { - char *pghost, - *pgport, - *pgoptions, - *pgtty; - char *dbName; - int nFields; - int i, - j; - int i_fnum, - d_fnum, - p_fnum; - - PGconn *conn; - PGresult *res; + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName; + int nFields; + int i, + j; + int i_fnum, + d_fnum, + p_fnum; + + PGconn *conn; + PGresult *res; /* * begin, by setting the parameters for a backend connection if the @@ -132,10 +132,10 @@ main() } for (i = 0; i < PQntuples(res); i++) { - int *ival; - float *dval; - int plen; - POLYGON *pval; + int *ival; + float *dval; + int plen; + POLYGON *pval; /* we hard-wire this to the 3 fields we know about */ ival = (int *) PQgetvalue(res, i, i_fnum); diff --git a/src/test/examples/testlibpq4.c b/src/test/examples/testlibpq4.c index 1d6c8f78856..5b0c4196487 100644 --- a/src/test/examples/testlibpq4.c +++ b/src/test/examples/testlibpq4.c @@ -32,21 +32,21 @@ check_conn(PGconn * conn) main() { - char *pghost, - *pgport, - *pgoptions, - *pgtty; - char *dbName1, - dbName2; - char *tblName; - int nFields; - int i, - j; - - PGconn *conn1, - conn2; - PGresult *res1, - res2; + char *pghost, + *pgport, + *pgoptions, + *pgtty; + char *dbName1, + dbName2; + char *tblName; + int nFields; + int i, + j; + + PGconn *conn1, + conn2; + PGresult *res1, + res2; if (argc != 4) { diff --git a/src/test/examples/testlo.c b/src/test/examples/testlo.c index ef207e373d3..676dfe20a21 100644 --- a/src/test/examples/testlo.c +++ b/src/test/examples/testlo.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/test/examples/testlo.c,v 1.4 1997/09/07 05:04:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/examples/testlo.c,v 1.5 1997/09/08 02:40:51 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,12 +31,12 @@ Oid importFile(PGconn * conn, char *filename) { - Oid lobjId; - int lobj_fd; - char buf[BUFSIZE]; - int nbytes, - tmp; - int fd; + Oid lobjId; + int lobj_fd; + char buf[BUFSIZE]; + int nbytes, + tmp; + int fd; /* * open the file to be read in @@ -79,10 +79,10 @@ importFile(PGconn * conn, char *filename) void pickout(PGconn * conn, Oid lobjId, int start, int len) { - int lobj_fd; - char *buf; - int nbytes; - int nread; + int lobj_fd; + char *buf; + int nbytes; + int nread; lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) @@ -109,11 +109,11 @@ pickout(PGconn * conn, Oid lobjId, int start, int len) void overwrite(PGconn * conn, Oid lobjId, int start, int len) { - int lobj_fd; - char *buf; - int nbytes; - int nwritten; - int i; + int lobj_fd; + char *buf; + int nbytes; + int nwritten; + int i; lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) @@ -148,11 +148,11 @@ overwrite(PGconn * conn, Oid lobjId, int start, int len) void exportFile(PGconn * conn, Oid lobjId, char *filename) { - int lobj_fd; - char buf[BUFSIZE]; - int nbytes, - tmp; - int fd; + int lobj_fd; + char buf[BUFSIZE]; + int nbytes, + tmp; + int fd; /* * create an inversion "object" @@ -203,12 +203,12 @@ exit_nicely(PGconn * conn) int main(int argc, char **argv) { - char *in_filename, - *out_filename; - char *database; - Oid lobjOid; - PGconn *conn; - PGresult *res; + char *in_filename, + *out_filename; + char *database; + Oid lobjOid; + PGconn *conn; + PGresult *res; if (argc != 4) { diff --git a/src/test/examples/testlo2.c b/src/test/examples/testlo2.c index f915a3ba3eb..adaad5df00a 100644 --- a/src/test/examples/testlo2.c +++ b/src/test/examples/testlo2.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/test/examples/Attic/testlo2.c,v 1.3 1997/09/07 05:04:08 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/examples/Attic/testlo2.c,v 1.4 1997/09/08 02:40:52 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -25,12 +25,12 @@ Oid importFile(PGconn * conn, char *filename) { - Oid lobjId; - int lobj_fd; - char buf[BUFSIZE]; - int nbytes, - tmp; - int fd; + Oid lobjId; + int lobj_fd; + char buf[BUFSIZE]; + int nbytes, + tmp; + int fd; /* * open the file to be read in @@ -73,10 +73,10 @@ importFile(PGconn * conn, char *filename) void pickout(PGconn * conn, Oid lobjId, int start, int len) { - int lobj_fd; - char *buf; - int nbytes; - int nread; + int lobj_fd; + char *buf; + int nbytes; + int nread; lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) @@ -103,11 +103,11 @@ pickout(PGconn * conn, Oid lobjId, int start, int len) void overwrite(PGconn * conn, Oid lobjId, int start, int len) { - int lobj_fd; - char *buf; - int nbytes; - int nwritten; - int i; + int lobj_fd; + char *buf; + int nbytes; + int nwritten; + int i; lobj_fd = lo_open(conn, lobjId, INV_READ); if (lobj_fd < 0) @@ -142,11 +142,11 @@ overwrite(PGconn * conn, Oid lobjId, int start, int len) void exportFile(PGconn * conn, Oid lobjId, char *filename) { - int lobj_fd; - char buf[BUFSIZE]; - int nbytes, - tmp; - int fd; + int lobj_fd; + char buf[BUFSIZE]; + int nbytes, + tmp; + int fd; /* * create an inversion "object" @@ -197,12 +197,12 @@ exit_nicely(PGconn * conn) int main(int argc, char **argv) { - char *in_filename, - *out_filename; - char *database; - Oid lobjOid; - PGconn *conn; - PGresult *res; + char *in_filename, + *out_filename; + char *database; + Oid lobjOid; + PGconn *conn; + PGresult *res; if (argc != 4) { diff --git a/src/test/regress/regress.c b/src/test/regress/regress.c index ceace603781..d6b2fe246f6 100644 --- a/src/test/regress/regress.c +++ b/src/test/regress/regress.c @@ -1,5 +1,5 @@ /* - * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.10 1997/09/07 05:04:10 momjian Exp $ + * $Header: /cvsroot/pgsql/src/test/regress/regress.c,v 1.11 1997/09/08 02:40:56 momjian Exp $ */ #include <float.h> /* faked on sunos */ @@ -16,74 +16,74 @@ #define RDELIM ')' #define DELIM ',' -typedef void *TUPLE; +typedef void *TUPLE; -extern double *regress_dist_ptpath(Point * pt, PATH * path); -extern double *regress_path_dist(PATH * p1, PATH * p2); -extern PATH *poly2path(POLYGON * poly); -extern Point *interpt_pp(PATH * p1, PATH * p2); -extern void regress_lseg_construct(LSEG * lseg, Point * pt1, Point * pt2); -extern char overpaid(TUPLE tuple); -extern int boxarea(BOX * box); -extern char *reverse_c16(char *string); +extern double *regress_dist_ptpath(Point * pt, PATH * path); +extern double *regress_path_dist(PATH * p1, PATH * p2); +extern PATH *poly2path(POLYGON * poly); +extern Point *interpt_pp(PATH * p1, PATH * p2); +extern void regress_lseg_construct(LSEG * lseg, Point * pt1, Point * pt2); +extern char overpaid(TUPLE tuple); +extern int boxarea(BOX * box); +extern char *reverse_c16(char *string); /* ** Distance from a point to a path */ -double * +double * regress_dist_ptpath(pt, path) -Point *pt; -PATH *path; +Point *pt; +PATH *path; { - double *result; - double *tmp; - int i; - LSEG lseg; + double *result; + double *tmp; + int i; + LSEG lseg; switch (path->npts) { - case 0: - result = PALLOCTYPE(double); - *result = Abs((double) DBL_MAX); /* +infinity */ - break; - case 1: - result = point_distance(pt, &path->p[0]); - break; - default: - - /* - * the distance from a point to a path is the smallest distance - * from the point to any of its constituent segments. - */ - Assert(path->npts > 1); - result = PALLOCTYPE(double); - for (i = 0; i < path->npts - 1; ++i) - { - regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]); - tmp = dist_ps(pt, &lseg); - if (i == 0 || *tmp < *result) - *result = *tmp; - PFREE(tmp); - - } - break; + case 0: + result = PALLOCTYPE(double); + *result = Abs((double) DBL_MAX); /* +infinity */ + break; + case 1: + result = point_distance(pt, &path->p[0]); + break; + default: + + /* + * the distance from a point to a path is the smallest + * distance from the point to any of its constituent segments. + */ + Assert(path->npts > 1); + result = PALLOCTYPE(double); + for (i = 0; i < path->npts - 1; ++i) + { + regress_lseg_construct(&lseg, &path->p[i], &path->p[i + 1]); + tmp = dist_ps(pt, &lseg); + if (i == 0 || *tmp < *result) + *result = *tmp; + PFREE(tmp); + + } + break; } return (result); } /* this essentially does a cartesian product of the lsegs in the two paths, and finds the min distance between any two lsegs */ -double * +double * regress_path_dist(p1, p2) -PATH *p1; -PATH *p2; +PATH *p1; +PATH *p2; { - double *min, - *tmp; - int i, - j; - LSEG seg1, - seg2; + double *min, + *tmp; + int i, + j; + LSEG seg1, + seg2; regress_lseg_construct(&seg1, &p1->p[0], &p1->p[1]); regress_lseg_construct(&seg2, &p2->p[0], &p2->p[1]); @@ -103,13 +103,13 @@ PATH *p2; return (min); } -PATH * +PATH * poly2path(poly) -POLYGON *poly; +POLYGON *poly; { - int i; - char *output = (char *) PALLOC(2 * (P_MAXDIG + 1) * poly->npts + 64); - char buf[2 * (P_MAXDIG) + 20]; + int i; + char *output = (char *) PALLOC(2 * (P_MAXDIG + 1) * poly->npts + 64); + char buf[2 * (P_MAXDIG) + 20]; sprintf(output, "(1, %*d", P_MAXDIG, poly->npts); @@ -125,23 +125,23 @@ POLYGON *poly; } /* return the point where two paths intersect. Assumes that they do. */ -Point * +Point * interpt_pp(p1, p2) -PATH *p1; -PATH *p2; +PATH *p1; +PATH *p2; { - Point *retval; - int i, - j; - LSEG seg1, - seg2; + Point *retval; + int i, + j; + LSEG seg1, + seg2; #if FALSE - LINE *ln; + LINE *ln; #endif - bool found; /* We've found the intersection */ + bool found; /* We've found the intersection */ found = false; /* Haven't found it yet */ @@ -167,9 +167,9 @@ PATH *p2; /* like lseg_construct, but assume space already allocated */ void regress_lseg_construct(lseg, pt1, pt2) -LSEG *lseg; -Point *pt1; -Point *pt2; +LSEG *lseg; +Point *pt1; +Point *pt2; { lseg->p[0].x = pt1->x; lseg->p[0].y = pt1->y; @@ -181,10 +181,10 @@ Point *pt2; char overpaid(tuple) -TUPLE tuple; +TUPLE tuple; { - bool isnull; - long salary; + bool isnull; + long salary; salary = (long) GetAttributeByName(tuple, "salary", &isnull); return (salary > 699); @@ -197,25 +197,25 @@ TUPLE tuple; typedef struct { - Point center; - double radius; -} WIDGET; + Point center; + double radius; +} WIDGET; -WIDGET *widget_in(char *str); -char *widget_out(WIDGET * widget); -int pt_in_widget(Point * point, WIDGET * widget); +WIDGET *widget_in(char *str); +char *widget_out(WIDGET * widget); +int pt_in_widget(Point * point, WIDGET * widget); #define NARGS 3 -WIDGET * +WIDGET * widget_in(str) -char *str; +char *str; { - char *p, - *coord[NARGS], - buf2[1000]; - int i; - WIDGET *result; + char *p, + *coord[NARGS], + buf2[1000]; + int i; + WIDGET *result; if (str == NULL) return (NULL); @@ -234,11 +234,11 @@ char *str; return (result); } -char * +char * widget_out(widget) -WIDGET *widget; +WIDGET *widget; { - char *result; + char *result; if (widget == NULL) return (NULL); @@ -251,10 +251,10 @@ WIDGET *widget; int pt_in_widget(point, widget) -Point *point; -WIDGET *widget; +Point *point; +WIDGET *widget; { - extern double point_dt(); + extern double point_dt(); return (point_dt(point, &widget->center) < widget->radius); } @@ -264,24 +264,24 @@ WIDGET *widget; int boxarea(box) -BOX *box; +BOX *box; { - int width, - height; + int width, + height; width = ABS(box->high.x - box->low.x); height = ABS(box->high.y - box->low.y); return (width * height); } -char * +char * reverse_c16(string) -char *string; +char *string; { - register i; - int len; - char *new_string; + register i; + int len; + char *new_string; if (!(new_string = palloc(16))) { diff --git a/src/tools/entab/entab.c b/src/tools/entab/entab.c index b11b84989e9..5aa94e6abf0 100644 --- a/src/tools/entab/entab.c +++ b/src/tools/entab/entab.c @@ -21,33 +21,33 @@ #define FALSE 0 #endif -void halt(); +void halt(); -extern char *optarg; -extern int optind; +extern char *optarg; +extern int optind; int main(argc, argv) -int argc; -char **argv; +int argc; +char **argv; { - int tab_size = 8, - min_spaces = 2, - protect_quotes = FALSE, - del_tabs = FALSE, - clip_lines = FALSE, - prv_spaces, - col_in_tab, - escaped, - nxt_spaces; - char in_line[BUFSIZ], - out_line[BUFSIZ], - *src, - *dst, - quote_char, - ch, - *cp; - FILE *in_file; + int tab_size = 8, + min_spaces = 2, + protect_quotes = FALSE, + del_tabs = FALSE, + clip_lines = FALSE, + prv_spaces, + col_in_tab, + escaped, + nxt_spaces; + char in_line[BUFSIZ], + out_line[BUFSIZ], + *src, + *dst, + quote_char, + ch, + *cp; + FILE *in_file; if ((cp = strrchr(argv[0], '/')) != NULL) ++cp; @@ -59,30 +59,30 @@ char **argv; while ((ch = getopt(argc, argv, "cdhqs:t:")) != -1) switch (ch) { - case 'c': - clip_lines = TRUE; - break; - case 'd': - del_tabs = TRUE; - break; - case 'q': - protect_quotes = TRUE; - break; - case 's': - min_spaces = atoi(optarg); - break; - case 't': - tab_size = atoi(optarg); - break; - case 'h': - case '?': - halt("USAGE: %s [ -cdqst ] [file ...]\n\ + case 'c': + clip_lines = TRUE; + break; + case 'd': + del_tabs = TRUE; + break; + case 'q': + protect_quotes = TRUE; + break; + case 's': + min_spaces = atoi(optarg); + break; + case 't': + tab_size = atoi(optarg); + break; + case 'h': + case '?': + halt("USAGE: %s [ -cdqst ] [file ...]\n\ -c (clip trailing whitespace)\n\ -d (delete tabs)\n\ -q (protect quotes)\n\ -s minimum_spaces\n\ -t tab_width\n", - cp); + cp); } argv += optind; diff --git a/src/tools/entab/halt.c b/src/tools/entab/halt.c index 5d48f58152e..c7b9ab6bb95 100644 --- a/src/tools/entab/halt.c +++ b/src/tools/entab/halt.c @@ -22,10 +22,10 @@ void halt(va_alist) va_dcl { - va_list arg_ptr; - char *format, - *pstr; - void (*sig_func) (); + va_list arg_ptr; + char *format, + *pstr; + void (*sig_func) (); va_start(arg_ptr); format = va_arg(arg_ptr, char *); diff --git a/src/tutorial/C-code/beard.c b/src/tutorial/C-code/beard.c index 31b83e97e87..f6f01a57582 100644 --- a/src/tutorial/C-code/beard.c +++ b/src/tutorial/C-code/beard.c @@ -7,15 +7,15 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/tutorial/C-code/Attic/beard.c,v 1.2 1997/09/07 05:04:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/tutorial/C-code/Attic/beard.c,v 1.3 1997/09/08 02:41:09 momjian Exp $ * *------------------------------------------------------------------------- */ typedef struct ImageHdr { - int size; -} ImageHdr; + int size; +} ImageHdr; #define BUFSIZE 10 @@ -26,12 +26,12 @@ typedef struct ImageHdr Oid beard(Oid picture) { - Oid beard; - int pic_fd, - beard_fd; - ImageHdr ihdr; - char buf[BUFSIZE]; - int cc; + Oid beard; + int pic_fd, + beard_fd; + ImageHdr ihdr; + char buf[BUFSIZE]; + int cc; if ((pic_fd = lo_open(picture, INV_READ)) == -1) elog(WARN, "Cannot access picture large object"); diff --git a/src/tutorial/C-code/complex.c b/src/tutorial/C-code/complex.c index 1041ff5ff71..63ebd1cba5a 100644 --- a/src/tutorial/C-code/complex.c +++ b/src/tutorial/C-code/complex.c @@ -14,34 +14,34 @@ typedef struct Complex { - double x; - double y; -} Complex; + double x; + double y; +} Complex; /* These prototypes declare the requirements that Postgres places on these user written functions. */ -Complex *complex_in(char *str); -char *complex_out(Complex * complex); -Complex *complex_add(Complex * a, Complex * b); -bool complex_abs_lt(Complex * a, Complex * b); -bool complex_abs_le(Complex * a, Complex * b); -bool complex_abs_eq(Complex * a, Complex * b); -bool complex_abs_ge(Complex * a, Complex * b); -bool complex_abs_gt(Complex * a, Complex * b); -int4 complex_abs_cmp(Complex * a, Complex * b); +Complex *complex_in(char *str); +char *complex_out(Complex * complex); +Complex *complex_add(Complex * a, Complex * b); +bool complex_abs_lt(Complex * a, Complex * b); +bool complex_abs_le(Complex * a, Complex * b); +bool complex_abs_eq(Complex * a, Complex * b); +bool complex_abs_ge(Complex * a, Complex * b); +bool complex_abs_gt(Complex * a, Complex * b); +int4 complex_abs_cmp(Complex * a, Complex * b); /***************************************************************************** * Input/Output functions *****************************************************************************/ -Complex * +Complex * complex_in(char *str) { - double x, - y; - Complex *result; + double x, + y; + Complex *result; if (sscanf(str, " ( %lf , %lf )", &x, &y) != 2) { @@ -62,10 +62,10 @@ complex_in(char *str) * pointer. POSTGRES thinks all output functions are: * char *out_func(char *); */ -char * +char * complex_out(Complex * complex) { - char *result; + char *result; if (complex == NULL) return (NULL); @@ -79,10 +79,10 @@ complex_out(Complex * complex) * New Operators *****************************************************************************/ -Complex * +Complex * complex_add(Complex * a, Complex * b) { - Complex *result; + Complex *result; result = (Complex *) palloc(sizeof(Complex)); result->x = a->x + b->x; @@ -100,8 +100,8 @@ complex_add(Complex * a, Complex * b) bool complex_abs_lt(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); return (amag < bmag); } @@ -109,8 +109,8 @@ complex_abs_lt(Complex * a, Complex * b) bool complex_abs_le(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); return (amag <= bmag); } @@ -118,8 +118,8 @@ complex_abs_le(Complex * a, Complex * b) bool complex_abs_eq(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); return (amag == bmag); } @@ -127,8 +127,8 @@ complex_abs_eq(Complex * a, Complex * b) bool complex_abs_ge(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); return (amag >= bmag); } @@ -136,8 +136,8 @@ complex_abs_ge(Complex * a, Complex * b) bool complex_abs_gt(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); return (amag > bmag); } @@ -145,8 +145,8 @@ complex_abs_gt(Complex * a, Complex * b) int4 complex_abs_cmp(Complex * a, Complex * b) { - double amag = Mag(a), - bmag = Mag(b); + double amag = Mag(a), + bmag = Mag(b); if (amag < bmag) return -1; @@ -166,12 +166,12 @@ complex_abs_cmp(Complex * a, Complex * b) * POSTGRES crashing, it is impossible to tell whether the bug is in your * code or POSTGRES's. */ -void test_main(void); +void test_main(void); void test_main() { - Complex *a; - Complex *b; + Complex *a; + Complex *b; a = complex_in("(4.01, 3.77 )"); printf("a = %s\n", complex_out(a)); diff --git a/src/tutorial/C-code/funcs.c b/src/tutorial/C-code/funcs.c index 989787e45ea..219a87c9472 100644 --- a/src/tutorial/C-code/funcs.c +++ b/src/tutorial/C-code/funcs.c @@ -17,9 +17,10 @@ Postgres in his CREATE FUNCTION statement. */ -int add_one(int arg); -char16 *concat16(char16 * arg1, char16 * arg2); -text *copytext(text * t); +int add_one(int arg); +char16 *concat16(char16 * arg1, char16 * arg2); +text *copytext(text * t); + bool c_overpaid(TUPLE t, /* the current instance of EMP */ int4 limit); @@ -32,24 +33,24 @@ add_one(int arg) return (arg + 1); } -char16 * +char16 * concat16(char16 * arg1, char16 * arg2) { - char16 *new_c16 = (char16 *) palloc(sizeof(char16)); + char16 *new_c16 = (char16 *) palloc(sizeof(char16)); memset(new_c16, 0, sizeof(char16)); strncpy((char *) new_c16, (char *) arg1, 16); return (char16 *) (strncat((char *) new_c16, (char *) arg2, 16)); } -text * +text * copytext(text * t) { /* * VARSIZE is the total size of the struct in bytes. */ - text *new_t = (text *) palloc(VARSIZE(t)); + text *new_t = (text *) palloc(VARSIZE(t)); memset(new_t, 0, VARSIZE(t)); @@ -69,8 +70,8 @@ bool c_overpaid(TUPLE t, /* the current instance of EMP */ int4 limit) { - bool isnull = false; - int4 salary; + bool isnull = false; + int4 salary; salary = (int4) GetAttributeByName(t, "salary", &isnull); diff --git a/src/utils/strdup.c b/src/utils/strdup.c index 762e2365c75..1330b977129 100644 --- a/src/utils/strdup.c +++ b/src/utils/strdup.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/utils/Attic/strdup.c,v 1.3 1997/09/07 05:04:45 momjian Exp $ + * $Header: /cvsroot/pgsql/src/utils/Attic/strdup.c,v 1.4 1997/09/08 02:41:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -15,10 +15,10 @@ #include <stdlib.h> #include "strdup.h" -char * +char * strdup(char const * string) { - char *nstr; + char *nstr; nstr = strcpy((char *) malloc(strlen(string) + 1), string); return nstr; diff --git a/src/utils/version.c b/src/utils/version.c index 9d7c75556b9..193668b68c3 100644 --- a/src/utils/version.c +++ b/src/utils/version.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.7 1997/09/07 05:04:48 momjian Exp $ + * $Header: /cvsroot/pgsql/src/utils/Attic/version.c,v 1.8 1997/09/08 02:41:22 momjian Exp $ * * NOTES * XXX eventually, should be able to handle version identifiers @@ -62,9 +62,9 @@ ValidatePgVersion(const char *path, char **reason_p) fill it with a text string explaining how it isn't compatible (or why we can't tell), and return a pointer to that space as <*reason_p>. -----------------------------------------------------------------------------*/ - int fd; - char version[4]; - char full_path[MAXPGPATH + 1]; + int fd; + char version[4]; + char full_path[MAXPGPATH + 1]; PathSetVersionFilePath(path, full_path); @@ -117,9 +117,9 @@ SetPgVersion(const char *path, char **reason_p) and return a pointer to that storage as <*reason_p>. If we succeed, return *reason_p = NULL. ---------------------------------------------------------------------------*/ - int fd; - char version[4]; - char full_path[MAXPGPATH + 1]; + int fd; + char version[4]; + char full_path[MAXPGPATH + 1]; PathSetVersionFilePath(path, full_path); @@ -133,7 +133,7 @@ SetPgVersion(const char *path, char **reason_p) } else { - int rc; /* return code from some function we call */ + int rc; /* return code from some function we call */ version[0] = '0' + PG_RELEASE; version[1] = '.'; |