diff options
Diffstat (limited to 'src/backend')
233 files changed, 6323 insertions, 5893 deletions
diff --git a/src/backend/access/common/heaptuple.c b/src/backend/access/common/heaptuple.c index 884db0ad21..9901965a48 100644 --- a/src/backend/access/common/heaptuple.c +++ b/src/backend/access/common/heaptuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.81 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/heaptuple.c,v 1.82 2002/09/04 20:31:08 momjian Exp $ * * NOTES * The old interface functions have been converted to macros @@ -326,9 +326,9 @@ nocachegetattr(HeapTuple tuple, /* * If slow is false, and we got here, we know that we have a tuple - * with no nulls or var-widths before the target attribute. If possible, - * we also want to initialize the remainder of the attribute cached - * offset values. + * with no nulls or var-widths before the target attribute. If + * possible, we also want to initialize the remainder of the attribute + * cached offset values. */ if (!slow) { @@ -702,8 +702,8 @@ heap_modifytuple(HeapTuple tuple, nulls); /* - * copy the identification info of the old tuple: t_ctid, t_self, - * and OID (if any) + * copy the identification info of the old tuple: t_ctid, t_self, and + * OID (if any) */ newTuple->t_data->t_ctid = tuple->t_data->t_ctid; newTuple->t_self = tuple->t_self; diff --git a/src/backend/access/common/indextuple.c b/src/backend/access/common/indextuple.c index 2fbc5dd0b1..30bbc4e354 100644 --- a/src/backend/access/common/indextuple.c +++ b/src/backend/access/common/indextuple.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.59 2002/08/25 17:20:00 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/indextuple.c,v 1.60 2002/09/04 20:31:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -319,9 +319,9 @@ nocache_index_getattr(IndexTuple tup, /* * If slow is false, and we got here, we know that we have a tuple - * with no nulls or var-widths before the target attribute. If possible, - * we also want to initialize the remainder of the attribute cached - * offset values. + * with no nulls or var-widths before the target attribute. If + * possible, we also want to initialize the remainder of the attribute + * cached offset values. */ if (!slow) { diff --git a/src/backend/access/common/printtup.c b/src/backend/access/common/printtup.c index db4187dba4..f1f96f1886 100644 --- a/src/backend/access/common/printtup.c +++ b/src/backend/access/common/printtup.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.64 2002/08/24 15:00:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/printtup.c,v 1.65 2002/09/04 20:31:08 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -23,7 +23,7 @@ static void printtup_setup(DestReceiver *self, int operation, - const char *portalName, TupleDesc typeinfo); + const char *portalName, TupleDesc typeinfo); static void printtup(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self); static void printtup_internal(HeapTuple tuple, TupleDesc typeinfo, DestReceiver *self); static void printtup_cleanup(DestReceiver *self); @@ -88,8 +88,8 @@ printtup_setup(DestReceiver *self, int operation, pq_puttextmessage('P', portalName); /* - * if this is a retrieve, then we send back the tuple - * descriptor of the tuples. + * if this is a retrieve, then we send back the tuple descriptor of + * the tuples. */ if (operation == CMD_SELECT) { @@ -100,7 +100,7 @@ printtup_setup(DestReceiver *self, int operation, pq_beginmessage(&buf); pq_sendbyte(&buf, 'T'); /* tuple descriptor message type */ - pq_sendint(&buf, natts, 2); /* # of attrs in tuples */ + pq_sendint(&buf, natts, 2); /* # of attrs in tuples */ for (i = 0; i < natts; ++i) { diff --git a/src/backend/access/common/tupdesc.c b/src/backend/access/common/tupdesc.c index 6d6cdf38ce..ce4452eec5 100644 --- a/src/backend/access/common/tupdesc.c +++ b/src/backend/access/common/tupdesc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.88 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/common/tupdesc.c,v 1.89 2002/09/04 20:31:09 momjian Exp $ * * NOTES * some of the executor utility code such as "ExecTypeFromTL" should be @@ -114,8 +114,8 @@ CreateTupleDescCopy(TupleDesc tupdesc) { desc->attrs[i] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE); memcpy(desc->attrs[i], - tupdesc->attrs[i], - ATTRIBUTE_TUPLE_SIZE); + tupdesc->attrs[i], + ATTRIBUTE_TUPLE_SIZE); desc->attrs[i]->attnotnull = false; desc->attrs[i]->atthasdef = false; } @@ -148,8 +148,8 @@ CreateTupleDescCopyConstr(TupleDesc tupdesc) { desc->attrs[i] = (Form_pg_attribute) palloc(ATTRIBUTE_TUPLE_SIZE); memcpy(desc->attrs[i], - tupdesc->attrs[i], - ATTRIBUTE_TUPLE_SIZE); + tupdesc->attrs[i], + ATTRIBUTE_TUPLE_SIZE); } if (constr) { @@ -425,9 +425,8 @@ TupleDescInitEntry(TupleDesc desc, * * (Why not just make the atttypid point to the OID type, instead of the * type the query returns? Because the executor uses the atttypid to - * tell the front end what type will be returned, - * and in the end the type returned will be the result of the query, - * not an OID.) + * tell the front end what type will be returned, and in the end the + * type returned will be the result of the query, not an OID.) * * (Why not wait until the return type of the set is known (i.e., the * recursive call to the executor to execute the set has returned) diff --git a/src/backend/access/gist/gist.c b/src/backend/access/gist/gist.c index 2849ca31ec..c238ea273e 100644 --- a/src/backend/access/gist/gist.c +++ b/src/backend/access/gist/gist.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.95 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gist.c,v 1.96 2002/09/04 20:31:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -294,6 +294,7 @@ gistinsert(PG_FUNCTION_ARGS) Datum *datum = (Datum *) PG_GETARG_POINTER(1); char *nulls = (char *) PG_GETARG_POINTER(2); ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3); + #ifdef NOT_USED Relation heapRel = (Relation) PG_GETARG_POINTER(4); bool checkUnique = PG_GETARG_BOOL(5); @@ -494,13 +495,13 @@ gistlayerinsert(Relation r, BlockNumber blkno, /* key is modified, so old version must be deleted */ ItemPointerSet(&oldtid, blkno, child); gistdelete(r, &oldtid); - + /* - * if child was splitted, new key for child will be inserted - * in the end list of child, so we must say to any scans - * that page is changed beginning from 'child' offset + * if child was splitted, new key for child will be inserted in + * the end list of child, so we must say to any scans that page is + * changed beginning from 'child' offset */ - if ( ret & SPLITED ) + if (ret & SPLITED) gistadjscans(r, GISTOP_SPLIT, blkno, child); } @@ -615,7 +616,7 @@ gistwritebuffer(Relation r, Page page, IndexTuple *itup, static int gistnospace(Page page, IndexTuple *itvec, int len) { - unsigned int size = 0; + unsigned int size = 0; int i; for (i = 0; i < len; i++) @@ -679,7 +680,7 @@ gistunion(Relation r, IndexTuple *itvec, int len, GISTSTATE *giststate) needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool)); /* workaround for 64-bit: ensure GISTENTRY array is maxaligned */ - storage = (char*)palloc( ((len == 1) ? 2 : len) * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); + storage = (char *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); evec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ); for (j = 0; j < r->rd_att->natts; j++) @@ -786,7 +787,7 @@ gistgetadjusted(Relation r, IndexTuple oldtup, IndexTuple addtup, GISTSTATE *gis int j; /* workaround for 64-bit: ensure GISTENTRY array is maxaligned */ - storage = (char*) palloc( 2 * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); + storage = (char *) palloc(2 * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); evec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ); VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ; ev0p = &((GISTENTRY *) VARDATA(evec))[0]; @@ -911,7 +912,7 @@ gistunionsubkey(Relation r, GISTSTATE *giststate, IndexTuple *itvec, GIST_SPLITV needfree = (bool *) palloc(((len == 1) ? 2 : len) * sizeof(bool)); /* workaround for 64-bit: ensure GISTENTRY array is maxaligned */ - storage = (char*)palloc( ((len == 1) ? 2 : len) * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); + storage = (char *) palloc(((len == 1) ? 2 : len) * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); evec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ); for (j = 1; j < r->rd_att->natts; j++) @@ -1098,7 +1099,7 @@ gistadjsubkey(Relation r, v->spl_nright = curlen; /* workaround for 64-bit: ensure GISTENTRY array is maxaligned */ - storage = (char*)palloc( 2 * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); + storage = (char *) palloc(2 * sizeof(GISTENTRY) + MAXALIGN(VARHDRSZ)); evec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ); VARATT_SIZEP(evec) = 2 * sizeof(GISTENTRY) + VARHDRSZ; ev0p = &((GISTENTRY *) VARDATA(evec))[0]; @@ -1276,7 +1277,7 @@ gistSplit(Relation r, /* workaround for 64-bit: ensure GISTENTRY array is maxaligned */ storage = palloc(MAXALIGN(VARHDRSZ) + (*len + 1) * sizeof(GISTENTRY)); entryvec = (bytea *) (storage + MAXALIGN(VARHDRSZ) - VARHDRSZ); - decompvec = (bool *) palloc( (*len + 1) * sizeof(bool)); + decompvec = (bool *) palloc((*len + 1) * sizeof(bool)); VARATT_SIZEP(entryvec) = (*len + 1) * sizeof(GISTENTRY) + VARHDRSZ; for (i = 1; i <= *len; i++) { diff --git a/src/backend/access/gist/gistget.c b/src/backend/access/gist/gistget.c index aaa26b41d2..2f5801fe78 100644 --- a/src/backend/access/gist/gistget.c +++ b/src/backend/access/gist/gistget.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.34 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/gist/gistget.c,v 1.35 2002/09/04 20:31:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,7 +33,7 @@ gistgettuple(PG_FUNCTION_ARGS) { IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1); - bool res; + bool res; /* if we have it cached in the scan desc, just return the value */ if (gistscancache(s, dir)) diff --git a/src/backend/access/hash/hash.c b/src/backend/access/hash/hash.c index 9a6ca258bc..3a75265f01 100644 --- a/src/backend/access/hash/hash.c +++ b/src/backend/access/hash/hash.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.59 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hash.c,v 1.60 2002/09/04 20:31:09 momjian Exp $ * * NOTES * This file contains only the public interface routines. @@ -164,6 +164,7 @@ hashinsert(PG_FUNCTION_ARGS) Datum *datum = (Datum *) PG_GETARG_POINTER(1); char *nulls = (char *) PG_GETARG_POINTER(2); ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3); + #ifdef NOT_USED Relation heapRel = (Relation) PG_GETARG_POINTER(4); bool checkUnique = PG_GETARG_BOOL(5); @@ -213,7 +214,7 @@ hashgettuple(PG_FUNCTION_ARGS) HashScanOpaque so = (HashScanOpaque) scan->opaque; Page page; OffsetNumber offnum; - bool res; + bool res; /* * If we've already initialized this scan, we can just advance it in @@ -228,18 +229,21 @@ hashgettuple(PG_FUNCTION_ARGS) if (scan->kill_prior_tuple) { /* - * Yes, so mark it by setting the LP_DELETE bit in the item flags. + * Yes, so mark it by setting the LP_DELETE bit in the item + * flags. */ offnum = ItemPointerGetOffsetNumber(&(scan->currentItemData)); page = BufferGetPage(so->hashso_curbuf); PageGetItemId(page, offnum)->lp_flags |= LP_DELETE; + /* * Since this can be redone later if needed, it's treated the - * same as a commit-hint-bit status update for heap tuples: - * we mark the buffer dirty but don't make a WAL log entry. + * same as a commit-hint-bit status update for heap tuples: we + * mark the buffer dirty but don't make a WAL log entry. */ SetBufferCommitInfoNeedsSave(so->hashso_curbuf); } + /* * Now continue the scan. */ diff --git a/src/backend/access/hash/hashfunc.c b/src/backend/access/hash/hashfunc.c index fb58bccf00..e6595de072 100644 --- a/src/backend/access/hash/hashfunc.c +++ b/src/backend/access/hash/hashfunc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.34 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashfunc.c,v 1.35 2002/09/04 20:31:09 momjian Exp $ * * NOTES * These functions are stored in pg_amproc. For each operator class @@ -96,7 +96,8 @@ hashname(PG_FUNCTION_ARGS) char *key = NameStr(*PG_GETARG_NAME(0)); int keylen = strlen(key); - Assert(keylen < NAMEDATALEN); /* else it's not truncated correctly */ + Assert(keylen < NAMEDATALEN); /* else it's not truncated + * correctly */ return hash_any((unsigned char *) key, keylen); } @@ -134,9 +135,9 @@ hashvarlena(PG_FUNCTION_ARGS) * high bits or all three low bits, whether the original value of a,b,c * is almost all zero or is uniformly distributed, * - If mix() is run forward or backward, at least 32 bits in a,b,c - * have at least 1/4 probability of changing. + * have at least 1/4 probability of changing. * - If mix() is run forward, every bit of c will change between 1/3 and - * 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) + * 2/3 of the time. (Well, 22/100 and 78/100 for some 2-bit deltas.) *---------- */ #define mix(a,b,c) \ @@ -147,17 +148,17 @@ hashvarlena(PG_FUNCTION_ARGS) a -= b; a -= c; a ^= (c>>12); \ b -= c; b -= a; b ^= (a<<16); \ c -= a; c -= b; c ^= (b>>5); \ - a -= b; a -= c; a ^= (c>>3); \ + a -= b; a -= c; a ^= (c>>3); \ b -= c; b -= a; b ^= (a<<10); \ c -= a; c -= b; c ^= (b>>15); \ } /* * hash_any() -- hash a variable-length key into a 32-bit value - * k : the key (the unaligned variable-length array of bytes) - * len : the length of the key, counting by bytes + * k : the key (the unaligned variable-length array of bytes) + * len : the length of the key, counting by bytes * - * Returns a uint32 value. Every bit of the key affects every bit of + * Returns a uint32 value. Every bit of the key affects every bit of * the return value. Every 1-bit and 2-bit delta achieves avalanche. * About 6*len+35 instructions. The best hash table sizes are powers * of 2. There is no need to do mod a prime (mod is sooo slow!). @@ -166,7 +167,10 @@ hashvarlena(PG_FUNCTION_ARGS) Datum hash_any(register const unsigned char *k, register int keylen) { - register uint32 a,b,c,len; + register uint32 a, + b, + c, + len; /* Set up the internal state */ len = keylen; @@ -176,32 +180,44 @@ hash_any(register const unsigned char *k, register int keylen) /* handle most of the key */ while (len >= 12) { - a += (k[0] +((uint32)k[1]<<8) +((uint32)k[2]<<16) +((uint32)k[3]<<24)); - b += (k[4] +((uint32)k[5]<<8) +((uint32)k[6]<<16) +((uint32)k[7]<<24)); - c += (k[8] +((uint32)k[9]<<8) +((uint32)k[10]<<16)+((uint32)k[11]<<24)); - mix(a,b,c); - k += 12; len -= 12; + a += (k[0] + ((uint32) k[1] << 8) + ((uint32) k[2] << 16) + ((uint32) k[3] << 24)); + b += (k[4] + ((uint32) k[5] << 8) + ((uint32) k[6] << 16) + ((uint32) k[7] << 24)); + c += (k[8] + ((uint32) k[9] << 8) + ((uint32) k[10] << 16) + ((uint32) k[11] << 24)); + mix(a, b, c); + k += 12; + len -= 12; } /* handle the last 11 bytes */ c += keylen; switch (len) /* all the case statements fall through */ { - case 11: c+=((uint32)k[10]<<24); - case 10: c+=((uint32)k[9]<<16); - case 9 : c+=((uint32)k[8]<<8); + case 11: + c += ((uint32) k[10] << 24); + case 10: + c += ((uint32) k[9] << 16); + case 9: + c += ((uint32) k[8] << 8); /* the first byte of c is reserved for the length */ - case 8 : b+=((uint32)k[7]<<24); - case 7 : b+=((uint32)k[6]<<16); - case 6 : b+=((uint32)k[5]<<8); - case 5 : b+=k[4]; - case 4 : a+=((uint32)k[3]<<24); - case 3 : a+=((uint32)k[2]<<16); - case 2 : a+=((uint32)k[1]<<8); - case 1 : a+=k[0]; + case 8: + b += ((uint32) k[7] << 24); + case 7: + b += ((uint32) k[6] << 16); + case 6: + b += ((uint32) k[5] << 8); + case 5: + b += k[4]; + case 4: + a += ((uint32) k[3] << 24); + case 3: + a += ((uint32) k[2] << 16); + case 2: + a += ((uint32) k[1] << 8); + case 1: + a += k[0]; /* case 0: nothing left to add */ } - mix(a,b,c); + mix(a, b, c); /* report the result */ return UInt32GetDatum(c); } diff --git a/src/backend/access/hash/hashscan.c b/src/backend/access/hash/hashscan.c index b597fc196a..272e182b6e 100644 --- a/src/backend/access/hash/hashscan.c +++ b/src/backend/access/hash/hashscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.28 2002/06/20 20:29:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/hash/hashscan.c,v 1.29 2002/09/04 20:31:09 momjian Exp $ * * NOTES * Because we can be doing an index scan on a relation while we @@ -45,7 +45,7 @@ static HashScanList HashScans = (HashScanList) NULL; static void _hash_scandel(IndexScanDesc scan, - BlockNumber blkno, OffsetNumber offno); + BlockNumber blkno, OffsetNumber offno); /* @@ -158,7 +158,7 @@ _hash_scandel(IndexScanDesc scan, BlockNumber blkno, OffsetNumber offno) * then step backwards (affecting current), then exchange again. */ ItemPointerData tmpitem; - Buffer tmpbuf; + Buffer tmpbuf; tmpitem = *mark; *mark = *current; diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c index 9acd6b3385..d7df449a63 100644 --- a/src/backend/access/heap/heapam.c +++ b/src/backend/access/heap/heapam.c @@ -8,12 +8,12 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.147 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/heapam.c,v 1.148 2002/09/04 20:31:09 momjian Exp $ * * * INTERFACE ROUTINES * relation_open - open any relation by relation OID - * relation_openrv - open any relation specified by a RangeVar + * relation_openrv - open any relation specified by a RangeVar * relation_openr - open a system relation by name * relation_close - close any relation * heap_open - open a heap relation by relation OID @@ -306,7 +306,7 @@ heapgettup(Relation relation, { if (ItemIdIsUsed(lpp)) { - bool valid; + bool valid; tuple->t_datamcxt = NULL; tuple->t_data = (HeapTupleHeader) PageGetItem((Page) dp, lpp); @@ -985,8 +985,8 @@ heap_fetch(Relation relation, *userbuf = buffer; /* - * Count the successful fetch in *pgstat_info if given, - * otherwise in the relation's default statistics area. + * Count the successful fetch in *pgstat_info if given, otherwise + * in the relation's default statistics area. */ if (pgstat_info != NULL) pgstat_count_heap_fetch(pgstat_info); @@ -1120,6 +1120,7 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) /* this is redundant with an Assert in HeapTupleSetOid */ Assert(tup->t_data->t_infomask & HEAP_HASOID); #endif + /* * If the object id of this tuple has already been assigned, trust * the caller. There are a couple of ways this can happen. At @@ -1224,10 +1225,10 @@ heap_insert(Relation relation, HeapTuple tup, CommandId cid) WriteBuffer(buffer); /* - * If tuple is cachable, mark it for invalidation from the caches in case - * we abort. Note it is OK to do this after WriteBuffer releases the - * buffer, because the "tup" data structure is all in local memory, - * not in the shared buffer. + * If tuple is cachable, mark it for invalidation from the caches in + * case we abort. Note it is OK to do this after WriteBuffer releases + * the buffer, because the "tup" data structure is all in local + * memory, not in the shared buffer. */ CacheInvalidateHeapTuple(relation, tup); @@ -1379,6 +1380,7 @@ l1: LockBuffer(buffer, BUFFER_LOCK_UNLOCK); #ifdef TUPLE_TOASTER_ACTIVE + /* * If the relation has toastable attributes, we need to delete no * longer needed items there too. We have to do this before @@ -1728,10 +1730,10 @@ l2: WriteBuffer(buffer); /* - * If new tuple is cachable, mark it for invalidation from the caches in - * case we abort. Note it is OK to do this after WriteBuffer releases - * the buffer, because the "newtup" data structure is all in local - * memory, not in the shared buffer. + * If new tuple is cachable, mark it for invalidation from the caches + * in case we abort. Note it is OK to do this after WriteBuffer + * releases the buffer, because the "newtup" data structure is all in + * local memory, not in the shared buffer. */ CacheInvalidateHeapTuple(relation, newtup); @@ -2045,16 +2047,16 @@ log_heap_update(Relation reln, Buffer oldbuf, ItemPointerData from, xlhdr.hdr.mask = newtup->t_data->t_infomask; if (move) /* remember xmin & xmax */ { - TransactionId xid[2]; /* xmax, xmin */ + TransactionId xid[2]; /* xmax, xmin */ if (newtup->t_data->t_infomask & (HEAP_XMAX_INVALID | - HEAP_MARKED_FOR_UPDATE)) + HEAP_MARKED_FOR_UPDATE)) xid[0] = InvalidTransactionId; else xid[0] = HeapTupleHeaderGetXmax(newtup->t_data); xid[1] = HeapTupleHeaderGetXmin(newtup->t_data); memcpy((char *) &xlhdr + hsize, - (char *) xid, + (char *) xid, 2 * sizeof(TransactionId)); hsize += 2 * sizeof(TransactionId); } @@ -2143,7 +2145,7 @@ heap_xlog_clean(bool redo, XLogRecPtr lsn, XLogRecord *record) PageRepairFragmentation(page, NULL); PageSetLSN(page, lsn); - PageSetSUI(page, ThisStartUpID); /* prev sui */ + PageSetSUI(page, ThisStartUpID); /* prev sui */ UnlockAndWriteBuffer(buffer); } @@ -2463,11 +2465,11 @@ newsame:; if (move) { - TransactionId xid[2]; /* xmax, xmin */ - + TransactionId xid[2]; /* xmax, xmin */ + hsize = SizeOfHeapUpdate + SizeOfHeapHeader; memcpy((char *) xid, - (char *) xlrec + hsize, 2 * sizeof(TransactionId)); + (char *) xlrec + hsize, 2 * sizeof(TransactionId)); htup->t_infomask = xlhdr.mask; htup->t_infomask &= ~(HEAP_XMIN_COMMITTED | HEAP_XMIN_INVALID | diff --git a/src/backend/access/heap/tuptoaster.c b/src/backend/access/heap/tuptoaster.c index ab6eff8262..f8a883b150 100644 --- a/src/backend/access/heap/tuptoaster.c +++ b/src/backend/access/heap/tuptoaster.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.35 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/heap/tuptoaster.c,v 1.36 2002/09/04 20:31:09 momjian Exp $ * * * INTERFACE ROUTINES @@ -46,7 +46,7 @@ static void toast_insert_or_update(Relation rel, HeapTuple newtup, static Datum toast_save_datum(Relation rel, Datum value); static varattrib *toast_fetch_datum(varattrib *attr); static varattrib *toast_fetch_datum_slice(varattrib *attr, - int32 sliceoffset, int32 length); + int32 sliceoffset, int32 length); /* ---------- @@ -165,73 +165,68 @@ heap_tuple_untoast_attr(varattrib *attr) /* ---------- * heap_tuple_untoast_attr_slice - * - * Public entry point to get back part of a toasted value - * from compression or external storage. + * Public entry point to get back part of a toasted value + * from compression or external storage. * ---------- */ -varattrib * +varattrib * heap_tuple_untoast_attr_slice(varattrib *attr, int32 sliceoffset, int32 slicelength) { varattrib *preslice; varattrib *result; - int32 attrsize; - + int32 attrsize; + if (VARATT_IS_COMPRESSED(attr)) { - varattrib *tmp; - + varattrib *tmp; + if (VARATT_IS_EXTERNAL(attr)) - { tmp = toast_fetch_datum(attr); - } else { - tmp = attr; /* compressed in main tuple */ + tmp = attr; /* compressed in main tuple */ } - + preslice = (varattrib *) palloc(attr->va_content.va_external.va_rawsize + VARHDRSZ); VARATT_SIZEP(preslice) = attr->va_content.va_external.va_rawsize + VARHDRSZ; pglz_decompress((PGLZ_Header *) tmp, VARATT_DATA(preslice)); - - if (tmp != attr) + + if (tmp != attr) pfree(tmp); } - else + else { /* Plain value */ if (VARATT_IS_EXTERNAL(attr)) - { + { /* fast path */ return (toast_fetch_datum_slice(attr, sliceoffset, slicelength)); } else - { preslice = attr; - } } - + /* slicing of datum for compressed cases and plain value */ - + attrsize = VARSIZE(preslice) - VARHDRSZ; - if (sliceoffset >= attrsize) + if (sliceoffset >= attrsize) { sliceoffset = 0; slicelength = 0; } - + if (((sliceoffset + slicelength) > attrsize) || slicelength < 0) - { slicelength = attrsize - sliceoffset; - } - + result = (varattrib *) palloc(slicelength + VARHDRSZ); VARATT_SIZEP(result) = slicelength + VARHDRSZ; - + memcpy(VARDATA(result), VARDATA(preslice) + sliceoffset, slicelength); - - if (preslice != attr) pfree(preslice); - + + if (preslice != attr) + pfree(preslice); + return result; } @@ -1053,9 +1048,9 @@ toast_fetch_datum(varattrib *attr) /* * Read the chunks by index * - * Note that because the index is actually on (valueid, chunkidx) - * we will see the chunks in chunkidx order, even though we didn't - * explicitly ask for it. + * Note that because the index is actually on (valueid, chunkidx) we will + * see the chunks in chunkidx order, even though we didn't explicitly + * ask for it. */ nextidx = 0; @@ -1146,45 +1141,44 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length) varattrib *result; int32 attrsize; int32 residx; - int32 nextidx; - int numchunks; - int startchunk; - int endchunk; + int32 nextidx; + int numchunks; + int startchunk; + int endchunk; int32 startoffset; int32 endoffset; - int totalchunks; + int totalchunks; Pointer chunk; bool isnull; int32 chunksize; - int32 chcpystrt; - int32 chcpyend; + int32 chcpystrt; + int32 chcpyend; attrsize = attr->va_content.va_external.va_extsize; totalchunks = ((attrsize - 1) / TOAST_MAX_CHUNK_SIZE) + 1; - if (sliceoffset >= attrsize) + if (sliceoffset >= attrsize) { - sliceoffset = 0; - length = 0; + sliceoffset = 0; + length = 0; } if (((sliceoffset + length) > attrsize) || length < 0) - { - length = attrsize - sliceoffset; - } + length = attrsize - sliceoffset; result = (varattrib *) palloc(length + VARHDRSZ); VARATT_SIZEP(result) = length + VARHDRSZ; if (VARATT_IS_COMPRESSED(attr)) VARATT_SIZEP(result) |= VARATT_FLAG_COMPRESSED; - - if (length == 0) return (result); /* Can save a lot of work at this point! */ + + if (length == 0) + return (result); /* Can save a lot of work at this point! */ startchunk = sliceoffset / TOAST_MAX_CHUNK_SIZE; endchunk = (sliceoffset + length - 1) / TOAST_MAX_CHUNK_SIZE; - numchunks = (endchunk - startchunk ) + 1; - + numchunks = (endchunk - startchunk) + 1; + startoffset = sliceoffset % TOAST_MAX_CHUNK_SIZE; endoffset = (sliceoffset + length - 1) % TOAST_MAX_CHUNK_SIZE; @@ -1204,33 +1198,34 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length) (bits16) 0, (AttrNumber) 1, (RegProcedure) F_OIDEQ, - ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); + ObjectIdGetDatum(attr->va_content.va_external.va_valueid)); + /* * Now dependent on number of chunks: */ - - if (numchunks == 1) + + if (numchunks == 1) { - ScanKeyEntryInitialize(&toastkey[1], + ScanKeyEntryInitialize(&toastkey[1], (bits16) 0, (AttrNumber) 2, (RegProcedure) F_INT4EQ, Int32GetDatum(startchunk)); - nscankeys = 2; + nscankeys = 2; } else { - ScanKeyEntryInitialize(&toastkey[1], + ScanKeyEntryInitialize(&toastkey[1], (bits16) 0, (AttrNumber) 2, (RegProcedure) F_INT4GE, Int32GetDatum(startchunk)); - ScanKeyEntryInitialize(&toastkey[2], + ScanKeyEntryInitialize(&toastkey[2], (bits16) 0, (AttrNumber) 2, (RegProcedure) F_INT4LE, Int32GetDatum(endchunk)); - nscankeys = 3; + nscankeys = 3; } /* @@ -1279,21 +1274,23 @@ toast_fetch_datum_slice(varattrib *attr, int32 sliceoffset, int32 length) */ chcpystrt = 0; chcpyend = chunksize - 1; - if (residx == startchunk) chcpystrt = startoffset; - if (residx == endchunk) chcpyend = endoffset; - - memcpy(((char *) VARATT_DATA(result)) + - (residx * TOAST_MAX_CHUNK_SIZE - sliceoffset) +chcpystrt, + if (residx == startchunk) + chcpystrt = startoffset; + if (residx == endchunk) + chcpyend = endoffset; + + memcpy(((char *) VARATT_DATA(result)) + + (residx * TOAST_MAX_CHUNK_SIZE - sliceoffset) + chcpystrt, VARATT_DATA(chunk) + chcpystrt, (chcpyend - chcpystrt) + 1); - + nextidx++; } /* * Final checks that we successfully fetched the datum */ - if ( nextidx != (endchunk + 1)) + if (nextidx != (endchunk + 1)) elog(ERROR, "missing chunk number %d for toast value %u", nextidx, attr->va_content.va_external.va_valueid); diff --git a/src/backend/access/index/genam.c b/src/backend/access/index/genam.c index 9bf88a795a..2a21e2962e 100644 --- a/src/backend/access/index/genam.c +++ b/src/backend/access/index/genam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.35 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/genam.c,v 1.36 2002/09/04 20:31:09 momjian Exp $ * * NOTES * many of the old access method routines have been turned into @@ -77,7 +77,7 @@ RelationGetIndexScan(Relation indexRelation, scan->heapRelation = NULL; /* may be set later */ scan->indexRelation = indexRelation; - scan->xs_snapshot = SnapshotNow; /* may be set later */ + scan->xs_snapshot = SnapshotNow; /* may be set later */ scan->numberOfKeys = nkeys; /* @@ -90,8 +90,8 @@ RelationGetIndexScan(Relation indexRelation, scan->keyData = NULL; scan->kill_prior_tuple = false; - scan->ignore_killed_tuples = true; /* default setting */ - scan->keys_are_unique = false; /* may be set by amrescan */ + scan->ignore_killed_tuples = true; /* default setting */ + scan->keys_are_unique = false; /* may be set by amrescan */ scan->got_tuple = false; scan->opaque = NULL; @@ -201,6 +201,7 @@ systable_beginscan(Relation heapRelation, /* We assume it's a system index, so index_openr is OK */ sysscan->irel = irel = index_openr(indexRelname); + /* * Change attribute numbers to be index column numbers. * @@ -210,7 +211,7 @@ systable_beginscan(Relation heapRelation, for (i = 0; i < nkeys; i++) { Assert(key[i].sk_attno == irel->rd_index->indkey[i]); - key[i].sk_attno = i+1; + key[i].sk_attno = i + 1; } sysscan->iscan = index_beginscan(heapRelation, irel, snapshot, nkeys, key); diff --git a/src/backend/access/index/indexam.c b/src/backend/access/index/indexam.c index fc53aeffb4..d2e11d2a8d 100644 --- a/src/backend/access/index/indexam.c +++ b/src/backend/access/index/indexam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.61 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/index/indexam.c,v 1.62 2002/09/04 20:31:09 momjian Exp $ * * INTERFACE ROUTINES * index_open - open an index relation by relation OID @@ -272,8 +272,8 @@ index_beginscan(Relation heapRelation, PointerGetDatum(key))); /* - * Save additional parameters into the scandesc. Everything else - * was set up by RelationGetIndexScan. + * Save additional parameters into the scandesc. Everything else was + * set up by RelationGetIndexScan. */ scan->heapRelation = heapRelation; scan->xs_snapshot = snapshot; @@ -293,7 +293,7 @@ index_beginscan(Relation heapRelation, * index_rescan - (re)start a scan of an index * * The caller may specify a new set of scankeys (but the number of keys - * cannot change). Note that this is also called when first starting + * cannot change). Note that this is also called when first starting * an indexscan; see RelationGetIndexScan. * ---------------- */ @@ -305,8 +305,8 @@ index_rescan(IndexScanDesc scan, ScanKey key) SCAN_CHECKS; GET_SCAN_PROCEDURE(rescan, amrescan); - scan->kill_prior_tuple = false; /* for safety */ - scan->keys_are_unique = false; /* may be set by amrescan */ + scan->kill_prior_tuple = false; /* for safety */ + scan->keys_are_unique = false; /* may be set by amrescan */ scan->got_tuple = false; OidFunctionCall2(procedure, @@ -375,7 +375,7 @@ index_restrpos(IndexScanDesc scan) SCAN_CHECKS; GET_SCAN_PROCEDURE(restrpos, amrestrpos); - scan->kill_prior_tuple = false; /* for safety */ + scan->kill_prior_tuple = false; /* for safety */ scan->got_tuple = false; OidFunctionCall1(procedure, PointerGetDatum(scan)); @@ -385,7 +385,7 @@ index_restrpos(IndexScanDesc scan) * index_getnext - get the next heap tuple from a scan * * The result is the next heap tuple satisfying the scan keys and the - * snapshot, or NULL if no more matching tuples exist. On success, + * snapshot, or NULL if no more matching tuples exist. On success, * the buffer containing the heap tuple is pinned (the pin will be dropped * at the next index_getnext or index_endscan). The index TID corresponding * to the heap tuple can be obtained if needed from scan->currentItemData. @@ -409,8 +409,8 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) scan->kill_prior_tuple = false; /* - * Can skip entering the index AM if we already got a tuple - * and it must be unique. + * Can skip entering the index AM if we already got a tuple and it + * must be unique. */ if (scan->keys_are_unique && scan->got_tuple) return NULL; @@ -454,9 +454,9 @@ index_getnext(IndexScanDesc scan, ScanDirection direction) * index AM to not return it on future indexscans. * * We told heap_fetch to keep a pin on the buffer, so we can - * re-access the tuple here. But we must re-lock the buffer first. - * Also, it's just barely possible for an update of hint bits to - * occur here. + * re-access the tuple here. But we must re-lock the buffer + * first. Also, it's just barely possible for an update of hint + * bits to occur here. */ LockBuffer(scan->xs_cbuf, BUFFER_LOCK_SHARE); sv_infomask = heapTuple->t_data->t_infomask; @@ -497,7 +497,7 @@ bool index_getnext_indexitem(IndexScanDesc scan, ScanDirection direction) { - bool found; + bool found; SCAN_CHECKS; @@ -642,10 +642,11 @@ index_getprocinfo(Relation irel, procId = loc[procindex]; /* - * Complain if function was not found during IndexSupportInitialize. - * This should not happen unless the system tables contain bogus - * entries for the index opclass. (If an AM wants to allow a - * support function to be optional, it can use index_getprocid.) + * Complain if function was not found during + * IndexSupportInitialize. This should not happen unless the + * system tables contain bogus entries for the index opclass. (If + * an AM wants to allow a support function to be optional, it can + * use index_getprocid.) */ if (!RegProcedureIsValid(procId)) elog(ERROR, "Missing support function %d for attribute %d of index %s", diff --git a/src/backend/access/nbtree/nbtinsert.c b/src/backend/access/nbtree/nbtinsert.c index 16d63e03c9..99011a5c95 100644 --- a/src/backend/access/nbtree/nbtinsert.c +++ b/src/backend/access/nbtree/nbtinsert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.95 2002/08/06 02:36:33 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtinsert.c,v 1.96 2002/09/04 20:31:09 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -119,14 +119,14 @@ top: * * NOTE: obviously, _bt_check_unique can only detect keys that are * already in the index; so it cannot defend against concurrent - * insertions of the same key. We protect against that by means - * of holding a write lock on the target page. Any other would-be + * insertions of the same key. We protect against that by means of + * holding a write lock on the target page. Any other would-be * inserter of the same key must acquire a write lock on the same * target page, so only one would-be inserter can be making the check - * at one time. Furthermore, once we are past the check we hold - * write locks continuously until we have performed our insertion, - * so no later inserter can fail to see our insertion. (This - * requires some care in _bt_insertonpg.) + * at one time. Furthermore, once we are past the check we hold write + * locks continuously until we have performed our insertion, so no + * later inserter can fail to see our insertion. (This requires some + * care in _bt_insertonpg.) * * If we must wait for another xact, we release the lock while waiting, * and then must start over completely. @@ -205,15 +205,16 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, if (offset <= maxoff) { /* - * _bt_compare returns 0 for (1,NULL) and (1,NULL) - this's how we - * handling NULLs - and so we must not use _bt_compare in real - * comparison, but only for ordering/finding items on pages. - - * vadim 03/24/97 + * _bt_compare returns 0 for (1,NULL) and (1,NULL) - this's + * how we handling NULLs - and so we must not use _bt_compare + * in real comparison, but only for ordering/finding items on + * pages. - vadim 03/24/97 */ if (!_bt_isequal(itupdesc, page, offset, natts, itup_scankey)) break; /* we're past all the equal tuples */ curitemid = PageGetItemId(page, offset); + /* * We can skip the heap fetch if the item is marked killed. */ @@ -226,10 +227,11 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, { /* it is a duplicate */ TransactionId xwait = - (TransactionIdIsValid(SnapshotDirty->xmin)) ? - SnapshotDirty->xmin : SnapshotDirty->xmax; + (TransactionIdIsValid(SnapshotDirty->xmin)) ? + SnapshotDirty->xmin : SnapshotDirty->xmax; ReleaseBuffer(hbuffer); + /* * If this tuple is being updated by other transaction * then we have to wait for its commit/abort. @@ -252,8 +254,8 @@ _bt_check_unique(Relation rel, BTItem btitem, Relation heapRel, { /* * Hmm, if we can't see the tuple, maybe it can be - * marked killed. This logic should match index_getnext - * and btgettuple. + * marked killed. This logic should match + * index_getnext and btgettuple. */ uint16 sv_infomask; @@ -421,7 +423,7 @@ _bt_insertonpg(Relation rel, { /* step right one page */ BlockNumber rblkno = lpageop->btpo_next; - Buffer rbuf; + Buffer rbuf; /* * must write-lock next page before releasing write lock on diff --git a/src/backend/access/nbtree/nbtree.c b/src/backend/access/nbtree/nbtree.c index 46787e577a..ac46681c61 100644 --- a/src/backend/access/nbtree/nbtree.c +++ b/src/backend/access/nbtree/nbtree.c @@ -12,7 +12,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.91 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtree.c,v 1.92 2002/09/04 20:31:10 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -315,24 +315,28 @@ btgettuple(PG_FUNCTION_ARGS) * buffer, too. */ _bt_restscan(scan); + /* * Check to see if we should kill the previously-fetched tuple. */ if (scan->kill_prior_tuple) { /* - * Yes, so mark it by setting the LP_DELETE bit in the item flags. + * Yes, so mark it by setting the LP_DELETE bit in the item + * flags. */ offnum = ItemPointerGetOffsetNumber(&(scan->currentItemData)); page = BufferGetPage(so->btso_curbuf); PageGetItemId(page, offnum)->lp_flags |= LP_DELETE; + /* * Since this can be redone later if needed, it's treated the - * same as a commit-hint-bit status update for heap tuples: - * we mark the buffer dirty but don't make a WAL log entry. + * same as a commit-hint-bit status update for heap tuples: we + * mark the buffer dirty but don't make a WAL log entry. */ SetBufferCommitInfoNeedsSave(so->btso_curbuf); } + /* * Now continue the scan. */ @@ -645,15 +649,15 @@ btbulkdelete(PG_FUNCTION_ARGS) /* * If this is first deletion on this page, trade in read * lock for a really-exclusive write lock. Then, step - * back one and re-examine the item, because other backends - * might have inserted item(s) while we weren't holding - * the lock! + * back one and re-examine the item, because other + * backends might have inserted item(s) while we weren't + * holding the lock! * * We assume that only concurrent insertions, not deletions, - * can occur while we're not holding the page lock (the caller - * should hold a suitable relation lock to ensure this). - * Therefore, the item we want to delete is either in the - * same slot as before, or some slot to its right. + * can occur while we're not holding the page lock (the + * caller should hold a suitable relation lock to ensure + * this). Therefore, the item we want to delete is either + * in the same slot as before, or some slot to its right. * Rechecking the same slot is necessary and sufficient to * get back in sync after any insertions. */ @@ -675,19 +679,19 @@ btbulkdelete(PG_FUNCTION_ARGS) } /* - * In either case, we now need to back up the scan one item, - * so that the next cycle will re-examine the same offnum on - * this page. + * In either case, we now need to back up the scan one + * item, so that the next cycle will re-examine the same + * offnum on this page. * * For now, just hack the current-item index. Will need to * be smarter when deletion includes removal of empty * index pages. * * We must decrement ip_posid in all cases but one: if the - * page was formerly rightmost but was split while we didn't - * hold the lock, and ip_posid is pointing to item 1, then - * ip_posid now points at the high key not a valid data item. - * In this case we do want to step forward. + * page was formerly rightmost but was split while we + * didn't hold the lock, and ip_posid is pointing to item + * 1, then ip_posid now points at the high key not a valid + * data item. In this case we do want to step forward. */ opaque = (BTPageOpaque) PageGetSpecialPointer(page); if (current->ip_posid >= P_FIRSTDATAKEY(opaque)) diff --git a/src/backend/access/nbtree/nbtutils.c b/src/backend/access/nbtree/nbtutils.c index 999c3ba462..50fe3312cc 100644 --- a/src/backend/access/nbtree/nbtutils.c +++ b/src/backend/access/nbtree/nbtutils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.50 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/nbtree/nbtutils.c,v 1.51 2002/09/04 20:31:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -22,7 +22,7 @@ #include "executor/execdebug.h" -static int _bt_getstrategynumber(RegProcedure sk_procedure, StrategyMap map); +static int _bt_getstrategynumber(RegProcedure sk_procedure, StrategyMap map); /* @@ -178,7 +178,7 @@ _bt_formitem(IndexTuple itup) * example. * * Furthermore, we detect the case where the index is unique and we have - * equality quals for all columns. In this case there can be at most one + * equality quals for all columns. In this case there can be at most one * (visible) matching tuple. index_getnext uses this to avoid uselessly * continuing the scan after finding one match. * @@ -439,8 +439,8 @@ _bt_orderkeys(IndexScanDesc scan) so->numberOfKeys = new_numberOfKeys; /* - * If unique index and we have equality keys for all columns, - * set keys_are_unique flag for higher levels. + * If unique index and we have equality keys for all columns, set + * keys_are_unique flag for higher levels. */ if (allEqualSoFar && relation->rd_index->indisunique && relation->rd_rel->relnatts == new_numberOfKeys) diff --git a/src/backend/access/rtree/rtget.c b/src/backend/access/rtree/rtget.c index 87ebb60559..9a21954c17 100644 --- a/src/backend/access/rtree/rtget.c +++ b/src/backend/access/rtree/rtget.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.27 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtget.c,v 1.28 2002/09/04 20:31:12 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ rtgettuple(PG_FUNCTION_ARGS) { IndexScanDesc s = (IndexScanDesc) PG_GETARG_POINTER(0); ScanDirection dir = (ScanDirection) PG_GETARG_INT32(1); - bool res; + bool res; /* if we have it cached in the scan desc, just return the value */ if (rtscancache(s, dir)) diff --git a/src/backend/access/rtree/rtree.c b/src/backend/access/rtree/rtree.c index 957b9865c5..650820085c 100644 --- a/src/backend/access/rtree/rtree.c +++ b/src/backend/access/rtree/rtree.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.74 2002/06/25 17:26:11 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/rtree/Attic/rtree.c,v 1.75 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -223,6 +223,7 @@ rtinsert(PG_FUNCTION_ARGS) Datum *datum = (Datum *) PG_GETARG_POINTER(1); char *nulls = (char *) PG_GETARG_POINTER(2); ItemPointer ht_ctid = (ItemPointer) PG_GETARG_POINTER(3); + #ifdef NOT_USED Relation heapRel = (Relation) PG_GETARG_POINTER(4); bool checkUnique = PG_GETARG_BOOL(5); diff --git a/src/backend/access/transam/transam.c b/src/backend/access/transam/transam.c index c4ca0c7071..3d3816430a 100644 --- a/src/backend/access/transam/transam.c +++ b/src/backend/access/transam/transam.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.53 2002/06/20 20:29:25 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/transam.c,v 1.54 2002/09/04 20:31:13 momjian Exp $ * * NOTES * This file contains the high level access-method interface to the @@ -27,7 +27,7 @@ * Flag indicating that we are bootstrapping. * * Transaction ID generation is disabled during bootstrap; we just use - * BootstrapTransactionId. Also, the transaction ID status-check routines + * BootstrapTransactionId. Also, the transaction ID status-check routines * are short-circuited; they claim that BootstrapTransactionId has already * committed, allowing tuples already inserted to be seen immediately. * ---------------- diff --git a/src/backend/access/transam/varsup.c b/src/backend/access/transam/varsup.c index 4b8e76085b..6453bad761 100644 --- a/src/backend/access/transam/varsup.c +++ b/src/backend/access/transam/varsup.c @@ -6,7 +6,7 @@ * Copyright (c) 2000, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.50 2002/06/11 13:40:50 wieck Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/varsup.c,v 1.51 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -68,12 +68,12 @@ GetNewTransactionId(void) * might see a partially-set xid here. But holding both locks at once * would be a nasty concurrency hit (and in fact could cause a * deadlock against GetSnapshotData). So for now, assume atomicity. - * Note that readers of PGPROC xid field should be careful to fetch the - * value only once, rather than assume they can read it multiple times - * and get the same answer each time. + * Note that readers of PGPROC xid field should be careful to fetch + * the value only once, rather than assume they can read it multiple + * times and get the same answer each time. * - * A solution to the atomic-store problem would be to give each PGPROC its - * own spinlock used only for fetching/storing that PGPROC's xid. + * A solution to the atomic-store problem would be to give each PGPROC + * its own spinlock used only for fetching/storing that PGPROC's xid. * (SInvalLock would then mean primarily that PROCs couldn't be added/ * removed while holding the lock.) */ diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index 1c1121e3e1..fd401e963e 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.131 2002/08/30 22:18:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xact.c,v 1.132 2002/09/04 20:31:13 momjian Exp $ * * NOTES * Transaction aborts can now occur two ways: @@ -265,7 +265,6 @@ SetTransactionFlushEnabled(bool state) { TransactionFlushState = (state == true); } - #endif @@ -421,7 +420,7 @@ CommandCounterIncrement(void) TransactionState s = CurrentTransactionState; s->commandId += 1; - if (s->commandId == FirstCommandId) /* check for overflow */ + if (s->commandId == FirstCommandId) /* check for overflow */ elog(ERROR, "You may only have 2^32-1 commands per transaction"); /* Propagate new command ID into query snapshots, if set */ @@ -517,8 +516,8 @@ void RecordTransactionCommit(void) { /* - * If we made neither any XLOG entries nor any temp-rel updates, - * we can omit recording the transaction commit at all. + * If we made neither any XLOG entries nor any temp-rel updates, we + * can omit recording the transaction commit at all. */ if (MyXactMadeXLogEntry || MyXactMadeTempRelUpdate) { @@ -531,10 +530,10 @@ RecordTransactionCommit(void) START_CRIT_SECTION(); /* - * We only need to log the commit in xlog if the transaction made any - * transaction-controlled XLOG entries. (Otherwise, its XID appears - * nowhere in permanent storage, so no one else will ever care if it - * committed.) + * We only need to log the commit in xlog if the transaction made + * any transaction-controlled XLOG entries. (Otherwise, its XID + * appears nowhere in permanent storage, so no one else will ever + * care if it committed.) */ if (MyLastRecPtr.xrecoff != 0) { @@ -560,20 +559,20 @@ RecordTransactionCommit(void) } /* - * We must flush our XLOG entries to disk if we made any XLOG entries, - * whether in or out of transaction control. For example, if we - * reported a nextval() result to the client, this ensures that any - * XLOG record generated by nextval will hit the disk before we report - * the transaction committed. + * We must flush our XLOG entries to disk if we made any XLOG + * entries, whether in or out of transaction control. For + * example, if we reported a nextval() result to the client, this + * ensures that any XLOG record generated by nextval will hit the + * disk before we report the transaction committed. */ if (MyXactMadeXLogEntry) { /* * Sleep before flush! So we can flush more than one commit - * records per single fsync. (The idea is some other backend may - * do the XLogFlush while we're sleeping. This needs work still, - * because on most Unixen, the minimum select() delay is 10msec or - * more, which is way too long.) + * records per single fsync. (The idea is some other backend + * may do the XLogFlush while we're sleeping. This needs work + * still, because on most Unixen, the minimum select() delay + * is 10msec or more, which is way too long.) * * We do not sleep if enableFsync is not turned on, nor if there * are fewer than CommitSiblings other backends with active @@ -593,13 +592,14 @@ RecordTransactionCommit(void) } /* - * We must mark the transaction committed in clog if its XID appears - * either in permanent rels or in local temporary rels. We test - * this by seeing if we made transaction-controlled entries *OR* - * local-rel tuple updates. Note that if we made only the latter, - * we have not emitted an XLOG record for our commit, and so in the - * event of a crash the clog update might be lost. This is okay - * because no one else will ever care whether we committed. + * We must mark the transaction committed in clog if its XID + * appears either in permanent rels or in local temporary rels. + * We test this by seeing if we made transaction-controlled + * entries *OR* local-rel tuple updates. Note that if we made + * only the latter, we have not emitted an XLOG record for our + * commit, and so in the event of a crash the clog update might be + * lost. This is okay because no one else will ever care whether + * we committed. */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate) TransactionIdCommit(xid); @@ -628,6 +628,7 @@ AtCommit_Cache(void) * Clean up the relation cache. */ AtEOXact_RelationCache(true); + /* * Make catalog changes visible to all backends. */ @@ -698,8 +699,8 @@ RecordTransactionAbort(void) { /* * If we made neither any transaction-controlled XLOG entries nor any - * temp-rel updates, we can omit recording the transaction abort at all. - * No one will ever care that it aborted. + * temp-rel updates, we can omit recording the transaction abort at + * all. No one will ever care that it aborted. */ if (MyLastRecPtr.xrecoff != 0 || MyXactMadeTempRelUpdate) { @@ -716,11 +717,12 @@ RecordTransactionAbort(void) START_CRIT_SECTION(); /* - * We only need to log the abort in XLOG if the transaction made any - * transaction-controlled XLOG entries. (Otherwise, its XID appears - * nowhere in permanent storage, so no one else will ever care if it - * committed.) We do not flush XLOG to disk in any case, since the - * default assumption after a crash would be that we aborted, anyway. + * We only need to log the abort in XLOG if the transaction made + * any transaction-controlled XLOG entries. (Otherwise, its XID + * appears nowhere in permanent storage, so no one else will ever + * care if it committed.) We do not flush XLOG to disk in any + * case, since the default assumption after a crash would be that + * we aborted, anyway. */ if (MyLastRecPtr.xrecoff != 0) { @@ -1165,8 +1167,8 @@ StartTransactionCommand(bool preventChain) TransactionState s = CurrentTransactionState; /* - * Remember if caller wants to prevent autocommit-off chaining. - * This is only allowed if not already in a transaction block. + * Remember if caller wants to prevent autocommit-off chaining. This + * is only allowed if not already in a transaction block. */ suppressChain = preventChain; if (preventChain && s->blockState != TBLOCK_DEFAULT) @@ -1260,16 +1262,18 @@ CommitTransactionCommand(bool forceCommit) { /* * If we aren't in a transaction block, and we are doing - * autocommit, just do our usual transaction commit. But - * if we aren't doing autocommit, start a transaction block - * automatically by switching to INPROGRESS state. (We handle - * this choice here, and not earlier, so that an explicit BEGIN - * issued in autocommit-off mode won't issue strange warnings.) + * autocommit, just do our usual transaction commit. But if + * we aren't doing autocommit, start a transaction block + * automatically by switching to INPROGRESS state. (We handle + * this choice here, and not earlier, so that an explicit + * BEGIN issued in autocommit-off mode won't issue strange + * warnings.) * - * Autocommit mode is forced by either a true forceCommit parameter - * to me, or a true preventChain parameter to the preceding - * StartTransactionCommand call. This is needed so that commands - * like VACUUM can ensure that the right things happen. + * Autocommit mode is forced by either a true forceCommit + * parameter to me, or a true preventChain parameter to the + * preceding StartTransactionCommand call. This is needed so + * that commands like VACUUM can ensure that the right things + * happen. */ case TBLOCK_DEFAULT: if (autocommit || forceCommit || suppressChain) @@ -1442,9 +1446,9 @@ BeginTransactionBlock(void) s->blockState = TBLOCK_BEGIN; /* - * do begin processing. NOTE: if you put anything here, check that - * it behaves properly in both autocommit-on and autocommit-off modes. - * In the latter case we will already have done some work in the new + * do begin processing. NOTE: if you put anything here, check that it + * behaves properly in both autocommit-on and autocommit-off modes. In + * the latter case we will already have done some work in the new * transaction. */ diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index d2955d4058..0ff60292e6 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.105 2002/09/02 02:47:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/access/transam/xlog.c,v 1.106 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,13 +131,13 @@ bool InRecovery = false; * * Note that XLOG records inserted outside transaction control are not * reflected into MyLastRecPtr. They do, however, cause MyXactMadeXLogEntry - * to be set true. The latter can be used to test whether the current xact + * to be set true. The latter can be used to test whether the current xact * made any loggable changes (including out-of-xact changes, such as * sequence updates). * * When we insert/update/delete a tuple in a temporary relation, we do not * make any XLOG record, since we don't care about recovering the state of - * the temp rel after a crash. However, we will still need to remember + * the temp rel after a crash. However, we will still need to remember * whether our transaction committed or aborted in that case. So, we must * set MyXactMadeTempRelUpdate true to indicate that the XID will be of * interest later. @@ -151,7 +151,7 @@ bool MyXactMadeTempRelUpdate = false; /* * ProcLastRecPtr points to the start of the last XLOG record inserted by the * current backend. It is updated for all inserts, transaction-controlled - * or not. ProcLastRecEnd is similar but points to end+1 of last record. + * or not. ProcLastRecEnd is similar but points to end+1 of last record. */ static XLogRecPtr ProcLastRecPtr = {0, 0}; @@ -162,7 +162,7 @@ XLogRecPtr ProcLastRecEnd = {0, 0}; * (which is almost but not quite the same as a pointer to the most recent * CHECKPOINT record). We update this from the shared-memory copy, * XLogCtl->Insert.RedoRecPtr, whenever we can safely do so (ie, when we - * hold the Insert lock). See XLogInsert for details. We are also allowed + * hold the Insert lock). See XLogInsert for details. We are also allowed * to update from XLogCtl->Insert.RedoRecPtr if we hold the info_lck; * see GetRedoRecPtr. */ @@ -766,7 +766,7 @@ begin:; /* * We do not acquire SInvalLock here because of possible deadlock. * Anyone who wants to inspect other procs' logRec must acquire - * WALInsertLock, instead. A better solution would be a per-PROC + * WALInsertLock, instead. A better solution would be a per-PROC * spinlock, but no time for that before 7.2 --- tgl 12/19/01. */ MyProc->logRec = RecPtr; @@ -1283,26 +1283,27 @@ XLogFlush(XLogRecPtr record) /* * If we still haven't flushed to the request point then we have a - * problem; most likely, the requested flush point is past end of XLOG. - * This has been seen to occur when a disk page has a corrupted LSN. + * problem; most likely, the requested flush point is past end of + * XLOG. This has been seen to occur when a disk page has a corrupted + * LSN. * * Formerly we treated this as a PANIC condition, but that hurts the * system's robustness rather than helping it: we do not want to take * down the whole system due to corruption on one data page. In - * particular, if the bad page is encountered again during recovery then - * we would be unable to restart the database at all! (This scenario - * has actually happened in the field several times with 7.1 releases. - * Note that we cannot get here while InRedo is true, but if the bad - * page is brought in and marked dirty during recovery then + * particular, if the bad page is encountered again during recovery + * then we would be unable to restart the database at all! (This + * scenario has actually happened in the field several times with 7.1 + * releases. Note that we cannot get here while InRedo is true, but if + * the bad page is brought in and marked dirty during recovery then * CreateCheckpoint will try to flush it at the end of recovery.) * * The current approach is to ERROR under normal conditions, but only - * WARNING during recovery, so that the system can be brought up even if - * there's a corrupt LSN. Note that for calls from xact.c, the ERROR - * will be promoted to PANIC since xact.c calls this routine inside a - * critical section. However, calls from bufmgr.c are not within - * critical sections and so we will not force a restart for a bad LSN - * on a data page. + * WARNING during recovery, so that the system can be brought up even + * if there's a corrupt LSN. Note that for calls from xact.c, the + * ERROR will be promoted to PANIC since xact.c calls this routine + * inside a critical section. However, calls from bufmgr.c are not + * within critical sections and so we will not force a restart for a + * bad LSN on a data page. */ if (XLByteLT(LogwrtResult.Flush, record)) elog(InRecovery ? WARNING : ERROR, @@ -1565,7 +1566,7 @@ PreallocXlogFiles(XLogRecPtr endptr) XLByteToPrevSeg(endptr, _logId, _logSeg); if ((endptr.xrecoff - 1) % XLogSegSize >= - (uint32) (0.75 * XLogSegSize)) + (uint32) (0.75 * XLogSegSize)) { NextLogSeg(_logId, _logSeg); use_existent = true; @@ -1618,8 +1619,8 @@ MoveOfflineLogs(uint32 log, uint32 seg, XLogRecPtr endptr) /* * Before deleting the file, see if it can be recycled as * a future log segment. We allow recycling segments up - * to XLOGfileslop segments beyond the current - * XLOG location. + * to XLOGfileslop segments beyond the current XLOG + * location. */ if (InstallXLogFileSegment(endlogId, endlogSeg, path, true, XLOGfileslop, @@ -2196,7 +2197,7 @@ ReadControlFile(void) if (ControlFile->catalog_version_no != CATALOG_VERSION_NO) elog(PANIC, "The database cluster was initialized with CATALOG_VERSION_NO %d,\n" - "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n" + "\tbut the backend was compiled with CATALOG_VERSION_NO %d.\n" "\tIt looks like you need to initdb.", ControlFile->catalog_version_no, CATALOG_VERSION_NO); if (ControlFile->blcksz != BLCKSZ) @@ -2221,7 +2222,7 @@ ReadControlFile(void) if (ControlFile->funcMaxArgs != FUNC_MAX_ARGS) elog(PANIC, - "The database cluster was initialized with FUNC_MAX_ARGS %d,\n" + "The database cluster was initialized with FUNC_MAX_ARGS %d,\n" "\tbut the backend was compiled with FUNC_MAX_ARGS %d.\n" "\tIt looks like you need to recompile or initdb.", ControlFile->funcMaxArgs, FUNC_MAX_ARGS); @@ -2235,21 +2236,21 @@ ReadControlFile(void) #else if (ControlFile->enableIntTimes != FALSE) elog(PANIC, - "The database cluster was initialized with HAVE_INT64_TIMESTAMP\n" - "\tbut the backend was compiled without HAVE_INT64_TIMESTAMP.\n" + "The database cluster was initialized with HAVE_INT64_TIMESTAMP\n" + "\tbut the backend was compiled without HAVE_INT64_TIMESTAMP.\n" "\tIt looks like you need to recompile or initdb."); #endif if (ControlFile->localeBuflen != LOCALE_NAME_BUFLEN) elog(PANIC, "The database cluster was initialized with LOCALE_NAME_BUFLEN %d,\n" - "\tbut the backend was compiled with LOCALE_NAME_BUFLEN %d.\n" + "\tbut the backend was compiled with LOCALE_NAME_BUFLEN %d.\n" "\tIt looks like you need to initdb.", ControlFile->localeBuflen, LOCALE_NAME_BUFLEN); if (setlocale(LC_COLLATE, ControlFile->lc_collate) == NULL) elog(PANIC, - "The database cluster was initialized with LC_COLLATE '%s',\n" + "The database cluster was initialized with LC_COLLATE '%s',\n" "\twhich is not recognized by setlocale().\n" "\tIt looks like you need to initdb.", ControlFile->lc_collate); @@ -3019,19 +3020,19 @@ CreateCheckPoint(bool shutdown) } /* - * Get UNDO record ptr - this is oldest of PGPROC->logRec values. We do - * this while holding insert lock to ensure that we won't miss any + * Get UNDO record ptr - this is oldest of PGPROC->logRec values. We + * do this while holding insert lock to ensure that we won't miss any * about-to-commit transactions (UNDO must include all xacts that have * commits after REDO point). * * XXX temporarily ifdef'd out to avoid three-way deadlock condition: * GetUndoRecPtr needs to grab SInvalLock to ensure that it is looking - * at a stable set of proc records, but grabbing SInvalLock while holding - * WALInsertLock is no good. GetNewTransactionId may cause a WAL record - * to be written while holding XidGenLock, and GetSnapshotData needs to - * get XidGenLock while holding SInvalLock, so there's a risk of deadlock. - * Need to find a better solution. See pgsql-hackers discussion of - * 17-Dec-01. + * at a stable set of proc records, but grabbing SInvalLock while + * holding WALInsertLock is no good. GetNewTransactionId may cause a + * WAL record to be written while holding XidGenLock, and + * GetSnapshotData needs to get XidGenLock while holding SInvalLock, + * so there's a risk of deadlock. Need to find a better solution. See + * pgsql-hackers discussion of 17-Dec-01. */ #ifdef NOT_USED checkPoint.undo = GetUndoRecPtr(); @@ -3298,9 +3299,7 @@ assign_xlog_sync_method(const char *method, bool doit, bool interactive) } #endif else - { return NULL; - } if (!doit) return method; diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 28faa61b29..26e522f6cf 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.140 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/bootstrap/bootstrap.c,v 1.141 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -191,7 +191,7 @@ usage(void) { fprintf(stderr, gettext("Usage:\n" - " postgres -boot [-d level] [-D datadir] [-F] [-o file] [-x num] dbname\n" + " postgres -boot [-d level] [-D datadir] [-F] [-o file] [-x num] dbname\n" " -d 1-5 debug mode\n" " -D datadir data directory\n" " -F turn off fsync\n" @@ -235,9 +235,7 @@ BootstrapMain(int argc, char *argv[]) * If we are running under the postmaster, this is done already. */ if (!IsUnderPostmaster) - { MemoryContextInit(); - } /* * process command arguments @@ -260,18 +258,19 @@ BootstrapMain(int argc, char *argv[]) potential_DataDir = optarg; break; case 'd': - { - /* Turn on debugging for the bootstrap process. */ - char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); - sprintf(debugstr, "debug%s", optarg); - SetConfigOption("server_min_messages", debugstr, - PGC_POSTMASTER, PGC_S_ARGV); - SetConfigOption("client_min_messages", debugstr, - PGC_POSTMASTER, PGC_S_ARGV); - pfree(debugstr); + { + /* Turn on debugging for the bootstrap process. */ + char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); + + sprintf(debugstr, "debug%s", optarg); + SetConfigOption("server_min_messages", debugstr, + PGC_POSTMASTER, PGC_S_ARGV); + SetConfigOption("client_min_messages", debugstr, + PGC_POSTMASTER, PGC_S_ARGV); + pfree(debugstr); + break; + } break; - } - break; case 'F': SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV); break; @@ -391,7 +390,8 @@ BootstrapMain(int argc, char *argv[]) InitDummyProcess(); /* needed to get LWLocks */ CreateDummyCaches(); CreateCheckPoint(false); - SetSavedRedoRecPtr(); /* pass redo ptr back to postmaster */ + SetSavedRedoRecPtr(); /* pass redo ptr back to + * postmaster */ proc_exit(0); /* done */ case BS_XLOG_STARTUP: @@ -587,7 +587,7 @@ DefineAttr(char *name, char *type, int attnum) namestrcpy(&attrtypes[attnum]->attname, name); elog(DEBUG3, "column %s %s", NameStr(attrtypes[attnum]->attname), type); - attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */ + attrtypes[attnum]->attnum = 1 + attnum; /* fillatt */ typeoid = gettype(type); @@ -640,14 +640,15 @@ DefineAttr(char *name, char *type, int attnum) } attrtypes[attnum]->attcacheoff = -1; attrtypes[attnum]->atttypmod = -1; + /* - * Mark as "not null" if type is fixed-width and prior columns are too. - * This corresponds to case where column can be accessed directly via - * C struct declaration. + * Mark as "not null" if type is fixed-width and prior columns are + * too. This corresponds to case where column can be accessed directly + * via C struct declaration. */ if (attlen > 0) { - int i; + int i; for (i = 0; i < attnum; i++) { @@ -829,7 +830,7 @@ cleanup() * and not an OID at all, until the first reference to a type not known in * Procid[]. At that point it will read and cache pg_type in the Typ array, * and subsequently return a real OID (and set the global pointer Ap to - * point at the found row in Typ). So caller must check whether Typ is + * point at the found row in Typ). So caller must check whether Typ is * still NULL to determine what the return value is! * ---------------- */ diff --git a/src/backend/catalog/aclchk.c b/src/backend/catalog/aclchk.c index ea3131b3fc..56c9a4fe65 100644 --- a/src/backend/catalog/aclchk.c +++ b/src/backend/catalog/aclchk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.76 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/aclchk.c,v 1.77 2002/09/04 20:31:13 momjian Exp $ * * NOTES * See acl.h. @@ -91,22 +91,25 @@ merge_acl_with_grant(Acl *old_acl, bool is_grant, foreach(j, grantees) { PrivGrantee *grantee = (PrivGrantee *) lfirst(j); - AclItem aclitem; + AclItem aclitem; uint32 idtype; if (grantee->username) { - aclitem.ai_id = get_usesysid(grantee->username); + aclitem. ai_id = get_usesysid(grantee->username); + idtype = ACL_IDTYPE_UID; } else if (grantee->groupname) { - aclitem.ai_id = get_grosysid(grantee->groupname); + aclitem. ai_id = get_grosysid(grantee->groupname); + idtype = ACL_IDTYPE_GID; } else { - aclitem.ai_id = ACL_ID_WORLD; + aclitem. ai_id = ACL_ID_WORLD; + idtype = ACL_IDTYPE_WORLD; } @@ -376,7 +379,7 @@ ExecuteGrantStmt_Function(GrantStmt *stmt) char replaces[Natts_pg_proc]; oid = LookupFuncNameTypeNames(func->funcname, func->funcargs, - stmt->is_grant ? "GRANT" : "REVOKE"); + stmt->is_grant ? "GRANT" : "REVOKE"); relation = heap_openr(ProcedureRelationName, RowExclusiveLock); tuple = SearchSysCache(PROCOID, @@ -569,8 +572,8 @@ ExecuteGrantStmt_Namespace(GrantStmt *stmt) aclcheck_error(ACLCHECK_NOT_OWNER, nspname); /* - * If there's no ACL, create a default using the pg_namespace.nspowner - * field. + * If there's no ACL, create a default using the + * pg_namespace.nspowner field. */ aclDatum = SysCacheGetAttr(NAMESPACENAME, tuple, Anum_pg_namespace_nspacl, @@ -1163,8 +1166,8 @@ pg_namespace_aclcheck(Oid nsp_oid, Oid userid, AclMode mode) Acl *acl; /* - * If we have been assigned this namespace as a temp namespace, - * assume we have all grantable privileges on it. + * If we have been assigned this namespace as a temp namespace, assume + * we have all grantable privileges on it. */ if (isTempNamespace(nsp_oid)) return ACLCHECK_OK; diff --git a/src/backend/catalog/catalog.c b/src/backend/catalog/catalog.c index 4c4578719c..2792d27220 100644 --- a/src/backend/catalog/catalog.c +++ b/src/backend/catalog/catalog.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.47 2002/06/20 20:29:26 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/catalog.c,v 1.48 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,8 +91,8 @@ GetDatabasePath(Oid tblNode) bool IsSystemRelation(Relation relation) { - return IsSystemNamespace(RelationGetNamespace(relation)) || - IsToastNamespace(RelationGetNamespace(relation)); + return IsSystemNamespace(RelationGetNamespace(relation)) || + IsToastNamespace(RelationGetNamespace(relation)); } /* @@ -104,10 +104,10 @@ IsSystemRelation(Relation relation) bool IsSystemClass(Form_pg_class reltuple) { - Oid relnamespace = reltuple->relnamespace; + Oid relnamespace = reltuple->relnamespace; - return IsSystemNamespace(relnamespace) || - IsToastNamespace(relnamespace); + return IsSystemNamespace(relnamespace) || + IsToastNamespace(relnamespace); } /* @@ -129,9 +129,9 @@ IsToastRelation(Relation relation) bool IsToastClass(Form_pg_class reltuple) { - Oid relnamespace = reltuple->relnamespace; + Oid relnamespace = reltuple->relnamespace; - return IsToastNamespace(relnamespace); + return IsToastNamespace(relnamespace); } /* diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c index d51c8d589a..8fb977e725 100644 --- a/src/backend/catalog/dependency.c +++ b/src/backend/catalog/dependency.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.8 2002/08/02 18:15:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/dependency.c,v 1.9 2002/09/04 20:31:13 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -69,46 +69,46 @@ typedef enum ObjectClasses /* expansible list of ObjectAddresses */ typedef struct ObjectAddresses { - ObjectAddress *refs; /* => palloc'd array */ - int numrefs; /* current number of references */ - int maxrefs; /* current size of palloc'd array */ - struct ObjectAddresses *link; /* list link for use in recursion */ + ObjectAddress *refs; /* => palloc'd array */ + int numrefs; /* current number of references */ + int maxrefs; /* current size of palloc'd array */ + struct ObjectAddresses *link; /* list link for use in recursion */ } ObjectAddresses; /* for find_expr_references_walker */ typedef struct { - ObjectAddresses addrs; /* addresses being accumulated */ - List *rtables; /* list of rangetables to resolve Vars */ + ObjectAddresses addrs; /* addresses being accumulated */ + List *rtables; /* list of rangetables to resolve Vars */ } find_expr_references_context; /* * Because not all system catalogs have predetermined OIDs, we build a table - * mapping between ObjectClasses and OIDs. This is done at most once per + * mapping between ObjectClasses and OIDs. This is done at most once per * backend run, to minimize lookup overhead. */ -static bool object_classes_initialized = false; +static bool object_classes_initialized = false; static Oid object_classes[MAX_OCLASS]; static bool recursiveDeletion(const ObjectAddress *object, - DropBehavior behavior, - const ObjectAddress *callingObject, - ObjectAddresses *pending, - Relation depRel); + DropBehavior behavior, + const ObjectAddress *callingObject, + ObjectAddresses *pending, + Relation depRel); static void doDeletion(const ObjectAddress *object); static bool find_expr_references_walker(Node *node, - find_expr_references_context *context); + find_expr_references_context *context); static void eliminate_duplicate_dependencies(ObjectAddresses *addrs); static int object_address_comparator(const void *a, const void *b); static void init_object_addresses(ObjectAddresses *addrs); static void add_object_address(ObjectClasses oclass, Oid objectId, int32 subId, - ObjectAddresses *addrs); + ObjectAddresses *addrs); static void add_exact_object_address(const ObjectAddress *object, - ObjectAddresses *addrs); + ObjectAddresses *addrs); static void del_object_address(const ObjectAddress *object, - ObjectAddresses *addrs); + ObjectAddresses *addrs); static void del_object_address_by_index(int index, ObjectAddresses *addrs); static void term_object_addresses(ObjectAddresses *addrs); static void init_object_classes(void); @@ -131,12 +131,12 @@ void performDeletion(const ObjectAddress *object, DropBehavior behavior) { - char *objDescription; - Relation depRel; + char *objDescription; + Relation depRel; /* - * Get object description for possible use in failure message. - * Must do this before deleting it ... + * Get object description for possible use in failure message. Must do + * this before deleting it ... */ objDescription = getObjectDescription(object); @@ -165,7 +165,7 @@ performDeletion(const ObjectAddress *object, * callingObject is NULL at the outer level, else identifies the object that * we recursed from (the reference object that someone else needs to delete). * pending is a linked list of objects that outer recursion levels want to - * delete. We remove the target object from any outer-level list it may + * delete. We remove the target object from any outer-level list it may * appear in. * depRel is the already-open pg_depend relation. * @@ -178,7 +178,7 @@ performDeletion(const ObjectAddress *object, * This is even more complex than one could wish, because it is possible for * the same pair of objects to be related by both NORMAL and AUTO (or IMPLICIT) * dependencies. (Since one or both paths might be indirect, it's very hard - * to prevent this; we must cope instead.) If there is an AUTO/IMPLICIT + * to prevent this; we must cope instead.) If there is an AUTO/IMPLICIT * deletion path then we should perform the deletion, and not fail because * of the NORMAL dependency. So, when we hit a NORMAL dependency we don't * immediately decide we've failed; instead we stick the NORMAL dependent @@ -191,7 +191,7 @@ performDeletion(const ObjectAddress *object, * * Note: in the case where the AUTO path is traversed first, we will never * see the NORMAL dependency path because of the pg_depend removals done in - * recursive executions of step 1. The pending list is necessary essentially + * recursive executions of step 1. The pending list is necessary essentially * just to make the behavior independent of the order in which pg_depend * entries are visited. */ @@ -202,16 +202,16 @@ recursiveDeletion(const ObjectAddress *object, ObjectAddresses *pending, Relation depRel) { - bool ok = true; - char *objDescription; - ObjectAddresses mypending; - ScanKeyData key[3]; - int nkeys; - SysScanDesc scan; - HeapTuple tup; - ObjectAddress otherObject; - ObjectAddress owningObject; - bool amOwned = false; + bool ok = true; + char *objDescription; + ObjectAddresses mypending; + ScanKeyData key[3]; + int nkeys; + SysScanDesc scan; + HeapTuple tup; + ObjectAddress otherObject; + ObjectAddress owningObject; + bool amOwned = false; /* * Get object description for possible use in messages. Must do this @@ -231,8 +231,8 @@ recursiveDeletion(const ObjectAddress *object, * ensures that we avoid infinite recursion in the case of cycles. * Also, some dependency types require extra processing here. * - * When dropping a whole object (subId = 0), remove all pg_depend - * records for its sub-objects too. + * When dropping a whole object (subId = 0), remove all pg_depend records + * for its sub-objects too. */ ScanKeyEntryInitialize(&key[0], 0x0, Anum_pg_depend_classid, F_OIDEQ, @@ -255,7 +255,7 @@ recursiveDeletion(const ObjectAddress *object, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); otherObject.classId = foundDep->refclassid; otherObject.objectId = foundDep->refobjid; @@ -268,9 +268,10 @@ recursiveDeletion(const ObjectAddress *object, /* no problem */ break; case DEPENDENCY_INTERNAL: + /* - * This object is part of the internal implementation - * of another object. We have three cases: + * This object is part of the internal implementation of + * another object. We have three cases: * * 1. At the outermost recursion level, disallow the DROP. * (We just elog here, rather than considering this drop @@ -279,30 +280,32 @@ recursiveDeletion(const ObjectAddress *object, */ if (callingObject == NULL) { - char *otherObjDesc = getObjectDescription(&otherObject); + char *otherObjDesc = getObjectDescription(&otherObject); elog(ERROR, "Cannot drop %s because %s requires it" "\n\tYou may drop %s instead", objDescription, otherObjDesc, otherObjDesc); } + /* - * 2. When recursing from the other end of this dependency, - * it's okay to continue with the deletion. This holds when - * recursing from a whole object that includes the nominal - * other end as a component, too. + * 2. When recursing from the other end of this + * dependency, it's okay to continue with the deletion. + * This holds when recursing from a whole object that + * includes the nominal other end as a component, too. */ if (callingObject->classId == otherObject.classId && callingObject->objectId == otherObject.objectId && - (callingObject->objectSubId == otherObject.objectSubId || - callingObject->objectSubId == 0)) + (callingObject->objectSubId == otherObject.objectSubId || + callingObject->objectSubId == 0)) break; + /* * 3. When recursing from anyplace else, transform this * deletion request into a delete of the other object. - * (This will be an error condition iff RESTRICT mode.) - * In this case we finish deleting my dependencies except - * for the INTERNAL link, which will be needed to cause - * the owning object to recurse back to me. + * (This will be an error condition iff RESTRICT mode.) In + * this case we finish deleting my dependencies except for + * the INTERNAL link, which will be needed to cause the + * owning object to recurse back to me. */ if (amOwned) /* shouldn't happen */ elog(ERROR, "recursiveDeletion: multiple INTERNAL dependencies for %s", @@ -312,6 +315,7 @@ recursiveDeletion(const ObjectAddress *object, /* "continue" bypasses the simple_heap_delete call below */ continue; case DEPENDENCY_PIN: + /* * Should not happen; PIN dependencies should have zeroes * in the depender fields... @@ -331,10 +335,10 @@ recursiveDeletion(const ObjectAddress *object, systable_endscan(scan); /* - * CommandCounterIncrement here to ensure that preceding changes - * are all visible; in particular, that the above deletions of pg_depend - * entries are visible. That prevents infinite recursion in case of - * a dependency loop (which is perfectly legal). + * CommandCounterIncrement here to ensure that preceding changes are + * all visible; in particular, that the above deletions of pg_depend + * entries are visible. That prevents infinite recursion in case of a + * dependency loop (which is perfectly legal). */ CommandCounterIncrement(); @@ -368,21 +372,21 @@ recursiveDeletion(const ObjectAddress *object, /* * Step 2: scan pg_depend records that link to this object, showing - * the things that depend on it. Recursively delete those things. - * (We don't delete the pg_depend records here, as the recursive call - * will do that.) Note it's important to delete the dependent objects + * the things that depend on it. Recursively delete those things. (We + * don't delete the pg_depend records here, as the recursive call will + * do that.) Note it's important to delete the dependent objects * before the referenced one, since the deletion routines might do - * things like try to update the pg_class record when deleting a - * check constraint. + * things like try to update the pg_class record when deleting a check + * constraint. * * Again, when dropping a whole object (subId = 0), find pg_depend * records for its sub-objects too. * * NOTE: because we are using SnapshotNow, if a recursive call deletes - * any pg_depend tuples that our scan hasn't yet visited, we will not see - * them as good when we do visit them. This is essential for correct - * behavior if there are multiple dependency paths between two objects - * --- else we might try to delete an already-deleted object. + * any pg_depend tuples that our scan hasn't yet visited, we will not + * see them as good when we do visit them. This is essential for + * correct behavior if there are multiple dependency paths between two + * objects --- else we might try to delete an already-deleted object. */ ScanKeyEntryInitialize(&key[0], 0x0, Anum_pg_depend_refclassid, F_OIDEQ, @@ -405,7 +409,7 @@ recursiveDeletion(const ObjectAddress *object, while (HeapTupleIsValid(tup = systable_getnext(scan))) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); otherObject.classId = foundDep->classid; otherObject.objectId = foundDep->objid; @@ -418,9 +422,9 @@ recursiveDeletion(const ObjectAddress *object, { /* * We've found a restricted object (or at least one - * that's not deletable along this path). Log for later - * processing. (Note it's okay if the same object gets - * into mypending multiple times.) + * that's not deletable along this path). Log for + * later processing. (Note it's okay if the same + * object gets into mypending multiple times.) */ add_exact_object_address(&otherObject, &mypending); } @@ -437,6 +441,7 @@ recursiveDeletion(const ObjectAddress *object, break; case DEPENDENCY_AUTO: case DEPENDENCY_INTERNAL: + /* * We propagate the DROP without complaint even in the * RESTRICT case. (However, normal dependencies on the @@ -451,6 +456,7 @@ recursiveDeletion(const ObjectAddress *object, ok = false; break; case DEPENDENCY_PIN: + /* * For a PIN dependency we just elog immediately; there * won't be any others to report. @@ -469,19 +475,19 @@ recursiveDeletion(const ObjectAddress *object, /* * If we found no restricted objects, or got rid of them all via other - * paths, we're in good shape. Otherwise continue step 2 by processing - * the remaining restricted objects. + * paths, we're in good shape. Otherwise continue step 2 by + * processing the remaining restricted objects. */ if (mypending.numrefs > 0) { /* - * Successively extract and delete each remaining object. - * Note that the right things will happen if some of these objects + * Successively extract and delete each remaining object. Note + * that the right things will happen if some of these objects * depend on others: we'll report/delete each one exactly once. */ while (mypending.numrefs > 0) { - ObjectAddress otherObject = mypending.refs[0]; + ObjectAddress otherObject = mypending.refs[0]; del_object_address_by_index(0, &mypending); @@ -508,19 +514,21 @@ recursiveDeletion(const ObjectAddress *object, doDeletion(object); /* - * Delete any comments associated with this object. (This is a convenient - * place to do it instead of having every object type know to do it.) + * Delete any comments associated with this object. (This is a + * convenient place to do it instead of having every object type know + * to do it.) */ DeleteComments(object->objectId, object->classId, object->objectSubId); /* - * If this object is mentioned in any caller's pending list, remove it. + * If this object is mentioned in any caller's pending list, remove + * it. */ del_object_address(object, pending); /* - * CommandCounterIncrement here to ensure that preceding changes - * are all visible. + * CommandCounterIncrement here to ensure that preceding changes are + * all visible. */ CommandCounterIncrement(); @@ -543,37 +551,37 @@ doDeletion(const ObjectAddress *object) switch (getObjectClass(object)) { case OCLASS_CLASS: - { - HeapTuple relTup; - char relKind; - - /* - * Need the relkind to figure out how to drop. - */ - relTup = SearchSysCache(RELOID, - ObjectIdGetDatum(object->objectId), - 0, 0, 0); - if (!HeapTupleIsValid(relTup)) - elog(ERROR, "doDeletion: Relation %u does not exist", - object->objectId); - relKind = ((Form_pg_class) GETSTRUCT(relTup))->relkind; - ReleaseSysCache(relTup); - - if (relKind == RELKIND_INDEX) - { - Assert(object->objectSubId == 0); - index_drop(object->objectId); - } - else { - if (object->objectSubId != 0) - RemoveAttributeById(object->objectId, - object->objectSubId); + HeapTuple relTup; + char relKind; + + /* + * Need the relkind to figure out how to drop. + */ + relTup = SearchSysCache(RELOID, + ObjectIdGetDatum(object->objectId), + 0, 0, 0); + if (!HeapTupleIsValid(relTup)) + elog(ERROR, "doDeletion: Relation %u does not exist", + object->objectId); + relKind = ((Form_pg_class) GETSTRUCT(relTup))->relkind; + ReleaseSysCache(relTup); + + if (relKind == RELKIND_INDEX) + { + Assert(object->objectSubId == 0); + index_drop(object->objectId); + } else - heap_drop_with_catalog(object->objectId); + { + if (object->objectSubId != 0) + RemoveAttributeById(object->objectId, + object->objectSubId); + else + heap_drop_with_catalog(object->objectId); + } + break; } - break; - } case OCLASS_PROC: RemoveFunctionById(object->objectId); @@ -644,7 +652,7 @@ doDeletion(const ObjectAddress *object) * It can be NIL if no such variables are expected. * * XXX is it important to create dependencies on the datatypes mentioned in - * the expression? In most cases this would be redundant (eg, a ref to an + * the expression? In most cases this would be redundant (eg, a ref to an * operator indirectly references its input and output datatypes), but I'm * not quite convinced there are no cases where we need it. */ @@ -653,7 +661,7 @@ recordDependencyOnExpr(const ObjectAddress *depender, Node *expr, List *rtable, DependencyType behavior) { - find_expr_references_context context; + find_expr_references_context context; init_object_addresses(&context.addrs); @@ -755,8 +763,8 @@ find_expr_references_walker(Node *node, bool result; /* - * Add whole-relation refs for each plain relation mentioned in the - * subquery's rtable. (Note: query_tree_walker takes care of + * Add whole-relation refs for each plain relation mentioned in + * the subquery's rtable. (Note: query_tree_walker takes care of * recursing into RTE_FUNCTION and RTE_SUBQUERY RTEs, so no need * to do that here.) */ @@ -787,7 +795,7 @@ find_expr_references_walker(Node *node, static void eliminate_duplicate_dependencies(ObjectAddresses *addrs) { - ObjectAddress *priorobj; + ObjectAddress *priorobj; int oldref, newrefs; @@ -803,13 +811,14 @@ eliminate_duplicate_dependencies(ObjectAddresses *addrs) newrefs = 1; for (oldref = 1; oldref < addrs->numrefs; oldref++) { - ObjectAddress *thisobj = addrs->refs + oldref; + ObjectAddress *thisobj = addrs->refs + oldref; if (priorobj->classId == thisobj->classId && priorobj->objectId == thisobj->objectId) { if (priorobj->objectSubId == thisobj->objectSubId) continue; /* identical, so drop thisobj */ + /* * If we have a whole-object reference and a reference to a * part of the same object, we don't need the whole-object @@ -852,9 +861,10 @@ object_address_comparator(const void *a, const void *b) return -1; if (obja->objectId > objb->objectId) return 1; + /* - * We sort the subId as an unsigned int so that 0 will come first. - * See logic in eliminate_duplicate_dependencies. + * We sort the subId as an unsigned int so that 0 will come first. See + * logic in eliminate_duplicate_dependencies. */ if ((unsigned int) obja->objectSubId < (unsigned int) objb->objectSubId) return -1; @@ -894,7 +904,7 @@ static void add_object_address(ObjectClasses oclass, Oid objectId, int32 subId, ObjectAddresses *addrs) { - ObjectAddress *item; + ObjectAddress *item; /* enlarge array if needed */ if (addrs->numrefs >= addrs->maxrefs) @@ -920,7 +930,7 @@ static void add_exact_object_address(const ObjectAddress *object, ObjectAddresses *addrs) { - ObjectAddress *item; + ObjectAddress *item; /* enlarge array if needed */ if (addrs->numrefs >= addrs->maxrefs) @@ -937,7 +947,7 @@ add_exact_object_address(const ObjectAddress *object, /* * If an ObjectAddresses array contains any matches for the given object, - * remove it/them. Also, do the same in any linked ObjectAddresses arrays. + * remove it/them. Also, do the same in any linked ObjectAddresses arrays. */ static void del_object_address(const ObjectAddress *object, @@ -948,9 +958,9 @@ del_object_address(const ObjectAddress *object, int i; /* Scan backwards to simplify deletion logic. */ - for (i = addrs->numrefs-1; i >= 0; i--) + for (i = addrs->numrefs - 1; i >= 0; i--) { - ObjectAddress *thisobj = addrs->refs + i; + ObjectAddress *thisobj = addrs->refs + i; if (object->classId == thisobj->classId && object->objectId == thisobj->objectId) @@ -1134,150 +1144,150 @@ getObjectDescription(const ObjectAddress *object) break; case OCLASS_CAST: - { - Relation castDesc; - ScanKeyData skey[1]; - SysScanDesc rcscan; - HeapTuple tup; - Form_pg_cast castForm; + { + Relation castDesc; + ScanKeyData skey[1]; + SysScanDesc rcscan; + HeapTuple tup; + Form_pg_cast castForm; - castDesc = heap_openr(CastRelationName, AccessShareLock); + castDesc = heap_openr(CastRelationName, AccessShareLock); - ScanKeyEntryInitialize(&skey[0], 0x0, - ObjectIdAttributeNumber, F_OIDEQ, - ObjectIdGetDatum(object->objectId)); + ScanKeyEntryInitialize(&skey[0], 0x0, + ObjectIdAttributeNumber, F_OIDEQ, + ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(castDesc, CastOidIndex, true, - SnapshotNow, 1, skey); + rcscan = systable_beginscan(castDesc, CastOidIndex, true, + SnapshotNow, 1, skey); - tup = systable_getnext(rcscan); + tup = systable_getnext(rcscan); - if (!HeapTupleIsValid(tup)) - elog(ERROR, "getObjectDescription: Cast %u does not exist", - object->objectId); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "getObjectDescription: Cast %u does not exist", + object->objectId); - castForm = (Form_pg_cast) GETSTRUCT(tup); + castForm = (Form_pg_cast) GETSTRUCT(tup); - appendStringInfo(&buffer, "cast from %s to %s", - format_type_be(castForm->castsource), - format_type_be(castForm->casttarget)); + appendStringInfo(&buffer, "cast from %s to %s", + format_type_be(castForm->castsource), + format_type_be(castForm->casttarget)); - systable_endscan(rcscan); - heap_close(castDesc, AccessShareLock); - break; - } + systable_endscan(rcscan); + heap_close(castDesc, AccessShareLock); + break; + } case OCLASS_CONSTRAINT: - { - Relation conDesc; - ScanKeyData skey[1]; - SysScanDesc rcscan; - HeapTuple tup; - Form_pg_constraint con; + { + Relation conDesc; + ScanKeyData skey[1]; + SysScanDesc rcscan; + HeapTuple tup; + Form_pg_constraint con; - conDesc = heap_openr(ConstraintRelationName, AccessShareLock); + conDesc = heap_openr(ConstraintRelationName, AccessShareLock); - ScanKeyEntryInitialize(&skey[0], 0x0, - ObjectIdAttributeNumber, F_OIDEQ, - ObjectIdGetDatum(object->objectId)); + ScanKeyEntryInitialize(&skey[0], 0x0, + ObjectIdAttributeNumber, F_OIDEQ, + ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(conDesc, ConstraintOidIndex, true, - SnapshotNow, 1, skey); + rcscan = systable_beginscan(conDesc, ConstraintOidIndex, true, + SnapshotNow, 1, skey); - tup = systable_getnext(rcscan); + tup = systable_getnext(rcscan); - if (!HeapTupleIsValid(tup)) - elog(ERROR, "getObjectDescription: Constraint %u does not exist", - object->objectId); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "getObjectDescription: Constraint %u does not exist", + object->objectId); - con = (Form_pg_constraint) GETSTRUCT(tup); + con = (Form_pg_constraint) GETSTRUCT(tup); - if (OidIsValid(con->conrelid)) - { - appendStringInfo(&buffer, "constraint %s on ", - NameStr(con->conname)); - getRelationDescription(&buffer, con->conrelid); - } - else - { - appendStringInfo(&buffer, "constraint %s", - NameStr(con->conname)); - } + if (OidIsValid(con->conrelid)) + { + appendStringInfo(&buffer, "constraint %s on ", + NameStr(con->conname)); + getRelationDescription(&buffer, con->conrelid); + } + else + { + appendStringInfo(&buffer, "constraint %s", + NameStr(con->conname)); + } - systable_endscan(rcscan); - heap_close(conDesc, AccessShareLock); - break; - } + systable_endscan(rcscan); + heap_close(conDesc, AccessShareLock); + break; + } case OCLASS_CONVERSION: - { - HeapTuple conTup; - - conTup = SearchSysCache(CONOID, - ObjectIdGetDatum(object->objectId), - 0, 0, 0); - if (!HeapTupleIsValid(conTup)) - elog(ERROR, "getObjectDescription: Conversion %u does not exist", - object->objectId); - appendStringInfo(&buffer, "conversion %s", - NameStr(((Form_pg_conversion) GETSTRUCT(conTup))->conname)); - ReleaseSysCache(conTup); - break; - } + { + HeapTuple conTup; + + conTup = SearchSysCache(CONOID, + ObjectIdGetDatum(object->objectId), + 0, 0, 0); + if (!HeapTupleIsValid(conTup)) + elog(ERROR, "getObjectDescription: Conversion %u does not exist", + object->objectId); + appendStringInfo(&buffer, "conversion %s", + NameStr(((Form_pg_conversion) GETSTRUCT(conTup))->conname)); + ReleaseSysCache(conTup); + break; + } case OCLASS_DEFAULT: - { - Relation attrdefDesc; - ScanKeyData skey[1]; - SysScanDesc adscan; - HeapTuple tup; - Form_pg_attrdef attrdef; - ObjectAddress colobject; + { + Relation attrdefDesc; + ScanKeyData skey[1]; + SysScanDesc adscan; + HeapTuple tup; + Form_pg_attrdef attrdef; + ObjectAddress colobject; - attrdefDesc = heap_openr(AttrDefaultRelationName, AccessShareLock); + attrdefDesc = heap_openr(AttrDefaultRelationName, AccessShareLock); - ScanKeyEntryInitialize(&skey[0], 0x0, - ObjectIdAttributeNumber, F_OIDEQ, - ObjectIdGetDatum(object->objectId)); + ScanKeyEntryInitialize(&skey[0], 0x0, + ObjectIdAttributeNumber, F_OIDEQ, + ObjectIdGetDatum(object->objectId)); - adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndex, true, - SnapshotNow, 1, skey); + adscan = systable_beginscan(attrdefDesc, AttrDefaultOidIndex, true, + SnapshotNow, 1, skey); - tup = systable_getnext(adscan); + tup = systable_getnext(adscan); - if (!HeapTupleIsValid(tup)) - elog(ERROR, "getObjectDescription: Default %u does not exist", - object->objectId); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "getObjectDescription: Default %u does not exist", + object->objectId); - attrdef = (Form_pg_attrdef) GETSTRUCT(tup); + attrdef = (Form_pg_attrdef) GETSTRUCT(tup); - colobject.classId = RelOid_pg_class; - colobject.objectId = attrdef->adrelid; - colobject.objectSubId = attrdef->adnum; + colobject.classId = RelOid_pg_class; + colobject.objectId = attrdef->adrelid; + colobject.objectSubId = attrdef->adnum; - appendStringInfo(&buffer, "default for %s", - getObjectDescription(&colobject)); + appendStringInfo(&buffer, "default for %s", + getObjectDescription(&colobject)); - systable_endscan(adscan); - heap_close(attrdefDesc, AccessShareLock); - break; - } + systable_endscan(adscan); + heap_close(attrdefDesc, AccessShareLock); + break; + } case OCLASS_LANGUAGE: - { - HeapTuple langTup; - - langTup = SearchSysCache(LANGOID, - ObjectIdGetDatum(object->objectId), - 0, 0, 0); - if (!HeapTupleIsValid(langTup)) - elog(ERROR, "getObjectDescription: Language %u does not exist", - object->objectId); - appendStringInfo(&buffer, "language %s", - NameStr(((Form_pg_language) GETSTRUCT(langTup))->lanname)); - ReleaseSysCache(langTup); - break; - } + { + HeapTuple langTup; + + langTup = SearchSysCache(LANGOID, + ObjectIdGetDatum(object->objectId), + 0, 0, 0); + if (!HeapTupleIsValid(langTup)) + elog(ERROR, "getObjectDescription: Language %u does not exist", + object->objectId); + appendStringInfo(&buffer, "language %s", + NameStr(((Form_pg_language) GETSTRUCT(langTup))->lanname)); + ReleaseSysCache(langTup); + break; + } case OCLASS_OPERATOR: appendStringInfo(&buffer, "operator %s", @@ -1285,126 +1295,126 @@ getObjectDescription(const ObjectAddress *object) break; case OCLASS_OPCLASS: - { - HeapTuple opcTup; - Form_pg_opclass opcForm; - HeapTuple amTup; - Form_pg_am amForm; - char *nspname; - - opcTup = SearchSysCache(CLAOID, - ObjectIdGetDatum(object->objectId), - 0, 0, 0); - if (!HeapTupleIsValid(opcTup)) - elog(ERROR, "cache lookup of opclass %u failed", - object->objectId); - opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); - - /* Qualify the name if not visible in search path */ - if (OpclassIsVisible(object->objectId)) - nspname = NULL; - else - nspname = get_namespace_name(opcForm->opcnamespace); - - appendStringInfo(&buffer, "operator class %s", - quote_qualified_identifier(nspname, - NameStr(opcForm->opcname))); - - amTup = SearchSysCache(AMOID, - ObjectIdGetDatum(opcForm->opcamid), - 0, 0, 0); - if (!HeapTupleIsValid(amTup)) - elog(ERROR, "syscache lookup for AM %u failed", - opcForm->opcamid); - amForm = (Form_pg_am) GETSTRUCT(amTup); - - appendStringInfo(&buffer, " for %s", - NameStr(amForm->amname)); - - ReleaseSysCache(amTup); - ReleaseSysCache(opcTup); - break; - } + { + HeapTuple opcTup; + Form_pg_opclass opcForm; + HeapTuple amTup; + Form_pg_am amForm; + char *nspname; + + opcTup = SearchSysCache(CLAOID, + ObjectIdGetDatum(object->objectId), + 0, 0, 0); + if (!HeapTupleIsValid(opcTup)) + elog(ERROR, "cache lookup of opclass %u failed", + object->objectId); + opcForm = (Form_pg_opclass) GETSTRUCT(opcTup); + + /* Qualify the name if not visible in search path */ + if (OpclassIsVisible(object->objectId)) + nspname = NULL; + else + nspname = get_namespace_name(opcForm->opcnamespace); + + appendStringInfo(&buffer, "operator class %s", + quote_qualified_identifier(nspname, + NameStr(opcForm->opcname))); + + amTup = SearchSysCache(AMOID, + ObjectIdGetDatum(opcForm->opcamid), + 0, 0, 0); + if (!HeapTupleIsValid(amTup)) + elog(ERROR, "syscache lookup for AM %u failed", + opcForm->opcamid); + amForm = (Form_pg_am) GETSTRUCT(amTup); + + appendStringInfo(&buffer, " for %s", + NameStr(amForm->amname)); + + ReleaseSysCache(amTup); + ReleaseSysCache(opcTup); + break; + } case OCLASS_REWRITE: - { - Relation ruleDesc; - ScanKeyData skey[1]; - SysScanDesc rcscan; - HeapTuple tup; - Form_pg_rewrite rule; + { + Relation ruleDesc; + ScanKeyData skey[1]; + SysScanDesc rcscan; + HeapTuple tup; + Form_pg_rewrite rule; - ruleDesc = heap_openr(RewriteRelationName, AccessShareLock); + ruleDesc = heap_openr(RewriteRelationName, AccessShareLock); - ScanKeyEntryInitialize(&skey[0], 0x0, - ObjectIdAttributeNumber, F_OIDEQ, - ObjectIdGetDatum(object->objectId)); + ScanKeyEntryInitialize(&skey[0], 0x0, + ObjectIdAttributeNumber, F_OIDEQ, + ObjectIdGetDatum(object->objectId)); - rcscan = systable_beginscan(ruleDesc, RewriteOidIndex, true, - SnapshotNow, 1, skey); + rcscan = systable_beginscan(ruleDesc, RewriteOidIndex, true, + SnapshotNow, 1, skey); - tup = systable_getnext(rcscan); + tup = systable_getnext(rcscan); - if (!HeapTupleIsValid(tup)) - elog(ERROR, "getObjectDescription: Rule %u does not exist", - object->objectId); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "getObjectDescription: Rule %u does not exist", + object->objectId); - rule = (Form_pg_rewrite) GETSTRUCT(tup); + rule = (Form_pg_rewrite) GETSTRUCT(tup); - appendStringInfo(&buffer, "rule %s on ", - NameStr(rule->rulename)); - getRelationDescription(&buffer, rule->ev_class); + appendStringInfo(&buffer, "rule %s on ", + NameStr(rule->rulename)); + getRelationDescription(&buffer, rule->ev_class); - systable_endscan(rcscan); - heap_close(ruleDesc, AccessShareLock); - break; - } + systable_endscan(rcscan); + heap_close(ruleDesc, AccessShareLock); + break; + } case OCLASS_TRIGGER: - { - Relation trigDesc; - ScanKeyData skey[1]; - SysScanDesc tgscan; - HeapTuple tup; - Form_pg_trigger trig; + { + Relation trigDesc; + ScanKeyData skey[1]; + SysScanDesc tgscan; + HeapTuple tup; + Form_pg_trigger trig; - trigDesc = heap_openr(TriggerRelationName, AccessShareLock); + trigDesc = heap_openr(TriggerRelationName, AccessShareLock); - ScanKeyEntryInitialize(&skey[0], 0x0, - ObjectIdAttributeNumber, F_OIDEQ, - ObjectIdGetDatum(object->objectId)); + ScanKeyEntryInitialize(&skey[0], 0x0, + ObjectIdAttributeNumber, F_OIDEQ, + ObjectIdGetDatum(object->objectId)); - tgscan = systable_beginscan(trigDesc, TriggerOidIndex, true, - SnapshotNow, 1, skey); + tgscan = systable_beginscan(trigDesc, TriggerOidIndex, true, + SnapshotNow, 1, skey); - tup = systable_getnext(tgscan); + tup = systable_getnext(tgscan); - if (!HeapTupleIsValid(tup)) - elog(ERROR, "getObjectDescription: Trigger %u does not exist", - object->objectId); + if (!HeapTupleIsValid(tup)) + elog(ERROR, "getObjectDescription: Trigger %u does not exist", + object->objectId); - trig = (Form_pg_trigger) GETSTRUCT(tup); + trig = (Form_pg_trigger) GETSTRUCT(tup); - appendStringInfo(&buffer, "trigger %s on ", - NameStr(trig->tgname)); - getRelationDescription(&buffer, trig->tgrelid); + appendStringInfo(&buffer, "trigger %s on ", + NameStr(trig->tgname)); + getRelationDescription(&buffer, trig->tgrelid); - systable_endscan(tgscan); - heap_close(trigDesc, AccessShareLock); - break; - } + systable_endscan(tgscan); + heap_close(trigDesc, AccessShareLock); + break; + } case OCLASS_SCHEMA: - { - char *nspname; + { + char *nspname; - nspname = get_namespace_name(object->objectId); - if (!nspname) - elog(ERROR, "getObjectDescription: Schema %u does not exist", - object->objectId); - appendStringInfo(&buffer, "schema %s", nspname); - break; - } + nspname = get_namespace_name(object->objectId); + if (!nspname) + elog(ERROR, "getObjectDescription: Schema %u does not exist", + object->objectId); + appendStringInfo(&buffer, "schema %s", nspname); + break; + } default: appendStringInfo(&buffer, "unknown object %u %u %d", @@ -1424,7 +1434,7 @@ static void getRelationDescription(StringInfo buffer, Oid relid) { HeapTuple relTup; - Form_pg_class relForm; + Form_pg_class relForm; char *nspname; char *relname; diff --git a/src/backend/catalog/heap.c b/src/backend/catalog/heap.c index 09afaf2df5..15f3e1e2d3 100644 --- a/src/backend/catalog/heap.c +++ b/src/backend/catalog/heap.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.224 2002/09/02 01:05:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/heap.c,v 1.225 2002/09/04 20:31:13 momjian Exp $ * * * INTERFACE ROUTINES @@ -67,10 +67,10 @@ static void AddNewRelationTuple(Relation pg_class_desc, Oid new_rel_oid, Oid new_type_oid, char relkind); static void AddNewRelationType(const char *typeName, - Oid typeNamespace, - Oid new_rel_oid, - char new_rel_kind, - Oid new_type_oid); + Oid typeNamespace, + Oid new_rel_oid, + char new_rel_kind, + Oid new_type_oid); static void RelationRemoveInheritance(Relation relation); static void StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin); static void StoreRelCheck(Relation rel, char *ccname, char *ccbin); @@ -214,14 +214,14 @@ heap_create(const char *relname, Oid relid; Oid dbid = shared_relation ? InvalidOid : MyDatabaseId; bool nailme = false; - RelFileNode rnode; + RelFileNode rnode; Relation rel; /* * sanity checks */ if (!allow_system_table_mods && - (IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) && + (IsSystemNamespace(relnamespace) || IsToastNamespace(relnamespace)) && IsNormalProcessingMode()) elog(ERROR, "cannot create %s.%s: " "system catalog modifications are currently disallowed", @@ -256,21 +256,13 @@ heap_create(const char *relname, relid = RelOid_pg_class; } else if (strcmp(ShadowRelationName, relname) == 0) - { relid = RelOid_pg_shadow; - } else if (strcmp(GroupRelationName, relname) == 0) - { relid = RelOid_pg_group; - } else if (strcmp(DatabaseRelationName, relname) == 0) - { relid = RelOid_pg_database; - } else - { relid = newoid(); - } } else relid = newoid(); @@ -293,7 +285,8 @@ heap_create(const char *relname, nailme); /* - * have the storage manager create the relation's disk file, if wanted. + * have the storage manager create the relation's disk file, if + * wanted. */ if (storage_create) heap_storage_create(rel); @@ -396,7 +389,7 @@ CheckAttributeNames(TupleDesc tupdesc, char relkind) */ for (i = 0; i < natts; i++) { - Oid att_type = tupdesc->attrs[i]->atttypid; + Oid att_type = tupdesc->attrs[i]->atttypid; if (att_type == UNKNOWNOID) elog(WARNING, "Attribute \"%s\" has an unknown type" @@ -427,8 +420,8 @@ AddNewAttributeTuples(Oid new_rel_oid, Relation rel; CatalogIndexState indstate; int natts = tupdesc->natts; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* * open pg_attribute and its indexes. @@ -451,7 +444,7 @@ AddNewAttributeTuples(Oid new_rel_oid, (*dpp)->attcacheoff = -1; tup = heap_addheader(Natts_pg_attribute, - false, + false, ATTRIBUTE_TUPLE_SIZE, (void *) *dpp); @@ -463,7 +456,7 @@ AddNewAttributeTuples(Oid new_rel_oid, myself.classId = RelOid_pg_class; myself.objectId = new_rel_oid; - myself.objectSubId = i+1; + myself.objectSubId = i + 1; referenced.classId = RelOid_pg_type; referenced.objectId = (*dpp)->atttypid; referenced.objectSubId = 0; @@ -475,7 +468,8 @@ AddNewAttributeTuples(Oid new_rel_oid, /* * Next we add the system attributes. Skip OID if rel has no OIDs. * Skip all for a view or type relation. We don't bother with making - * datatype dependencies here, since presumably all these types are pinned. + * datatype dependencies here, since presumably all these types are + * pinned. */ if (relkind != RELKIND_VIEW && relkind != RELKIND_COMPOSITE_TYPE) { @@ -488,7 +482,7 @@ AddNewAttributeTuples(Oid new_rel_oid, Form_pg_attribute attStruct; tup = heap_addheader(Natts_pg_attribute, - false, + false, ATTRIBUTE_TUPLE_SIZE, (void *) *dpp); @@ -497,9 +491,9 @@ AddNewAttributeTuples(Oid new_rel_oid, attStruct->attrelid = new_rel_oid; /* - * Unneeded since they should be OK in the constant data - * anyway - */ + * Unneeded since they should be OK in the constant data + * anyway + */ /* attStruct->attstattarget = 0; */ /* attStruct->attcacheoff = -1; */ @@ -590,7 +584,7 @@ AddNewRelationTuple(Relation pg_class_desc, * ---------------- */ tup = heap_addheader(Natts_pg_class_fixed, - true, + true, CLASS_TUPLE_SIZE, (void *) new_rel_reltup); @@ -628,13 +622,13 @@ AddNewRelationType(const char *typeName, * * OLD and probably obsolete comments: * - * The sizes are set to oid size because it makes implementing sets - * MUCH easier, and no one (we hope) uses these fields to figure out - * how much space to allocate for the type. An oid is the type used - * for a set definition. When a user requests a set, what they - * actually get is the oid of a tuple in the pg_proc catalog, so the - * size of the "set" is the size of an oid. Similarly, byval being - * true makes sets much easier, and it isn't used by anything else. + * The sizes are set to oid size because it makes implementing sets MUCH + * easier, and no one (we hope) uses these fields to figure out how + * much space to allocate for the type. An oid is the type used for a + * set definition. When a user requests a set, what they actually get + * is the oid of a tuple in the pg_proc catalog, so the size of the + * "set" is the size of an oid. Similarly, byval being true makes sets + * much easier, and it isn't used by anything else. */ TypeCreate(typeName, /* type name */ typeNamespace, /* type namespace */ @@ -689,10 +683,10 @@ heap_create_with_catalog(const char *relname, if (get_relname_relid(relname, relnamespace)) elog(ERROR, "Relation '%s' already exists", relname); - + /* * Create the relcache entry (mostly dummy at this point) and the - * physical disk file. (If we fail further down, it's the smgr's + * physical disk file. (If we fail further down, it's the smgr's * responsibility to remove the disk file again.) * * NB: create a physical file only if it's not a view or type relation. @@ -702,7 +696,7 @@ heap_create_with_catalog(const char *relname, tupdesc, shared_relation, (relkind != RELKIND_VIEW && - relkind != RELKIND_COMPOSITE_TYPE), + relkind != RELKIND_COMPOSITE_TYPE), allow_system_table_mods); /* Fetch the relation OID assigned by heap_create */ @@ -746,14 +740,14 @@ heap_create_with_catalog(const char *relname, AddNewAttributeTuples(new_rel_oid, new_rel_desc->rd_att, relkind); /* - * make a dependency link to force the relation to be deleted if - * its namespace is. Skip this in bootstrap mode, since we don't - * make dependencies while bootstrapping. + * make a dependency link to force the relation to be deleted if its + * namespace is. Skip this in bootstrap mode, since we don't make + * dependencies while bootstrapping. */ if (!IsBootstrapProcessingMode()) { - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; myself.classId = RelOid_pg_class; myself.objectId = new_rel_oid; @@ -768,8 +762,9 @@ heap_create_with_catalog(const char *relname, * store constraints and defaults passed in the tupdesc, if any. * * NB: this may do a CommandCounterIncrement and rebuild the relcache - * entry, so the relation must be valid and self-consistent at this point. - * In particular, there are not yet constraints and defaults anywhere. + * entry, so the relation must be valid and self-consistent at this + * point. In particular, there are not yet constraints and defaults + * anywhere. */ StoreConstraints(new_rel_desc, tupdesc); @@ -788,8 +783,8 @@ heap_create_with_catalog(const char *relname, * RelationRemoveInheritance * * Formerly, this routine checked for child relations and aborted the - * deletion if any were found. Now we rely on the dependency mechanism - * to check for or delete child relations. By the time we get here, + * deletion if any were found. Now we rely on the dependency mechanism + * to check for or delete child relations. By the time we get here, * there are no children and we need only remove any pg_inherits rows * linking this relation to its parent(s). */ @@ -811,9 +806,7 @@ RelationRemoveInheritance(Relation relation) SnapshotNow, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) - { simple_heap_delete(catalogRelation, &tuple->t_self); - } systable_endscan(scan); heap_close(catalogRelation, RowExclusiveLock); @@ -863,7 +856,7 @@ void DeleteAttributeTuples(Oid relid) { Relation attrel; - SysScanDesc scan; + SysScanDesc scan; ScanKeyData key[1]; HeapTuple atttup; @@ -880,9 +873,7 @@ DeleteAttributeTuples(Oid relid) /* Delete all the matching tuples */ while ((atttup = systable_getnext(scan)) != NULL) - { simple_heap_delete(attrel, &atttup->t_self); - } /* Clean up after the scan */ systable_endscan(scan); @@ -907,10 +898,10 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) /* * Grab an exclusive lock on the target table, which we will NOT - * release until end of transaction. (In the simple case where - * we are directly dropping this column, AlterTableDropColumn already - * did this ... but when cascading from a drop of some other object, - * we may not have any lock.) + * release until end of transaction. (In the simple case where we are + * directly dropping this column, AlterTableDropColumn already did + * this ... but when cascading from a drop of some other object, we + * may not have any lock.) */ rel = relation_open(relid, AccessExclusiveLock); @@ -920,7 +911,7 @@ RemoveAttributeById(Oid relid, AttrNumber attnum) ObjectIdGetDatum(relid), Int16GetDatum(attnum), 0, 0); - if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ + if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "RemoveAttributeById: Failed to find attribute %d in relation %u", attnum, relid); attStruct = (Form_pg_attribute) GETSTRUCT(tuple); @@ -985,7 +976,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum, /* There should be at most one matching tuple, but we loop anyway */ while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - ObjectAddress object; + ObjectAddress object; object.classId = RelationGetRelid(attrdef_rel); object.objectId = HeapTupleGetOid(tuple); @@ -1007,7 +998,7 @@ RemoveAttrDefault(Oid relid, AttrNumber attnum, /* * RemoveAttrDefaultById * - * Remove a pg_attrdef entry specified by OID. This is the guts of + * Remove a pg_attrdef entry specified by OID. This is the guts of * attribute-default removal. Note it should be called via performDeletion, * not directly. */ @@ -1058,7 +1049,7 @@ RemoveAttrDefaultById(Oid attrdefId) ObjectIdGetDatum(myrelid), Int16GetDatum(myattnum), 0, 0); - if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ + if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "RemoveAttrDefaultById: cache lookup failed for rel %u attr %d", myrelid, myattnum); @@ -1175,7 +1166,7 @@ StoreAttrDefault(Relation rel, AttrNumber attnum, char *adbin) HeapTuple atttup; Form_pg_attribute attStruct; Oid attrdefOid; - ObjectAddress colobject, + ObjectAddress colobject, defobject; /* @@ -1307,8 +1298,8 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin) attNos = (int16 *) palloc(keycount * sizeof(int16)); foreach(vl, varList) { - Var *var = (Var *) lfirst(vl); - int j; + Var *var = (Var *) lfirst(vl); + int j; for (j = 0; j < i; j++) if (attNos[j] == var->varattno) @@ -1324,24 +1315,24 @@ StoreRelCheck(Relation rel, char *ccname, char *ccbin) /* * Create the Check Constraint */ - CreateConstraintEntry(ccname, /* Constraint Name */ - RelationGetNamespace(rel), /* namespace */ - CONSTRAINT_CHECK, /* Constraint Type */ - false, /* Is Deferrable */ + CreateConstraintEntry(ccname, /* Constraint Name */ + RelationGetNamespace(rel), /* namespace */ + CONSTRAINT_CHECK, /* Constraint Type */ + false, /* Is Deferrable */ false, /* Is Deferred */ - RelationGetRelid(rel), /* relation */ - attNos, /* attrs in the constraint */ - keycount, /* # attrs in the constraint */ - InvalidOid, /* not a domain constraint */ - InvalidOid, /* Foreign key fields */ + RelationGetRelid(rel), /* relation */ + attNos, /* attrs in the constraint */ + keycount, /* # attrs in the constraint */ + InvalidOid, /* not a domain constraint */ + InvalidOid, /* Foreign key fields */ NULL, 0, ' ', ' ', ' ', - expr, /* Tree form check constraint */ + expr, /* Tree form check constraint */ ccbin, /* Binary form check constraint */ - ccsrc); /* Source form check constraint */ + ccsrc); /* Source form check constraint */ pfree(ccsrc); } @@ -1366,8 +1357,8 @@ StoreConstraints(Relation rel, TupleDesc tupdesc) /* * Deparsing of constraint expressions will fail unless the * just-created pg_attribute tuples for this relation are made - * visible. So, bump the command counter. CAUTION: this will - * cause a relcache entry rebuild. + * visible. So, bump the command counter. CAUTION: this will cause a + * relcache entry rebuild. */ CommandCounterIncrement(); @@ -1513,12 +1504,14 @@ AddRelationRawConstraints(Relation rel, List *listptr2; /* - * Generate a name that does not conflict with pre-existing - * constraints, nor with any auto-generated names so far. + * Generate a name that does not conflict with + * pre-existing constraints, nor with any auto-generated + * names so far. */ ccname = GenerateConstraintName(RelationGetRelid(rel), RelationGetNamespace(rel), &constr_name_ctr); + /* * Check against other new constraints, in case the user * has specified a name that looks like an auto-generated @@ -1668,7 +1661,7 @@ cookDefault(ParseState *pstate, int32 atttypmod, char *attname) { - Node *expr; + Node *expr; Assert(raw_default != NULL); @@ -1699,18 +1692,18 @@ cookDefault(ParseState *pstate, /* * Check that it will be possible to coerce the expression to the - * column's type. We store the expression without coercion, - * however, to avoid premature coercion in cases like + * column's type. We store the expression without coercion, however, + * to avoid premature coercion in cases like * * CREATE TABLE tbl (fld timestamp DEFAULT 'now'::text); * - * NB: this should match the code in optimizer/prep/preptlist.c that - * will actually do the coercion, to ensure we don't accept an - * unusable default expression. + * NB: this should match the code in optimizer/prep/preptlist.c that will + * actually do the coercion, to ensure we don't accept an unusable + * default expression. */ if (OidIsValid(atttypid)) { - Oid type_id = exprType(expr); + Oid type_id = exprType(expr); if (type_id != atttypid) { @@ -1718,7 +1711,7 @@ cookDefault(ParseState *pstate, atttypid, atttypmod, false) == NULL) elog(ERROR, "Column \"%s\" is of type %s" " but default expression is of type %s" - "\n\tYou will need to rewrite or cast the expression", + "\n\tYou will need to rewrite or cast the expression", attname, format_type_be(atttypid), format_type_be(type_id)); @@ -1735,7 +1728,7 @@ cookDefault(ParseState *pstate, */ fix_opids(expr); - return(expr); + return (expr); } @@ -1753,7 +1746,7 @@ RemoveRelConstraints(Relation rel, const char *constrName, { int ndeleted = 0; Relation conrel; - SysScanDesc conscan; + SysScanDesc conscan; ScanKeyData key[1]; HeapTuple contup; @@ -1773,11 +1766,11 @@ RemoveRelConstraints(Relation rel, const char *constrName, */ while ((contup = systable_getnext(conscan)) != NULL) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(contup); + Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(contup); if (strcmp(NameStr(con->conname), constrName) == 0) { - ObjectAddress conobj; + ObjectAddress conobj; conobj.classId = RelationGetRelid(conrel); conobj.objectId = HeapTupleGetOid(contup); @@ -1815,9 +1808,7 @@ RemoveStatistics(Relation rel) SnapshotNow, 1, &key); while (HeapTupleIsValid(tuple = systable_getnext(scan))) - { simple_heap_delete(pgstatistic, &tuple->t_self); - } systable_endscan(scan); heap_close(pgstatistic, RowExclusiveLock); @@ -1836,7 +1827,7 @@ RelationTruncateIndexes(Oid heapId) { Relation indexRelation; ScanKeyData entry; - SysScanDesc scan; + SysScanDesc scan; HeapTuple indexTuple; /* Scan pg_index to find indexes on specified heap */ diff --git a/src/backend/catalog/index.c b/src/backend/catalog/index.c index f91600f94a..4909c2ea08 100644 --- a/src/backend/catalog/index.c +++ b/src/backend/catalog/index.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.195 2002/09/03 16:00:02 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/index.c,v 1.196 2002/09/04 20:31:14 momjian Exp $ * * * INTERFACE ROUTINES @@ -320,13 +320,13 @@ UpdateRelationRelation(Relation indexRelation) /* XXX Natts_pg_class_fixed is a hack - see pg_class.h */ tuple = heap_addheader(Natts_pg_class_fixed, - true, + true, CLASS_TUPLE_SIZE, (void *) indexRelation->rd_rel); /* - * the new tuple must have the oid already chosen for the index. - * sure would be embarrassing to do this sort of thing in polite company. + * the new tuple must have the oid already chosen for the index. sure + * would be embarrassing to do this sort of thing in polite company. */ HeapTupleSetOid(tuple, RelationGetRelid(indexRelation)); simple_heap_insert(pg_class, tuple); @@ -391,7 +391,7 @@ AppendAttributeTuples(Relation indexRelation, int numatts) Assert(indexTupDesc->attrs[i]->attcacheoff == -1); new_tuple = heap_addheader(Natts_pg_attribute, - false, + false, ATTRIBUTE_TUPLE_SIZE, (void *) indexTupDesc->attrs[i]); @@ -478,7 +478,7 @@ UpdateIndexRelation(Oid indexoid, * form a tuple to insert into pg_index */ tuple = heap_addheader(Natts_pg_index, - false, + false, itupLen, (void *) indexForm); @@ -532,8 +532,8 @@ index_create(Oid heapRelationId, heapRelation = heap_open(heapRelationId, ShareLock); /* - * The index will be in the same namespace as its parent table, - * and is shared across databases if and only if the parent is. + * The index will be in the same namespace as its parent table, and is + * shared across databases if and only if the parent is. */ namespaceId = RelationGetNamespace(heapRelation); shared_relation = heapRelation->rd_rel->relisshared; @@ -554,7 +554,7 @@ index_create(Oid heapRelationId, * We cannot allow indexing a shared relation after initdb (because * there's no way to make the entry in other databases' pg_class). * Unfortunately we can't distinguish initdb from a manually started - * standalone backend. However, we can at least prevent this mistake + * standalone backend. However, we can at least prevent this mistake * under normal multi-user operation. */ if (shared_relation && IsUnderPostmaster) @@ -577,6 +577,7 @@ index_create(Oid heapRelationId, classObjectId); indexTupDesc->tdhasoid = false; + /* * create the index relation's relcache entry and physical disk file. * (If we fail further down, it's the smgr's responsibility to remove @@ -643,20 +644,20 @@ index_create(Oid heapRelationId, * Register constraint and dependencies for the index. * * If the index is from a CONSTRAINT clause, construct a pg_constraint - * entry. The index is then linked to the constraint, which in turn is - * linked to the table. If it's not a CONSTRAINT, make the dependency - * directly on the table. + * entry. The index is then linked to the constraint, which in turn + * is linked to the table. If it's not a CONSTRAINT, make the + * dependency directly on the table. * - * We don't need a dependency on the namespace, because there'll be - * an indirect dependency via our parent table. + * We don't need a dependency on the namespace, because there'll be an + * indirect dependency via our parent table. * - * During bootstrap we can't register any dependencies, and we don't - * try to make a constraint either. + * During bootstrap we can't register any dependencies, and we don't try + * to make a constraint either. */ if (!IsBootstrapProcessingMode()) { - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; myself.classId = RelOid_pg_class; myself.objectId = indexoid; @@ -674,25 +675,25 @@ index_create(Oid heapRelationId, else { elog(ERROR, "index_create: constraint must be PRIMARY or UNIQUE"); - constraintType = 0; /* keep compiler quiet */ + constraintType = 0; /* keep compiler quiet */ } conOid = CreateConstraintEntry(indexRelationName, namespaceId, constraintType, - false, /* isDeferrable */ - false, /* isDeferred */ + false, /* isDeferrable */ + false, /* isDeferred */ heapRelationId, indexInfo->ii_KeyAttrNumbers, indexInfo->ii_NumKeyAttrs, - InvalidOid, /* no domain */ - InvalidOid, /* no foreign key */ + InvalidOid, /* no domain */ + InvalidOid, /* no foreign key */ NULL, 0, ' ', ' ', ' ', - NULL, /* no check constraint */ + NULL, /* no check constraint */ NULL, NULL); @@ -807,6 +808,7 @@ index_drop(Oid indexId) * fix RELATION relation */ DeleteRelationTuple(indexId); + /* * fix ATTRIBUTE relation */ @@ -839,11 +841,12 @@ index_drop(Oid indexId) smgrunlink(DEFAULT_SMGR, userIndexRelation); /* - * We are presently too lazy to attempt to compute the new correct value - * of relhasindex (the next VACUUM will fix it if necessary). So there is - * no need to update the pg_class tuple for the owning relation. - * But we must send out a shared-cache-inval notice on the owning relation - * to ensure other backends update their relcache lists of indexes. + * We are presently too lazy to attempt to compute the new correct + * value of relhasindex (the next VACUUM will fix it if necessary). + * So there is no need to update the pg_class tuple for the owning + * relation. But we must send out a shared-cache-inval notice on the + * owning relation to ensure other backends update their relcache + * lists of indexes. */ CacheInvalidateRelcache(heapId); @@ -1640,7 +1643,7 @@ IndexBuildHeapScan(Relation heapRelation, * transaction.) */ if (!TransactionIdIsCurrentTransactionId( - HeapTupleHeaderGetXmin(heapTuple->t_data))) + HeapTupleHeaderGetXmin(heapTuple->t_data))) elog(ERROR, "IndexBuildHeapScan: concurrent insert in progress"); indexIt = true; tupleIsAlive = true; @@ -1655,7 +1658,7 @@ IndexBuildHeapScan(Relation heapRelation, * transaction.) */ if (!TransactionIdIsCurrentTransactionId( - HeapTupleHeaderGetXmax(heapTuple->t_data))) + HeapTupleHeaderGetXmax(heapTuple->t_data))) elog(ERROR, "IndexBuildHeapScan: concurrent delete in progress"); indexIt = true; tupleIsAlive = false; @@ -1798,12 +1801,12 @@ reindex_index(Oid indexId, bool force, bool inplace) /* * Open our index relation and get an exclusive lock on it. * - * Note: doing this before opening the parent heap relation means - * there's a possibility for deadlock failure against another xact - * that is doing normal accesses to the heap and index. However, - * it's not real clear why you'd be needing to do REINDEX on a table - * that's in active use, so I'd rather have the protection of making - * sure the index is locked down. + * Note: doing this before opening the parent heap relation means there's + * a possibility for deadlock failure against another xact that is + * doing normal accesses to the heap and index. However, it's not + * real clear why you'd be needing to do REINDEX on a table that's in + * active use, so I'd rather have the protection of making sure the + * index is locked down. */ iRel = index_open(indexId); if (iRel == NULL) diff --git a/src/backend/catalog/indexing.c b/src/backend/catalog/indexing.c index 4206c33edb..27d66b4b2e 100644 --- a/src/backend/catalog/indexing.c +++ b/src/backend/catalog/indexing.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.101 2002/08/06 02:36:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/indexing.c,v 1.102 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,7 @@ CatalogOpenIndexes(Relation heapRel) resultRelInfo = makeNode(ResultRelInfo); resultRelInfo->ri_RangeTableIndex = 1; /* dummy */ resultRelInfo->ri_RelationDesc = heapRel; - resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */ + resultRelInfo->ri_TrigDesc = NULL; /* we don't fire triggers */ ExecOpenIndices(resultRelInfo); @@ -132,14 +132,14 @@ CatalogIndexInsert(CatalogIndexState indstate, HeapTuple heapTuple) * CatalogUpdateIndexes - do all the indexing work for a new catalog tuple * * This is a convenience routine for the common case where we only need - * to insert or update a single tuple in a system catalog. Avoid using it for + * to insert or update a single tuple in a system catalog. Avoid using it for * multiple tuples, since opening the indexes and building the index info * structures is moderately expensive. */ void CatalogUpdateIndexes(Relation heapRel, HeapTuple heapTuple) { - CatalogIndexState indstate; + CatalogIndexState indstate; indstate = CatalogOpenIndexes(heapRel); CatalogIndexInsert(indstate, heapTuple); diff --git a/src/backend/catalog/namespace.c b/src/backend/catalog/namespace.c index 1b4f2aef8e..182d9016e9 100644 --- a/src/backend/catalog/namespace.c +++ b/src/backend/catalog/namespace.c @@ -13,7 +13,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.34 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/namespace.c,v 1.35 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,10 +60,10 @@ * 2. If a TEMP table namespace has been initialized in this session, it * is always searched just after any special namespace. * - * 3. The system catalog namespace is always searched. If the system + * 3. The system catalog namespace is always searched. If the system * namespace is present in the explicit path then it will be searched in * the specified order; otherwise it will be searched after TEMP tables and - * *before* the explicit list. (It might seem that the system namespace + * *before* the explicit list. (It might seem that the system namespace * should be implicitly last, but this behavior appears to be required by * SQL99. Also, this provides a way to search the system namespace first * without thereby making it the default creation target namespace.) @@ -76,7 +76,7 @@ * In bootstrap mode, the search path is set equal to 'pg_catalog', so that * the system namespace is the only one searched or inserted into. * The initdb script is also careful to set search_path to 'pg_catalog' for - * its post-bootstrap standalone backend runs. Otherwise the default search + * its post-bootstrap standalone backend runs. Otherwise the default search * path is determined by GUC. The factory default path contains the PUBLIC * namespace (if it exists), preceded by the user's personal namespace * (if one exists). @@ -109,7 +109,7 @@ static bool namespaceSearchPathValid = true; /* * myTempNamespace is InvalidOid until and unless a TEMP namespace is set up * in a particular backend session (this happens when a CREATE TEMP TABLE - * command is first executed). Thereafter it's the OID of the temp namespace. + * command is first executed). Thereafter it's the OID of the temp namespace. * firstTempTransaction flags whether we've committed creation of the TEMP * namespace or not. */ @@ -127,7 +127,7 @@ static Oid mySpecialNamespace = InvalidOid; * This is the text equivalent of the search path --- it's the value * of the GUC variable 'search_path'. */ -char *namespace_search_path = NULL; +char *namespace_search_path = NULL; /* Local functions */ @@ -138,11 +138,11 @@ static void RemoveTempRelationsCallback(void); static void NamespaceCallback(Datum arg, Oid relid); /* These don't really need to appear in any header file */ -Datum pg_table_is_visible(PG_FUNCTION_ARGS); -Datum pg_type_is_visible(PG_FUNCTION_ARGS); -Datum pg_function_is_visible(PG_FUNCTION_ARGS); -Datum pg_operator_is_visible(PG_FUNCTION_ARGS); -Datum pg_opclass_is_visible(PG_FUNCTION_ARGS); +Datum pg_table_is_visible(PG_FUNCTION_ARGS); +Datum pg_type_is_visible(PG_FUNCTION_ARGS); +Datum pg_function_is_visible(PG_FUNCTION_ARGS); +Datum pg_operator_is_visible(PG_FUNCTION_ARGS); +Datum pg_opclass_is_visible(PG_FUNCTION_ARGS); /* @@ -230,7 +230,7 @@ RangeVarGetCreationNamespace(const RangeVar *newRelation) { /* use exact schema given */ namespaceId = GetSysCacheOid(NAMESPACENAME, - CStringGetDatum(newRelation->schemaname), + CStringGetDatum(newRelation->schemaname), 0, 0, 0); if (!OidIsValid(namespaceId)) elog(ERROR, "Namespace \"%s\" does not exist", @@ -312,10 +312,10 @@ RelationIsVisible(Oid relid) else { /* - * If it is in the path, it might still not be visible; it could be - * hidden by another relation of the same name earlier in the path. - * So we must do a slow check to see if this rel would be found by - * RelnameGetRelid. + * If it is in the path, it might still not be visible; it could + * be hidden by another relation of the same name earlier in the + * path. So we must do a slow check to see if this rel would be + * found by RelnameGetRelid. */ char *relname = NameStr(relform->relname); @@ -394,10 +394,10 @@ TypeIsVisible(Oid typid) else { /* - * If it is in the path, it might still not be visible; it could be - * hidden by another type of the same name earlier in the path. - * So we must do a slow check to see if this type would be found by - * TypenameGetTypid. + * If it is in the path, it might still not be visible; it could + * be hidden by another type of the same name earlier in the path. + * So we must do a slow check to see if this type would be found + * by TypenameGetTypid. */ char *typname = NameStr(typform->typname); @@ -492,18 +492,18 @@ FuncnameGetCandidates(List *names, int nargs) /* * Okay, it's in the search path, but does it have the same - * arguments as something we already accepted? If so, keep + * arguments as something we already accepted? If so, keep * only the one that appears earlier in the search path. * - * If we have an ordered list from SearchSysCacheList (the - * normal case), then any conflicting proc must immediately - * adjoin this one in the list, so we only need to look at - * the newest result item. If we have an unordered list, - * we have to scan the whole result list. + * If we have an ordered list from SearchSysCacheList (the normal + * case), then any conflicting proc must immediately adjoin + * this one in the list, so we only need to look at the newest + * result item. If we have an unordered list, we have to scan + * the whole result list. */ if (resultList) { - FuncCandidateList prevResult; + FuncCandidateList prevResult; if (catlist->ordered) { @@ -521,8 +521,8 @@ FuncnameGetCandidates(List *names, int nargs) prevResult = prevResult->next) { if (nargs == prevResult->nargs && - memcmp(procform->proargtypes, prevResult->args, - nargs * sizeof(Oid)) == 0) + memcmp(procform->proargtypes, prevResult->args, + nargs * sizeof(Oid)) == 0) break; } } @@ -531,7 +531,7 @@ FuncnameGetCandidates(List *names, int nargs) /* We have a match with a previous result */ Assert(pathpos != prevResult->pathpos); if (pathpos > prevResult->pathpos) - continue; /* keep previous result */ + continue; /* keep previous result */ /* replace previous result */ prevResult->pathpos = pathpos; prevResult->oid = HeapTupleGetOid(proctup); @@ -595,10 +595,10 @@ FunctionIsVisible(Oid funcid) else { /* - * If it is in the path, it might still not be visible; it could be - * hidden by another proc of the same name and arguments earlier - * in the path. So we must do a slow check to see if this is the - * same proc that would be found by FuncnameGetCandidates. + * If it is in the path, it might still not be visible; it could + * be hidden by another proc of the same name and arguments + * earlier in the path. So we must do a slow check to see if this + * is the same proc that would be found by FuncnameGetCandidates. */ char *proname = NameStr(procform->proname); int nargs = procform->pronargs; @@ -641,7 +641,7 @@ FunctionIsVisible(Oid funcid) * identical entries in later namespaces. * * The returned items always have two args[] entries --- one or the other - * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too. + * will be InvalidOid for a prefix or postfix oprkind. nargs is 2, too. */ FuncCandidateList OpernameGetCandidates(List *names, char oprkind) @@ -707,18 +707,18 @@ OpernameGetCandidates(List *names, char oprkind) /* * Okay, it's in the search path, but does it have the same - * arguments as something we already accepted? If so, keep + * arguments as something we already accepted? If so, keep * only the one that appears earlier in the search path. * - * If we have an ordered list from SearchSysCacheList (the - * normal case), then any conflicting oper must immediately - * adjoin this one in the list, so we only need to look at - * the newest result item. If we have an unordered list, - * we have to scan the whole result list. + * If we have an ordered list from SearchSysCacheList (the normal + * case), then any conflicting oper must immediately adjoin + * this one in the list, so we only need to look at the newest + * result item. If we have an unordered list, we have to scan + * the whole result list. */ if (resultList) { - FuncCandidateList prevResult; + FuncCandidateList prevResult; if (catlist->ordered) { @@ -744,7 +744,7 @@ OpernameGetCandidates(List *names, char oprkind) /* We have a match with a previous result */ Assert(pathpos != prevResult->pathpos); if (pathpos > prevResult->pathpos) - continue; /* keep previous result */ + continue; /* keep previous result */ /* replace previous result */ prevResult->pathpos = pathpos; prevResult->oid = HeapTupleGetOid(opertup); @@ -807,10 +807,11 @@ OperatorIsVisible(Oid oprid) else { /* - * If it is in the path, it might still not be visible; it could be - * hidden by another operator of the same name and arguments earlier - * in the path. So we must do a slow check to see if this is the - * same operator that would be found by OpernameGetCandidates. + * If it is in the path, it might still not be visible; it could + * be hidden by another operator of the same name and arguments + * earlier in the path. So we must do a slow check to see if this + * is the same operator that would be found by + * OpernameGetCandidates. */ char *oprname = NameStr(oprform->oprname); FuncCandidateList clist; @@ -882,18 +883,18 @@ OpclassGetCandidates(Oid amid) /* * Okay, it's in the search path, but does it have the same name - * as something we already accepted? If so, keep - * only the one that appears earlier in the search path. + * as something we already accepted? If so, keep only the one + * that appears earlier in the search path. * - * If we have an ordered list from SearchSysCacheList (the - * normal case), then any conflicting opclass must immediately - * adjoin this one in the list, so we only need to look at - * the newest result item. If we have an unordered list, - * we have to scan the whole result list. + * If we have an ordered list from SearchSysCacheList (the normal + * case), then any conflicting opclass must immediately adjoin + * this one in the list, so we only need to look at the newest + * result item. If we have an unordered list, we have to scan the + * whole result list. */ if (resultList) { - OpclassCandidateList prevResult; + OpclassCandidateList prevResult; if (catlist->ordered) { @@ -919,7 +920,7 @@ OpclassGetCandidates(Oid amid) /* We have a match with a previous result */ Assert(pathpos != prevResult->pathpos); if (pathpos > prevResult->pathpos) - continue; /* keep previous result */ + continue; /* keep previous result */ /* replace previous result */ prevResult->opcname_tmp = NameStr(opcform->opcname); prevResult->pathpos = pathpos; @@ -1019,10 +1020,10 @@ OpclassIsVisible(Oid opcid) else { /* - * If it is in the path, it might still not be visible; it could be - * hidden by another opclass of the same name earlier in the path. - * So we must do a slow check to see if this opclass would be found by - * OpclassnameGetOpcid. + * If it is in the path, it might still not be visible; it could + * be hidden by another opclass of the same name earlier in the + * path. So we must do a slow check to see if this opclass would + * be found by OpclassnameGetOpcid. */ char *opcname = NameStr(opcform->opcname); @@ -1063,6 +1064,7 @@ DeconstructQualifiedName(List *names, catalogname = strVal(lfirst(names)); schemaname = strVal(lsecond(names)); objname = strVal(lfirst(lnext(lnext(names)))); + /* * We check the catalog name and then ignore it. */ @@ -1190,7 +1192,7 @@ char * NameListToString(List *names) { StringInfoData string; - List *l; + List *l; initStringInfo(&string); @@ -1248,11 +1250,12 @@ PopSpecialNamespace(Oid namespaceId) /* * FindConversionByName - find a conversion by possibly qualified name */ -Oid FindConversionByName(List *name) +Oid +FindConversionByName(List *name) { - char *conversion_name; - Oid namespaceId; - Oid conoid; + char *conversion_name; + Oid namespaceId; + Oid conoid; List *lptr; /* Convert list of names to a name and namespace */ @@ -1285,7 +1288,8 @@ Oid FindConversionByName(List *name) /* * FindDefaultConversionProc - find default encoding cnnversion proc */ -Oid FindDefaultConversionProc(int4 for_encoding, int4 to_encoding) +Oid +FindDefaultConversionProc(int4 for_encoding, int4 to_encoding) { Oid proc; List *lptr; @@ -1341,13 +1345,13 @@ recomputeNamespacePath(void) * Convert the list of names to a list of OIDs. If any names are not * recognizable or we don't have read access, just leave them out of * the list. (We can't raise an error, since the search_path setting - * has already been accepted.) Don't make duplicate entries, either. + * has already been accepted.) Don't make duplicate entries, either. */ oidlist = NIL; foreach(l, namelist) { - char *curname = (char *) lfirst(l); - Oid namespaceId; + char *curname = (char *) lfirst(l); + Oid namespaceId; if (strcmp(curname, "$user") == 0) { @@ -1359,7 +1363,7 @@ recomputeNamespacePath(void) 0, 0, 0); if (HeapTupleIsValid(tuple)) { - char *uname; + char *uname; uname = NameStr(((Form_pg_shadow) GETSTRUCT(tuple))->usename); namespaceId = GetSysCacheOid(NAMESPACENAME, @@ -1396,9 +1400,9 @@ recomputeNamespacePath(void) firstNS = (Oid) lfirsti(oidlist); /* - * Add any implicitly-searched namespaces to the list. Note these - * go on the front, not the back; also notice that we do not check - * USAGE permissions for these. + * Add any implicitly-searched namespaces to the list. Note these go + * on the front, not the back; also notice that we do not check USAGE + * permissions for these. */ if (!intMember(PG_CATALOG_NAMESPACE, oidlist)) oidlist = lconsi(PG_CATALOG_NAMESPACE, oidlist); @@ -1453,13 +1457,13 @@ InitTempTableNamespace(void) Oid namespaceId; /* - * First, do permission check to see if we are authorized to make - * temp tables. We use a nonstandard error message here since + * First, do permission check to see if we are authorized to make temp + * tables. We use a nonstandard error message here since * "databasename: permission denied" might be a tad cryptic. * - * Note we apply the check to the session user, not the currently - * active userid, since we are not going to change our minds about - * temp table availability during the session. + * Note we apply the check to the session user, not the currently active + * userid, since we are not going to change our minds about temp table + * availability during the session. */ if (pg_database_aclcheck(MyDatabaseId, GetSessionUserId(), ACL_CREATE_TEMP) != ACLCHECK_OK) @@ -1476,11 +1480,11 @@ InitTempTableNamespace(void) /* * First use of this temp namespace in this database; create it. * The temp namespaces are always owned by the superuser. We - * leave their permissions at default --- i.e., no access except to - * superuser --- to ensure that unprivileged users can't peek + * leave their permissions at default --- i.e., no access except + * to superuser --- to ensure that unprivileged users can't peek * at other backends' temp tables. This works because the places - * that access the temp namespace for my own backend skip permissions - * checks on it. + * that access the temp namespace for my own backend skip + * permissions checks on it. */ namespaceId = NamespaceCreate(namespaceName, BOOTSTRAP_USESYSID); /* Advance command counter to make namespace visible */ @@ -1504,7 +1508,7 @@ InitTempTableNamespace(void) firstTempTransaction = true; - namespaceSearchPathValid = false; /* need to rebuild list */ + namespaceSearchPathValid = false; /* need to rebuild list */ } /* @@ -1516,7 +1520,7 @@ AtEOXact_Namespace(bool isCommit) /* * If we abort the transaction in which a temp namespace was selected, * we'll have to do any creation or cleanout work over again. So, - * just forget the namespace entirely until next time. On the other + * just forget the namespace entirely until next time. On the other * hand, if we commit then register an exit callback to clean out the * temp tables at backend shutdown. (We only want to register the * callback once per session, so this is a good place to do it.) @@ -1528,17 +1532,18 @@ AtEOXact_Namespace(bool isCommit) else { myTempNamespace = InvalidOid; - namespaceSearchPathValid = false; /* need to rebuild list */ + namespaceSearchPathValid = false; /* need to rebuild list */ } firstTempTransaction = false; } + /* * Clean up if someone failed to do PopSpecialNamespace */ if (OidIsValid(mySpecialNamespace)) { mySpecialNamespace = InvalidOid; - namespaceSearchPathValid = false; /* need to rebuild list */ + namespaceSearchPathValid = false; /* need to rebuild list */ } } @@ -1561,14 +1566,14 @@ RemoveTempRelations(Oid tempNamespaceId) /* * Scan pg_class to find all the relations in the target namespace. - * Ignore indexes, though, on the assumption that they'll go away - * when their tables are deleted. + * Ignore indexes, though, on the assumption that they'll go away when + * their tables are deleted. * - * NOTE: if there are deletion constraints between temp relations, - * then our CASCADE delete call may cause as-yet-unvisited objects - * to go away. This is okay because we are using SnapshotNow; when - * the scan does reach those pg_class tuples, they'll be ignored as - * already deleted. + * NOTE: if there are deletion constraints between temp relations, then + * our CASCADE delete call may cause as-yet-unvisited objects to go + * away. This is okay because we are using SnapshotNow; when the scan + * does reach those pg_class tuples, they'll be ignored as already + * deleted. */ ScanKeyEntryInitialize(&key, 0x0, Anum_pg_class_relnamespace, @@ -1605,7 +1610,7 @@ RemoveTempRelations(Oid tempNamespaceId) static void RemoveTempRelationsCallback(void) { - if (OidIsValid(myTempNamespace)) /* should always be true */ + if (OidIsValid(myTempNamespace)) /* should always be true */ { /* Need to ensure we have a usable transaction. */ AbortOutOfAnyTransaction(); @@ -1644,18 +1649,19 @@ assign_search_path(const char *newval, bool doit, bool interactive) /* * If we aren't inside a transaction, we cannot do database access so - * cannot verify the individual names. Must accept the list on faith. + * cannot verify the individual names. Must accept the list on faith. */ if (interactive && IsTransactionState()) { /* * Verify that all the names are either valid namespace names or * "$user". We do not require $user to correspond to a valid - * namespace. We do not check for USAGE rights, either; should we? + * namespace. We do not check for USAGE rights, either; should + * we? */ foreach(l, namelist) { - char *curname = (char *) lfirst(l); + char *curname = (char *) lfirst(l); if (strcmp(curname, "$user") == 0) continue; @@ -1670,9 +1676,9 @@ assign_search_path(const char *newval, bool doit, bool interactive) freeList(namelist); /* - * We mark the path as needing recomputation, but don't do anything until - * it's needed. This avoids trying to do database access during GUC - * initialization. + * We mark the path as needing recomputation, but don't do anything + * until it's needed. This avoids trying to do database access during + * GUC initialization. */ if (doit) namespaceSearchPathValid = false; @@ -1692,7 +1698,8 @@ InitializeSearchPath(void) { /* * In bootstrap mode, the search path must be 'pg_catalog' so that - * tables are created in the proper namespace; ignore the GUC setting. + * tables are created in the proper namespace; ignore the GUC + * setting. */ MemoryContext oldcxt; @@ -1707,8 +1714,8 @@ InitializeSearchPath(void) else { /* - * In normal mode, arrange for a callback on any syscache invalidation - * of pg_namespace rows. + * In normal mode, arrange for a callback on any syscache + * invalidation of pg_namespace rows. */ CacheRegisterSyscacheCallback(NAMESPACEOID, NamespaceCallback, diff --git a/src/backend/catalog/pg_aggregate.c b/src/backend/catalog/pg_aggregate.c index 719d229b8d..7b83cf960d 100644 --- a/src/backend/catalog/pg_aggregate.c +++ b/src/backend/catalog/pg_aggregate.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.54 2002/08/22 00:01:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_aggregate.c,v 1.55 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,8 +54,8 @@ AggregateCreate(const char *aggName, Oid procOid; TupleDesc tupDesc; int i; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* sanity checks */ if (!aggName) @@ -85,12 +85,12 @@ AggregateCreate(const char *aggName, proc = (Form_pg_proc) GETSTRUCT(tup); if (proc->prorettype != aggTransType) elog(ERROR, "return type of transition function %s is not %s", - NameListToString(aggtransfnName), format_type_be(aggTransType)); + NameListToString(aggtransfnName), format_type_be(aggTransType)); /* * If the transfn is strict and the initval is NULL, make sure input - * type and transtype are the same (or at least binary-compatible), - * so that it's OK to use the first input value as the initial + * type and transtype are the same (or at least binary-compatible), so + * that it's OK to use the first input value as the initial * transValue. */ if (proc->proisstrict && agginitval == NULL) @@ -128,26 +128,29 @@ AggregateCreate(const char *aggName, /* * Everything looks okay. Try to create the pg_proc entry for the - * aggregate. (This could fail if there's already a conflicting entry.) + * aggregate. (This could fail if there's already a conflicting + * entry.) */ MemSet(fnArgs, 0, FUNC_MAX_ARGS * sizeof(Oid)); fnArgs[0] = aggBaseType; procOid = ProcedureCreate(aggName, aggNamespace, - false, /* no replacement */ - false, /* doesn't return a set */ - finaltype, /* returnType */ - INTERNALlanguageId, /* languageObjectId */ + false, /* no replacement */ + false, /* doesn't return a set */ + finaltype, /* returnType */ + INTERNALlanguageId, /* languageObjectId */ 0, - "aggregate_dummy", /* placeholder proc */ - "-", /* probin */ - true, /* isAgg */ - false, /* security invoker (currently not definable for agg) */ - false, /* isStrict (not needed for agg) */ - PROVOLATILE_IMMUTABLE, /* volatility (not needed for agg) */ - 1, /* parameterCount */ - fnArgs); /* parameterTypes */ + "aggregate_dummy", /* placeholder proc */ + "-", /* probin */ + true, /* isAgg */ + false, /* security invoker (currently not + * definable for agg) */ + false, /* isStrict (not needed for agg) */ + PROVOLATILE_IMMUTABLE, /* volatility (not + * needed for agg) */ + 1, /* parameterCount */ + fnArgs); /* parameterTypes */ /* * Okay to create the pg_aggregate entry. diff --git a/src/backend/catalog/pg_constraint.c b/src/backend/catalog/pg_constraint.c index 85ca6eab64..92d455223b 100644 --- a/src/backend/catalog/pg_constraint.c +++ b/src/backend/catalog/pg_constraint.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.5 2002/08/26 17:53:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_constraint.c,v 1.6 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ * Create a constraint table entry. * * Subsidiary records (such as triggers or indexes to implement the - * constraint) are *not* created here. But we do make dependency links + * constraint) are *not* created here. But we do make dependency links * from the constraint to the things it depends on. */ Oid @@ -136,7 +136,7 @@ CreateConstraintEntry(const char *constraintName, */ if (conBin) values[Anum_pg_constraint_conbin - 1] = DirectFunctionCall1(textin, - CStringGetDatum(conBin)); + CStringGetDatum(conBin)); else nulls[Anum_pg_constraint_conbin - 1] = 'n'; @@ -145,7 +145,7 @@ CreateConstraintEntry(const char *constraintName, */ if (conSrc) values[Anum_pg_constraint_consrc - 1] = DirectFunctionCall1(textin, - CStringGetDatum(conSrc)); + CStringGetDatum(conSrc)); else nulls[Anum_pg_constraint_consrc - 1] = 'n'; @@ -165,10 +165,10 @@ CreateConstraintEntry(const char *constraintName, if (OidIsValid(relId)) { /* - * Register auto dependency from constraint to owning relation, - * or to specific column(s) if any are mentioned. + * Register auto dependency from constraint to owning relation, or + * to specific column(s) if any are mentioned. */ - ObjectAddress relobject; + ObjectAddress relobject; relobject.classId = RelOid_pg_class; relobject.objectId = relId; @@ -195,7 +195,7 @@ CreateConstraintEntry(const char *constraintName, * Register normal dependency from constraint to foreign relation, * or to specific column(s) if any are mentioned. */ - ObjectAddress relobject; + ObjectAddress relobject; relobject.classId = RelOid_pg_class; relobject.objectId = foreignRelId; @@ -219,11 +219,11 @@ CreateConstraintEntry(const char *constraintName, if (conExpr != NULL) { /* - * Register dependencies from constraint to objects mentioned - * in CHECK expression. We gin up a rather bogus rangetable - * list to handle any Vars in the constraint. + * Register dependencies from constraint to objects mentioned in + * CHECK expression. We gin up a rather bogus rangetable list to + * handle any Vars in the constraint. */ - RangeTblEntry rte; + RangeTblEntry rte; MemSet(&rte, 0, sizeof(rte)); rte.type = T_RangeTblEntry; @@ -271,7 +271,7 @@ ConstraintNameIsUsed(Oid relId, Oid relNamespace, const char *cname) while (HeapTupleIsValid(tup = systable_getnext(conscan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); + Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); if (con->conrelid == relId) { @@ -338,7 +338,7 @@ GenerateConstraintName(Oid relId, Oid relNamespace, int *counter) while (HeapTupleIsValid(tup = systable_getnext(conscan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); + Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tup); if (con->conrelid == relId) { @@ -366,7 +366,7 @@ ConstraintNameIsGenerated(const char *cname) { if (cname[0] != '$') return false; - if (strspn(cname+1, "0123456789") != strlen(cname+1)) + if (strspn(cname + 1, "0123456789") != strlen(cname + 1)) return false; return true; } @@ -377,11 +377,11 @@ ConstraintNameIsGenerated(const char *cname) void RemoveConstraintById(Oid conId) { - Relation conDesc; - ScanKeyData skey[1]; - SysScanDesc conscan; - HeapTuple tup; - Form_pg_constraint con; + Relation conDesc; + ScanKeyData skey[1]; + SysScanDesc conscan; + HeapTuple tup; + Form_pg_constraint con; conDesc = heap_openr(ConstraintRelationName, RowExclusiveLock); @@ -399,8 +399,8 @@ RemoveConstraintById(Oid conId) con = (Form_pg_constraint) GETSTRUCT(tup); /* - * If the constraint is for a relation, open and exclusive-lock - * the relation it's for. + * If the constraint is for a relation, open and exclusive-lock the + * relation it's for. * * XXX not clear what we should lock, if anything, for other constraints. */ @@ -411,16 +411,16 @@ RemoveConstraintById(Oid conId) rel = heap_open(con->conrelid, AccessExclusiveLock); /* - * We need to update the relcheck count if it is a check constraint - * being dropped. This update will force backends to rebuild - * relcache entries when we commit. + * We need to update the relcheck count if it is a check + * constraint being dropped. This update will force backends to + * rebuild relcache entries when we commit. */ if (con->contype == CONSTRAINT_CHECK) { - Relation pgrel; - HeapTuple relTup; - Form_pg_class classForm; - + Relation pgrel; + HeapTuple relTup; + Form_pg_class classForm; + pgrel = heap_openr(RelationRelationName, RowExclusiveLock); relTup = SearchSysCacheCopy(RELOID, ObjectIdGetDatum(con->conrelid), diff --git a/src/backend/catalog/pg_conversion.c b/src/backend/catalog/pg_conversion.c index 7dfd0679a2..bd721507ed 100644 --- a/src/backend/catalog/pg_conversion.c +++ b/src/backend/catalog/pg_conversion.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.5 2002/08/06 05:40:45 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_conversion.c,v 1.6 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,12 +36,13 @@ * Add a new tuple to pg_coversion. * --------------- */ -Oid ConversionCreate(const char *conname, Oid connamespace, - int32 conowner, - int4 conforencoding, int4 contoencoding, - Oid conproc, bool def) +Oid +ConversionCreate(const char *conname, Oid connamespace, + int32 conowner, + int4 conforencoding, int4 contoencoding, + Oid conproc, bool def) { - int i; + int i; Relation rel; TupleDesc tupDesc; HeapTuple tup; @@ -49,8 +50,8 @@ Oid ConversionCreate(const char *conname, Oid connamespace, Datum values[Natts_pg_conversion]; NameData cname; Oid oid; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* sanity checks */ if (!conname) @@ -58,20 +59,22 @@ Oid ConversionCreate(const char *conname, Oid connamespace, /* make sure there is no existing conversion of same name */ if (SearchSysCacheExists(CONNAMESP, - PointerGetDatum(conname), - ObjectIdGetDatum(connamespace), - 0,0)) + PointerGetDatum(conname), + ObjectIdGetDatum(connamespace), + 0, 0)) elog(ERROR, "conversion name \"%s\" already exists", conname); if (def) { - /* make sure there is no existing default - <for encoding><to encoding> pair in this name space */ + /* + * make sure there is no existing default <for encoding><to + * encoding> pair in this name space + */ if (FindDefaultConversion(connamespace, conforencoding, contoencoding)) elog(ERROR, "default conversion for %s to %s already exists", - pg_encoding_to_char(conforencoding),pg_encoding_to_char(contoencoding)); + pg_encoding_to_char(conforencoding), pg_encoding_to_char(contoencoding)); } /* open pg_conversion */ @@ -129,8 +132,9 @@ Oid ConversionCreate(const char *conname, Oid connamespace, * Drop a conversion and do dependency check. * --------------- */ -void ConversionDrop(const char *conname, Oid connamespace, - int32 conowner, DropBehavior behavior) +void +ConversionDrop(const char *conname, Oid connamespace, + int32 conowner, DropBehavior behavior) { Relation rel; TupleDesc tupDesc; @@ -138,8 +142,8 @@ void ConversionDrop(const char *conname, Oid connamespace, HeapScanDesc scan; ScanKeyData scanKeyData; Form_pg_conversion body; - ObjectAddress object; - Oid myoid; + ObjectAddress object; + Oid myoid; /* sanity checks */ if (!conname) @@ -156,12 +160,12 @@ void ConversionDrop(const char *conname, Oid connamespace, tupDesc = rel->rd_att; scan = heap_beginscan(rel, SnapshotNow, - 1, &scanKeyData); + 1, &scanKeyData); /* search for the target tuple */ while (HeapTupleIsValid(tuple = heap_getnext(scan, ForwardScanDirection))) { - body = (Form_pg_conversion)GETSTRUCT(tuple); + body = (Form_pg_conversion) GETSTRUCT(tuple); if (!strncmp(NameStr(body->conname), conname, NAMEDATALEN)) break; } @@ -172,12 +176,12 @@ void ConversionDrop(const char *conname, Oid connamespace, return; } - if (!superuser() && ((Form_pg_conversion)GETSTRUCT(tuple))->conowner != GetUserId()) + if (!superuser() && ((Form_pg_conversion) GETSTRUCT(tuple))->conowner != GetUserId()) elog(ERROR, "permission denied"); myoid = HeapTupleGetOid(tuple); heap_endscan(scan); - heap_close(rel, AccessShareLock); + heap_close(rel, AccessShareLock); /* * Do the deletion @@ -215,7 +219,7 @@ RemoveConversionById(Oid conversionOid) tupDesc = rel->rd_att; scan = heap_beginscan(rel, SnapshotNow, - 1, &scanKeyData); + 1, &scanKeyData); /* search for the target tuple */ if (HeapTupleIsValid(tuple = heap_getnext(scan, ForwardScanDirection))) @@ -233,28 +237,29 @@ RemoveConversionById(Oid conversionOid) * If found, returns the procedure's oid, otherwise InvalidOid. * --------------- */ -Oid FindDefaultConversion(Oid name_space, int4 for_encoding, int4 to_encoding) +Oid +FindDefaultConversion(Oid name_space, int4 for_encoding, int4 to_encoding) { - CatCList *catlist; + CatCList *catlist; HeapTuple tuple; Form_pg_conversion body; - Oid proc = InvalidOid; - int i; + Oid proc = InvalidOid; + int i; /* Check we have usage rights in target namespace */ if (pg_namespace_aclcheck(name_space, GetUserId(), ACL_USAGE) != ACLCHECK_OK) return proc; catlist = SearchSysCacheList(CONDEFAULT, 3, - ObjectIdGetDatum(name_space), - Int32GetDatum(for_encoding), - Int32GetDatum(to_encoding), - 0); + ObjectIdGetDatum(name_space), + Int32GetDatum(for_encoding), + Int32GetDatum(to_encoding), + 0); for (i = 0; i < catlist->n_members; i++) { tuple = &catlist->members[i]->tuple; - body = (Form_pg_conversion)GETSTRUCT(tuple); + body = (Form_pg_conversion) GETSTRUCT(tuple); if (body->condefault == TRUE) { proc = body->conproc; @@ -272,22 +277,23 @@ Oid FindDefaultConversion(Oid name_space, int4 for_encoding, int4 to_encoding) * Returns conversion oid. * --------------- */ -Oid FindConversion(const char *conname, Oid connamespace) +Oid +FindConversion(const char *conname, Oid connamespace) { HeapTuple tuple; - Oid procoid; - Oid conoid; + Oid procoid; + Oid conoid; AclResult aclresult; /* search pg_conversion by connamespace and conversion name */ tuple = SearchSysCache(CONNAMESP, PointerGetDatum(conname), ObjectIdGetDatum(connamespace), - 0,0); + 0, 0); if (!HeapTupleIsValid(tuple)) return InvalidOid; - procoid = ((Form_pg_conversion)GETSTRUCT(tuple))->conproc; + procoid = ((Form_pg_conversion) GETSTRUCT(tuple))->conproc; conoid = HeapTupleGetOid(tuple); ReleaseSysCache(tuple); @@ -318,7 +324,7 @@ pg_convert3(PG_FUNCTION_ARGS) text *retval; unsigned char *str; unsigned char *result; - int len; + int len; if (!OidIsValid(convoid)) elog(ERROR, "Conversion does not exist"); @@ -331,13 +337,13 @@ pg_convert3(PG_FUNCTION_ARGS) tuple = SearchSysCache(CONOID, ObjectIdGetDatum(convoid), - 0,0,0); + 0, 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "Conversion %u search from syscache failed", convoid); result = palloc(len * 4 + 1); - body = (Form_pg_conversion)GETSTRUCT(tuple); + body = (Form_pg_conversion) GETSTRUCT(tuple); OidFunctionCall5(body->conproc, Int32GetDatum(body->conforencoding), Int32GetDatum(body->contoencoding), @@ -347,9 +353,11 @@ pg_convert3(PG_FUNCTION_ARGS) ReleaseSysCache(tuple); - /* build text data type structre. we cannot use textin() here, - since textin assumes that input string encoding is same as - database encoding. */ + /* + * build text data type structre. we cannot use textin() here, since + * textin assumes that input string encoding is same as database + * encoding. + */ len = strlen(result) + VARHDRSZ; retval = palloc(len); VARATT_SIZEP(retval) = len; diff --git a/src/backend/catalog/pg_depend.c b/src/backend/catalog/pg_depend.c index 0427b37bb9..cd058a1306 100644 --- a/src/backend/catalog/pg_depend.c +++ b/src/backend/catalog/pg_depend.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v 1.5 2002/08/11 21:17:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_depend.c,v 1.6 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -44,7 +44,7 @@ recordDependencyOn(const ObjectAddress *depender, /* * Record multiple dependencies (of the same kind) for a single dependent - * object. This has a little less overhead than recording each separately. + * object. This has a little less overhead than recording each separately. */ void recordMultipleDependencies(const ObjectAddress *depender, @@ -79,9 +79,9 @@ recordMultipleDependencies(const ObjectAddress *depender, for (i = 0; i < nreferenced; i++, referenced++) { /* - * If the referenced object is pinned by the system, there's no real - * need to record dependencies on it. This saves lots of space in - * pg_depend, so it's worth the time taken to check. + * If the referenced object is pinned by the system, there's no + * real need to record dependencies on it. This saves lots of + * space in pg_depend, so it's worth the time taken to check. */ if (!isObjectPinned(referenced, dependDesc)) { @@ -89,15 +89,15 @@ recordMultipleDependencies(const ObjectAddress *depender, * Record the Dependency. Note we don't bother to check for * duplicate dependencies; there's no harm in them. */ - values[Anum_pg_depend_classid - 1] = ObjectIdGetDatum(depender->classId); - values[Anum_pg_depend_objid - 1] = ObjectIdGetDatum(depender->objectId); - values[Anum_pg_depend_objsubid - 1] = Int32GetDatum(depender->objectSubId); + values[Anum_pg_depend_classid - 1] = ObjectIdGetDatum(depender->classId); + values[Anum_pg_depend_objid - 1] = ObjectIdGetDatum(depender->objectId); + values[Anum_pg_depend_objsubid - 1] = Int32GetDatum(depender->objectSubId); - values[Anum_pg_depend_refclassid - 1] = ObjectIdGetDatum(referenced->classId); - values[Anum_pg_depend_refobjid - 1] = ObjectIdGetDatum(referenced->objectId); - values[Anum_pg_depend_refobjsubid - 1] = Int32GetDatum(referenced->objectSubId); + values[Anum_pg_depend_refclassid - 1] = ObjectIdGetDatum(referenced->classId); + values[Anum_pg_depend_refobjid - 1] = ObjectIdGetDatum(referenced->objectId); + values[Anum_pg_depend_refobjsubid - 1] = Int32GetDatum(referenced->objectSubId); - values[Anum_pg_depend_deptype -1] = CharGetDatum((char) behavior); + values[Anum_pg_depend_deptype - 1] = CharGetDatum((char) behavior); tup = heap_formtuple(dependDesc->rd_att, values, nulls); @@ -130,11 +130,11 @@ recordMultipleDependencies(const ObjectAddress *depender, long deleteDependencyRecordsFor(Oid classId, Oid objectId) { - long count = 0; - Relation depRel; - ScanKeyData key[2]; - SysScanDesc scan; - HeapTuple tup; + long count = 0; + Relation depRel; + ScanKeyData key[2]; + SysScanDesc scan; + HeapTuple tup; depRel = heap_openr(DependRelationName, RowExclusiveLock); @@ -174,7 +174,7 @@ static bool isObjectPinned(const ObjectAddress *object, Relation rel) { bool ret = false; - SysScanDesc scan; + SysScanDesc scan; HeapTuple tup; ScanKeyData key[2]; @@ -192,13 +192,13 @@ isObjectPinned(const ObjectAddress *object, Relation rel) /* * Since we won't generate additional pg_depend entries for pinned * objects, there can be at most one entry referencing a pinned - * object. Hence, it's sufficient to look at the first returned + * object. Hence, it's sufficient to look at the first returned * tuple; we don't need to loop. */ tup = systable_getnext(scan); if (HeapTupleIsValid(tup)) { - Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); + Form_pg_depend foundDep = (Form_pg_depend) GETSTRUCT(tup); if (foundDep->deptype == DEPENDENCY_PIN) ret = true; diff --git a/src/backend/catalog/pg_operator.c b/src/backend/catalog/pg_operator.c index 8c6174608f..941212a649 100644 --- a/src/backend/catalog/pg_operator.c +++ b/src/backend/catalog/pg_operator.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.76 2002/08/22 00:01:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_operator.c,v 1.77 2002/09/04 20:31:14 momjian Exp $ * * NOTES * these routines moved here from commands/define.c and somewhat cleaned up. @@ -34,28 +34,28 @@ static Oid OperatorGet(const char *operatorName, - Oid operatorNamespace, - Oid leftObjectId, - Oid rightObjectId, - bool *defined); + Oid operatorNamespace, + Oid leftObjectId, + Oid rightObjectId, + bool *defined); static Oid OperatorLookup(List *operatorName, - Oid leftObjectId, - Oid rightObjectId, - bool *defined); + Oid leftObjectId, + Oid rightObjectId, + bool *defined); static Oid OperatorShellMake(const char *operatorName, - Oid operatorNamespace, - Oid leftTypeId, - Oid rightTypeId); + Oid operatorNamespace, + Oid leftTypeId, + Oid rightTypeId); static void OperatorUpd(Oid baseId, Oid commId, Oid negId); static Oid get_other_operator(List *otherOp, - Oid otherLeftTypeId, Oid otherRightTypeId, - const char *operatorName, Oid operatorNamespace, - Oid leftTypeId, Oid rightTypeId, - bool isCommutator); + Oid otherLeftTypeId, Oid otherRightTypeId, + const char *operatorName, Oid operatorNamespace, + Oid leftTypeId, Oid rightTypeId, + bool isCommutator); static void makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid); @@ -229,23 +229,23 @@ OperatorShellMake(const char *operatorName, */ i = 0; namestrcpy(&oname, operatorName); - values[i++] = NameGetDatum(&oname); /* oprname */ + values[i++] = NameGetDatum(&oname); /* oprname */ values[i++] = ObjectIdGetDatum(operatorNamespace); /* oprnamespace */ - values[i++] = Int32GetDatum(GetUserId()); /* oprowner */ + values[i++] = Int32GetDatum(GetUserId()); /* oprowner */ values[i++] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l'); /* oprkind */ - values[i++] = BoolGetDatum(false); /* oprcanhash */ - values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ - values[i++] = ObjectIdGetDatum(rightTypeId); /* oprright */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprresult */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprcom */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprnegate */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprlsortop */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprrsortop */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprltcmpop */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprgtcmpop */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprcode */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprrest */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* oprjoin */ + values[i++] = BoolGetDatum(false); /* oprcanhash */ + values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ + values[i++] = ObjectIdGetDatum(rightTypeId); /* oprright */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprresult */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprcom */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprnegate */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprlsortop */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprrsortop */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprltcmpop */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprgtcmpop */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprcode */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprrest */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* oprjoin */ /* * open pg_operator @@ -506,14 +506,14 @@ OperatorCreate(const char *operatorName, i = 0; namestrcpy(&oname, operatorName); - values[i++] = NameGetDatum(&oname); /* oprname */ + values[i++] = NameGetDatum(&oname); /* oprname */ values[i++] = ObjectIdGetDatum(operatorNamespace); /* oprnamespace */ - values[i++] = Int32GetDatum(GetUserId()); /* oprowner */ + values[i++] = Int32GetDatum(GetUserId()); /* oprowner */ values[i++] = CharGetDatum(leftTypeId ? (rightTypeId ? 'b' : 'r') : 'l'); /* oprkind */ - values[i++] = BoolGetDatum(canHash); /* oprcanhash */ - values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ - values[i++] = ObjectIdGetDatum(rightTypeId); /* oprright */ - values[i++] = ObjectIdGetDatum(operResultType); /* oprresult */ + values[i++] = BoolGetDatum(canHash); /* oprcanhash */ + values[i++] = ObjectIdGetDatum(leftTypeId); /* oprleft */ + values[i++] = ObjectIdGetDatum(rightTypeId); /* oprright */ + values[i++] = ObjectIdGetDatum(operResultType); /* oprresult */ /* * Set up the other operators. If they do not currently exist, create @@ -528,16 +528,17 @@ OperatorCreate(const char *operatorName, operatorName, operatorNamespace, leftTypeId, rightTypeId, true); + /* - * self-linkage to this operator; will fix below. Note - * that only self-linkage for commutation makes sense. + * self-linkage to this operator; will fix below. Note that only + * self-linkage for commutation makes sense. */ if (!OidIsValid(commutatorId)) selfCommutator = true; } else commutatorId = InvalidOid; - values[i++] = ObjectIdGetDatum(commutatorId); /* oprcom */ + values[i++] = ObjectIdGetDatum(commutatorId); /* oprcom */ if (negatorName) { @@ -550,20 +551,20 @@ OperatorCreate(const char *operatorName, } else negatorId = InvalidOid; - values[i++] = ObjectIdGetDatum(negatorId); /* oprnegate */ + values[i++] = ObjectIdGetDatum(negatorId); /* oprnegate */ if (leftSortName) { /* left sort op takes left-side data type */ leftSortId = get_other_operator(leftSortName, - leftTypeId, leftTypeId, - operatorName, operatorNamespace, - leftTypeId, rightTypeId, - false); + leftTypeId, leftTypeId, + operatorName, operatorNamespace, + leftTypeId, rightTypeId, + false); } else leftSortId = InvalidOid; - values[i++] = ObjectIdGetDatum(leftSortId); /* oprlsortop */ + values[i++] = ObjectIdGetDatum(leftSortId); /* oprlsortop */ if (rightSortName) { @@ -576,7 +577,7 @@ OperatorCreate(const char *operatorName, } else rightSortId = InvalidOid; - values[i++] = ObjectIdGetDatum(rightSortId); /* oprrsortop */ + values[i++] = ObjectIdGetDatum(rightSortId); /* oprrsortop */ if (ltCompareName) { @@ -589,7 +590,7 @@ OperatorCreate(const char *operatorName, } else ltCompareId = InvalidOid; - values[i++] = ObjectIdGetDatum(ltCompareId); /* oprltcmpop */ + values[i++] = ObjectIdGetDatum(ltCompareId); /* oprltcmpop */ if (gtCompareName) { @@ -602,11 +603,11 @@ OperatorCreate(const char *operatorName, } else gtCompareId = InvalidOid; - values[i++] = ObjectIdGetDatum(gtCompareId); /* oprgtcmpop */ + values[i++] = ObjectIdGetDatum(gtCompareId); /* oprgtcmpop */ - values[i++] = ObjectIdGetDatum(procOid); /* oprcode */ - values[i++] = ObjectIdGetDatum(restOid); /* oprrest */ - values[i++] = ObjectIdGetDatum(joinOid); /* oprjoin */ + values[i++] = ObjectIdGetDatum(procOid); /* oprcode */ + values[i++] = ObjectIdGetDatum(restOid); /* oprrest */ + values[i++] = ObjectIdGetDatum(joinOid); /* oprjoin */ pg_operator_desc = heap_openr(OperatorRelationName, RowExclusiveLock); @@ -703,8 +704,8 @@ get_other_operator(List *otherOp, Oid otherLeftTypeId, Oid otherRightTypeId, otherRightTypeId == rightTypeId) { /* - * self-linkage to this operator; caller will fix later. Note - * that only self-linkage for commutation makes sense. + * self-linkage to this operator; caller will fix later. Note that + * only self-linkage for commutation makes sense. */ if (!isCommutator) elog(ERROR, "operator cannot be its own negator or sort operator"); @@ -868,9 +869,9 @@ OperatorUpd(Oid baseId, Oid commId, Oid negId) static void makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid) { - Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple); - ObjectAddress myself, - referenced; + Form_pg_operator oper = (Form_pg_operator) GETSTRUCT(tuple); + ObjectAddress myself, + referenced; myself.classId = pg_operator_relid; myself.objectId = HeapTupleGetOid(tuple); @@ -918,11 +919,11 @@ makeOperatorDependencies(HeapTuple tuple, Oid pg_operator_relid) /* * NOTE: we do not consider the operator to depend on the associated * operators oprcom, oprnegate, oprlsortop, oprrsortop, oprltcmpop, - * oprgtcmpop. We would not want to delete this operator if those - * go away, but only reset the link fields; which is not a function - * that the dependency code can presently handle. (Something could - * perhaps be done with objectSubId though.) For now, it's okay to - * let those links dangle if a referenced operator is removed. + * oprgtcmpop. We would not want to delete this operator if those go + * away, but only reset the link fields; which is not a function that + * the dependency code can presently handle. (Something could perhaps + * be done with objectSubId though.) For now, it's okay to let those + * links dangle if a referenced operator is removed. */ /* Dependency on implementation function */ diff --git a/src/backend/catalog/pg_proc.c b/src/backend/catalog/pg_proc.c index 805ce61930..ba667a2654 100644 --- a/src/backend/catalog/pg_proc.c +++ b/src/backend/catalog/pg_proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.92 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_proc.c,v 1.93 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,9 +34,9 @@ static void checkretval(Oid rettype, char fn_typtype, List *queryTreeList); -Datum fmgr_internal_validator(PG_FUNCTION_ARGS); -Datum fmgr_c_validator(PG_FUNCTION_ARGS); -Datum fmgr_sql_validator(PG_FUNCTION_ARGS); +Datum fmgr_internal_validator(PG_FUNCTION_ARGS); +Datum fmgr_c_validator(PG_FUNCTION_ARGS); +Datum fmgr_sql_validator(PG_FUNCTION_ARGS); /* ---------------------------------------------------------------- @@ -73,8 +73,8 @@ ProcedureCreate(const char *procedureName, TupleDesc tupDesc; Oid retval; bool is_update; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* * sanity checks @@ -153,16 +153,16 @@ ProcedureCreate(const char *procedureName, i = 0; namestrcpy(&procname, procedureName); values[i++] = NameGetDatum(&procname); /* proname */ - values[i++] = ObjectIdGetDatum(procNamespace); /* pronamespace */ + values[i++] = ObjectIdGetDatum(procNamespace); /* pronamespace */ values[i++] = Int32GetDatum(GetUserId()); /* proowner */ - values[i++] = ObjectIdGetDatum(languageObjectId); /* prolang */ - values[i++] = BoolGetDatum(isAgg); /* proisagg */ - values[i++] = BoolGetDatum(security_definer); /* prosecdef */ + values[i++] = ObjectIdGetDatum(languageObjectId); /* prolang */ + values[i++] = BoolGetDatum(isAgg); /* proisagg */ + values[i++] = BoolGetDatum(security_definer); /* prosecdef */ values[i++] = BoolGetDatum(isStrict); /* proisstrict */ values[i++] = BoolGetDatum(returnsSet); /* proretset */ values[i++] = CharGetDatum(volatility); /* provolatile */ - values[i++] = UInt16GetDatum(parameterCount); /* pronargs */ - values[i++] = ObjectIdGetDatum(returnType); /* prorettype */ + values[i++] = UInt16GetDatum(parameterCount); /* pronargs */ + values[i++] = ObjectIdGetDatum(returnType); /* prorettype */ values[i++] = PointerGetDatum(typev); /* proargtypes */ values[i++] = DirectFunctionCall1(textin, /* prosrc */ CStringGetDatum(prosrc)); @@ -213,8 +213,8 @@ ProcedureCreate(const char *procedureName, } /* do not change existing ownership or permissions, either */ - replaces[Anum_pg_proc_proowner-1] = ' '; - replaces[Anum_pg_proc_proacl-1] = ' '; + replaces[Anum_pg_proc_proowner - 1] = ' '; + replaces[Anum_pg_proc_proacl - 1] = ' '; /* Okay, do it... */ tup = heap_modifytuple(oldtup, rel, values, nulls, replaces); @@ -228,7 +228,7 @@ ProcedureCreate(const char *procedureName, /* Creating a new procedure */ /* start out with empty permissions */ - nulls[Anum_pg_proc_proacl-1] = 'n'; + nulls[Anum_pg_proc_proacl - 1] = 'n'; tup = heap_formtuple(tupDesc, values, nulls); simple_heap_insert(rel, tup); @@ -332,7 +332,8 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) tlist = parse->targetList; /* - * The last query must be a SELECT if and only if return type isn't VOID. + * The last query must be a SELECT if and only if return type isn't + * VOID. */ if (rettype == VOIDOID) { @@ -360,8 +361,8 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) /* * For base-type returns, the target list should have exactly one - * entry, and its type should agree with what the user declared. (As - * of Postgres 7.2, we accept binary-compatible types too.) + * entry, and its type should agree with what the user declared. + * (As of Postgres 7.2, we accept binary-compatible types too.) */ if (tlistlen != 1) elog(ERROR, "function declared to return %s returns multiple columns in final SELECT", @@ -378,11 +379,11 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) Assert(typerelid != InvalidOid); /* - * If the target list is of length 1, and the type of the varnode in - * the target list matches the declared return type, this is okay. - * This can happen, for example, where the body of the function is - * 'SELECT func2()', where func2 has the same return type as the - * function that's calling it. + * If the target list is of length 1, and the type of the varnode + * in the target list matches the declared return type, this is + * okay. This can happen, for example, where the body of the + * function is 'SELECT func2()', where func2 has the same return + * type as the function that's calling it. */ if (tlistlen == 1) { @@ -392,15 +393,15 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) } /* - * Otherwise verify that the targetlist matches the return tuple type. - * This part of the typechecking is a hack. We look up the relation - * that is the declared return type, and scan the non-deleted - * attributes to ensure that they match the datatypes of the - * non-resjunk columns. + * Otherwise verify that the targetlist matches the return tuple + * type. This part of the typechecking is a hack. We look up the + * relation that is the declared return type, and scan the + * non-deleted attributes to ensure that they match the datatypes + * of the non-resjunk columns. */ reln = relation_open(typerelid, AccessShareLock); relnatts = reln->rd_rel->relnatts; - rellogcols = 0; /* we'll count nondeleted cols as we go */ + rellogcols = 0; /* we'll count nondeleted cols as we go */ colindex = 0; foreach(tlistitem, tlist) @@ -413,7 +414,8 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) if (tle->resdom->resjunk) continue; - do { + do + { colindex++; if (colindex > relnatts) elog(ERROR, "function declared to return %s does not SELECT the right number of columns (%d)", @@ -453,8 +455,8 @@ checkretval(Oid rettype, char fn_typtype, List *queryTreeList) Assert(typerelid == InvalidOid); /* - * For RECORD return type, defer this check until we get the - * first tuple. + * For RECORD return type, defer this check until we get the first + * tuple. */ } else @@ -532,7 +534,7 @@ fmgr_c_validator(PG_FUNCTION_ARGS) if (isnull) elog(ERROR, "null probin"); probin = DatumGetCString(DirectFunctionCall1(textout, tmp)); - + (void) load_external_function(probin, prosrc, true, &libraryhandle); (void) fetch_finfo_record(libraryhandle, prosrc); diff --git a/src/backend/catalog/pg_type.c b/src/backend/catalog/pg_type.c index e3eb6abe32..d43c1edeee 100644 --- a/src/backend/catalog/pg_type.c +++ b/src/backend/catalog/pg_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.81 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/catalog/pg_type.c,v 1.82 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -73,7 +73,7 @@ TypeShellMake(const char *typeName, Oid typeNamespace) i = 0; namestrcpy(&name, typeName); values[i++] = NameGetDatum(&name); /* typname */ - values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ + values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ values[i++] = ObjectIdGetDatum(InvalidOid); /* typowner */ values[i++] = Int16GetDatum(0); /* typlen */ values[i++] = BoolGetDatum(false); /* typbyval */ @@ -84,12 +84,12 @@ TypeShellMake(const char *typeName, Oid typeNamespace) values[i++] = ObjectIdGetDatum(InvalidOid); /* typelem */ values[i++] = ObjectIdGetDatum(InvalidOid); /* typinput */ values[i++] = ObjectIdGetDatum(InvalidOid); /* typoutput */ - values[i++] = CharGetDatum('i'); /* typalign */ - values[i++] = CharGetDatum('p'); /* typstorage */ - values[i++] = BoolGetDatum(false); /* typnotnull */ - values[i++] = ObjectIdGetDatum(InvalidOid); /* typbasetype */ - values[i++] = Int32GetDatum(-1); /* typtypmod */ - values[i++] = Int32GetDatum(0); /* typndims */ + values[i++] = CharGetDatum('i'); /* typalign */ + values[i++] = CharGetDatum('p'); /* typstorage */ + values[i++] = BoolGetDatum(false); /* typnotnull */ + values[i++] = ObjectIdGetDatum(InvalidOid); /* typbasetype */ + values[i++] = Int32GetDatum(-1); /* typtypmod */ + values[i++] = Int32GetDatum(0); /* typndims */ nulls[i++] = 'n'; /* typdefaultbin */ nulls[i++] = 'n'; /* typdefault */ @@ -129,8 +129,8 @@ Oid TypeCreate(const char *typeName, Oid typeNamespace, Oid assignedTypeOid, - Oid relationOid, /* only for 'c'atalog typeType */ - char relationKind, /* ditto */ + Oid relationOid, /* only for 'c'atalog typeType */ + char relationKind, /* ditto */ int16 internalSize, char typeType, char typDelim, @@ -138,13 +138,13 @@ TypeCreate(const char *typeName, Oid outputProcedure, Oid elementType, Oid baseType, - const char *defaultTypeValue, /* human readable rep */ + const char *defaultTypeValue, /* human readable rep */ const char *defaultTypeBin, /* cooked rep */ bool passedByValue, char alignment, char storage, int32 typeMod, - int32 typNDims, /* Array dimensions for baseType */ + int32 typNDims, /* Array dimensions for baseType */ bool typeNotNull) { Relation pg_type_desc; @@ -158,8 +158,8 @@ TypeCreate(const char *typeName, int i; /* - * We assume that the caller validated the arguments individually, - * but did not check for bad combinations. + * We assume that the caller validated the arguments individually, but + * did not check for bad combinations. * * Validate size specifications: either positive (fixed-length) or -1 * (varlena) or -2 (cstring). Pass-by-value types must have a fixed @@ -195,27 +195,27 @@ TypeCreate(const char *typeName, i = 0; namestrcpy(&name, typeName); values[i++] = NameGetDatum(&name); /* typname */ - values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ + values[i++] = ObjectIdGetDatum(typeNamespace); /* typnamespace */ values[i++] = Int32GetDatum(GetUserId()); /* typowner */ values[i++] = Int16GetDatum(internalSize); /* typlen */ values[i++] = BoolGetDatum(passedByValue); /* typbyval */ values[i++] = CharGetDatum(typeType); /* typtype */ - values[i++] = BoolGetDatum(true); /* typisdefined */ + values[i++] = BoolGetDatum(true); /* typisdefined */ values[i++] = CharGetDatum(typDelim); /* typdelim */ values[i++] = ObjectIdGetDatum(typeType == 'c' ? relationOid : InvalidOid); /* typrelid */ - values[i++] = ObjectIdGetDatum(elementType); /* typelem */ - values[i++] = ObjectIdGetDatum(inputProcedure); /* typinput */ - values[i++] = ObjectIdGetDatum(outputProcedure); /* typoutput */ + values[i++] = ObjectIdGetDatum(elementType); /* typelem */ + values[i++] = ObjectIdGetDatum(inputProcedure); /* typinput */ + values[i++] = ObjectIdGetDatum(outputProcedure); /* typoutput */ values[i++] = CharGetDatum(alignment); /* typalign */ values[i++] = CharGetDatum(storage); /* typstorage */ - values[i++] = BoolGetDatum(typeNotNull); /* typnotnull */ - values[i++] = ObjectIdGetDatum(baseType); /* typbasetype */ - values[i++] = Int32GetDatum(typeMod); /* typtypmod */ - values[i++] = Int32GetDatum(typNDims); /* typndims */ + values[i++] = BoolGetDatum(typeNotNull); /* typnotnull */ + values[i++] = ObjectIdGetDatum(baseType); /* typbasetype */ + values[i++] = Int32GetDatum(typeMod); /* typtypmod */ + values[i++] = Int32GetDatum(typNDims); /* typndims */ /* - * initialize the default binary value for this type. Check for - * nulls of course. + * initialize the default binary value for this type. Check for nulls + * of course. */ if (defaultTypeBin) values[i] = DirectFunctionCall1(textin, @@ -229,7 +229,7 @@ TypeCreate(const char *typeName, */ if (defaultTypeValue) values[i] = DirectFunctionCall1(textin, - CStringGetDatum(defaultTypeValue)); + CStringGetDatum(defaultTypeValue)); else nulls[i] = 'n'; i++; /* typdefault */ @@ -291,8 +291,8 @@ TypeCreate(const char *typeName, */ if (!IsBootstrapProcessingMode()) { - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; myself.classId = RelOid_pg_type; myself.objectId = typeObjectId; @@ -321,13 +321,13 @@ TypeCreate(const char *typeName, /* * If the type is a rowtype for a relation, mark it as internally - * dependent on the relation, *unless* it is a stand-alone composite - * type relation. For the latter case, we have to reverse the - * dependency. + * dependent on the relation, *unless* it is a stand-alone + * composite type relation. For the latter case, we have to + * reverse the dependency. * - * In the former case, this allows the type to be auto-dropped - * when the relation is, and not otherwise. And in the latter, - * of course we get the opposite effect. + * In the former case, this allows the type to be auto-dropped when + * the relation is, and not otherwise. And in the latter, of + * course we get the opposite effect. */ if (OidIsValid(relationOid)) { @@ -342,11 +342,11 @@ TypeCreate(const char *typeName, } /* - * If the type is an array type, mark it auto-dependent on the base - * type. (This is a compromise between the typical case where the - * array type is automatically generated and the case where it is - * manually created: we'd prefer INTERNAL for the former case and - * NORMAL for the latter.) + * If the type is an array type, mark it auto-dependent on the + * base type. (This is a compromise between the typical case + * where the array type is automatically generated and the case + * where it is manually created: we'd prefer INTERNAL for the + * former case and NORMAL for the latter.) */ if (OidIsValid(elementType)) { diff --git a/src/backend/commands/aggregatecmds.c b/src/backend/commands/aggregatecmds.c index 85ee9e3f53..552573dc1a 100644 --- a/src/backend/commands/aggregatecmds.c +++ b/src/backend/commands/aggregatecmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.4 2002/08/22 00:01:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/aggregatecmds.c,v 1.5 2002/09/04 20:31:14 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -110,8 +110,8 @@ DefineAggregate(List *names, List *parameters) * We have historically allowed the command to look like basetype = 'ANY' * so we must do a case-insensitive comparison for the name ANY. Ugh. * - * basetype can be a pseudo-type, but transtype can't, since we need - * to be able to store values of the transtype. + * basetype can be a pseudo-type, but transtype can't, since we need to + * be able to store values of the transtype. */ if (strcasecmp(TypeNameToString(baseType), "ANY") == 0) baseTypeId = ANYOID; @@ -127,10 +127,10 @@ DefineAggregate(List *names, List *parameters) * Most of the argument-checking is done inside of AggregateCreate */ AggregateCreate(aggName, /* aggregate name */ - aggNamespace, /* namespace */ + aggNamespace, /* namespace */ transfuncName, /* step function name */ finalfuncName, /* final function name */ - baseTypeId, /* type of data being aggregated */ + baseTypeId, /* type of data being aggregated */ transTypeId, /* transition data type */ initval); /* initial condition */ } @@ -154,8 +154,8 @@ RemoveAggregate(RemoveAggrStmt *stmt) * if a basetype is passed in, then attempt to find an aggregate for * that specific type. * - * else attempt to find an aggregate with a basetype of ANYOID. - * This means that the aggregate is to apply to all basetypes (eg, COUNT). + * else attempt to find an aggregate with a basetype of ANYOID. This + * means that the aggregate is to apply to all basetypes (eg, COUNT). */ if (aggType) basetypeID = typenameTypeId(aggType); @@ -170,7 +170,7 @@ RemoveAggregate(RemoveAggrStmt *stmt) tup = SearchSysCache(PROCOID, ObjectIdGetDatum(procOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveAggregate: couldn't find pg_proc tuple for %s", NameListToString(aggName)); diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 2d9a2daa0c..5c20b05447 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.45 2002/08/26 18:45:57 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/analyze.c,v 1.46 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -110,10 +110,10 @@ typedef struct /* Default statistics target (GUC parameter) */ -int default_statistics_target = 10; +int default_statistics_target = 10; -static int elevel = -1; +static int elevel = -1; static MemoryContext anl_context = NULL; @@ -163,9 +163,9 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) elevel = DEBUG1; /* - * Use the current context for storing analysis info. vacuum.c ensures - * that this context will be cleared when I return, thus releasing the - * memory allocated here. + * Use the current context for storing analysis info. vacuum.c + * ensures that this context will be cleared when I return, thus + * releasing the memory allocated here. */ anl_context = CurrentMemoryContext; @@ -219,7 +219,7 @@ analyze_rel(Oid relid, VacuumStmt *vacstmt) * We can ANALYZE any table except pg_statistic. See update_attstats */ if (IsSystemNamespace(RelationGetNamespace(onerel)) && - strcmp(RelationGetRelationName(onerel), StatisticRelationName) == 0) + strcmp(RelationGetRelationName(onerel), StatisticRelationName) == 0) { relation_close(onerel, AccessShareLock); return; @@ -1042,11 +1042,15 @@ compute_minimal_stats(VacAttrStats *stats, */ int f1 = nonnull_cnt - summultiple; int d = f1 + nmultiple; - double numer, denom, stadistinct; + double numer, + denom, + stadistinct; + + numer = (double) numrows *(double) d; - numer = (double) numrows * (double) d; denom = (double) (numrows - f1) + - (double) f1 * (double) numrows / totalrows; + (double) f1 *(double) numrows / totalrows; + stadistinct = numer / denom; /* Clamp to sane range in case of roundoff error */ if (stadistinct < (double) d) @@ -1361,11 +1365,15 @@ compute_scalar_stats(VacAttrStats *stats, */ int f1 = ndistinct - nmultiple + toowide_cnt; int d = f1 + nmultiple; - double numer, denom, stadistinct; + double numer, + denom, + stadistinct; + + numer = (double) numrows *(double) d; - numer = (double) numrows * (double) d; denom = (double) (numrows - f1) + - (double) f1 * (double) numrows / totalrows; + (double) f1 *(double) numrows / totalrows; + stadistinct = numer / denom; /* Clamp to sane range in case of roundoff error */ if (stadistinct < (double) d) @@ -1666,7 +1674,7 @@ compare_mcvs(const void *a, const void *b) * relation for ANALYZE (ie, ShareUpdateExclusiveLock instead * of AccessShareLock); but that cure seems worse than the disease, * especially now that ANALYZE doesn't start a new transaction - * for each relation. The lock could be held for a long time... + * for each relation. The lock could be held for a long time... */ static void update_attstats(Oid relid, int natts, VacAttrStats **vacattrstats) diff --git a/src/backend/commands/cluster.c b/src/backend/commands/cluster.c index d49aa0b678..55cee5b4a7 100644 --- a/src/backend/commands/cluster.c +++ b/src/backend/commands/cluster.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.89 2002/09/03 01:04:41 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/cluster.c,v 1.90 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ static void swap_relfilenodes(Oid r1, Oid r2); * * This clusters the table by creating a new, clustered table and * swapping the relfilenodes of the new table and the old table, so - * the OID of the original table is preserved. Thus we do not lose + * the OID of the original table is preserved. Thus we do not lose * GRANT, inheritance nor references to this table (this was a bug * in releases thru 7.3). * @@ -111,11 +111,11 @@ cluster(RangeVar *oldrelation, char *oldindexname) RelationGetRelationName(OldHeap)); /* - * Disallow clustering system relations. This will definitely NOT work - * for shared relations (we have no way to update pg_class rows in other - * databases), nor for nailed-in-cache relations (the relfilenode values - * for those are hardwired, see relcache.c). It might work for other - * system relations, but I ain't gonna risk it. + * Disallow clustering system relations. This will definitely NOT + * work for shared relations (we have no way to update pg_class rows + * in other databases), nor for nailed-in-cache relations (the + * relfilenode values for those are hardwired, see relcache.c). It + * might work for other system relations, but I ain't gonna risk it. */ if (IsSystemRelation(OldHeap)) elog(ERROR, "CLUSTER: cannot cluster system relation \"%s\"", @@ -130,16 +130,20 @@ cluster(RangeVar *oldrelation, char *oldindexname) /* * Create the new heap, using a temporary name in the same namespace - * as the existing table. NOTE: there is some risk of collision with user - * relnames. Working around this seems more trouble than it's worth; in - * particular, we can't create the new heap in a different namespace from - * the old, or we will have problems with the TEMP status of temp tables. + * as the existing table. NOTE: there is some risk of collision with + * user relnames. Working around this seems more trouble than it's + * worth; in particular, we can't create the new heap in a different + * namespace from the old, or we will have problems with the TEMP + * status of temp tables. */ snprintf(NewHeapName, NAMEDATALEN, "pg_temp_%u", OIDOldHeap); OIDNewHeap = make_new_heap(OIDOldHeap, NewHeapName); - /* We don't need CommandCounterIncrement() because make_new_heap did it. */ + /* + * We don't need CommandCounterIncrement() because make_new_heap did + * it. + */ /* * Copy the heap data into the new table in the desired order. @@ -244,14 +248,14 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) while ((tuple = index_getnext(scan, ForwardScanDirection)) != NULL) { /* - * We must copy the tuple because heap_insert() will overwrite - * the commit-status fields of the tuple it's handed, and the - * retrieved tuple will actually be in a disk buffer! Thus, - * the source relation would get trashed, which is bad news if - * we abort later on. (This was a bug in releases thru 7.0) + * We must copy the tuple because heap_insert() will overwrite the + * commit-status fields of the tuple it's handed, and the + * retrieved tuple will actually be in a disk buffer! Thus, the + * source relation would get trashed, which is bad news if we + * abort later on. (This was a bug in releases thru 7.0) * - * Note that the copied tuple will have the original OID, if any, - * so this does preserve OIDs. + * Note that the copied tuple will have the original OID, if any, so + * this does preserve OIDs. */ HeapTuple copiedTuple = heap_copytuple(tuple); @@ -276,15 +280,15 @@ copy_heap_data(Oid OIDNewHeap, Oid OIDOldHeap, Oid OIDOldIndex) static List * get_indexattr_list(Relation OldHeap, Oid OldIndex) { - List *indexes = NIL; + List *indexes = NIL; List *indlist; /* Ask the relcache to produce a list of the indexes of the old rel */ foreach(indlist, RelationGetIndexList(OldHeap)) { - Oid indexOID = (Oid) lfirsti(indlist); - HeapTuple indexTuple; - HeapTuple classTuple; + Oid indexOID = (Oid) lfirsti(indlist); + HeapTuple indexTuple; + HeapTuple classTuple; Form_pg_index indexForm; Form_pg_class classForm; IndexAttrs *attrs; @@ -320,7 +324,8 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex) ReleaseSysCache(classTuple); ReleaseSysCache(indexTuple); - /* Cons the gathered data into the list. We do not care about + /* + * Cons the gathered data into the list. We do not care about * ordering, and this is more efficient than append. */ indexes = lcons(attrs, indexes); @@ -330,13 +335,13 @@ get_indexattr_list(Relation OldHeap, Oid OldIndex) } /* - * Create new indexes and swap the filenodes with old indexes. Then drop + * Create new indexes and swap the filenodes with old indexes. Then drop * the new index (carrying the old index filenode along). */ static void recreate_indexattr(Oid OIDOldHeap, List *indexes) { - List *elem; + List *elem; foreach(elem, indexes) { @@ -352,13 +357,13 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes) snprintf(newIndexName, NAMEDATALEN, "pg_temp_%u", attrs->indexOID); /* - * The new index will have primary and constraint status set to false, - * but since we will only use its filenode it doesn't matter: - * after the filenode swap the index will keep the constraint - * status of the old index. + * The new index will have primary and constraint status set to + * false, but since we will only use its filenode it doesn't + * matter: after the filenode swap the index will keep the + * constraint status of the old index. */ newIndexOID = index_create(OIDOldHeap, newIndexName, - attrs->indexInfo, attrs->accessMethodOID, + attrs->indexInfo, attrs->accessMethodOID, attrs->classOID, false, false, allowSystemTableMods); CommandCounterIncrement(); @@ -369,8 +374,8 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes) CommandCounterIncrement(); /* - * Make sure that indisclustered is correct: it should be set - * only for the index we just clustered on. + * Make sure that indisclustered is correct: it should be set only + * for the index we just clustered on. */ pg_index = heap_openr(IndexRelationName, RowExclusiveLock); tuple = SearchSysCacheCopy(INDEXRELID, @@ -392,13 +397,13 @@ recreate_indexattr(Oid OIDOldHeap, List *indexes) object.classId = RelOid_pg_class; object.objectId = newIndexOID; object.objectSubId = 0; - + /* - * The relation is local to our transaction and we know - * nothing depends on it, so DROP_RESTRICT should be OK. + * The relation is local to our transaction and we know nothing + * depends on it, so DROP_RESTRICT should be OK. */ performDeletion(&object, DROP_RESTRICT); - + /* performDeletion does CommandCounterIncrement() at its end */ } } @@ -473,7 +478,7 @@ swap_relfilenodes(Oid r1, Oid r2) /* Update the tuples in pg_class */ simple_heap_update(relRelation, &reltup1->t_self, reltup1); simple_heap_update(relRelation, &reltup2->t_self, reltup2); - + /* Keep system catalogs current */ indstate = CatalogOpenIndexes(relRelation); CatalogIndexInsert(indstate, reltup1); @@ -481,16 +486,17 @@ swap_relfilenodes(Oid r1, Oid r2) CatalogCloseIndexes(indstate); /* - * If we have toast tables associated with the relations being swapped, - * change their dependency links to re-associate them with their new - * owning relations. Otherwise the wrong one will get dropped ... + * If we have toast tables associated with the relations being + * swapped, change their dependency links to re-associate them with + * their new owning relations. Otherwise the wrong one will get + * dropped ... * - * NOTE: for now, we can assume the new table will have a TOAST table - * if and only if the old one does. This logic might need work if we - * get smarter about dropped columns. + * NOTE: for now, we can assume the new table will have a TOAST table if + * and only if the old one does. This logic might need work if we get + * smarter about dropped columns. * - * NOTE: at present, a TOAST table's only dependency is the one on - * its owning table. If more are ever created, we'd need to use something + * NOTE: at present, a TOAST table's only dependency is the one on its + * owning table. If more are ever created, we'd need to use something * more selective than deleteDependencyRecordsFor() to get rid of only * the link we want. */ @@ -532,12 +538,12 @@ swap_relfilenodes(Oid r1, Oid r2) } /* - * Blow away the old relcache entries now. We need this kluge because - * relcache.c indexes relcache entries by rd_node as well as OID. - * It will get confused if it is asked to (re)build an entry with a new + * Blow away the old relcache entries now. We need this kluge because + * relcache.c indexes relcache entries by rd_node as well as OID. It + * will get confused if it is asked to (re)build an entry with a new * rd_node value when there is still another entry laying about with - * that same rd_node value. (Fortunately, since one of the entries - * is local in our transaction, it's sufficient to clear out our own + * that same rd_node value. (Fortunately, since one of the entries is + * local in our transaction, it's sufficient to clear out our own * relcache this way; the problem cannot arise for other backends when * they see our update on the non-local relation.) */ diff --git a/src/backend/commands/comment.c b/src/backend/commands/comment.c index a692531485..fb8e641416 100644 --- a/src/backend/commands/comment.c +++ b/src/backend/commands/comment.c @@ -7,7 +7,7 @@ * Copyright (c) 1996-2001, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.59 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/comment.c,v 1.60 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,7 +231,7 @@ DeleteComments(Oid oid, Oid classoid, int32 subid) Relation description; ScanKeyData skey[3]; int nkeys; - SysScanDesc sd; + SysScanDesc sd; HeapTuple oldtuple; /* Use the index to search for all matching old tuples */ @@ -260,9 +260,7 @@ DeleteComments(Oid oid, Oid classoid, int32 subid) SnapshotNow, nkeys, skey); while ((oldtuple = systable_getnext(sd)) != NULL) - { simple_heap_delete(description, &oldtuple->t_self); - } /* Done */ @@ -357,8 +355,8 @@ CommentAttribute(List *qualname, char *comment) nnames = length(qualname); if (nnames < 2) elog(ERROR, "CommentAttribute: must specify relation.attribute"); - relname = ltruncate(nnames-1, listCopy(qualname)); - attrname = strVal(nth(nnames-1, qualname)); + relname = ltruncate(nnames - 1, listCopy(qualname)); + attrname = strVal(nth(nnames - 1, qualname)); /* Open the containing relation to ensure it won't go away meanwhile */ rel = makeRangeVarFromNameList(relname); @@ -521,13 +519,13 @@ CommentRule(List *qualname, char *comment) else { elog(ERROR, "rule \"%s\" does not exist", rulename); - reloid = ruleoid = 0; /* keep compiler quiet */ + reloid = ruleoid = 0; /* keep compiler quiet */ } if (HeapTupleIsValid(tuple = heap_getnext(scanDesc, ForwardScanDirection))) elog(ERROR, "There are multiple rules \"%s\"" - "\n\tPlease specify a relation name as well as a rule name", + "\n\tPlease specify a relation name as well as a rule name", rulename); heap_endscan(scanDesc); @@ -540,8 +538,8 @@ CommentRule(List *qualname, char *comment) { /* New-style: rule and relname both provided */ Assert(nnames >= 2); - relname = ltruncate(nnames-1, listCopy(qualname)); - rulename = strVal(nth(nnames-1, qualname)); + relname = ltruncate(nnames - 1, listCopy(qualname)); + rulename = strVal(nth(nnames - 1, qualname)); /* Open the owning relation to ensure it won't go away meanwhile */ rel = makeRangeVarFromNameList(relname); @@ -724,7 +722,7 @@ CommentTrigger(List *qualname, char *comment) Relation pg_trigger, relation; HeapTuple triggertuple; - SysScanDesc scan; + SysScanDesc scan; ScanKeyData entry[2]; Oid oid; @@ -732,8 +730,8 @@ CommentTrigger(List *qualname, char *comment) nnames = length(qualname); if (nnames < 2) elog(ERROR, "CommentTrigger: must specify relation and trigger"); - relname = ltruncate(nnames-1, listCopy(qualname)); - trigname = strVal(nth(nnames-1, qualname)); + relname = ltruncate(nnames - 1, listCopy(qualname)); + trigname = strVal(nth(nnames - 1, qualname)); /* Open the owning relation to ensure it won't go away meanwhile */ rel = makeRangeVarFromNameList(relname); @@ -799,7 +797,7 @@ CommentConstraint(List *qualname, char *comment) Relation pg_constraint, relation; HeapTuple tuple; - SysScanDesc scan; + SysScanDesc scan; ScanKeyData skey[1]; Oid conOid = InvalidOid; @@ -807,8 +805,8 @@ CommentConstraint(List *qualname, char *comment) nnames = length(qualname); if (nnames < 2) elog(ERROR, "CommentConstraint: must specify relation and constraint"); - relName = ltruncate(nnames-1, listCopy(qualname)); - conName = strVal(nth(nnames-1, qualname)); + relName = ltruncate(nnames - 1, listCopy(qualname)); + conName = strVal(nth(nnames - 1, qualname)); /* Open the owning relation to ensure it won't go away meanwhile */ rel = makeRangeVarFromNameList(relName); @@ -820,9 +818,9 @@ CommentConstraint(List *qualname, char *comment) aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(relation)); /* - * Fetch the constraint tuple from pg_constraint. There may be more than - * one match, because constraints are not required to have unique names; - * if so, error out. + * Fetch the constraint tuple from pg_constraint. There may be more + * than one match, because constraints are not required to have unique + * names; if so, error out. */ pg_constraint = heap_openr(ConstraintRelationName, AccessShareLock); @@ -835,7 +833,7 @@ CommentConstraint(List *qualname, char *comment) while (HeapTupleIsValid(tuple = systable_getnext(scan))) { - Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); + Form_pg_constraint con = (Form_pg_constraint) GETSTRUCT(tuple); if (strcmp(NameStr(con->conname), conName) == 0) { diff --git a/src/backend/commands/conversioncmds.c b/src/backend/commands/conversioncmds.c index 7d65a1a785..614d3676c2 100644 --- a/src/backend/commands/conversioncmds.c +++ b/src/backend/commands/conversioncmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.3 2002/08/22 00:01:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/conversioncmds.c,v 1.4 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,19 +33,19 @@ void CreateConversionCommand(CreateConversionStmt *stmt) { Oid namespaceId; - char *conversion_name; + char *conversion_name; AclResult aclresult; int for_encoding; int to_encoding; Oid funcoid; Oid funcnamespace; - char *dummy; + char *dummy; const char *for_encoding_name = stmt->for_encoding_name; const char *to_encoding_name = stmt->to_encoding_name; - List *func_name = stmt->func_name; + List *func_name = stmt->func_name; - static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID}; + static Oid funcargs[] = {INT4OID, INT4OID, CSTRINGOID, CSTRINGOID, INT4OID}; /* Convert list of names to a name and namespace */ namespaceId = QualifiedNameGetCreationNamespace(stmt->conversion_name, &conversion_name); @@ -64,10 +64,11 @@ CreateConversionCommand(CreateConversionStmt *stmt) if (to_encoding < 0) elog(ERROR, "Invalid to encoding name: %s", to_encoding_name); - /* Check the existence of the conversion function. - * Function name could be a qualified name. + /* + * Check the existence of the conversion function. Function name could + * be a qualified name. */ - funcoid = LookupFuncName(func_name, sizeof(funcargs)/sizeof(Oid), funcargs); + funcoid = LookupFuncName(func_name, sizeof(funcargs) / sizeof(Oid), funcargs); if (!OidIsValid(funcoid)) elog(ERROR, "Function %s does not exist", NameListToString(func_name)); @@ -80,8 +81,11 @@ CreateConversionCommand(CreateConversionStmt *stmt) aclresult = pg_proc_aclcheck(funcoid, GetUserId(), ACL_EXECUTE); if (aclresult != ACLCHECK_OK) aclcheck_error(aclresult, get_namespace_name(funcnamespace)); - - /* All seem ok, go ahead (possible failure would be a duplicate conversion name) */ + + /* + * All seem ok, go ahead (possible failure would be a duplicate + * conversion name) + */ ConversionCreate(conversion_name, namespaceId, GetUserId(), for_encoding, to_encoding, funcoid, stmt->def); } @@ -93,7 +97,7 @@ void DropConversionCommand(List *name, DropBehavior behavior) { Oid namespaceId; - char *conversion_name; + char *conversion_name; AclResult aclresult; /* Convert list of names to a name and namespace */ @@ -104,9 +108,9 @@ DropConversionCommand(List *name, DropBehavior behavior) if (aclresult != ACLCHECK_OK) aclcheck_error(aclresult, get_namespace_name(namespaceId)); - /* Go ahead (possible failure would be: - * none existing conversion - * not ower of this conversion + /* + * Go ahead (possible failure would be: none existing conversion not + * ower of this conversion */ ConversionDrop(conversion_name, namespaceId, GetUserId(), behavior); } diff --git a/src/backend/commands/copy.c b/src/backend/commands/copy.c index c8463ac8f8..d9da44c465 100644 --- a/src/backend/commands/copy.c +++ b/src/backend/commands/copy.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.170 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/copy.c,v 1.171 2002/09/04 20:31:14 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,9 +53,9 @@ typedef enum CopyReadResult /* non-export function prototypes */ static void CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, - FILE *fp, char *delim, char *null_print); + FILE *fp, char *delim, char *null_print); static void CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, - FILE *fp, char *delim, char *null_print); + FILE *fp, char *delim, char *null_print); static Oid GetInputFunction(Oid type); static Oid GetTypeElement(Oid type); static char *CopyReadAttribute(FILE *fp, const char *delim, CopyReadResult *result); @@ -268,17 +268,17 @@ CopyDonePeek(FILE *fp, int c, bool pickup) void DoCopy(const CopyStmt *stmt) { - RangeVar *relation = stmt->relation; - char *filename = stmt->filename; - bool is_from = stmt->is_from; - bool pipe = (stmt->filename == NULL); - List *option; - List *attnamelist = stmt->attlist; - List *attnumlist; - bool binary = false; - bool oids = false; - char *delim = NULL; - char *null_print = NULL; + RangeVar *relation = stmt->relation; + char *filename = stmt->filename; + bool is_from = stmt->is_from; + bool pipe = (stmt->filename == NULL); + List *option; + List *attnamelist = stmt->attlist; + List *attnumlist; + bool binary = false; + bool oids = false; + char *delim = NULL; + char *null_print = NULL; FILE *fp; Relation rel; AclMode required_access = (is_from ? ACL_INSERT : ACL_SELECT); @@ -336,7 +336,7 @@ DoCopy(const CopyStmt *stmt) if (!null_print) null_print = "\\N"; - + /* * Open and lock the relation, using the appropriate lock type. */ @@ -512,8 +512,8 @@ DoCopy(const CopyStmt *stmt) * Copy from relation TO file. */ static void -CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, - FILE *fp, char *delim, char *null_print) +CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, + FILE *fp, char *delim, char *null_print) { HeapTuple tuple; TupleDesc tupDesc; @@ -537,24 +537,23 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, /* * Get info about the columns we need to process. * - * For binary copy we really only need isvarlena, but compute it - * all... + * For binary copy we really only need isvarlena, but compute it all... */ out_functions = (FmgrInfo *) palloc(num_phys_attrs * sizeof(FmgrInfo)); elements = (Oid *) palloc(num_phys_attrs * sizeof(Oid)); isvarlena = (bool *) palloc(num_phys_attrs * sizeof(bool)); foreach(cur, attnumlist) { - int attnum = lfirsti(cur); + int attnum = lfirsti(cur); Oid out_func_oid; - if (!getTypeOutputInfo(attr[attnum-1]->atttypid, - &out_func_oid, &elements[attnum-1], - &isvarlena[attnum-1])) + if (!getTypeOutputInfo(attr[attnum - 1]->atttypid, + &out_func_oid, &elements[attnum - 1], + &isvarlena[attnum - 1])) elog(ERROR, "COPY: couldn't lookup info for type %u", - attr[attnum-1]->atttypid); - fmgr_info(out_func_oid, &out_functions[attnum-1]); - if (binary && attr[attnum-1]->attlen == -2) + attr[attnum - 1]->atttypid); + fmgr_info(out_func_oid, &out_functions[attnum - 1]); + if (binary && attr[attnum - 1]->attlen == -2) elog(ERROR, "COPY BINARY: cstring not supported"); } @@ -597,7 +596,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, /* Send OID if wanted --- note fld_count doesn't include it */ if (oids) { - Oid oid = HeapTupleGetOid(tuple); + Oid oid = HeapTupleGetOid(tuple); fld_size = sizeof(Oid); CopySendData(&fld_size, sizeof(int16), fp); @@ -610,7 +609,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, if (oids) { string = DatumGetCString(DirectFunctionCall1(oidout, - ObjectIdGetDatum(HeapTupleGetOid(tuple)))); + ObjectIdGetDatum(HeapTupleGetOid(tuple)))); CopySendString(string, fp); pfree(string); need_delim = true; @@ -619,7 +618,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, foreach(cur, attnumlist) { - int attnum = lfirsti(cur); + int attnum = lfirsti(cur); Datum origvalue, value; bool isnull; @@ -653,25 +652,25 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, * (or for binary case, becase we must output untoasted * value). */ - if (isvarlena[attnum-1]) + if (isvarlena[attnum - 1]) value = PointerGetDatum(PG_DETOAST_DATUM(origvalue)); else value = origvalue; if (!binary) { - string = DatumGetCString(FunctionCall3(&out_functions[attnum-1], + string = DatumGetCString(FunctionCall3(&out_functions[attnum - 1], value, - ObjectIdGetDatum(elements[attnum-1]), - Int32GetDatum(attr[attnum-1]->atttypmod))); + ObjectIdGetDatum(elements[attnum - 1]), + Int32GetDatum(attr[attnum - 1]->atttypmod))); CopyAttributeOut(fp, string, delim); pfree(string); } else { - fld_size = attr[attnum-1]->attlen; + fld_size = attr[attnum - 1]->attlen; CopySendData(&fld_size, sizeof(int16), fp); - if (isvarlena[attnum-1]) + if (isvarlena[attnum - 1]) { /* varlena */ Assert(fld_size == -1); @@ -679,7 +678,7 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, VARSIZE(value), fp); } - else if (!attr[attnum-1]->attbyval) + else if (!attr[attnum - 1]->attbyval) { /* fixed-length pass-by-reference */ Assert(fld_size > 0); @@ -734,13 +733,15 @@ CopyTo(Relation rel, List *attnumlist, bool binary, bool oids, * Copy FROM file to relation. */ static void -CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, +CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, FILE *fp, char *delim, char *null_print) { HeapTuple tuple; TupleDesc tupDesc; Form_pg_attribute *attr; - AttrNumber num_phys_attrs, attr_count, num_defaults; + AttrNumber num_phys_attrs, + attr_count, + num_defaults; FmgrInfo *in_functions; Oid *elements; int i; @@ -755,8 +756,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, TupleTableSlot *slot; bool file_has_oids; int *defmap; - Node **defexprs; /* array of default att expressions */ - ExprContext *econtext; /* used for ExecEvalExpr for default atts */ + Node **defexprs; /* array of default att expressions */ + ExprContext *econtext; /* used for ExecEvalExpr for default atts */ MemoryContext oldcontext = CurrentMemoryContext; tupDesc = RelationGetDescr(rel); @@ -787,9 +788,9 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, ExecSetSlotDescriptor(slot, tupDesc, false); /* - * pick up the input function and default expression (if any) for - * each attribute in the relation. (We don't actually use the - * input function if it's a binary copy.) + * pick up the input function and default expression (if any) for each + * attribute in the relation. (We don't actually use the input + * function if it's a binary copy.) */ defmap = (int *) palloc(sizeof(int) * num_phys_attrs); defexprs = (Node **) palloc(sizeof(Node *) * num_phys_attrs); @@ -874,13 +875,13 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, while (!done) { - bool skip_tuple; - Oid loaded_oid = InvalidOid; + bool skip_tuple; + Oid loaded_oid = InvalidOid; CHECK_FOR_INTERRUPTS(); copy_lineno++; - + /* Reset the per-tuple exprcontext */ ResetPerTupleExprContext(estate); @@ -894,8 +895,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, if (!binary) { - CopyReadResult result = NORMAL_ATTR; - char *string; + CopyReadResult result = NORMAL_ATTR; + char *string; if (file_has_oids) { @@ -918,14 +919,14 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, elog(ERROR, "Invalid Oid"); } } - + /* * Loop to read the user attributes on the line. */ foreach(cur, attnumlist) { - int attnum = lfirsti(cur); - int m = attnum - 1; + int attnum = lfirsti(cur); + int m = attnum - 1; /* * If prior attr on this line was ended by newline or EOF, @@ -953,8 +954,8 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, { values[m] = FunctionCall3(&in_functions[m], CStringGetDatum(string), - ObjectIdGetDatum(elements[m]), - Int32GetDatum(attr[m]->atttypmod)); + ObjectIdGetDatum(elements[m]), + Int32GetDatum(attr[m]->atttypmod)); nulls[m] = ' '; } } @@ -1009,7 +1010,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, i = 0; foreach(cur, attnumlist) { - int attnum = lfirsti(cur); + int attnum = lfirsti(cur); i++; @@ -1018,9 +1019,9 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, elog(ERROR, "COPY BINARY: unexpected EOF"); if (fld_size == 0) continue; /* it's NULL; nulls[attnum-1] already set */ - if (fld_size != attr[attnum-1]->attlen) + if (fld_size != attr[attnum - 1]->attlen) elog(ERROR, "COPY BINARY: sizeof(field %d) is %d, expected %d", - i, (int) fld_size, (int) attr[attnum-1]->attlen); + i, (int) fld_size, (int) attr[attnum - 1]->attlen); if (fld_size == -1) { /* varlena field */ @@ -1039,9 +1040,9 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, fp); if (CopyGetEof(fp)) elog(ERROR, "COPY BINARY: unexpected EOF"); - values[attnum-1] = PointerGetDatum(varlena_ptr); + values[attnum - 1] = PointerGetDatum(varlena_ptr); } - else if (!attr[attnum-1]->attbyval) + else if (!attr[attnum - 1]->attbyval) { /* fixed-length pass-by-reference */ Pointer refval_ptr; @@ -1051,7 +1052,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, CopyGetData(refval_ptr, fld_size, fp); if (CopyGetEof(fp)) elog(ERROR, "COPY BINARY: unexpected EOF"); - values[attnum-1] = PointerGetDatum(refval_ptr); + values[attnum - 1] = PointerGetDatum(refval_ptr); } else { @@ -1059,29 +1060,28 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, Datum datumBuf; /* - * We need this horsing around because we don't - * know how shorter data values are aligned within - * a Datum. + * We need this horsing around because we don't know + * how shorter data values are aligned within a Datum. */ Assert(fld_size > 0 && fld_size <= sizeof(Datum)); CopyGetData(&datumBuf, fld_size, fp); if (CopyGetEof(fp)) elog(ERROR, "COPY BINARY: unexpected EOF"); - values[attnum-1] = fetch_att(&datumBuf, true, fld_size); + values[attnum - 1] = fetch_att(&datumBuf, true, fld_size); } - nulls[attnum-1] = ' '; + nulls[attnum - 1] = ' '; } } /* - * Now compute and insert any defaults available for the - * columns not provided by the input data. Anything not - * processed here or above will remain NULL. + * Now compute and insert any defaults available for the columns + * not provided by the input data. Anything not processed here or + * above will remain NULL. */ for (i = 0; i < num_defaults; i++) { - bool isnull; + bool isnull; values[defmap[i]] = ExecEvalExpr(defexprs[i], econtext, &isnull, NULL); @@ -1093,7 +1093,7 @@ CopyFrom(Relation rel, List *attnumlist, bool binary, bool oids, * And now we can form the input tuple. */ tuple = heap_formtuple(tupDesc, values, nulls); - + if (oids && file_has_oids) HeapTupleSetOid(tuple, loaded_oid); @@ -1464,14 +1464,14 @@ CopyAttributeOut(FILE *fp, char *server_string, char *delim) static List * CopyGetAttnums(Relation rel, List *attnamelist) { - List *attnums = NIL; + List *attnums = NIL; if (attnamelist == NIL) { /* Generate default column list */ - TupleDesc tupDesc = RelationGetDescr(rel); + TupleDesc tupDesc = RelationGetDescr(rel); Form_pg_attribute *attr = tupDesc->attrs; - int attr_count = tupDesc->natts; + int attr_count = tupDesc->natts; int i; for (i = 0; i < attr_count; i++) diff --git a/src/backend/commands/dbcommands.c b/src/backend/commands/dbcommands.c index f5bacf6b3c..addb6dcae4 100644 --- a/src/backend/commands/dbcommands.c +++ b/src/backend/commands/dbcommands.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.104 2002/09/03 22:17:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/dbcommands.c,v 1.105 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,14 +79,14 @@ createdb(const CreatedbStmt *stmt) int32 datdba; List *option; DefElem *downer = NULL; - DefElem *dpath = NULL; - DefElem *dtemplate = NULL; - DefElem *dencoding = NULL; + DefElem *dpath = NULL; + DefElem *dtemplate = NULL; + DefElem *dencoding = NULL; char *dbname = stmt->dbname; char *dbowner = NULL; char *dbpath = NULL; char *dbtemplate = NULL; - int encoding = -1; + int encoding = -1; /* Extract options from the statement node tree */ foreach(option, stmt->options) @@ -133,7 +133,7 @@ createdb(const CreatedbStmt *stmt) /* obtain sysid of proposed owner */ if (dbowner) - datdba = get_usesysid(dbowner); /* will elog if no such user */ + datdba = get_usesysid(dbowner); /* will elog if no such user */ else datdba = GetUserId(); @@ -185,7 +185,7 @@ createdb(const CreatedbStmt *stmt) */ if (!src_istemplate) { - if (!superuser() && GetUserId() != src_owner ) + if (!superuser() && GetUserId() != src_owner) elog(ERROR, "CREATE DATABASE: permission to copy \"%s\" denied", dbtemplate); } @@ -226,10 +226,10 @@ createdb(const CreatedbStmt *stmt) * database), and resolve alternate physical location if one is * specified. * - * If an alternate location is specified but is the same as the - * normal path, just drop the alternate-location spec (this seems - * friendlier than erroring out). We must test this case to avoid - * creating a circular symlink below. + * If an alternate location is specified but is the same as the normal + * path, just drop the alternate-location spec (this seems friendlier + * than erroring out). We must test this case to avoid creating a + * circular symlink below. */ nominal_loc = GetDatabasePath(dboid); alt_loc = resolve_alt_dbpath(dbpath, dboid); @@ -328,11 +328,12 @@ createdb(const CreatedbStmt *stmt) /* do not set datpath to null, GetRawDatabaseInfo won't cope */ new_record[Anum_pg_database_datpath - 1] = DirectFunctionCall1(textin, CStringGetDatum(dbpath ? dbpath : "")); + /* * We deliberately set datconfig and datacl to defaults (NULL), rather * than copying them from the template database. Copying datacl would - * be a bad idea when the owner is not the same as the template's owner. - * It's more debatable whether datconfig should be copied. + * be a bad idea when the owner is not the same as the template's + * owner. It's more debatable whether datconfig should be copied. */ new_record_nulls[Anum_pg_database_datconfig - 1] = 'n'; new_record_nulls[Anum_pg_database_datacl - 1] = 'n'; @@ -495,7 +496,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) HeapTuple tuple, newtuple; Relation rel; - ScanKeyData scankey; + ScanKeyData scankey; HeapScanDesc scan; Datum repl_val[Natts_pg_database]; char repl_null[Natts_pg_database]; @@ -512,25 +513,25 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) elog(ERROR, "database \"%s\" does not exist", stmt->dbname); if (!(superuser() - || ((Form_pg_database) GETSTRUCT(tuple))->datdba == GetUserId())) + || ((Form_pg_database) GETSTRUCT(tuple))->datdba == GetUserId())) elog(ERROR, "permission denied"); MemSet(repl_repl, ' ', sizeof(repl_repl)); - repl_repl[Anum_pg_database_datconfig-1] = 'r'; + repl_repl[Anum_pg_database_datconfig - 1] = 'r'; - if (strcmp(stmt->variable, "all")==0 && valuestr == NULL) + if (strcmp(stmt->variable, "all") == 0 && valuestr == NULL) { /* RESET ALL */ - repl_null[Anum_pg_database_datconfig-1] = 'n'; - repl_val[Anum_pg_database_datconfig-1] = (Datum) 0; + repl_null[Anum_pg_database_datconfig - 1] = 'n'; + repl_val[Anum_pg_database_datconfig - 1] = (Datum) 0; } else { - Datum datum; - bool isnull; - ArrayType *a; + Datum datum; + bool isnull; + ArrayType *a; - repl_null[Anum_pg_database_datconfig-1] = ' '; + repl_null[Anum_pg_database_datconfig - 1] = ' '; datum = heap_getattr(tuple, Anum_pg_database_datconfig, RelationGetDescr(rel), &isnull); @@ -542,7 +543,7 @@ AlterDatabaseSet(AlterDatabaseSetStmt *stmt) else a = GUCArrayDelete(a, stmt->variable); - repl_val[Anum_pg_database_datconfig-1] = PointerGetDatum(a); + repl_val[Anum_pg_database_datconfig - 1] = PointerGetDatum(a); } newtuple = heap_modifytuple(tuple, rel, repl_val, repl_null, repl_repl); diff --git a/src/backend/commands/define.c b/src/backend/commands/define.c index 02b730944b..09687818d8 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.79 2002/08/10 19:01:53 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/define.c,v 1.80 2002/09/04 20:31:15 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -132,10 +132,11 @@ defGetInt64(DefElem *def) case T_Integer: return (int64) intVal(def->arg); case T_Float: + /* * Values too large for int4 will be represented as Float - * constants by the lexer. Accept these if they are valid int8 - * strings. + * constants by the lexer. Accept these if they are valid + * int8 strings. */ return DatumGetInt64(DirectFunctionCall1(int8in, CStringGetDatum(strVal(def->arg)))); @@ -188,14 +189,14 @@ defGetTypeName(DefElem *def) case T_TypeName: return (TypeName *) def->arg; case T_String: - { - /* Allow quoted typename for backwards compatibility */ - TypeName *n = makeNode(TypeName); - - n->names = makeList1(def->arg); - n->typmod = -1; - return n; - } + { + /* Allow quoted typename for backwards compatibility */ + TypeName *n = makeNode(TypeName); + + n->names = makeList1(def->arg); + n->typmod = -1; + return n; + } default: elog(ERROR, "Define: argument of \"%s\" must be a type name", def->defname); diff --git a/src/backend/commands/explain.c b/src/backend/commands/explain.c index bf8b6fb27b..4edc718421 100644 --- a/src/backend/commands/explain.c +++ b/src/backend/commands/explain.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994-5, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.86 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/explain.c,v 1.87 2002/09/04 20:31:15 momjian Exp $ * */ @@ -41,18 +41,18 @@ typedef struct ExplainState static StringInfo Explain_PlanToString(Plan *plan, ExplainState *es); static void ExplainOneQuery(Query *query, ExplainStmt *stmt, - TupOutputState *tstate); + TupOutputState *tstate); static void explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, - int indent, ExplainState *es); + int indent, ExplainState *es); static void show_scan_qual(List *qual, bool is_or_qual, const char *qlabel, - int scanrelid, Plan *outer_plan, - StringInfo str, int indent, ExplainState *es); + int scanrelid, Plan *outer_plan, + StringInfo str, int indent, ExplainState *es); static void show_upper_qual(List *qual, const char *qlabel, - const char *outer_name, int outer_varno, Plan *outer_plan, - const char *inner_name, int inner_varno, Plan *inner_plan, - StringInfo str, int indent, ExplainState *es); + const char *outer_name, int outer_varno, Plan *outer_plan, + const char *inner_name, int inner_varno, Plan *inner_plan, + StringInfo str, int indent, ExplainState *es); static void show_sort_keys(List *tlist, int nkeys, const char *qlabel, - StringInfo str, int indent, ExplainState *es); + StringInfo str, int indent, ExplainState *es); static Node *make_ors_ands_explicit(List *orclauses); /* @@ -189,7 +189,7 @@ ExplainOneQuery(Query *query, ExplainStmt *stmt, TupOutputState *tstate) do_text_output_multiline(tstate, f); pfree(f); if (es->printCost) - do_text_output_oneline(tstate, ""); /* separator line */ + do_text_output_oneline(tstate, ""); /* separator line */ } } @@ -325,7 +325,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, relation = index_open(lfirsti(l)); appendStringInfo(str, "%s%s", (++i > 1) ? ", " : "", - quote_identifier(RelationGetRelationName(relation))); + quote_identifier(RelationGetRelationName(relation))); index_close(relation); } /* FALL THRU */ @@ -335,7 +335,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, { RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid, es->rtable); - char *relname; + char *relname; /* Assume it's on a real relation */ Assert(rte->rtekind == RTE_RELATION); @@ -347,7 +347,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, quote_identifier(relname)); if (strcmp(rte->eref->aliasname, relname) != 0) appendStringInfo(str, " %s", - quote_identifier(rte->eref->aliasname)); + quote_identifier(rte->eref->aliasname)); } break; case T_SubqueryScan: @@ -365,10 +365,10 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, { RangeTblEntry *rte = rt_fetch(((Scan *) plan)->scanrelid, es->rtable); - Expr *expr; - Func *funcnode; - Oid funcid; - char *proname; + Expr *expr; + Func *funcnode; + Oid funcid; + char *proname; /* Assert it's on a RangeFunction */ Assert(rte->rtekind == RTE_FUNCTION); @@ -384,7 +384,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, quote_identifier(proname)); if (strcmp(rte->eref->aliasname, proname) != 0) appendStringInfo(str, " %s", - quote_identifier(rte->eref->aliasname)); + quote_identifier(rte->eref->aliasname)); } break; default: @@ -482,7 +482,7 @@ explain_outNode(StringInfo str, Plan *plan, Plan *outer_plan, case T_SubqueryScan: show_upper_qual(plan->qual, "Filter", - "subplan", 1, ((SubqueryScan *) plan)->subplan, + "subplan", 1, ((SubqueryScan *) plan)->subplan, "", 0, NULL, str, indent, es); break; @@ -662,14 +662,14 @@ show_scan_qual(List *qual, bool is_or_qual, const char *qlabel, /* * If we have an outer plan that is referenced by the qual, add it to - * the deparse context. If not, don't (so that we don't force prefixes - * unnecessarily). + * the deparse context. If not, don't (so that we don't force + * prefixes unnecessarily). */ if (outer_plan) { if (intMember(OUTER, pull_varnos(node))) outercontext = deparse_context_for_subplan("outer", - outer_plan->targetlist, + outer_plan->targetlist, es->rtable); else outercontext = NULL; @@ -760,10 +760,11 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel, /* * In this routine we expect that the plan node's tlist has not been - * processed by set_plan_references(). Normally, any Vars will contain - * valid varnos referencing the actual rtable. But we might instead be - * looking at a dummy tlist generated by prepunion.c; if there are - * Vars with zero varno, use the tlist itself to determine their names. + * processed by set_plan_references(). Normally, any Vars will + * contain valid varnos referencing the actual rtable. But we might + * instead be looking at a dummy tlist generated by prepunion.c; if + * there are Vars with zero varno, use the tlist itself to determine + * their names. */ if (intMember(0, pull_varnos((Node *) tlist))) { @@ -811,7 +812,7 @@ show_sort_keys(List *tlist, int nkeys, const char *qlabel, } /* - * Indexscan qual lists have an implicit OR-of-ANDs structure. Make it + * Indexscan qual lists have an implicit OR-of-ANDs structure. Make it * explicit so deparsing works properly. */ static Node * @@ -823,13 +824,11 @@ make_ors_ands_explicit(List *orclauses) return (Node *) make_ands_explicit(lfirst(orclauses)); else { - List *args = NIL; - List *orptr; + List *args = NIL; + List *orptr; foreach(orptr, orclauses) - { args = lappend(args, make_ands_explicit(lfirst(orptr))); - } return (Node *) make_orclause(args); } diff --git a/src/backend/commands/functioncmds.c b/src/backend/commands/functioncmds.c index 6d6ad94a4e..47ebe0d761 100644 --- a/src/backend/commands/functioncmds.c +++ b/src/backend/commands/functioncmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.18 2002/08/22 00:01:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/functioncmds.c,v 1.19 2002/09/04 20:31:15 momjian Exp $ * * DESCRIPTION * These routines take the parse tree and pick out the @@ -61,7 +61,7 @@ * allow a shell type to be used, or even created if the specified return type * doesn't exist yet. (Without this, there's no way to define the I/O procs * for a new type.) But SQL function creation won't cope, so error out if - * the target language is SQL. (We do this here, not in the SQL-function + * the target language is SQL. (We do this here, not in the SQL-function * validator, so as not to produce a WARNING and then an ERROR for the same * condition.) */ @@ -69,7 +69,7 @@ static void compute_return_type(TypeName *returnType, Oid languageOid, Oid *prorettype_p, bool *returnsSet_p) { - Oid rettype; + Oid rettype; rettype = LookupTypeName(returnType); @@ -87,7 +87,7 @@ compute_return_type(TypeName *returnType, Oid languageOid, } else { - char *typnam = TypeNameToString(returnType); + char *typnam = TypeNameToString(returnType); Oid namespaceId; AclResult aclresult; char *typname; @@ -184,41 +184,41 @@ compute_attributes_sql_style(const List *options, bool *security_definer) { const List *option; - DefElem *as_item = NULL; - DefElem *language_item = NULL; - DefElem *volatility_item = NULL; - DefElem *strict_item = NULL; - DefElem *security_item = NULL; + DefElem *as_item = NULL; + DefElem *language_item = NULL; + DefElem *volatility_item = NULL; + DefElem *strict_item = NULL; + DefElem *security_item = NULL; foreach(option, options) { DefElem *defel = (DefElem *) lfirst(option); - if (strcmp(defel->defname, "as")==0) + if (strcmp(defel->defname, "as") == 0) { if (as_item) elog(ERROR, "conflicting or redundant options"); as_item = defel; } - else if (strcmp(defel->defname, "language")==0) + else if (strcmp(defel->defname, "language") == 0) { if (language_item) elog(ERROR, "conflicting or redundant options"); language_item = defel; } - else if (strcmp(defel->defname, "volatility")==0) + else if (strcmp(defel->defname, "volatility") == 0) { if (volatility_item) elog(ERROR, "conflicting or redundant options"); volatility_item = defel; } - else if (strcmp(defel->defname, "strict")==0) + else if (strcmp(defel->defname, "strict") == 0) { if (strict_item) elog(ERROR, "conflicting or redundant options"); strict_item = defel; } - else if (strcmp(defel->defname, "security")==0) + else if (strcmp(defel->defname, "security") == 0) { if (security_item) elog(ERROR, "conflicting or redundant options"); @@ -229,7 +229,7 @@ compute_attributes_sql_style(const List *options, } if (as_item) - *as = (List *)as_item->arg; + *as = (List *) as_item->arg; else elog(ERROR, "no function body specified"); @@ -240,11 +240,11 @@ compute_attributes_sql_style(const List *options, if (volatility_item) { - if (strcmp(strVal(volatility_item->arg), "immutable")==0) + if (strcmp(strVal(volatility_item->arg), "immutable") == 0) *volatility_p = PROVOLATILE_IMMUTABLE; - else if (strcmp(strVal(volatility_item->arg), "stable")==0) + else if (strcmp(strVal(volatility_item->arg), "stable") == 0) *volatility_p = PROVOLATILE_STABLE; - else if (strcmp(strVal(volatility_item->arg), "volatile")==0) + else if (strcmp(strVal(volatility_item->arg), "volatile") == 0) *volatility_p = PROVOLATILE_VOLATILE; else elog(ERROR, "invalid volatility"); @@ -386,7 +386,7 @@ CreateFunction(CreateFunctionStmt *stmt) /* override attributes from explicit list */ compute_attributes_sql_style(stmt->options, - &as_clause, &language, &volatility, &isStrict, &security); + &as_clause, &language, &volatility, &isStrict, &security); /* Convert language name to canonical case */ case_translate_language_name(language, languageName); @@ -439,13 +439,12 @@ CreateFunction(CreateFunctionStmt *stmt) if (languageOid == INTERNALlanguageId) { /* - * In PostgreSQL versions before 6.5, the SQL name of the - * created function could not be different from the internal - * name, and "prosrc" wasn't used. So there is code out there - * that does CREATE FUNCTION xyz AS '' LANGUAGE 'internal'. - * To preserve some modicum of backwards compatibility, accept - * an empty "prosrc" value as meaning the supplied SQL - * function name. + * In PostgreSQL versions before 6.5, the SQL name of the created + * function could not be different from the internal name, and + * "prosrc" wasn't used. So there is code out there that does + * CREATE FUNCTION xyz AS '' LANGUAGE 'internal'. To preserve some + * modicum of backwards compatibility, accept an empty "prosrc" + * value as meaning the supplied SQL function name. */ if (strlen(prosrc_str) == 0) prosrc_str = funcname; @@ -488,7 +487,7 @@ void RemoveFunction(RemoveFuncStmt *stmt) { List *functionName = stmt->funcname; - List *argTypes = stmt->args; /* list of TypeName nodes */ + List *argTypes = stmt->args; /* list of TypeName nodes */ Oid funcOid; HeapTuple tup; ObjectAddress object; @@ -496,13 +495,13 @@ RemoveFunction(RemoveFuncStmt *stmt) /* * Find the function, do permissions and validity checks */ - funcOid = LookupFuncNameTypeNames(functionName, argTypes, + funcOid = LookupFuncNameTypeNames(functionName, argTypes, "RemoveFunction"); tup = SearchSysCache(PROCOID, ObjectIdGetDatum(funcOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveFunction: couldn't find tuple for function %s", NameListToString(functionName)); @@ -557,7 +556,7 @@ RemoveFunctionById(Oid funcOid) tup = SearchSysCache(PROCOID, ObjectIdGetDatum(funcOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveFunctionById: couldn't find tuple for function %u", funcOid); @@ -579,7 +578,7 @@ RemoveFunctionById(Oid funcOid) tup = SearchSysCache(AGGFNOID, ObjectIdGetDatum(funcOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveFunctionById: couldn't find pg_aggregate tuple for %u", funcOid); @@ -611,7 +610,7 @@ CreateCast(CreateCastStmt *stmt) int i; ObjectAddress myself, - referenced; + referenced; sourcetypeid = LookupTypeName(stmt->sourcetype); if (!OidIsValid(sourcetypeid)) @@ -693,10 +692,10 @@ CreateCast(CreateCastStmt *stmt) } /* ready to go */ - values[Anum_pg_cast_castsource-1] = ObjectIdGetDatum(sourcetypeid); - values[Anum_pg_cast_casttarget-1] = ObjectIdGetDatum(targettypeid); - values[Anum_pg_cast_castfunc-1] = ObjectIdGetDatum(funcid); - values[Anum_pg_cast_castimplicit-1] = BoolGetDatum(stmt->implicit); + values[Anum_pg_cast_castsource - 1] = ObjectIdGetDatum(sourcetypeid); + values[Anum_pg_cast_casttarget - 1] = ObjectIdGetDatum(targettypeid); + values[Anum_pg_cast_castfunc - 1] = ObjectIdGetDatum(funcid); + values[Anum_pg_cast_castimplicit - 1] = BoolGetDatum(stmt->implicit); for (i = 0; i < Natts_pg_cast; ++i) nulls[i] = ' '; @@ -760,9 +759,9 @@ DropCast(DropCastStmt *stmt) TypeNameToString(stmt->targettype)); tuple = SearchSysCache(CASTSOURCETARGET, - ObjectIdGetDatum(sourcetypeid), - ObjectIdGetDatum(targettypeid), - 0, 0); + ObjectIdGetDatum(sourcetypeid), + ObjectIdGetDatum(targettypeid), + 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "cast from type %s to type %s does not exist", TypeNameToString(stmt->sourcetype), diff --git a/src/backend/commands/indexcmds.c b/src/backend/commands/indexcmds.c index b951fccb98..6f0c8438a8 100644 --- a/src/backend/commands/indexcmds.c +++ b/src/backend/commands/indexcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.86 2002/08/30 22:18:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/indexcmds.c,v 1.87 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,9 +117,9 @@ DefineIndex(RangeVar *heapRelation, /* * Verify we (still) have CREATE rights in the rel's namespace. - * (Presumably we did when the rel was created, but maybe not anymore.) - * Skip check if bootstrapping, since permissions machinery may not - * be working yet. + * (Presumably we did when the rel was created, but maybe not + * anymore.) Skip check if bootstrapping, since permissions machinery + * may not be working yet. */ if (!IsBootstrapProcessingMode()) { @@ -254,8 +254,8 @@ CheckPredicate(List *predList, List *rangeTable, Oid baseRelOid) elog(ERROR, "Cannot use aggregate in index predicate"); /* - * A predicate using mutable functions is probably wrong, for the - * same reasons that we don't allow a functional index to use one. + * A predicate using mutable functions is probably wrong, for the same + * reasons that we don't allow a functional index to use one. */ if (contain_mutable_functions((Node *) predList)) elog(ERROR, "Functions in index predicate must be marked isImmutable"); @@ -432,7 +432,7 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType, if (schemaname) { /* Look in specific schema only */ - Oid namespaceId; + Oid namespaceId; namespaceId = LookupExplicitNamespace(schemaname); tuple = SearchSysCache(CLAAMNAMENSP, @@ -458,15 +458,15 @@ GetAttrOpClass(IndexElem *attribute, Oid attrType, NameListToString(attribute->opclass), accessMethodName); /* - * Verify that the index operator class accepts this - * datatype. Note we will accept binary compatibility. + * Verify that the index operator class accepts this datatype. Note + * we will accept binary compatibility. */ opClassId = HeapTupleGetOid(tuple); opInputType = ((Form_pg_opclass) GETSTRUCT(tuple))->opcintype; if (!IsBinaryCompatible(attrType, opInputType)) elog(ERROR, "operator class \"%s\" does not accept data type %s", - NameListToString(attribute->opclass), format_type_be(attrType)); + NameListToString(attribute->opclass), format_type_be(attrType)); ReleaseSysCache(tuple); @@ -547,7 +547,7 @@ RemoveIndex(RangeVar *relation, DropBehavior behavior) if (((Form_pg_class) GETSTRUCT(tuple))->relkind != RELKIND_INDEX) elog(ERROR, "relation \"%s\" is of type \"%c\"", - relation->relname, ((Form_pg_class) GETSTRUCT(tuple))->relkind); + relation->relname, ((Form_pg_class) GETSTRUCT(tuple))->relkind); ReleaseSysCache(tuple); @@ -704,7 +704,7 @@ ReindexDatabase(const char *dbname, bool force, bool all) relcnt = relalc = 0; while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - char relkind; + char relkind; if (!all) { diff --git a/src/backend/commands/lockcmds.c b/src/backend/commands/lockcmds.c index fe2295cef0..c2bb202c9c 100644 --- a/src/backend/commands/lockcmds.c +++ b/src/backend/commands/lockcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/lockcmds.c,v 1.3 2002/06/20 20:29:27 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/lockcmds.c,v 1.4 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,8 +43,8 @@ LockTableCommand(LockStmt *lockstmt) Relation rel; /* - * We don't want to open the relation until we've checked privilege. - * So, manually get the relation OID. + * We don't want to open the relation until we've checked + * privilege. So, manually get the relation OID. */ reloid = RangeVarGetRelid(relation, false); diff --git a/src/backend/commands/opclasscmds.c b/src/backend/commands/opclasscmds.c index a0430a8786..277394626a 100644 --- a/src/backend/commands/opclasscmds.c +++ b/src/backend/commands/opclasscmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.4 2002/08/22 00:01:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/opclasscmds.c,v 1.5 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ static void storeOperators(Oid opclassoid, int numOperators, - Oid *operators, bool *recheck); + Oid *operators, bool *recheck); static void storeProcedures(Oid opclassoid, int numProcs, Oid *procedures); @@ -68,8 +68,8 @@ DefineOpClass(CreateOpClassStmt *stmt) AclResult aclresult; NameData opcName; int i; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* Convert list of names to a name and namespace */ namespaceoid = QualifiedNameGetCreationNamespace(stmt->opclassname, @@ -107,9 +107,9 @@ DefineOpClass(CreateOpClassStmt *stmt) storageoid = InvalidOid; /* - * Create work arrays to hold info about operators and procedures. - * We do this mainly so that we can detect duplicate strategy - * numbers and support-proc numbers. + * Create work arrays to hold info about operators and procedures. We + * do this mainly so that we can detect duplicate strategy numbers and + * support-proc numbers. */ operators = (Oid *) palloc(sizeof(Oid) * numOperators); MemSet(operators, 0, sizeof(Oid) * numOperators); @@ -141,11 +141,11 @@ DefineOpClass(CreateOpClassStmt *stmt) item->number); if (item->args != NIL) { - TypeName *typeName1 = (TypeName *) lfirst(item->args); - TypeName *typeName2 = (TypeName *) lsecond(item->args); + TypeName *typeName1 = (TypeName *) lfirst(item->args); + TypeName *typeName2 = (TypeName *) lsecond(item->args); operOid = LookupOperNameTypeNames(item->name, - typeName1, typeName2, + typeName1, typeName2, "DefineOpClass"); /* No need to check for error */ } @@ -221,8 +221,8 @@ DefineOpClass(CreateOpClassStmt *stmt) rel = heap_openr(OperatorClassRelationName, RowExclusiveLock); /* - * Make sure there is no existing opclass of this name (this is - * just to give a more friendly error message than "duplicate key"). + * Make sure there is no existing opclass of this name (this is just + * to give a more friendly error message than "duplicate key"). */ if (SearchSysCacheExists(CLAAMNAMENSP, ObjectIdGetDatum(amoid), @@ -233,12 +233,12 @@ DefineOpClass(CreateOpClassStmt *stmt) opcname, stmt->amname); /* - * If we are creating a default opclass, check there isn't one already. - * (XXX should we restrict this test to visible opclasses?) + * If we are creating a default opclass, check there isn't one + * already. (XXX should we restrict this test to visible opclasses?) */ if (stmt->isDefault) { - ScanKeyData skey[1]; + ScanKeyData skey[1]; SysScanDesc scan; ScanKeyEntryInitialize(&skey[0], 0x0, @@ -276,11 +276,11 @@ DefineOpClass(CreateOpClassStmt *stmt) values[i++] = ObjectIdGetDatum(amoid); /* opcamid */ namestrcpy(&opcName, opcname); values[i++] = NameGetDatum(&opcName); /* opcname */ - values[i++] = ObjectIdGetDatum(namespaceoid); /* opcnamespace */ + values[i++] = ObjectIdGetDatum(namespaceoid); /* opcnamespace */ values[i++] = Int32GetDatum(GetUserId()); /* opcowner */ values[i++] = ObjectIdGetDatum(typeoid); /* opcintype */ - values[i++] = BoolGetDatum(stmt->isDefault); /* opcdefault */ - values[i++] = ObjectIdGetDatum(storageoid); /* opckeytype */ + values[i++] = BoolGetDatum(stmt->isDefault); /* opcdefault */ + values[i++] = ObjectIdGetDatum(storageoid); /* opckeytype */ tup = heap_formtuple(rel->rd_att, values, nulls); @@ -291,8 +291,8 @@ DefineOpClass(CreateOpClassStmt *stmt) heap_freetuple(tup); /* - * Now add tuples to pg_amop and pg_amproc tying in the - * operators and functions. + * Now add tuples to pg_amop and pg_amproc tying in the operators and + * functions. */ storeOperators(opclassoid, numOperators, operators, recheck); storeProcedures(opclassoid, numProcs, procedures); @@ -358,11 +358,12 @@ static void storeOperators(Oid opclassoid, int numOperators, Oid *operators, bool *recheck) { - Relation rel; - Datum values[Natts_pg_amop]; - char nulls[Natts_pg_amop]; - HeapTuple tup; - int i, j; + Relation rel; + Datum values[Natts_pg_amop]; + char nulls[Natts_pg_amop]; + HeapTuple tup; + int i, + j; rel = heap_openr(AccessMethodOperatorRelationName, RowExclusiveLock); @@ -378,9 +379,9 @@ storeOperators(Oid opclassoid, int numOperators, } i = 0; - values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */ - values[i++] = Int16GetDatum(j + 1); /* amopstrategy */ - values[i++] = BoolGetDatum(recheck[j]); /* amopreqcheck */ + values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */ + values[i++] = Int16GetDatum(j + 1); /* amopstrategy */ + values[i++] = BoolGetDatum(recheck[j]); /* amopreqcheck */ values[i++] = ObjectIdGetDatum(operators[j]); /* amopopr */ tup = heap_formtuple(rel->rd_att, values, nulls); @@ -401,11 +402,12 @@ storeOperators(Oid opclassoid, int numOperators, static void storeProcedures(Oid opclassoid, int numProcs, Oid *procedures) { - Relation rel; - Datum values[Natts_pg_amproc]; - char nulls[Natts_pg_amproc]; - HeapTuple tup; - int i, j; + Relation rel; + Datum values[Natts_pg_amproc]; + char nulls[Natts_pg_amproc]; + HeapTuple tup; + int i, + j; rel = heap_openr(AccessMethodProcedureRelationName, RowExclusiveLock); @@ -421,9 +423,9 @@ storeProcedures(Oid opclassoid, int numProcs, Oid *procedures) } i = 0; - values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */ - values[i++] = Int16GetDatum(j + 1); /* amprocnum */ - values[i++] = ObjectIdGetDatum(procedures[j]); /* amproc */ + values[i++] = ObjectIdGetDatum(opclassoid); /* amopclaid */ + values[i++] = Int16GetDatum(j + 1); /* amprocnum */ + values[i++] = ObjectIdGetDatum(procedures[j]); /* amproc */ tup = heap_formtuple(rel->rd_att, values, nulls); @@ -445,14 +447,15 @@ storeProcedures(Oid opclassoid, int numProcs, Oid *procedures) void RemoveOpClass(RemoveOpClassStmt *stmt) { - Oid amID, opcID; + Oid amID, + opcID; char *schemaname; char *opcname; HeapTuple tuple; ObjectAddress object; /* - * Get the access method's OID. + * Get the access method's OID. */ amID = GetSysCacheOid(AMNAME, CStringGetDatum(stmt->amname), @@ -471,7 +474,7 @@ RemoveOpClass(RemoveOpClassStmt *stmt) if (schemaname) { /* Look in specific schema only */ - Oid namespaceId; + Oid namespaceId; namespaceId = LookupExplicitNamespace(schemaname); tuple = SearchSysCache(CLAAMNAMENSP, @@ -523,10 +526,10 @@ RemoveOpClass(RemoveOpClassStmt *stmt) void RemoveOpClassById(Oid opclassOid) { - Relation rel; - HeapTuple tup; - ScanKeyData skey[1]; - SysScanDesc scan; + Relation rel; + HeapTuple tup; + ScanKeyData skey[1]; + SysScanDesc scan; /* * First remove the pg_opclass entry itself. @@ -536,7 +539,7 @@ RemoveOpClassById(Oid opclassOid) tup = SearchSysCache(CLAOID, ObjectIdGetDatum(opclassOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveOpClassById: couldn't find pg_class entry %u", opclassOid); @@ -559,9 +562,7 @@ RemoveOpClassById(Oid opclassOid) SnapshotNow, 1, skey); while (HeapTupleIsValid(tup = systable_getnext(scan))) - { simple_heap_delete(rel, &tup->t_self); - } systable_endscan(scan); heap_close(rel, RowExclusiveLock); @@ -579,9 +580,7 @@ RemoveOpClassById(Oid opclassOid) SnapshotNow, 1, skey); while (HeapTupleIsValid(tup = systable_getnext(scan))) - { simple_heap_delete(rel, &tup->t_self); - } systable_endscan(scan); heap_close(rel, RowExclusiveLock); diff --git a/src/backend/commands/operatorcmds.c b/src/backend/commands/operatorcmds.c index 4d91ce48bf..bb82e0df56 100644 --- a/src/backend/commands/operatorcmds.c +++ b/src/backend/commands/operatorcmds.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.6 2002/07/24 19:11:09 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/operatorcmds.c,v 1.7 2002/09/04 20:31:15 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -62,7 +62,7 @@ DefineOperator(List *names, List *parameters) char *oprName; Oid oprNamespace; AclResult aclresult; - bool canHash = false; /* operator hashes */ + bool canHash = false; /* operator hashes */ bool canMerge = false; /* operator merges */ List *functionName = NIL; /* function for operator */ TypeName *typeName1 = NULL; /* first type name */ @@ -74,7 +74,7 @@ DefineOperator(List *names, List *parameters) List *negatorName = NIL; /* optional negator operator name */ List *restrictionName = NIL; /* optional restrict. sel. * procedure */ - List *joinName = NIL; /* optional join sel. procedure */ + List *joinName = NIL; /* optional join sel. procedure */ List *leftSortName = NIL; /* optional left sort operator */ List *rightSortName = NIL; /* optional right sort operator */ List *ltCompareName = NIL; /* optional < compare operator */ @@ -173,7 +173,7 @@ DefineOperator(List *names, List *parameters) * now have OperatorCreate do all the work.. */ OperatorCreate(oprName, /* operator name */ - oprNamespace, /* namespace */ + oprNamespace, /* namespace */ typeId1, /* left type id */ typeId2, /* right type id */ functionName, /* function for operator */ @@ -185,9 +185,9 @@ DefineOperator(List *names, List *parameters) joinName, /* optional join sel. procedure name */ canHash, /* operator hashes */ leftSortName, /* optional left sort operator */ - rightSortName, /* optional right sort operator */ - ltCompareName, /* optional < comparison op */ - gtCompareName); /* optional < comparison op */ + rightSortName, /* optional right sort operator */ + ltCompareName, /* optional < comparison op */ + gtCompareName); /* optional < comparison op */ } @@ -198,9 +198,9 @@ DefineOperator(List *names, List *parameters) void RemoveOperator(RemoveOperStmt *stmt) { - List *operatorName = stmt->opname; - TypeName *typeName1 = (TypeName *) lfirst(stmt->args); - TypeName *typeName2 = (TypeName *) lsecond(stmt->args); + List *operatorName = stmt->opname; + TypeName *typeName1 = (TypeName *) lfirst(stmt->args); + TypeName *typeName2 = (TypeName *) lsecond(stmt->args); Oid operOid; HeapTuple tup; ObjectAddress object; @@ -211,7 +211,7 @@ RemoveOperator(RemoveOperStmt *stmt) tup = SearchSysCache(OPEROID, ObjectIdGetDatum(operOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveOperator: failed to find tuple for operator '%s'", NameListToString(operatorName)); @@ -247,7 +247,7 @@ RemoveOperatorById(Oid operOid) tup = SearchSysCache(OPEROID, ObjectIdGetDatum(operOid), 0, 0, 0); - if (!HeapTupleIsValid(tup)) /* should not happen */ + if (!HeapTupleIsValid(tup)) /* should not happen */ elog(ERROR, "RemoveOperatorById: failed to find tuple for operator %u", operOid); diff --git a/src/backend/commands/portalcmds.c b/src/backend/commands/portalcmds.c index 754ea46246..0454b21b11 100644 --- a/src/backend/commands/portalcmds.c +++ b/src/backend/commands/portalcmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.2 2002/05/21 22:05:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/portalcmds.c,v 1.3 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -134,12 +134,12 @@ PerformPortalFetch(char *name, * Determine which direction to go in, and check to see if we're * already at the end of the available tuples in that direction. If * so, set the direction to NoMovement to avoid trying to fetch any - * tuples. (This check exists because not all plan node types - * are robust about being called again if they've already returned - * NULL once.) Then call the executor (we must not skip this, because - * the destination needs to see a setup and shutdown even if no tuples - * are available). Finally, update the atStart/atEnd state depending - * on the number of tuples that were retrieved. + * tuples. (This check exists because not all plan node types are + * robust about being called again if they've already returned NULL + * once.) Then call the executor (we must not skip this, because the + * destination needs to see a setup and shutdown even if no tuples are + * available). Finally, update the atStart/atEnd state depending on + * the number of tuples that were retrieved. */ if (forward) { @@ -151,9 +151,9 @@ PerformPortalFetch(char *name, ExecutorRun(queryDesc, estate, direction, (long) count); if (estate->es_processed > 0) - portal->atStart = false; /* OK to back up now */ + portal->atStart = false; /* OK to back up now */ if (count <= 0 || (int) estate->es_processed < count) - portal->atEnd = true; /* we retrieved 'em all */ + portal->atEnd = true; /* we retrieved 'em all */ } else { @@ -165,9 +165,9 @@ PerformPortalFetch(char *name, ExecutorRun(queryDesc, estate, direction, (long) count); if (estate->es_processed > 0) - portal->atEnd = false; /* OK to go forward now */ + portal->atEnd = false; /* OK to go forward now */ if (count <= 0 || (int) estate->es_processed < count) - portal->atStart = true; /* we retrieved 'em all */ + portal->atStart = true; /* we retrieved 'em all */ } /* Return command status if wanted */ diff --git a/src/backend/commands/prepare.c b/src/backend/commands/prepare.c index 9dbe214616..cf869ed75e 100644 --- a/src/backend/commands/prepare.c +++ b/src/backend/commands/prepare.c @@ -6,7 +6,7 @@ * Copyright (c) 2002, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.1 2002/08/27 04:55:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/prepare.c,v 1.2 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ typedef struct List *query_list; /* list of queries */ List *plan_list; /* list of plans */ List *argtype_list; /* list of parameter type OIDs */ - MemoryContext context; /* context containing this query */ + MemoryContext context; /* context containing this query */ } QueryHashEntry; /* @@ -47,7 +47,7 @@ static HTAB *prepared_queries = NULL; static void InitQueryHashTable(void); static void StoreQuery(const char *stmt_name, List *query_list, - List *plan_list, List *argtype_list); + List *plan_list, List *argtype_list); static QueryHashEntry *FetchQuery(const char *plan_name); static void RunQuery(QueryDesc *qdesc, EState *state); @@ -58,9 +58,9 @@ static void RunQuery(QueryDesc *qdesc, EState *state); void PrepareQuery(PrepareStmt *stmt) { - List *plan_list = NIL; - List *query_list, - *query_list_item; + List *plan_list = NIL; + List *query_list, + *query_list_item; if (!stmt->name) elog(ERROR, "No statement name given"); @@ -73,8 +73,8 @@ PrepareQuery(PrepareStmt *stmt) foreach(query_list_item, query_list) { - Query *query = (Query *) lfirst(query_list_item); - Plan *plan; + Query *query = (Query *) lfirst(query_list_item); + Plan *plan; /* We can't generate plans for utility statements. */ if (query->commandType == CMD_UTILITY) @@ -97,10 +97,10 @@ PrepareQuery(PrepareStmt *stmt) void ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) { - QueryHashEntry *entry; - List *l, - *query_list, - *plan_list; + QueryHashEntry *entry; + List *l, + *query_list, + *plan_list; ParamListInfo paramLI = NULL; /* Look it up in the hash table */ @@ -115,8 +115,8 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) /* Evaluate parameters, if any */ if (entry->argtype_list != NIL) { - int nargs = length(entry->argtype_list); - int i = 0; + int nargs = length(entry->argtype_list); + int i = 0; ExprContext *econtext = MakeExprContext(NULL, CurrentMemoryContext); /* Parser should have caught this error, but check */ @@ -126,10 +126,10 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) paramLI = (ParamListInfo) palloc((nargs + 1) * sizeof(ParamListInfoData)); MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData)); - foreach (l, stmt->params) + foreach(l, stmt->params) { - Node *n = lfirst(l); - bool isNull; + Node *n = lfirst(l); + bool isNull; paramLI[i].value = ExecEvalExprSwitchContext(n, econtext, @@ -147,9 +147,9 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) /* Execute each query */ foreach(l, query_list) { - Query *query = lfirst(l); - Plan *plan = lfirst(plan_list); - bool is_last_query; + Query *query = lfirst(l); + Plan *plan = lfirst(plan_list); + bool is_last_query; plan_list = lnext(plan_list); is_last_query = (plan_list == NIL); @@ -158,8 +158,8 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) ProcessUtility(query->utilityStmt, outputDest, NULL); else { - QueryDesc *qdesc; - EState *state; + QueryDesc *qdesc; + EState *state; if (Show_executor_stats) ResetUsage(); @@ -185,11 +185,11 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) } /* - * If we're processing multiple queries, we need to increment - * the command counter between them. For the last query, - * there's no need to do this, it's done automatically. + * If we're processing multiple queries, we need to increment the + * command counter between them. For the last query, there's no + * need to do this, it's done automatically. */ - if (! is_last_query) + if (!is_last_query) CommandCounterIncrement(); } @@ -202,7 +202,7 @@ ExecuteQuery(ExecuteStmt *stmt, CommandDest outputDest) static void InitQueryHashTable(void) { - HASHCTL hash_ctl; + HASHCTL hash_ctl; MemSet(&hash_ctl, 0, sizeof(hash_ctl)); @@ -229,9 +229,9 @@ StoreQuery(const char *stmt_name, List *query_list, List *plan_list, { QueryHashEntry *entry; MemoryContext oldcxt, - entrycxt; - char key[HASH_KEY_LEN]; - bool found; + entrycxt; + char key[HASH_KEY_LEN]; + bool found; /* Initialize the hash table, if necessary */ if (!prepared_queries) @@ -258,10 +258,10 @@ StoreQuery(const char *stmt_name, List *query_list, List *plan_list, oldcxt = MemoryContextSwitchTo(entrycxt); /* - * We need to copy the data so that it is stored in the correct - * memory context. Do this before making hashtable entry, so that - * an out-of-memory failure only wastes memory and doesn't leave us - * with an incomplete (ie corrupt) hashtable entry. + * We need to copy the data so that it is stored in the correct memory + * context. Do this before making hashtable entry, so that an + * out-of-memory failure only wastes memory and doesn't leave us with + * an incomplete (ie corrupt) hashtable entry. */ query_list = (List *) copyObject(query_list); plan_list = (List *) copyObject(plan_list); @@ -293,7 +293,7 @@ StoreQuery(const char *stmt_name, List *query_list, List *plan_list, static QueryHashEntry * FetchQuery(const char *plan_name) { - char key[HASH_KEY_LEN]; + char key[HASH_KEY_LEN]; QueryHashEntry *entry; /* @@ -306,8 +306,8 @@ FetchQuery(const char *plan_name) /* * We can't just use the statement name as supplied by the user: the - * hash package is picky enough that it needs to be NULL-padded out - * to the appropriate length to work correctly. + * hash package is picky enough that it needs to be NULL-padded out to + * the appropriate length to work correctly. */ MemSet(key, 0, sizeof(key)); strncpy(key, plan_name, sizeof(key)); @@ -344,7 +344,7 @@ FetchQueryParams(const char *plan_name) static void RunQuery(QueryDesc *qdesc, EState *state) { - TupleDesc tupdesc; + TupleDesc tupdesc; tupdesc = ExecutorStart(qdesc, state); @@ -363,7 +363,7 @@ RunQuery(QueryDesc *qdesc, EState *state) void DeallocateQuery(DeallocateStmt *stmt) { - char key[HASH_KEY_LEN]; + char key[HASH_KEY_LEN]; QueryHashEntry *entry; /* @@ -376,18 +376,18 @@ DeallocateQuery(DeallocateStmt *stmt) /* * We can't just use the statement name as supplied by the user: the - * hash package is picky enough that it needs to be NULL-padded out - * to the appropriate length to work correctly. + * hash package is picky enough that it needs to be NULL-padded out to + * the appropriate length to work correctly. */ MemSet(key, 0, sizeof(key)); strncpy(key, stmt->name, sizeof(key)); /* * First lookup the entry, so we can release all the subsidiary memory - * it has allocated (when it's removed, hash_search() will return - * a dangling pointer, so it needs to be done prior to HASH_REMOVE). - * This requires an extra hash-table lookup, but DEALLOCATE - * isn't exactly a performance bottleneck. + * it has allocated (when it's removed, hash_search() will return a + * dangling pointer, so it needs to be done prior to HASH_REMOVE). + * This requires an extra hash-table lookup, but DEALLOCATE isn't + * exactly a performance bottleneck. */ entry = (QueryHashEntry *) hash_search(prepared_queries, key, diff --git a/src/backend/commands/proclang.c b/src/backend/commands/proclang.c index 8aa2addc51..0d282e8f85 100644 --- a/src/backend/commands/proclang.c +++ b/src/backend/commands/proclang.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.41 2002/08/22 00:01:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/proclang.c,v 1.42 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,8 @@ void CreateProceduralLanguage(CreatePLangStmt *stmt) { char languageName[NAMEDATALEN]; - Oid procOid, valProcOid; + Oid procOid, + valProcOid; Oid typev[FUNC_MAX_ARGS]; char nulls[Natts_pg_language]; Datum values[Natts_pg_language]; @@ -49,8 +50,8 @@ CreateProceduralLanguage(CreatePLangStmt *stmt) HeapTuple tup; TupleDesc tupDesc; int i; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* * Check permission diff --git a/src/backend/commands/schemacmds.c b/src/backend/commands/schemacmds.c index 621006758c..09165d47bd 100644 --- a/src/backend/commands/schemacmds.c +++ b/src/backend/commands/schemacmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.5 2002/07/18 16:47:24 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/schemacmds.c,v 1.6 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -61,15 +61,17 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) owner_name = authId; /* The following will error out if user does not exist */ owner_userid = get_usesysid(owner_name); + /* - * Set the current user to the requested authorization so - * that objects created in the statement have the requested - * owner. (This will revert to session user on error or at - * the end of this routine.) + * Set the current user to the requested authorization so that + * objects created in the statement have the requested owner. + * (This will revert to session user on error or at the end of + * this routine.) */ SetUserId(owner_userid); } - else /* not superuser */ + else +/* not superuser */ { owner_userid = saved_userid; owner_name = GetUserNameFromId(owner_userid); @@ -98,17 +100,17 @@ CreateSchemaCommand(CreateSchemaStmt *stmt) /* * Temporarily make the new namespace be the front of the search path, - * as well as the default creation target namespace. This will be undone - * at the end of this routine, or upon error. + * as well as the default creation target namespace. This will be + * undone at the end of this routine, or upon error. */ PushSpecialNamespace(namespaceId); /* * Examine the list of commands embedded in the CREATE SCHEMA command, * and reorganize them into a sequentially executable order with no - * forward references. Note that the result is still a list of raw - * parsetrees in need of parse analysis --- we cannot, in general, - * run analyze.c on one statement until we have actually executed the + * forward references. Note that the result is still a list of raw + * parsetrees in need of parse analysis --- we cannot, in general, run + * analyze.c on one statement until we have actually executed the * prior ones. */ parsetree_list = analyzeCreateSchemaStmt(stmt); @@ -171,12 +173,12 @@ RemoveSchema(List *names, DropBehavior behavior) aclcheck_error(ACLCHECK_NOT_OWNER, namespaceName); /* - * Do the deletion. Objects contained in the schema are removed - * by means of their dependency links to the schema. + * Do the deletion. Objects contained in the schema are removed by + * means of their dependency links to the schema. * - * XXX currently, index opclasses don't have creation/deletion - * commands, so they will not get removed when the containing - * schema is removed. This is annoying but not fatal. + * XXX currently, index opclasses don't have creation/deletion commands, + * so they will not get removed when the containing schema is removed. + * This is annoying but not fatal. */ object.classId = get_system_catalog_relid(NamespaceRelationName); object.objectId = namespaceId; diff --git a/src/backend/commands/sequence.c b/src/backend/commands/sequence.c index fd62e41f71..5906788247 100644 --- a/src/backend/commands/sequence.c +++ b/src/backend/commands/sequence.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.86 2002/09/03 18:50:54 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/sequence.c,v 1.87 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,7 +60,7 @@ typedef struct sequence_magic * rely on the relcache, since it's only, well, a cache, and may decide to * discard entries.) * - * XXX We use linear search to find pre-existing SeqTable entries. This is + * XXX We use linear search to find pre-existing SeqTable entries. This is * good when only a small number of sequences are touched in a session, but * would suck with many different sequences. Perhaps use a hashtable someday. */ @@ -81,9 +81,9 @@ static SeqTable seqtab = NULL; /* Head of list of SeqTable items */ static void init_sequence(const char *caller, RangeVar *relation, - SeqTable *p_elm, Relation *p_rel); + SeqTable *p_elm, Relation *p_rel); static Form_pg_sequence read_info(const char *caller, SeqTable elm, - Relation rel, Buffer *buf); + Relation rel, Buffer *buf); static void init_params(CreateSeqStmt *seq, Form_pg_sequence new); static void do_setval(RangeVar *sequence, int64 next, bool iscalled); @@ -226,15 +226,15 @@ DefineSequence(CreateSeqStmt *seq) * Two special hacks here: * * 1. Since VACUUM does not process sequences, we have to force the tuple - * to have xmin = FrozenTransactionId now. Otherwise it would become - * invisible to SELECTs after 2G transactions. It is okay to do this + * to have xmin = FrozenTransactionId now. Otherwise it would become + * invisible to SELECTs after 2G transactions. It is okay to do this * because if the current transaction aborts, no other xact will ever * examine the sequence tuple anyway. * * 2. Even though heap_insert emitted a WAL log record, we have to emit * an XLOG_SEQ_LOG record too, since (a) the heap_insert record will * not have the right xmin, and (b) REDO of the heap_insert record - * would re-init page and sequence magic number would be lost. This + * would re-init page and sequence magic number would be lost. This * means two log records instead of one :-( */ LockBuffer(buf, BUFFER_LOCK_EXCLUSIVE); @@ -243,11 +243,12 @@ DefineSequence(CreateSeqStmt *seq) { /* - * Note that the "tuple" structure is still just a local tuple record - * created by heap_formtuple; its t_data pointer doesn't point at the - * disk buffer. To scribble on the disk buffer we need to fetch the - * item pointer. But do the same to the local tuple, since that will - * be the source for the WAL log record, below. + * Note that the "tuple" structure is still just a local tuple + * record created by heap_formtuple; its t_data pointer doesn't + * point at the disk buffer. To scribble on the disk buffer we + * need to fetch the item pointer. But do the same to the local + * tuple, since that will be the source for the WAL log record, + * below. */ ItemId itemId; Item item; @@ -323,7 +324,7 @@ nextval(PG_FUNCTION_ARGS) bool logit = false; sequence = makeRangeVarFromNameList(textToQualifiedNameList(seqin, - "nextval")); + "nextval")); /* open and AccessShareLock sequence */ init_sequence("nextval", sequence, &elm, &seqrel); @@ -358,14 +359,14 @@ nextval(PG_FUNCTION_ARGS) } /* - * Decide whether we should emit a WAL log record. If so, force up + * Decide whether we should emit a WAL log record. If so, force up * the fetch count to grab SEQ_LOG_VALS more values than we actually * need to cache. (These will then be usable without logging.) * - * If this is the first nextval after a checkpoint, we must force - * a new WAL record to be written anyway, else replay starting from the + * If this is the first nextval after a checkpoint, we must force a new + * WAL record to be written anyway, else replay starting from the * checkpoint would fail to advance the sequence past the logged - * values. In this case we may as well fetch extra values. + * values. In this case we may as well fetch extra values. */ if (log < fetch) { @@ -401,7 +402,8 @@ nextval(PG_FUNCTION_ARGS) break; /* stop fetching */ if (!seq->is_cycled) { - char buf[100]; + char buf[100]; + snprintf(buf, 100, INT64_FORMAT, maxv); elog(ERROR, "%s.nextval: reached MAXVALUE (%s)", sequence->relname, buf); @@ -421,7 +423,8 @@ nextval(PG_FUNCTION_ARGS) break; /* stop fetching */ if (!seq->is_cycled) { - char buf[100]; + char buf[100]; + snprintf(buf, 100, INT64_FORMAT, minv); elog(ERROR, "%s.nextval: reached MINVALUE (%s)", sequence->relname, buf); @@ -507,7 +510,7 @@ currval(PG_FUNCTION_ARGS) int64 result; sequence = makeRangeVarFromNameList(textToQualifiedNameList(seqin, - "currval")); + "currval")); /* open and AccessShareLock sequence */ init_sequence("currval", sequence, &elm, &seqrel); @@ -560,7 +563,10 @@ do_setval(RangeVar *sequence, int64 next, bool iscalled) if ((next < seq->min_value) || (next > seq->max_value)) { - char bufv[100], bufm[100], bufx[100]; + char bufv[100], + bufm[100], + bufx[100]; + snprintf(bufv, 100, INT64_FORMAT, next); snprintf(bufm, 100, INT64_FORMAT, seq->min_value); snprintf(bufx, 100, INT64_FORMAT, seq->max_value); @@ -632,7 +638,7 @@ setval(PG_FUNCTION_ARGS) RangeVar *sequence; sequence = makeRangeVarFromNameList(textToQualifiedNameList(seqin, - "setval")); + "setval")); do_setval(sequence, next, true); @@ -652,7 +658,7 @@ setval_and_iscalled(PG_FUNCTION_ARGS) RangeVar *sequence; sequence = makeRangeVarFromNameList(textToQualifiedNameList(seqin, - "setval")); + "setval")); do_setval(sequence, next, iscalled); @@ -672,7 +678,7 @@ init_sequence(const char *caller, RangeVar *relation, TransactionId thisxid = GetCurrentTransactionId(); SeqTable elm; Relation seqrel; - + /* Look to see if we already have a seqtable entry for relation */ for (elm = seqtab; elm != NULL; elm = elm->next) { @@ -697,9 +703,9 @@ init_sequence(const char *caller, RangeVar *relation, * Allocate new seqtable entry if we didn't find one. * * NOTE: seqtable entries remain in the list for the life of a backend. - * If the sequence itself is deleted then the entry becomes wasted memory, - * but it's small enough that this should not matter. - */ + * If the sequence itself is deleted then the entry becomes wasted + * memory, but it's small enough that this should not matter. + */ if (elm == NULL) { /* @@ -828,7 +834,9 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) if (new->min_value >= new->max_value) { - char bufm[100], bufx[100]; + char bufm[100], + bufx[100]; + snprintf(bufm, 100, INT64_FORMAT, new->min_value); snprintf(bufx, 100, INT64_FORMAT, new->max_value); elog(ERROR, "DefineSequence: MINVALUE (%s) must be less than MAXVALUE (%s)", @@ -847,7 +855,9 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) if (new->last_value < new->min_value) { - char bufs[100], bufm[100]; + char bufs[100], + bufm[100]; + snprintf(bufs, 100, INT64_FORMAT, new->last_value); snprintf(bufm, 100, INT64_FORMAT, new->min_value); elog(ERROR, "DefineSequence: START value (%s) can't be less than MINVALUE (%s)", @@ -855,7 +865,9 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) } if (new->last_value > new->max_value) { - char bufs[100], bufm[100]; + char bufs[100], + bufm[100]; + snprintf(bufs, 100, INT64_FORMAT, new->last_value); snprintf(bufm, 100, INT64_FORMAT, new->max_value); elog(ERROR, "DefineSequence: START value (%s) can't be greater than MAXVALUE (%s)", @@ -866,7 +878,8 @@ init_params(CreateSeqStmt *seq, Form_pg_sequence new) new->cache_value = 1; else if ((new->cache_value = defGetInt64(cache_value)) <= 0) { - char buf[100]; + char buf[100]; + snprintf(buf, 100, INT64_FORMAT, new->cache_value); elog(ERROR, "DefineSequence: CACHE (%s) can't be <= 0", buf); diff --git a/src/backend/commands/tablecmds.c b/src/backend/commands/tablecmds.c index 8709111a86..3b06c6915b 100644 --- a/src/backend/commands/tablecmds.c +++ b/src/backend/commands/tablecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.38 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/tablecmds.c,v 1.39 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,11 +60,11 @@ static void setRelhassubclassInRelation(Oid relationId, bool relhassubclass); static void CheckTupleType(Form_pg_class tuple_class); static bool needs_toast_table(Relation rel); static void validateForeignKeyConstraint(FkConstraint *fkconstraint, - Relation rel, Relation pkrel); -static Oid createForeignKeyConstraint(Relation rel, Relation pkrel, - FkConstraint *fkconstraint); + Relation rel, Relation pkrel); +static Oid createForeignKeyConstraint(Relation rel, Relation pkrel, + FkConstraint *fkconstraint); static void createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, - Oid constrOid); + Oid constrOid); static char *fkMatchTypeToString(char match_type); /* Used by attribute and relation renaming routines: */ @@ -114,9 +114,8 @@ DefineRelation(CreateStmt *stmt, char relkind) /* * Look up the namespace in which we are supposed to create the - * relation. Check we have permission to create there. - * Skip check if bootstrapping, since permissions machinery may not - * be working yet. + * relation. Check we have permission to create there. Skip check if + * bootstrapping, since permissions machinery may not be working yet. */ namespaceId = RangeVarGetCreationNamespace(stmt->relation); @@ -136,7 +135,7 @@ DefineRelation(CreateStmt *stmt, char relkind) */ schema = MergeAttributes(schema, stmt->inhRelations, stmt->relation->istemp, - &inheritOids, &old_constraints, &parentHasOids); + &inheritOids, &old_constraints, &parentHasOids); numberOfAttributes = length(schema); if (numberOfAttributes <= 0) @@ -180,10 +179,10 @@ DefineRelation(CreateStmt *stmt, char relkind) else { /* - * Generate a constraint name. NB: this should match the + * Generate a constraint name. NB: this should match the * form of names that GenerateConstraintName() may produce - * for names added later. We are assured that there is - * no name conflict, because MergeAttributes() did not pass + * for names added later. We are assured that there is no + * name conflict, because MergeAttributes() did not pass * back any names of this form. */ check[ncheck].ccname = (char *) palloc(NAMEDATALEN); @@ -242,8 +241,8 @@ DefineRelation(CreateStmt *stmt, char relkind) * CREATE TABLE. * * Another task that's conveniently done at this step is to add - * dependency links between columns and supporting relations (such - * as SERIAL sequences). + * dependency links between columns and supporting relations (such as + * SERIAL sequences). * * First, scan schema to find new column defaults. */ @@ -271,7 +270,7 @@ DefineRelation(CreateStmt *stmt, char relkind) if (colDef->support != NULL) { /* Create dependency for supporting relation for this column */ - ObjectAddress colobject, + ObjectAddress colobject, suppobject; colobject.classId = RelOid_pg_class; @@ -334,9 +333,9 @@ TruncateRelation(const RangeVar *relation) Relation rel; Oid relid; Oid toastrelid; - ScanKeyData key; - Relation fkeyRel; - SysScanDesc fkeyScan; + ScanKeyData key; + Relation fkeyRel; + SysScanDesc fkeyScan; HeapTuple tuple; /* Grab exclusive lock in preparation for truncate */ @@ -366,8 +365,7 @@ TruncateRelation(const RangeVar *relation) aclcheck_error(ACLCHECK_NOT_OWNER, RelationGetRelationName(rel)); /* - * Don't allow truncate on tables which are referenced - * by foreign keys + * Don't allow truncate on tables which are referenced by foreign keys */ fkeyRel = heap_openr(ConstraintRelationName, AccessShareLock); @@ -380,8 +378,8 @@ TruncateRelation(const RangeVar *relation) SnapshotNow, 1, &key); /* - * First foreign key found with us as the reference - * should throw an error. + * First foreign key found with us as the reference should throw an + * error. */ while (HeapTupleIsValid(tuple = systable_getnext(fkeyScan))) { @@ -554,7 +552,8 @@ MergeAttributes(List *schema, List *supers, bool istemp, /* * newattno[] will contain the child-table attribute numbers for * the attributes of this parent table. (They are not the same - * for parents after the first one, nor if we have dropped columns.) + * for parents after the first one, nor if we have dropped + * columns.) */ newattno = (AttrNumber *) palloc(tupleDesc->natts * sizeof(AttrNumber)); @@ -572,9 +571,10 @@ MergeAttributes(List *schema, List *supers, bool istemp, */ if (attribute->attisdropped) { - /* - * change_varattnos_of_a_node asserts that this is greater than - * zero, so if anything tries to use it, we should find out. + /* + * change_varattnos_of_a_node asserts that this is greater + * than zero, so if anything tries to use it, we should + * find out. */ newattno[parent_attno - 1] = 0; continue; @@ -684,6 +684,7 @@ MergeAttributes(List *schema, List *supers, bool istemp, Node *expr; cdef->contype = CONSTR_CHECK; + /* * Do not inherit generated constraint names, since they * might conflict across multiple inheritance parents. @@ -857,8 +858,8 @@ StoreCatalogInheritance(Oid relationId, List *supers) return; /* - * Store INHERITS information in pg_inherits using direct ancestors only. - * Also enter dependencies on the direct ancestors. + * Store INHERITS information in pg_inherits using direct ancestors + * only. Also enter dependencies on the direct ancestors. */ relation = heap_openr(InheritsRelationName, RowExclusiveLock); desc = RelationGetDescr(relation); @@ -1076,7 +1077,7 @@ renameatt(Oid myrelid, * * normally, only the owner of a class can change its schema. */ - if (!allowSystemTableMods + if (!allowSystemTableMods && IsSystemRelation(targetrelation)) elog(ERROR, "renameatt: class \"%s\" is a system catalog", RelationGetRelationName(targetrelation)); @@ -1141,8 +1142,8 @@ renameatt(Oid myrelid, oldattname); /* - * if the attribute is inherited, forbid the renaming, unless we - * are already inside a recursive rename. + * if the attribute is inherited, forbid the renaming, unless we are + * already inside a recursive rename. */ if (attform->attisinherited && !recursing) elog(ERROR, "renameatt: inherited attribute \"%s\" may not be renamed", @@ -1233,7 +1234,8 @@ renameatt(Oid myrelid, true, false); } - relation_close(targetrelation, NoLock); /* close rel but keep lock! */ + relation_close(targetrelation, NoLock); /* close rel but keep + * lock! */ } /* @@ -1382,7 +1384,7 @@ update_ri_trigger_args(Oid relid, { Relation tgrel; ScanKeyData skey[1]; - SysScanDesc trigscan; + SysScanDesc trigscan; HeapTuple tuple; Datum values[Natts_pg_trigger]; char nulls[Natts_pg_trigger]; @@ -1577,8 +1579,8 @@ AlterTableAddColumn(Oid myrelid, HeapTuple typeTuple; Form_pg_type tform; int attndims; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; /* * Grab an exclusive lock on the target table, which we will NOT @@ -1666,7 +1668,7 @@ AlterTableAddColumn(Oid myrelid, if (colDef->is_not_null) elog(ERROR, "Adding NOT NULL columns is not implemented." - "\n\tAdd the column, then use ALTER TABLE ... SET NOT NULL."); + "\n\tAdd the column, then use ALTER TABLE ... SET NOT NULL."); pgclass = heap_openr(RelationRelationName, RowExclusiveLock); @@ -1678,8 +1680,9 @@ AlterTableAddColumn(Oid myrelid, RelationGetRelationName(rel)); /* - * this test is deliberately not attisdropped-aware, since if one tries - * to add a column matching a dropped column name, it's gonna fail anyway. + * this test is deliberately not attisdropped-aware, since if one + * tries to add a column matching a dropped column name, it's gonna + * fail anyway. */ if (SearchSysCacheExists(ATTNAME, ObjectIdGetDatum(myrelid), @@ -1706,7 +1709,7 @@ AlterTableAddColumn(Oid myrelid, tform = (Form_pg_type) GETSTRUCT(typeTuple); attributeTuple = heap_addheader(Natts_pg_attribute, - false, + false, ATTRIBUTE_TUPLE_SIZE, (void *) &attributeD); @@ -1806,8 +1809,8 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, HeapTuple tuple; AttrNumber attnum; Relation attr_rel; - List *indexoidlist; - List *indexoidscan; + List *indexoidlist; + List *indexoidscan; rel = heap_open(myrelid, AccessExclusiveLock); @@ -1874,10 +1877,10 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, foreach(indexoidscan, indexoidlist) { - Oid indexoid = lfirsti(indexoidscan); + Oid indexoid = lfirsti(indexoidscan); HeapTuple indexTuple; - Form_pg_index indexStruct; - int i; + Form_pg_index indexStruct; + int i; indexTuple = SearchSysCache(INDEXRELID, ObjectIdGetDatum(indexoid), @@ -1891,11 +1894,11 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, if (indexStruct->indisprimary) { /* - * Loop over each attribute in the primary key and - * see if it matches the to-be-altered attribute + * Loop over each attribute in the primary key and see if it + * matches the to-be-altered attribute */ for (i = 0; i < INDEX_MAX_KEYS && - indexStruct->indkey[i] != InvalidAttrNumber; i++) + indexStruct->indkey[i] != InvalidAttrNumber; i++) { if (indexStruct->indkey[i] == attnum) elog(ERROR, "ALTER TABLE: Attribute \"%s\" is in a primary key", colName); @@ -1913,7 +1916,7 @@ AlterTableAlterColumnDropNotNull(Oid myrelid, bool recurse, attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock); tuple = SearchSysCacheCopyAttName(myrelid, colName); - if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ + if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"", RelationGetRelationName(rel), colName); @@ -1940,7 +1943,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse, HeapTuple tuple; AttrNumber attnum; Relation attr_rel; - HeapScanDesc scan; + HeapScanDesc scan; TupleDesc tupdesc; rel = heap_open(myrelid, AccessExclusiveLock); @@ -2000,8 +2003,8 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse, colName); /* - * Perform a scan to ensure that there are no NULL - * values already in the relation + * Perform a scan to ensure that there are no NULL values already in + * the relation */ tupdesc = RelationGetDescr(rel); @@ -2009,7 +2012,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse, while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Datum d; + Datum d; bool isnull; d = heap_getattr(tuple, attnum, tupdesc, &isnull); @@ -2027,7 +2030,7 @@ AlterTableAlterColumnSetNotNull(Oid myrelid, bool recurse, attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock); tuple = SearchSysCacheCopyAttName(myrelid, colName); - if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ + if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "ALTER TABLE: relation \"%s\" has no column \"%s\"", RelationGetRelationName(rel), colName); @@ -2153,7 +2156,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse, { Relation rel; int newtarget = 1; - char newstorage = 'p'; + char newstorage = 'p'; Relation attrelation; HeapTuple tuple; Form_pg_attribute attrtuple; @@ -2200,7 +2203,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse, else if (*flagType == 'M') { /* STORAGE */ - char *storagemode; + char *storagemode; Assert(IsA(flagValue, String)); storagemode = strVal(flagValue); @@ -2246,7 +2249,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse, if (childrelid == myrelid) continue; AlterTableAlterColumnFlags(childrelid, - false, colName, flagValue, flagType); + false, colName, flagValue, flagType); } } @@ -2263,6 +2266,7 @@ AlterTableAlterColumnFlags(Oid myrelid, bool recurse, if (attrtuple->attnum < 0) elog(ERROR, "ALTER TABLE: cannot change system attribute \"%s\"", colName); + /* * Now change the appropriate field */ @@ -2306,7 +2310,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, AttrNumber n; TupleDesc tupleDesc; bool success; - ObjectAddress object; + ObjectAddress object; rel = heap_open(myrelid, AccessExclusiveLock); @@ -2336,8 +2340,9 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, colName); /* - * Make sure there will be at least one user column left in the relation - * after we drop this one. Zero-length tuples tend to confuse us. + * Make sure there will be at least one user column left in the + * relation after we drop this one. Zero-length tuples tend to + * confuse us. */ tupleDesc = RelationGetDescr(rel); @@ -2355,7 +2360,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, if (!success) elog(ERROR, "ALTER TABLE: Cannot drop last column from table \"%s\"", - RelationGetRelationName(rel)); + RelationGetRelationName(rel)); /* Don't drop inherited columns */ if (tupleDesc->attrs[attnum - 1]->attisinherited && !recursing) @@ -2363,8 +2368,8 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, colName); /* - * If we are asked to drop ONLY in this table (no recursion), - * we need to mark the inheritors' attribute as non-inherited. + * If we are asked to drop ONLY in this table (no recursion), we need + * to mark the inheritors' attribute as non-inherited. */ if (!recurse && !recursing) { @@ -2378,14 +2383,14 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, attr_rel = heap_openr(AttributeRelationName, RowExclusiveLock); foreach(child, children) { - Oid childrelid = lfirsti(child); - Relation childrel; + Oid childrelid = lfirsti(child); + Relation childrel; HeapTuple tuple; childrel = heap_open(childrelid, AccessExclusiveLock); tuple = SearchSysCacheCopyAttName(childrelid, colName); - if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ + if (!HeapTupleIsValid(tuple)) /* shouldn't happen */ elog(ERROR, "ALTER TABLE: relation %u has no column \"%s\"", childrelid, colName); @@ -2407,7 +2412,7 @@ AlterTableDropColumn(Oid myrelid, bool recurse, bool recursing, if (recurse) { List *child, - *children; + *children; /* this routine is actually in the planner */ children = find_all_inheritors(myrelid); @@ -2495,8 +2500,8 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, foreach(listptr, newConstraints) { /* - * copy is because we may destructively alter the node below - * by inserting a generated name; this name is not necessarily + * copy is because we may destructively alter the node below by + * inserting a generated name; this name is not necessarily * correct for children or parents. */ Node *newConstraint = copyObject(lfirst(listptr)); @@ -2533,16 +2538,16 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, if (constr->name) { if (ConstraintNameIsUsed(RelationGetRelid(rel), - RelationGetNamespace(rel), - constr->name)) + RelationGetNamespace(rel), + constr->name)) elog(ERROR, "constraint \"%s\" already exists for relation \"%s\"", constr->name, - RelationGetRelationName(rel)); + RelationGetRelationName(rel)); } else constr->name = GenerateConstraintName(RelationGetRelid(rel), - RelationGetNamespace(rel), - &counter); + RelationGetNamespace(rel), + &counter); /* * We need to make a parse state and range @@ -2552,8 +2557,8 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, */ pstate = make_parsestate(NULL); rte = addRangeTableEntryForRelation(pstate, - myrelid, - makeAlias(RelationGetRelationName(rel), NIL), + myrelid, + makeAlias(RelationGetRelationName(rel), NIL), false, true); addRTEtoQuery(pstate, rte, true, true); @@ -2657,23 +2662,23 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, if (fkconstraint->constr_name) { if (ConstraintNameIsUsed(RelationGetRelid(rel), - RelationGetNamespace(rel), - fkconstraint->constr_name)) + RelationGetNamespace(rel), + fkconstraint->constr_name)) elog(ERROR, "constraint \"%s\" already exists for relation \"%s\"", fkconstraint->constr_name, RelationGetRelationName(rel)); } else fkconstraint->constr_name = GenerateConstraintName(RelationGetRelid(rel), - RelationGetNamespace(rel), - &counter); + RelationGetNamespace(rel), + &counter); /* * Grab an exclusive lock on the pk table, so that * someone doesn't delete rows out from under us. * (Although a lesser lock would do for that purpose, - * we'll need exclusive lock anyway to add triggers - * to the pk table; trying to start with a lesser lock + * we'll need exclusive lock anyway to add triggers to + * the pk table; trying to start with a lesser lock * will just create a risk of deadlock.) */ pkrel = heap_openrv(fkconstraint->pktable, @@ -2716,12 +2721,14 @@ AlterTableAddConstraint(Oid myrelid, bool recurse, fkconstraint); /* - * Create the triggers that will enforce the constraint. + * Create the triggers that will enforce the + * constraint. */ createForeignKeyTriggers(rel, fkconstraint, constrOid); /* - * Close pk table, but keep lock until we've committed. + * Close pk table, but keep lock until we've + * committed. */ heap_close(pkrel, NoLock); @@ -2754,10 +2761,9 @@ validateForeignKeyConstraint(FkConstraint *fkconstraint, int count; /* - * Scan through each tuple, calling RI_FKey_check_ins - * (insert trigger) as if that tuple had just been - * inserted. If any of those fail, it should - * elog(ERROR) and that's that. + * Scan through each tuple, calling RI_FKey_check_ins (insert trigger) + * as if that tuple had just been inserted. If any of those fail, it + * should elog(ERROR) and that's that. */ MemSet(&trig, 0, sizeof(trig)); trig.tgoid = InvalidOid; @@ -2848,7 +2854,7 @@ createForeignKeyConstraint(Relation rel, Relation pkrel, i = 0; foreach(l, fkconstraint->fk_attrs) { - char *id = strVal(lfirst(l)); + char *id = strVal(lfirst(l)); AttrNumber attno; attno = get_attnum(RelationGetRelid(rel), id); @@ -2864,7 +2870,7 @@ createForeignKeyConstraint(Relation rel, Relation pkrel, i = 0; foreach(l, fkconstraint->pk_attrs) { - char *id = strVal(lfirst(l)); + char *id = strVal(lfirst(l)); AttrNumber attno; attno = get_attnum(RelationGetRelid(pkrel), id); @@ -2883,14 +2889,14 @@ createForeignKeyConstraint(Relation rel, Relation pkrel, RelationGetRelid(rel), fkattr, fkcount, - InvalidOid, /* not a domain constraint */ + InvalidOid, /* not a domain constraint */ RelationGetRelid(pkrel), pkattr, pkcount, fkconstraint->fk_upd_action, fkconstraint->fk_del_action, fkconstraint->fk_matchtype, - NULL, /* no check constraint */ + NULL, /* no check constraint */ NULL, NULL); } @@ -2910,7 +2916,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, constrobj; /* - * Reconstruct a RangeVar for my relation (not passed in, unfortunately). + * Reconstruct a RangeVar for my relation (not passed in, + * unfortunately). */ myRel = makeRangeVar(get_namespace_name(RelationGetNamespace(rel)), RelationGetRelationName(rel)); @@ -2956,9 +2963,9 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); fk_attr = fkconstraint->fk_attrs; pk_attr = fkconstraint->pk_attrs; if (length(fk_attr) != length(pk_attr)) @@ -2983,8 +2990,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, CommandCounterIncrement(); /* - * Build and execute a CREATE CONSTRAINT TRIGGER statement for the - * ON DELETE action on the referenced table. + * Build and execute a CREATE CONSTRAINT TRIGGER statement for the ON + * DELETE action on the referenced table. */ fk_trigger = makeNode(CreateTrigStmt); fk_trigger->trigname = fkconstraint->constr_name; @@ -3032,9 +3039,9 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); fk_attr = fkconstraint->fk_attrs; pk_attr = fkconstraint->pk_attrs; while (fk_attr != NIL) @@ -3054,8 +3061,8 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, CommandCounterIncrement(); /* - * Build and execute a CREATE CONSTRAINT TRIGGER statement for the - * ON UPDATE action on the referenced table. + * Build and execute a CREATE CONSTRAINT TRIGGER statement for the ON + * UPDATE action on the referenced table. */ fk_trigger = makeNode(CreateTrigStmt); fk_trigger->trigname = fkconstraint->constr_name; @@ -3103,9 +3110,9 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, fk_trigger->args = lappend(fk_trigger->args, makeString(myRel->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkconstraint->pktable->relname)); + makeString(fkconstraint->pktable->relname)); fk_trigger->args = lappend(fk_trigger->args, - makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); + makeString(fkMatchTypeToString(fkconstraint->fk_matchtype))); fk_attr = fkconstraint->fk_attrs; pk_attr = fkconstraint->pk_attrs; while (fk_attr != NIL) @@ -3129,7 +3136,7 @@ createForeignKeyTriggers(Relation rel, FkConstraint *fkconstraint, static char * fkMatchTypeToString(char match_type) { - switch (match_type) + switch (match_type) { case FKCONSTR_MATCH_FULL: return pstrdup("FULL"); @@ -3227,10 +3234,10 @@ AlterTableDropConstraint(Oid myrelid, bool recurse, void AlterTableOwner(Oid relationOid, int32 newOwnerSysId) { - Relation target_rel; - Relation class_rel; - HeapTuple tuple; - Form_pg_class tuple_class; + Relation target_rel; + Relation class_rel; + HeapTuple tuple; + Form_pg_class tuple_class; /* Get exclusive lock till end of transaction on the target table */ /* Use relation_open here so that we work on indexes... */ @@ -3250,8 +3257,8 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId) CheckTupleType(tuple_class); /* - * Okay, this is a valid tuple: change its ownership and - * write to the heap. + * Okay, this is a valid tuple: change its ownership and write to the + * heap. */ tuple_class->relowner = newOwnerSysId; simple_heap_update(class_rel, &tuple->t_self, tuple); @@ -3267,16 +3274,15 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId) if (tuple_class->relkind == RELKIND_RELATION || tuple_class->relkind == RELKIND_TOASTVALUE) { - List *index_oid_list, *i; + List *index_oid_list, + *i; /* Find all the indexes belonging to this relation */ index_oid_list = RelationGetIndexList(target_rel); /* For each index, recursively change its ownership */ foreach(i, index_oid_list) - { AlterTableOwner(lfirsti(i), newOwnerSysId); - } freeList(index_oid_list); } @@ -3285,9 +3291,7 @@ AlterTableOwner(Oid relationOid, int32 newOwnerSysId) { /* If it has a toast table, recurse to change its ownership */ if (tuple_class->reltoastrelid != InvalidOid) - { AlterTableOwner(tuple_class->reltoastrelid, newOwnerSysId); - } } heap_freetuple(tuple); @@ -3355,7 +3359,7 @@ AlterTableCreateToastTable(Oid relOid, bool silent) * We cannot allow toasting a shared relation after initdb (because * there's no way to mark it toasted in other databases' pg_class). * Unfortunately we can't distinguish initdb from a manually started - * standalone backend. However, we can at least prevent this mistake + * standalone backend. However, we can at least prevent this mistake * under normal multi-user operation. */ shared_relation = rel->rd_rel->relisshared; @@ -3453,10 +3457,11 @@ AlterTableCreateToastTable(Oid relOid, bool silent) tupdesc->attrs[2]->attstorage = 'p'; /* - * Note: the toast relation is placed in the regular pg_toast namespace - * even if its master relation is a temp table. There cannot be any - * naming collision, and the toast rel will be destroyed when its master - * is, so there's no need to handle the toast rel as temp. + * Note: the toast relation is placed in the regular pg_toast + * namespace even if its master relation is a temp table. There + * cannot be any naming collision, and the toast rel will be destroyed + * when its master is, so there's no need to handle the toast rel as + * temp. */ toast_relid = heap_create_with_catalog(toast_relname, PG_TOAST_NAMESPACE, @@ -3471,12 +3476,12 @@ AlterTableCreateToastTable(Oid relOid, bool silent) /* * Create unique index on chunk_id, chunk_seq. * - * NOTE: the normal TOAST access routines could actually function with - * a single-column index on chunk_id only. However, the slice access + * NOTE: the normal TOAST access routines could actually function with a + * single-column index on chunk_id only. However, the slice access * routines use both columns for faster access to an individual chunk. - * In addition, we want it to be unique as a check against the + * In addition, we want it to be unique as a check against the * possibility of duplicate TOAST chunk OIDs. The index might also be - * a little more efficient this way, since btree isn't all that happy + * a little more efficient this way, since btree isn't all that happy * with large numbers of equal keys. */ @@ -3516,8 +3521,8 @@ AlterTableCreateToastTable(Oid relOid, bool silent) heap_freetuple(reltup); /* - * Register dependency from the toast table to the master, so that - * the toast table will be deleted if the master is. + * Register dependency from the toast table to the master, so that the + * toast table will be deleted if the master is. */ baseobject.classId = RelOid_pg_class; baseobject.objectId = relOid; diff --git a/src/backend/commands/trigger.c b/src/backend/commands/trigger.c index 4b76510514..1d0e969176 100644 --- a/src/backend/commands/trigger.c +++ b/src/backend/commands/trigger.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.130 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/trigger.c,v 1.131 2002/09/04 20:31:15 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ static void DeferredTriggerExecute(DeferredTriggerEvent event, int itemno, * Create a trigger. Returns the OID of the created trigger. * * forConstraint, if true, says that this trigger is being created to - * implement a constraint. The caller will then be expected to make + * implement a constraint. The caller will then be expected to make * a pg_depend entry linking the trigger to that constraint (and thereby * to the owning relation(s)). */ @@ -69,7 +69,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) Relation rel; AclResult aclresult; Relation tgrel; - SysScanDesc tgscan; + SysScanDesc tgscan; ScanKeyData key; Relation pgrel; HeapTuple tuple; @@ -82,8 +82,8 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) char *trigname; char *constrname; Oid constrrelid; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; rel = heap_openrv(stmt->relation, AccessExclusiveLock); @@ -98,7 +98,7 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) if (!allowSystemTableMods && IsSystemRelation(rel)) elog(ERROR, "CreateTrigger: can't create trigger for system relation %s", - stmt->relation->relname); + stmt->relation->relname); /* permission checks */ @@ -132,9 +132,9 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) /* * If trigger is an RI constraint, use specified trigger name as - * constraint name and build a unique trigger name instead. - * This is mainly for backwards compatibility with CREATE CONSTRAINT - * TRIGGER commands. + * constraint name and build a unique trigger name instead. This is + * mainly for backwards compatibility with CREATE CONSTRAINT TRIGGER + * commands. */ if (stmt->isconstraint) { @@ -183,10 +183,10 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) } /* - * Scan pg_trigger for existing triggers on relation. We do this mainly - * because we must count them; a secondary benefit is to give a nice - * error message if there's already a trigger of the same name. (The - * unique index on tgrelid/tgname would complain anyway.) + * Scan pg_trigger for existing triggers on relation. We do this + * mainly because we must count them; a secondary benefit is to give a + * nice error message if there's already a trigger of the same name. + * (The unique index on tgrelid/tgname would complain anyway.) * * NOTE that this is cool only because we have AccessExclusiveLock on the * relation, so the trigger set won't be changing underneath us. @@ -241,13 +241,13 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) values[Anum_pg_trigger_tgrelid - 1] = ObjectIdGetDatum(RelationGetRelid(rel)); values[Anum_pg_trigger_tgname - 1] = DirectFunctionCall1(namein, - CStringGetDatum(trigname)); + CStringGetDatum(trigname)); values[Anum_pg_trigger_tgfoid - 1] = ObjectIdGetDatum(funcoid); values[Anum_pg_trigger_tgtype - 1] = Int16GetDatum(tgtype); values[Anum_pg_trigger_tgenabled - 1] = BoolGetDatum(true); values[Anum_pg_trigger_tgisconstraint - 1] = BoolGetDatum(stmt->isconstraint); values[Anum_pg_trigger_tgconstrname - 1] = DirectFunctionCall1(namein, - CStringGetDatum(constrname)); + CStringGetDatum(constrname)); values[Anum_pg_trigger_tgconstrrelid - 1] = ObjectIdGetDatum(constrrelid); values[Anum_pg_trigger_tgdeferrable - 1] = BoolGetDatum(stmt->deferrable); values[Anum_pg_trigger_tginitdeferred - 1] = BoolGetDatum(stmt->initdeferred); @@ -354,8 +354,9 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) * CREATE TRIGGER command, also make trigger be auto-dropped if its * relation is dropped or if the FK relation is dropped. (Auto drop * is compatible with our pre-7.3 behavior.) If the trigger is being - * made for a constraint, we can skip the relation links; the dependency - * on the constraint will indirectly depend on the relations. + * made for a constraint, we can skip the relation links; the + * dependency on the constraint will indirectly depend on the + * relations. */ referenced.classId = RelOid_pg_proc; referenced.objectId = funcoid; @@ -389,10 +390,10 @@ CreateTrigger(CreateTrigStmt *stmt, bool forConstraint) void DropTrigger(Oid relid, const char *trigname, DropBehavior behavior) { - Relation tgrel; - ScanKeyData skey[2]; - SysScanDesc tgscan; - HeapTuple tup; + Relation tgrel; + ScanKeyData skey[2]; + SysScanDesc tgscan; + HeapTuple tup; ObjectAddress object; /* @@ -440,14 +441,14 @@ void RemoveTriggerById(Oid trigOid) { Relation tgrel; - SysScanDesc tgscan; - ScanKeyData skey[1]; + SysScanDesc tgscan; + ScanKeyData skey[1]; HeapTuple tup; Oid relid; Relation rel; Relation pgrel; HeapTuple tuple; - Form_pg_class classForm; + Form_pg_class classForm; tgrel = heap_openr(TriggerRelationName, RowExclusiveLock); @@ -495,8 +496,8 @@ RemoveTriggerById(Oid trigOid) * rebuild relcache entries. * * Note this is OK only because we have AccessExclusiveLock on the rel, - * so no one else is creating/deleting triggers on this rel at the same - * time. + * so no one else is creating/deleting triggers on this rel at the + * same time. */ pgrel = heap_openr(RelationRelationName, RowExclusiveLock); tuple = SearchSysCacheCopy(RELOID, @@ -545,7 +546,7 @@ renametrig(Oid relid, Relation targetrel; Relation tgrel; HeapTuple tuple; - SysScanDesc tgscan; + SysScanDesc tgscan; ScanKeyData key[2]; /* @@ -555,10 +556,10 @@ renametrig(Oid relid, targetrel = heap_open(relid, AccessExclusiveLock); /* - * Scan pg_trigger twice for existing triggers on relation. We do this in - * order to ensure a trigger does not exist with newname (The unique index - * on tgrelid/tgname would complain anyway) and to ensure a trigger does - * exist with oldname. + * Scan pg_trigger twice for existing triggers on relation. We do + * this in order to ensure a trigger does not exist with newname (The + * unique index on tgrelid/tgname would complain anyway) and to ensure + * a trigger does exist with oldname. * * NOTE that this is cool only because we have AccessExclusiveLock on the * relation, so the trigger set won't be changing underneath us. @@ -601,7 +602,7 @@ renametrig(Oid relid, /* * Update pg_trigger tuple with new tgname. */ - tuple = heap_copytuple(tuple); /* need a modifiable copy */ + tuple = heap_copytuple(tuple); /* need a modifiable copy */ namestrcpy(&((Form_pg_trigger) GETSTRUCT(tuple))->tgname, newname); @@ -611,9 +612,10 @@ renametrig(Oid relid, CatalogUpdateIndexes(tgrel, tuple); /* - * Invalidate relation's relcache entry so that other backends (and - * this one too!) are sent SI message to make them rebuild relcache - * entries. (Ideally this should happen automatically...) + * Invalidate relation's relcache entry so that other backends + * (and this one too!) are sent SI message to make them rebuild + * relcache entries. (Ideally this should happen + * automatically...) */ CacheInvalidateRelcache(relid); } @@ -649,17 +651,17 @@ RelationBuildTriggers(Relation relation) int found = 0; Relation tgrel; ScanKeyData skey; - SysScanDesc tgscan; + SysScanDesc tgscan; HeapTuple htup; triggers = (Trigger *) MemoryContextAlloc(CacheMemoryContext, ntrigs * sizeof(Trigger)); /* - * Note: since we scan the triggers using TriggerRelidNameIndex, - * we will be reading the triggers in name order, except possibly - * during emergency-recovery operations (ie, IsIgnoringSystemIndexes). - * This in turn ensures that triggers will be fired in name order. + * Note: since we scan the triggers using TriggerRelidNameIndex, we + * will be reading the triggers in name order, except possibly during + * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This + * in turn ensures that triggers will be fired in name order. */ ScanKeyEntryInitialize(&skey, (bits16) 0x0, @@ -1528,17 +1530,17 @@ deferredTriggerInvokeEvents(bool immediate_only) /* * If immediate_only is true, we remove fully-processed events from - * the event queue to recycle space. If immediate_only is false, - * we are going to discard the whole event queue on return anyway, - * so no need to bother with "retail" pfree's. + * the event queue to recycle space. If immediate_only is false, we + * are going to discard the whole event queue on return anyway, so no + * need to bother with "retail" pfree's. * * In a scenario with many commands in a transaction and many - * deferred-to-end-of-transaction triggers, it could get annoying - * to rescan all the deferred triggers at each command end. - * To speed this up, we could remember the actual end of the queue at - * EndQuery and examine only events that are newer. On state changes - * we simply reset the saved position to the beginning of the queue - * and process all events once with the new states. + * deferred-to-end-of-transaction triggers, it could get annoying to + * rescan all the deferred triggers at each command end. To speed this + * up, we could remember the actual end of the queue at EndQuery and + * examine only events that are newer. On state changes we simply + * reset the saved position to the beginning of the queue and process + * all events once with the new states. */ /* Make a per-tuple memory context for trigger function calls */ @@ -1559,8 +1561,8 @@ deferredTriggerInvokeEvents(bool immediate_only) /* * Check if event is already completely done. */ - if (! (event->dte_event & (TRIGGER_DEFERRED_DONE | - TRIGGER_DEFERRED_CANCELED))) + if (!(event->dte_event & (TRIGGER_DEFERRED_DONE | + TRIGGER_DEFERRED_CANCELED))) { MemoryContextReset(per_tuple_context); @@ -1577,16 +1579,16 @@ deferredTriggerInvokeEvents(bool immediate_only) * should call it now. */ if (immediate_only && - deferredTriggerCheckState(event->dte_item[i].dti_tgoid, - event->dte_item[i].dti_state)) + deferredTriggerCheckState(event->dte_item[i].dti_tgoid, + event->dte_item[i].dti_state)) { still_deferred_ones = true; continue; } /* - * So let's fire it... but first, open the correct relation - * if this is not the same relation as before. + * So let's fire it... but first, open the correct + * relation if this is not the same relation as before. */ if (rel == NULL || rel->rd_id != event->dte_relid) { @@ -1596,14 +1598,14 @@ deferredTriggerInvokeEvents(bool immediate_only) pfree(finfo); /* - * We assume that an appropriate lock is still held by the - * executor, so grab no new lock here. + * We assume that an appropriate lock is still held by + * the executor, so grab no new lock here. */ rel = heap_open(event->dte_relid, NoLock); /* - * Allocate space to cache fmgr lookup info for triggers - * of this relation. + * Allocate space to cache fmgr lookup info for + * triggers of this relation. */ finfo = (FmgrInfo *) palloc(rel->trigdesc->numtriggers * sizeof(FmgrInfo)); @@ -1615,15 +1617,15 @@ deferredTriggerInvokeEvents(bool immediate_only) per_tuple_context); event->dte_item[i].dti_state |= TRIGGER_DEFERRED_DONE; - } /* end loop over items within event */ + } /* end loop over items within event */ } /* * If it's now completely done, throw it away. * * NB: it's possible the trigger calls above added more events to the - * queue, or that calls we will do later will want to add more, - * so we have to be careful about maintaining list validity here. + * queue, or that calls we will do later will want to add more, so + * we have to be careful about maintaining list validity here. */ next_event = event->dte_next; @@ -1724,6 +1726,7 @@ DeferredTriggerBeginXact(void) oldcxt = MemoryContextSwitchTo(deftrig_cxt); deftrig_all_isset = false; + /* * If unspecified, constraints default to IMMEDIATE, per SQL */ @@ -1827,8 +1830,8 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) /* * If called outside a transaction block, we can safely return: this - * command cannot effect any subsequent transactions, and there - * are no "session-level" trigger settings. + * command cannot effect any subsequent transactions, and there are no + * "session-level" trigger settings. */ if (!IsTransactionBlock()) return; @@ -1879,7 +1882,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) { char *cname = strVal(lfirst(l)); ScanKeyData skey; - SysScanDesc tgscan; + SysScanDesc tgscan; HeapTuple htup; /* @@ -1892,7 +1895,7 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) * Setup to scan pg_trigger by tgconstrname ... */ ScanKeyEntryInitialize(&skey, (bits16) 0x0, - (AttrNumber) Anum_pg_trigger_tgconstrname, + (AttrNumber) Anum_pg_trigger_tgconstrname, (RegProcedure) F_NAMEEQ, PointerGetDatum(cname)); @@ -1910,9 +1913,9 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) Oid constr_oid; /* - * If we found some, check that they fit the deferrability but - * skip ON <event> RESTRICT ones, since they are silently - * never deferrable. + * If we found some, check that they fit the deferrability + * but skip ON <event> RESTRICT ones, since they are + * silently never deferrable. */ if (stmt->deferred && !pg_trigger->tgdeferrable && pg_trigger->tgfoid != F_RI_FKEY_RESTRICT_UPD && @@ -1971,11 +1974,11 @@ DeferredTriggerSetState(ConstraintsSetStmt *stmt) /* * SQL99 requires that when a constraint is set to IMMEDIATE, any - * deferred checks against that constraint must be made when the - * SET CONSTRAINTS command is executed -- i.e. the effects of the - * SET CONSTRAINTS command applies retroactively. This happens "for - * free" since we have already made the necessary modifications to - * the constraints, and deferredTriggerEndQuery() is called by + * deferred checks against that constraint must be made when the SET + * CONSTRAINTS command is executed -- i.e. the effects of the SET + * CONSTRAINTS command applies retroactively. This happens "for free" + * since we have already made the necessary modifications to the + * constraints, and deferredTriggerEndQuery() is called by * finish_xact_command(). */ } @@ -2062,6 +2065,7 @@ DeferredTriggerSaveEvent(ResultRelInfo *relinfo, int event, break; case TRIGGER_EVENT_UPDATE: + /* * Check if one of the referenced keys is changed. */ diff --git a/src/backend/commands/typecmds.c b/src/backend/commands/typecmds.c index bb1250b357..165a42b7c3 100644 --- a/src/backend/commands/typecmds.c +++ b/src/backend/commands/typecmds.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.12 2002/08/29 00:17:03 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/typecmds.c,v 1.13 2002/09/04 20:31:16 momjian Exp $ * * DESCRIPTION * The "DefineFoo" routines take the parse tree and pick out the @@ -49,7 +49,7 @@ #include "utils/syscache.h" -static Oid findTypeIOFunction(List *procname, Oid typeOid, bool isOutput); +static Oid findTypeIOFunction(List *procname, Oid typeOid, bool isOutput); /* * DefineType @@ -101,15 +101,15 @@ DefineType(List *names, List *parameters) if (strcasecmp(defel->defname, "internallength") == 0) internalLength = defGetTypeLength(defel); else if (strcasecmp(defel->defname, "externallength") == 0) - ; /* ignored -- remove after 7.3 */ + ; /* ignored -- remove after 7.3 */ else if (strcasecmp(defel->defname, "input") == 0) inputName = defGetQualifiedName(defel); else if (strcasecmp(defel->defname, "output") == 0) outputName = defGetQualifiedName(defel); else if (strcasecmp(defel->defname, "send") == 0) - ; /* ignored -- remove after 7.3 */ + ; /* ignored -- remove after 7.3 */ else if (strcasecmp(defel->defname, "receive") == 0) - ; /* ignored -- remove after 7.3 */ + ; /* ignored -- remove after 7.3 */ else if (strcasecmp(defel->defname, "delimiter") == 0) { char *p = defGetString(defel); @@ -203,8 +203,9 @@ DefineType(List *names, List *parameters) outputOid = findTypeIOFunction(outputName, typoid, true); /* - * Verify that I/O procs return the expected thing. OPAQUE is an allowed, - * but deprecated, alternative to the fully type-safe choices. + * Verify that I/O procs return the expected thing. OPAQUE is an + * allowed, but deprecated, alternative to the fully type-safe + * choices. */ resulttype = get_func_rettype(inputOid); if (!(OidIsValid(typoid) && resulttype == typoid)) @@ -229,26 +230,26 @@ DefineType(List *names, List *parameters) * now have TypeCreate do all the real work. */ typoid = - TypeCreate(typeName, /* type name */ - typeNamespace, /* namespace */ - InvalidOid, /* preassigned type oid (not done here) */ - InvalidOid, /* relation oid (n/a here) */ - 0, /* relation kind (ditto) */ - internalLength, /* internal size */ - 'b', /* type-type (base type) */ - delimiter, /* array element delimiter */ - inputOid, /* input procedure */ - outputOid, /* output procedure */ - elemType, /* element type ID */ - InvalidOid, /* base type ID (only for domains) */ + TypeCreate(typeName, /* type name */ + typeNamespace, /* namespace */ + InvalidOid, /* preassigned type oid (not done here) */ + InvalidOid, /* relation oid (n/a here) */ + 0, /* relation kind (ditto) */ + internalLength, /* internal size */ + 'b', /* type-type (base type) */ + delimiter, /* array element delimiter */ + inputOid, /* input procedure */ + outputOid, /* output procedure */ + elemType, /* element type ID */ + InvalidOid, /* base type ID (only for domains) */ defaultValue, /* default type value */ - NULL, /* no binary form available */ - byValue, /* passed by value */ - alignment, /* required alignment */ - storage, /* TOAST strategy */ - -1, /* typMod (Domains only) */ - 0, /* Array Dimensions of typbasetype */ - false); /* Type NOT NULL */ + NULL, /* no binary form available */ + byValue, /* passed by value */ + alignment, /* required alignment */ + storage, /* TOAST strategy */ + -1, /* typMod (Domains only) */ + 0, /* Array Dimensions of typbasetype */ + false); /* Type NOT NULL */ /* * When we create a base type (as opposed to a complex type) we need @@ -392,7 +393,7 @@ DefineDomain(CreateDomainStmt *stmt) List *listptr; Oid basetypeoid; Oid domainoid; - Form_pg_type baseType; + Form_pg_type baseType; /* Convert list of names to a name and namespace */ domainNamespace = QualifiedNameGetCreationNamespace(stmt->domainname, @@ -406,7 +407,7 @@ DefineDomain(CreateDomainStmt *stmt) /* * Domainnames, unlike typenames don't need to account for the '_' - * prefix. So they can be one character longer. + * prefix. So they can be one character longer. */ if (strlen(domainName) > (NAMEDATALEN - 1)) elog(ERROR, "CREATE DOMAIN: domain names must be %d characters or less", @@ -421,9 +422,10 @@ DefineDomain(CreateDomainStmt *stmt) basetypeoid = HeapTupleGetOid(typeTup); /* - * Base type must be a plain base type. Domains over pseudo types would - * create a security hole. Domains of domains might be made to work in - * the future, but not today. Ditto for domains over complex types. + * Base type must be a plain base type. Domains over pseudo types + * would create a security hole. Domains of domains might be made to + * work in the future, but not today. Ditto for domains over complex + * types. */ typtype = baseType->typtype; if (typtype != 'b') @@ -450,13 +452,13 @@ DefineDomain(CreateDomainStmt *stmt) outputProcedure = baseType->typoutput; /* Inherited default value */ - datum = SysCacheGetAttr(TYPEOID, typeTup, + datum = SysCacheGetAttr(TYPEOID, typeTup, Anum_pg_type_typdefault, &isnull); if (!isnull) defaultValue = DatumGetCString(DirectFunctionCall1(textout, datum)); /* Inherited default binary value */ - datum = SysCacheGetAttr(TYPEOID, typeTup, + datum = SysCacheGetAttr(TYPEOID, typeTup, Anum_pg_type_typdefaultbin, &isnull); if (!isnull) defaultValueBin = DatumGetCString(DirectFunctionCall1(textout, datum)); @@ -469,11 +471,11 @@ DefineDomain(CreateDomainStmt *stmt) basetypelem = baseType->typelem; /* - * Run through constraints manually to avoid the additional - * processing conducted by DefineRelation() and friends. + * Run through constraints manually to avoid the additional processing + * conducted by DefineRelation() and friends. * - * Besides, we don't want any constraints to be cooked. We'll - * do that when the table is created via MergeDomainAttributes(). + * Besides, we don't want any constraints to be cooked. We'll do that + * when the table is created via MergeDomainAttributes(). */ foreach(listptr, schema) { @@ -482,77 +484,79 @@ DefineDomain(CreateDomainStmt *stmt) switch (colDef->contype) { - /* - * The inherited default value may be overridden by the user - * with the DEFAULT <expr> statement. - * - * We have to search the entire constraint tree returned as we - * don't want to cook or fiddle too much. - */ + /* + * The inherited default value may be overridden by the + * user with the DEFAULT <expr> statement. + * + * We have to search the entire constraint tree returned as + * we don't want to cook or fiddle too much. + */ case CONSTR_DEFAULT: if (defaultExpr) elog(ERROR, "CREATE DOMAIN has multiple DEFAULT expressions"); /* Create a dummy ParseState for transformExpr */ pstate = make_parsestate(NULL); + /* - * Cook the colDef->raw_expr into an expression. - * Note: Name is strictly for error message + * Cook the colDef->raw_expr into an expression. Note: + * Name is strictly for error message */ defaultExpr = cookDefault(pstate, colDef->raw_expr, basetypeoid, stmt->typename->typmod, domainName); + /* - * Expression must be stored as a nodeToString result, - * but we also require a valid textual representation - * (mainly to make life easier for pg_dump). + * Expression must be stored as a nodeToString result, but + * we also require a valid textual representation (mainly + * to make life easier for pg_dump). */ defaultValue = deparse_expression(defaultExpr, - deparse_context_for(domainName, - InvalidOid), - false); + deparse_context_for(domainName, + InvalidOid), + false); defaultValueBin = nodeToString(defaultExpr); break; - /* - * Find the NULL constraint. - */ + /* + * Find the NULL constraint. + */ case CONSTR_NOTNULL: if (nullDefined) elog(ERROR, "CREATE DOMAIN has conflicting NULL / NOT NULL constraint"); typNotNull = true; nullDefined = true; - break; + break; case CONSTR_NULL: if (nullDefined) elog(ERROR, "CREATE DOMAIN has conflicting NULL / NOT NULL constraint"); typNotNull = false; nullDefined = true; - break; + break; - case CONSTR_UNIQUE: - elog(ERROR, "CREATE DOMAIN / UNIQUE indexes not supported"); - break; + case CONSTR_UNIQUE: + elog(ERROR, "CREATE DOMAIN / UNIQUE indexes not supported"); + break; - case CONSTR_PRIMARY: - elog(ERROR, "CREATE DOMAIN / PRIMARY KEY indexes not supported"); - break; + case CONSTR_PRIMARY: + elog(ERROR, "CREATE DOMAIN / PRIMARY KEY indexes not supported"); + break; - case CONSTR_CHECK: - elog(ERROR, "DefineDomain: CHECK Constraints not supported"); - break; + case CONSTR_CHECK: + elog(ERROR, "DefineDomain: CHECK Constraints not supported"); + break; - case CONSTR_ATTR_DEFERRABLE: - case CONSTR_ATTR_NOT_DEFERRABLE: - case CONSTR_ATTR_DEFERRED: - case CONSTR_ATTR_IMMEDIATE: - elog(ERROR, "DefineDomain: DEFERRABLE, NON DEFERRABLE, DEFERRED and IMMEDIATE not supported"); - break; + case CONSTR_ATTR_DEFERRABLE: + case CONSTR_ATTR_NOT_DEFERRABLE: + case CONSTR_ATTR_DEFERRED: + case CONSTR_ATTR_IMMEDIATE: + elog(ERROR, "DefineDomain: DEFERRABLE, NON DEFERRABLE, DEFERRED and IMMEDIATE not supported"); + break; default: - elog(ERROR, "DefineDomain: unrecognized constraint node type"); - break; + elog(ERROR, "DefineDomain: unrecognized constraint node type"); + break; } } @@ -560,33 +564,33 @@ DefineDomain(CreateDomainStmt *stmt) * Have TypeCreate do all the real work. */ domainoid = - TypeCreate(domainName, /* type name */ + TypeCreate(domainName, /* type name */ domainNamespace, /* namespace */ - InvalidOid, /* preassigned type oid (none here) */ - InvalidOid, /* relation oid (n/a here) */ - 0, /* relation kind (ditto) */ + InvalidOid, /* preassigned type oid (none here) */ + InvalidOid, /* relation oid (n/a here) */ + 0, /* relation kind (ditto) */ internalLength, /* internal size */ - 'd', /* type-type (domain type) */ - delimiter, /* array element delimiter */ + 'd', /* type-type (domain type) */ + delimiter, /* array element delimiter */ inputProcedure, /* input procedure */ outputProcedure, /* output procedure */ - basetypelem, /* element type ID */ - basetypeoid, /* base type ID */ - defaultValue, /* default type value (text) */ + basetypelem, /* element type ID */ + basetypeoid, /* base type ID */ + defaultValue, /* default type value (text) */ defaultValueBin, /* default type value (binary) */ - byValue, /* passed by value */ - alignment, /* required alignment */ - storage, /* TOAST strategy */ - stmt->typename->typmod, /* typeMod value */ - typNDims, /* Array dimensions for base type */ - typNotNull); /* Type NOT NULL */ + byValue, /* passed by value */ + alignment, /* required alignment */ + storage, /* TOAST strategy */ + stmt->typename->typmod, /* typeMod value */ + typNDims, /* Array dimensions for base type */ + typNotNull); /* Type NOT NULL */ /* * Add any dependencies needed for the default expression. */ if (defaultExpr) { - ObjectAddress domobject; + ObjectAddress domobject; domobject.classId = RelOid_pg_type; domobject.objectId = domainoid; @@ -678,10 +682,10 @@ findTypeIOFunction(List *procname, Oid typeOid, bool isOutput) if (isOutput) { /* - * Output functions can take a single argument of the type, - * or two arguments (data value, element OID). The signature - * may use OPAQUE in place of the actual type name; this is the - * only possibility if the type doesn't yet exist as a shell. + * Output functions can take a single argument of the type, or two + * arguments (data value, element OID). The signature may use + * OPAQUE in place of the actual type name; this is the only + * possibility if the type doesn't yet exist as a shell. * * Note: although we could throw a NOTICE in this routine if OPAQUE * is used, we do not because of the probability that it'd be @@ -728,8 +732,8 @@ findTypeIOFunction(List *procname, Oid typeOid, bool isOutput) else { /* - * Input functions can take a single argument of type CSTRING, - * or three arguments (string, element OID, typmod). The signature + * Input functions can take a single argument of type CSTRING, or + * three arguments (string, element OID, typmod). The signature * may use OPAQUE in place of CSTRING. */ MemSet(argList, 0, FUNC_MAX_ARGS * sizeof(Oid)); @@ -793,7 +797,7 @@ DefineCompositeType(const RangeVar *typevar, List *coldeflist) if (coldeflist == NIL) elog(ERROR, "attempted to define composite type relation with" - " no attrs"); + " no attrs"); /* * now create the parameters for keys/inheritance etc. All of them are diff --git a/src/backend/commands/user.c b/src/backend/commands/user.c index 8a4b31f443..620e1bed23 100644 --- a/src/backend/commands/user.c +++ b/src/backend/commands/user.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.110 2002/09/02 02:47:01 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/user.c,v 1.111 2002/09/04 20:31:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ extern bool Password_encryption; static void CheckPgUserAclNotNull(void); static void UpdateGroupMembership(Relation group_rel, HeapTuple group_tuple, - List *members); + List *members); static IdList *IdListToArray(List *members); static List *IdArrayToList(IdList *oldarray); @@ -52,7 +52,8 @@ static List *IdArrayToList(IdList *oldarray); * Outputs string in quotes, with double-quotes duplicated. * We could use quote_ident(), but that expects a TEXT argument. */ -static void fputs_quote(char *str, FILE *fp) +static void +fputs_quote(char *str, FILE *fp) { fputc('"', fp); while (*str) @@ -79,7 +80,7 @@ group_getfilename(void) char *pfnam; bufsize = strlen(DataDir) + strlen("/global/") + - strlen(USER_GROUP_FILE) + 1; + strlen(USER_GROUP_FILE) + 1; pfnam = (char *) palloc(bufsize); snprintf(pfnam, bufsize, "%s/global/%s", DataDir, USER_GROUP_FILE); @@ -99,7 +100,7 @@ user_getfilename(void) char *pfnam; bufsize = strlen(DataDir) + strlen("/global/") + - strlen(PWD_FILE) + 1; + strlen(PWD_FILE) + 1; pfnam = (char *) palloc(bufsize); snprintf(pfnam, bufsize, "%s/global/%s", DataDir, PWD_FILE); @@ -125,8 +126,8 @@ write_group_file(Relation urel, Relation grel) /* * Create a temporary filename to be renamed later. This prevents the - * backend from clobbering the pg_group file while the postmaster might - * be reading from it. + * backend from clobbering the pg_group file while the postmaster + * might be reading from it. */ filename = group_getfilename(); bufsize = strlen(filename) + 12; @@ -143,14 +144,16 @@ write_group_file(Relation urel, Relation grel) scan = heap_beginscan(grel, SnapshotSelf, 0, NULL); while ((tuple = heap_getnext(scan, ForwardScanDirection)) != NULL) { - Datum datum, grolist_datum; + Datum datum, + grolist_datum; bool isnull; char *groname; IdList *grolist_p; AclId *aidp; - int i, j, + int i, + j, num; - char *usename; + char *usename; bool first_user = true; datum = heap_getattr(tuple, Anum_pg_group_groname, dsc, &isnull); @@ -199,8 +202,8 @@ write_group_file(Relation urel, Relation grel) continue; } - /* File format is: - * "dbname" "user1" "user2" "user3" + /* + * File format is: "dbname" "user1" "user2" "user3" */ if (first_user) { @@ -833,8 +836,8 @@ AlterUserSet(AlterUserSetStmt *stmt) valuestr = flatten_set_variable_args(stmt->variable, stmt->value); /* - * RowExclusiveLock is sufficient, because we don't need to update - * the flat password file. + * RowExclusiveLock is sufficient, because we don't need to update the + * flat password file. */ rel = heap_openr(ShadowRelationName, RowExclusiveLock); oldtuple = SearchSysCache(SHADOWNAME, @@ -844,23 +847,23 @@ AlterUserSet(AlterUserSetStmt *stmt) elog(ERROR, "user \"%s\" does not exist", stmt->user); if (!(superuser() - || ((Form_pg_shadow) GETSTRUCT(oldtuple))->usesysid == GetUserId())) + || ((Form_pg_shadow) GETSTRUCT(oldtuple))->usesysid == GetUserId())) elog(ERROR, "permission denied"); for (i = 0; i < Natts_pg_shadow; i++) repl_repl[i] = ' '; - repl_repl[Anum_pg_shadow_useconfig-1] = 'r'; - if (strcmp(stmt->variable, "all")==0 && valuestr == NULL) + repl_repl[Anum_pg_shadow_useconfig - 1] = 'r'; + if (strcmp(stmt->variable, "all") == 0 && valuestr == NULL) /* RESET ALL */ - repl_null[Anum_pg_shadow_useconfig-1] = 'n'; + repl_null[Anum_pg_shadow_useconfig - 1] = 'n'; else { - Datum datum; - bool isnull; - ArrayType *array; + Datum datum; + bool isnull; + ArrayType *array; - repl_null[Anum_pg_shadow_useconfig-1] = ' '; + repl_null[Anum_pg_shadow_useconfig - 1] = ' '; datum = SysCacheGetAttr(SHADOWNAME, oldtuple, Anum_pg_shadow_useconfig, &isnull); @@ -872,7 +875,7 @@ AlterUserSet(AlterUserSetStmt *stmt) else array = GUCArrayDelete(array, stmt->variable); - repl_val[Anum_pg_shadow_useconfig-1] = PointerGetDatum(array); + repl_val[Anum_pg_shadow_useconfig - 1] = PointerGetDatum(array); } newtuple = heap_modifytuple(oldtuple, rel, repl_val, repl_null, repl_repl); @@ -1253,12 +1256,12 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) * create user */ { /* - * convert the to be added usernames to sysids and add them to - * the list + * convert the to be added usernames to sysids and add them to the + * list */ foreach(item, stmt->listUsers) { - int32 sysid; + int32 sysid; if (strcmp(tag, "ALTER GROUP") == 0) { @@ -1282,6 +1285,7 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) if (!intMember(sysid, newlist)) newlist = lappendi(newlist, sysid); else + /* * we silently assume here that this error will only come * up in a ALTER GROUP statement @@ -1306,8 +1310,8 @@ AlterGroup(AlterGroupStmt *stmt, const char *tag) else { /* - * convert the to be dropped usernames to sysids and - * remove them from the list + * convert the to be dropped usernames to sysids and remove + * them from the list */ foreach(item, stmt->listUsers) { @@ -1375,7 +1379,7 @@ UpdateGroupMembership(Relation group_rel, HeapTuple group_tuple, new_record_repl[Anum_pg_group_grolist - 1] = 'r'; tuple = heap_modifytuple(group_tuple, group_rel, - new_record, new_record_nulls, new_record_repl); + new_record, new_record_nulls, new_record_repl); simple_heap_update(group_rel, &group_tuple->t_self, tuple); @@ -1401,12 +1405,10 @@ IdListToArray(List *members) newarray->elemtype = INT4OID; ARR_NDIM(newarray) = 1; /* one dimensional array */ ARR_LBOUND(newarray)[0] = 1; /* axis starts at one */ - ARR_DIMS(newarray)[0] = nmembers; /* axis is this long */ + ARR_DIMS(newarray)[0] = nmembers; /* axis is this long */ i = 0; foreach(item, members) - { ((int *) ARR_DATA_PTR(newarray))[i++] = lfirsti(item); - } return newarray; } diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 3e8cc79596..a9b2e4206e 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.236 2002/09/02 01:05:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuum.c,v 1.237 2002/09/04 20:31:16 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -100,7 +100,7 @@ typedef struct VRelStats static MemoryContext vac_context = NULL; -static int elevel = -1; +static int elevel = -1; static TransactionId OldestXmin; static TransactionId FreezeLimit; @@ -204,8 +204,9 @@ vacuum(VacuumStmt *vacstmt) ALLOCSET_DEFAULT_MAXSIZE); /* - * If we are running only ANALYZE, we don't need per-table transactions, - * but we still need a memory context with table lifetime. + * If we are running only ANALYZE, we don't need per-table + * transactions, but we still need a memory context with table + * lifetime. */ if (vacstmt->analyze && !vacstmt->vacuum) anl_context = AllocSetContextCreate(QueryContext, @@ -221,29 +222,29 @@ vacuum(VacuumStmt *vacstmt) * Formerly, there was code here to prevent more than one VACUUM from * executing concurrently in the same database. However, there's no * good reason to prevent that, and manually removing lockfiles after - * a vacuum crash was a pain for dbadmins. So, forget about lockfiles, - * and just rely on the locks we grab on each target table + * a vacuum crash was a pain for dbadmins. So, forget about + * lockfiles, and just rely on the locks we grab on each target table * to ensure that there aren't two VACUUMs running on the same table * at the same time. */ /* - * The strangeness with committing and starting transactions here is due - * to wanting to run each table's VACUUM as a separate transaction, so - * that we don't hold locks unnecessarily long. Also, if we are doing - * VACUUM ANALYZE, the ANALYZE part runs as a separate transaction from - * the VACUUM to further reduce locking. + * The strangeness with committing and starting transactions here is + * due to wanting to run each table's VACUUM as a separate + * transaction, so that we don't hold locks unnecessarily long. Also, + * if we are doing VACUUM ANALYZE, the ANALYZE part runs as a separate + * transaction from the VACUUM to further reduce locking. * * vacuum_rel expects to be entered with no transaction active; it will * start and commit its own transaction. But we are called by an SQL * command, and so we are executing inside a transaction already. We * commit the transaction started in PostgresMain() here, and start - * another one before exiting to match the commit waiting for us back in - * PostgresMain(). + * another one before exiting to match the commit waiting for us back + * in PostgresMain(). * * In the case of an ANALYZE statement (no vacuum, just analyze) it's - * okay to run the whole thing in the outer transaction, and so we skip - * transaction start/stop operations. + * okay to run the whole thing in the outer transaction, and so we + * skip transaction start/stop operations. */ if (vacstmt->vacuum) { @@ -254,22 +255,23 @@ vacuum(VacuumStmt *vacstmt) * * Compute the initially applicable OldestXmin and FreezeLimit * XIDs, so that we can record these values at the end of the - * VACUUM. Note that individual tables may well be processed with - * newer values, but we can guarantee that no (non-shared) - * relations are processed with older ones. + * VACUUM. Note that individual tables may well be processed + * with newer values, but we can guarantee that no + * (non-shared) relations are processed with older ones. * - * It is okay to record non-shared values in pg_database, even though - * we may vacuum shared relations with older cutoffs, because only - * the minimum of the values present in pg_database matters. We - * can be sure that shared relations have at some time been - * vacuumed with cutoffs no worse than the global minimum; for, if - * there is a backend in some other DB with xmin = OLDXMIN that's - * determining the cutoff with which we vacuum shared relations, - * it is not possible for that database to have a cutoff newer - * than OLDXMIN recorded in pg_database. + * It is okay to record non-shared values in pg_database, even + * though we may vacuum shared relations with older cutoffs, + * because only the minimum of the values present in + * pg_database matters. We can be sure that shared relations + * have at some time been vacuumed with cutoffs no worse than + * the global minimum; for, if there is a backend in some + * other DB with xmin = OLDXMIN that's determining the cutoff + * with which we vacuum shared relations, it is not possible + * for that database to have a cutoff newer than OLDXMIN + * recorded in pg_database. */ vacuum_set_xid_limits(vacstmt, false, - &initialOldestXmin, &initialFreezeLimit); + &initialOldestXmin, &initialFreezeLimit); } /* matches the StartTransaction in PostgresMain() */ @@ -281,7 +283,7 @@ vacuum(VacuumStmt *vacstmt) */ foreach(cur, vrl) { - Oid relid = (Oid) lfirsti(cur); + Oid relid = (Oid) lfirsti(cur); if (vacstmt->vacuum) vacuum_rel(relid, vacstmt, RELKIND_RELATION); @@ -290,10 +292,11 @@ vacuum(VacuumStmt *vacstmt) MemoryContext old_context = NULL; /* - * If we vacuumed, use new transaction for analyze. Otherwise, - * we can use the outer transaction, but we still need to call - * analyze_rel in a memory context that will be cleaned up on - * return (else we leak memory while processing multiple tables). + * If we vacuumed, use new transaction for analyze. + * Otherwise, we can use the outer transaction, but we still + * need to call analyze_rel in a memory context that will be + * cleaned up on return (else we leak memory while processing + * multiple tables). */ if (vacstmt->vacuum) StartTransactionCommand(true); @@ -320,16 +323,17 @@ vacuum(VacuumStmt *vacstmt) /* here, we are not in a transaction */ /* - * This matches the CommitTransaction waiting for us in PostgresMain(). - * We tell xact.c not to chain the upcoming commit, so that a VACUUM - * doesn't start a transaction block, even when autocommit is off. + * This matches the CommitTransaction waiting for us in + * PostgresMain(). We tell xact.c not to chain the upcoming + * commit, so that a VACUUM doesn't start a transaction block, + * even when autocommit is off. */ StartTransactionCommand(true); /* - * If we did a database-wide VACUUM, update the database's pg_database - * row with info about the transaction IDs used, and try to truncate - * pg_clog. + * If we did a database-wide VACUUM, update the database's + * pg_database row with info about the transaction IDs used, and + * try to truncate pg_clog. */ if (vacstmt->relation == NULL) { @@ -366,7 +370,7 @@ getrels(const RangeVar *vacrel, const char *stmttype) if (vacrel) { /* Process specific relation */ - Oid relid; + Oid relid; relid = RangeVarGetRelid(vacrel, false); @@ -517,9 +521,9 @@ vac_update_relstats(Oid relid, BlockNumber num_pages, double num_tuples, /* * Invalidate the tuple in the catcaches; this also arranges to flush - * the relation's relcache entry. (If we fail to commit for some reason, - * no flush will occur, but no great harm is done since there are no - * noncritical state updates here.) + * the relation's relcache entry. (If we fail to commit for some + * reason, no flush will occur, but no great harm is done since there + * are no noncritical state updates here.) */ CacheInvalidateHeapTuple(rd, &rtup); @@ -647,8 +651,8 @@ vac_truncate_clog(TransactionId vacuumXID, TransactionId frozenXID) heap_close(relation, AccessShareLock); /* - * Do not truncate CLOG if we seem to have suffered wraparound already; - * the computed minimum XID might be bogus. + * Do not truncate CLOG if we seem to have suffered wraparound + * already; the computed minimum XID might be bogus. */ if (vacuumAlreadyWrapped) { @@ -740,7 +744,8 @@ vacuum_rel(Oid relid, VacuumStmt *vacstmt, char expected_relkind) * * We allow the user to vacuum a table if he is superuser, the table * owner, or the database owner (but in the latter case, only if it's - * not a shared relation). pg_class_ownercheck includes the superuser case. + * not a shared relation). pg_class_ownercheck includes the superuser + * case. * * Note we choose to treat permissions failure as a WARNING and keep * trying to vacuum the rest of the DB --- is this appropriate? @@ -1581,21 +1586,23 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, * by "recent" transactions then we have to move all chain of * tuples to another places. * - * NOTE: this test is not 100% accurate: it is possible for - * a tuple to be an updated one with recent xmin, and yet not - * have a corresponding tuple in the vtlinks list. Presumably + * NOTE: this test is not 100% accurate: it is possible for a + * tuple to be an updated one with recent xmin, and yet not + * have a corresponding tuple in the vtlinks list. Presumably * there was once a parent tuple with xmax matching the xmin, * but it's possible that that tuple has been removed --- for - * example, if it had xmin = xmax then HeapTupleSatisfiesVacuum - * would deem it removable as soon as the xmin xact completes. + * example, if it had xmin = xmax then + * HeapTupleSatisfiesVacuum would deem it removable as soon as + * the xmin xact completes. * * To be on the safe side, we abandon the repair_frag process if - * we cannot find the parent tuple in vtlinks. This may be overly - * conservative; AFAICS it would be safe to move the chain. + * we cannot find the parent tuple in vtlinks. This may be + * overly conservative; AFAICS it would be safe to move the + * chain. */ if (((tuple.t_data->t_infomask & HEAP_UPDATED) && !TransactionIdPrecedes(HeapTupleHeaderGetXmin(tuple.t_data), - OldestXmin)) || + OldestXmin)) || (!(tuple.t_data->t_infomask & (HEAP_XMAX_INVALID | HEAP_MARKED_FOR_UPDATE)) && !(ItemPointerEquals(&(tuple.t_self), @@ -1626,7 +1633,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (vacrelstats->vtlinks == NULL) { elog(WARNING, "Parent item in update-chain not found - can't continue repair_frag"); - break; /* out of walk-along-page loop */ + break; /* out of walk-along-page loop */ } vtmove = (VTupleMove) palloc(100 * sizeof(VTupleMoveData)); @@ -1638,7 +1645,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, * we have to move to the end of chain. */ while (!(tp.t_data->t_infomask & (HEAP_XMAX_INVALID | - HEAP_MARKED_FOR_UPDATE)) && + HEAP_MARKED_FOR_UPDATE)) && !(ItemPointerEquals(&(tp.t_self), &(tp.t_data->t_ctid)))) { @@ -1704,7 +1711,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, { /* can't move item anywhere */ chain_move_failed = true; - break; /* out of check-all-items loop */ + break; /* out of check-all-items loop */ } to_item = i; to_vacpage = fraged_pages->pagedesc[to_item]; @@ -1732,8 +1739,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* At beginning of chain? */ if (!(tp.t_data->t_infomask & HEAP_UPDATED) || - TransactionIdPrecedes(HeapTupleHeaderGetXmin(tp.t_data), - OldestXmin)) + TransactionIdPrecedes(HeapTupleHeaderGetXmin(tp.t_data), + OldestXmin)) break; /* No, move to tuple with prior row version */ @@ -1749,14 +1756,14 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* see discussion above */ elog(WARNING, "Parent item in update-chain not found - can't continue repair_frag"); chain_move_failed = true; - break; /* out of check-all-items loop */ + break; /* out of check-all-items loop */ } tp.t_self = vtlp->this_tid; Pbuf = ReadBuffer(onerel, - ItemPointerGetBlockNumber(&(tp.t_self))); + ItemPointerGetBlockNumber(&(tp.t_self))); Ppage = BufferGetPage(Pbuf); Pitemid = PageGetItemId(Ppage, - ItemPointerGetOffsetNumber(&(tp.t_self))); + ItemPointerGetOffsetNumber(&(tp.t_self))); /* this can't happen since we saw tuple earlier: */ if (!ItemIdIsUsed(Pitemid)) elog(ERROR, "Parent itemid marked as unused"); @@ -1768,25 +1775,24 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, &(Ptp.t_data->t_ctid))); /* - * Read above about cases when - * !ItemIdIsUsed(Citemid) (child item is - * removed)... Due to the fact that at the moment - * we don't remove unuseful part of update-chain, - * it's possible to get too old parent row here. - * Like as in the case which caused this problem, - * we stop shrinking here. I could try to find - * real parent row but want not to do it because - * of real solution will be implemented anyway, - * later, and we are too close to 6.5 release. - - * vadim 06/11/99 + * Read above about cases when !ItemIdIsUsed(Citemid) + * (child item is removed)... Due to the fact that at + * the moment we don't remove unuseful part of + * update-chain, it's possible to get too old parent + * row here. Like as in the case which caused this + * problem, we stop shrinking here. I could try to + * find real parent row but want not to do it because + * of real solution will be implemented anyway, later, + * and we are too close to 6.5 release. - vadim + * 06/11/99 */ if (!(TransactionIdEquals(HeapTupleHeaderGetXmax(Ptp.t_data), - HeapTupleHeaderGetXmin(tp.t_data)))) + HeapTupleHeaderGetXmin(tp.t_data)))) { ReleaseBuffer(Pbuf); elog(WARNING, "Too old parent tuple found - can't continue repair_frag"); chain_move_failed = true; - break; /* out of check-all-items loop */ + break; /* out of check-all-items loop */ } tp.t_datamcxt = Ptp.t_datamcxt; tp.t_data = Ptp.t_data; @@ -1795,7 +1801,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, ReleaseBuffer(Cbuf); Cbuf = Pbuf; freeCbuf = true; - } /* end of check-all-items loop */ + } /* end of check-all-items loop */ if (freeCbuf) ReleaseBuffer(Cbuf); @@ -1804,9 +1810,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, if (chain_move_failed) { /* - * Undo changes to offsets_used state. We don't bother - * cleaning up the amount-free state, since we're not - * going to do any further tuple motion. + * Undo changes to offsets_used state. We don't + * bother cleaning up the amount-free state, since + * we're not going to do any further tuple motion. */ for (i = 0; i < num_vtmove; i++) { @@ -1939,7 +1945,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } else { - /* No XLOG record, but still need to flag that XID exists on disk */ + /* + * No XLOG record, but still need to flag that XID + * exists on disk + */ MyXactMadeTempRelUpdate = true; } @@ -1985,7 +1994,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, WriteBuffer(cur_buffer); WriteBuffer(Cbuf); - } /* end of move-the-tuple-chain loop */ + } /* end of move-the-tuple-chain loop */ cur_buffer = InvalidBuffer; pfree(vtmove); @@ -1993,7 +2002,7 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* advance to next tuple in walk-along-page loop */ continue; - } /* end of is-tuple-in-chain test */ + } /* end of is-tuple-in-chain test */ /* try to find new page for this tuple */ if (cur_buffer == InvalidBuffer || @@ -2031,10 +2040,9 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, /* * register invalidation of source tuple in catcaches. * - * (Note: we do not need to register the copied tuple, - * because we are not changing the tuple contents and - * so there cannot be any need to flush negative - * catcache entries.) + * (Note: we do not need to register the copied tuple, because we + * are not changing the tuple contents and so there cannot be + * any need to flush negative catcache entries.) */ CacheInvalidateHeapTuple(onerel, &tuple); @@ -2090,7 +2098,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } else { - /* No XLOG record, but still need to flag that XID exists on disk */ + /* + * No XLOG record, but still need to flag that XID exists + * on disk + */ MyXactMadeTempRelUpdate = true; } @@ -2116,8 +2127,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } /* walk along page */ /* - * If we broke out of the walk-along-page loop early (ie, still have - * offnum <= maxoff), then we failed to move some tuple off + * If we broke out of the walk-along-page loop early (ie, still + * have offnum <= maxoff), then we failed to move some tuple off * this page. No point in shrinking any more, so clean up and * exit the per-page loop. */ @@ -2126,7 +2137,8 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, OffsetNumber off; /* - * Fix vacpage state for any unvisited tuples remaining on page + * Fix vacpage state for any unvisited tuples remaining on + * page */ for (off = OffsetNumberNext(offnum); off <= maxoff; @@ -2389,7 +2401,10 @@ repair_frag(VRelStats *vacrelstats, Relation onerel, } else { - /* No XLOG record, but still need to flag that XID exists on disk */ + /* + * No XLOG record, but still need to flag that XID exists + * on disk + */ MyXactMadeTempRelUpdate = true; } diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c index 4fb613cc67..023472e221 100644 --- a/src/backend/commands/vacuumlazy.c +++ b/src/backend/commands/vacuumlazy.c @@ -31,7 +31,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.18 2002/08/06 02:36:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/vacuumlazy.c,v 1.19 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ typedef struct LVRelStats } LVRelStats; -static int elevel = -1; +static int elevel = -1; static TransactionId OldestXmin; static TransactionId FreezeLimit; @@ -756,7 +756,7 @@ lazy_truncate_heap(Relation onerel, LVRelStats *vacrelstats) */ elog(elevel, "Truncated %u --> %u pages.\n\t%s", old_rel_pages, - new_rel_pages, vac_show_rusage(&ru0)); + new_rel_pages, vac_show_rusage(&ru0)); } /* diff --git a/src/backend/commands/variable.c b/src/backend/commands/variable.c index 55a11a766c..6f6f50a908 100644 --- a/src/backend/commands/variable.c +++ b/src/backend/commands/variable.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.70 2002/07/18 02:02:29 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/variable.c,v 1.71 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -111,8 +111,8 @@ assign_datestyle(const char *value, bool doit, bool interactive) * Easiest way to get the current DEFAULT state is to fetch * the DEFAULT string from guc.c and recursively parse it. * - * We can't simply "return assign_datestyle(...)" because we - * need to handle constructs like "DEFAULT, ISO". + * We can't simply "return assign_datestyle(...)" because we need + * to handle constructs like "DEFAULT, ISO". */ int saveDateStyle = DateStyle; bool saveEuroDates = EuroDates; @@ -164,7 +164,7 @@ assign_datestyle(const char *value, bool doit, bool interactive) return value; /* - * Prepare the canonical string to return. GUC wants it malloc'd. + * Prepare the canonical string to return. GUC wants it malloc'd. */ result = (char *) malloc(32); if (!result) @@ -188,8 +188,8 @@ assign_datestyle(const char *value, bool doit, bool interactive) strcat(result, newEuroDates ? ", EURO" : ", US"); /* - * Finally, it's safe to assign to the global variables; - * the assignment cannot fail now. + * Finally, it's safe to assign to the global variables; the + * assignment cannot fail now. */ DateStyle = newDateStyle; EuroDates = newEuroDates; @@ -203,7 +203,7 @@ assign_datestyle(const char *value, bool doit, bool interactive) const char * show_datestyle(void) { - static char buf[64]; + static char buf[64]; switch (DateStyle) { @@ -270,6 +270,7 @@ assign_timezone(const char *value, bool doit, bool interactive) return NULL; } *endptr = '\0'; + /* * Try to parse it. XXX an invalid interval format will result in * elog, which is not desirable for GUC. We did what we could to @@ -277,9 +278,9 @@ assign_timezone(const char *value, bool doit, bool interactive) * coming in from postgresql.conf might contain anything. */ interval = DatumGetIntervalP(DirectFunctionCall3(interval_in, - CStringGetDatum(val), - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + CStringGetDatum(val), + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); pfree(val); if (interval->month != 0) { @@ -318,8 +319,8 @@ assign_timezone(const char *value, bool doit, bool interactive) * available under Solaris, among others. Apparently putenv() * called as below clears the process-specific environment * variables. Other reasonable arguments to putenv() (e.g. - * "TZ=", "TZ", "") result in a core dump (under Linux anyway). - * - thomas 1998-01-26 + * "TZ=", "TZ", "") result in a core dump (under Linux + * anyway). - thomas 1998-01-26 */ if (doit) { @@ -339,13 +340,14 @@ assign_timezone(const char *value, bool doit, bool interactive) * Otherwise assume it is a timezone name. * * XXX unfortunately we have no reasonable way to check whether a - * timezone name is good, so we have to just assume that it is. + * timezone name is good, so we have to just assume that it + * is. */ if (doit) { strcpy(tzbuf, "TZ="); - strncat(tzbuf, value, sizeof(tzbuf)-4); - if (putenv(tzbuf) != 0) /* shouldn't happen? */ + strncat(tzbuf, value, sizeof(tzbuf) - 4); + if (putenv(tzbuf) != 0) /* shouldn't happen? */ elog(LOG, "assign_timezone: putenv failed"); tzset(); HasCTZSet = false; @@ -360,7 +362,7 @@ assign_timezone(const char *value, bool doit, bool interactive) return value; /* - * Prepare the canonical string to return. GUC wants it malloc'd. + * Prepare the canonical string to return. GUC wants it malloc'd. */ result = (char *) malloc(sizeof(tzbuf)); if (!result) @@ -372,13 +374,9 @@ assign_timezone(const char *value, bool doit, bool interactive) (double) CTimeZone / 3600.0); } else if (tzbuf[0] == 'T') - { strcpy(result, tzbuf + 3); - } else - { strcpy(result, "UNKNOWN"); - } return result; } @@ -399,7 +397,7 @@ show_timezone(void) interval.time = CTimeZone; tzn = DatumGetCString(DirectFunctionCall1(interval_out, - IntervalPGetDatum(&interval))); + IntervalPGetDatum(&interval))); } else tzn = getenv("TZ"); @@ -422,11 +420,20 @@ assign_XactIsoLevel(const char *value, bool doit, bool interactive) elog(ERROR, "SET TRANSACTION ISOLATION LEVEL must be called before any query"); if (strcmp(value, "serializable") == 0) - { if (doit) XactIsoLevel = XACT_SERIALIZABLE; } + { + if (doit) + XactIsoLevel = XACT_SERIALIZABLE; + } else if (strcmp(value, "read committed") == 0) - { if (doit) XactIsoLevel = XACT_READ_COMMITTED; } + { + if (doit) + XactIsoLevel = XACT_READ_COMMITTED; + } else if (strcmp(value, "default") == 0) - { if (doit) XactIsoLevel = DefaultXactIsoLevel; } + { + if (doit) + XactIsoLevel = DefaultXactIsoLevel; + } else return NULL; @@ -475,11 +482,12 @@ assign_client_encoding(const char *value, bool doit, bool interactive) encoding = pg_valid_client_encoding(value); if (encoding < 0) return NULL; - - /* XXX SetClientEncoding depends on namespace functions which are - * not available at startup time. So we accept requested client - * encoding anyway which might not be valid (e.g. no conversion - * procs available). + + /* + * XXX SetClientEncoding depends on namespace functions which are not + * available at startup time. So we accept requested client encoding + * anyway which might not be valid (e.g. no conversion procs + * available). */ if (SetClientEncoding(encoding, doit) < 0) { diff --git a/src/backend/commands/view.c b/src/backend/commands/view.c index 91420319a8..0ce309750c 100644 --- a/src/backend/commands/view.c +++ b/src/backend/commands/view.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.70 2002/09/02 20:04:40 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/commands/view.c,v 1.71 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) * the (non-junk) targetlist items from the view's SELECT list. */ attrList = NIL; - foreach (t, tlist) + foreach(t, tlist) { TargetEntry *entry = lfirst(t); Resdom *res = entry->resdom; @@ -115,32 +115,32 @@ DefineVirtualRelation(const RangeVar *relation, List *tlist, bool replace) * Create a tuple descriptor to compare against the existing view, * and verify it matches. */ - descriptor = BuildDescForRelation(attrList); + descriptor = BuildDescForRelation(attrList); checkViewTupleDesc(descriptor, rel->rd_att); /* * Seems okay, so return the OID of the pre-existing view. */ - relation_close(rel, NoLock); /* keep the lock! */ + relation_close(rel, NoLock); /* keep the lock! */ return viewOid; } else { /* - * now create the parameters for keys/inheritance etc. All of them are - * nil... + * now create the parameters for keys/inheritance etc. All of them + * are nil... */ createStmt->relation = (RangeVar *) relation; createStmt->tableElts = attrList; createStmt->inhRelations = NIL; createStmt->constraints = NIL; createStmt->hasoids = false; - + /* - * finally create the relation (this will error out if there's - * an existing view, so we don't need more code to complain - * if "replace" is false). + * finally create the relation (this will error out if there's an + * existing view, so we don't need more code to complain if + * "replace" is false). */ return DefineRelation(createStmt, RELKIND_VIEW); } @@ -179,6 +179,7 @@ checkViewTupleDesc(TupleDesc newdesc, TupleDesc olddesc) NameStr(oldattr->attname)); /* We can ignore the remaining attributes of an attribute... */ } + /* * We ignore the constraint fields. The new view desc can't have any * constraints, and the only ones that could be on the old view are @@ -316,8 +317,8 @@ DefineView(const RangeVar *view, Query *viewParse, bool replace) /* * Create the view relation * - * NOTE: if it already exists and replace is false, the xact will - * be aborted. + * NOTE: if it already exists and replace is false, the xact will be + * aborted. */ viewOid = DefineVirtualRelation(view, viewParse->targetList, replace); diff --git a/src/backend/executor/execJunk.c b/src/backend/executor/execJunk.c index d808b85337..761ff403dd 100644 --- a/src/backend/executor/execJunk.c +++ b/src/backend/executor/execJunk.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.31 2002/07/20 05:16:57 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execJunk.c,v 1.32 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -383,8 +383,8 @@ ExecRemoveJunk(JunkFilter *junkfilter, TupleTableSlot *slot) * information for the new "clean" tuple. * * Note: we use memory on the stack to optimize things when we are - * dealing with a small number of attributes. for large tuples we - * just use palloc. + * dealing with a small number of attributes. for large tuples we just + * use palloc. */ if (cleanLength > 64) { diff --git a/src/backend/executor/execMain.c b/src/backend/executor/execMain.c index fd4431ce5f..300c415a01 100644 --- a/src/backend/executor/execMain.c +++ b/src/backend/executor/execMain.c @@ -27,7 +27,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.177 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execMain.c,v 1.178 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,14 +63,14 @@ static TupleTableSlot *ExecutePlan(EState *estate, Plan *plan, ScanDirection direction, DestReceiver *destfunc); static void ExecSelect(TupleTableSlot *slot, - DestReceiver *destfunc, - EState *estate); + DestReceiver *destfunc, + EState *estate); static void ExecInsert(TupleTableSlot *slot, ItemPointer tupleid, EState *estate); static void ExecDelete(TupleTableSlot *slot, ItemPointer tupleid, EState *estate); static void ExecUpdate(TupleTableSlot *slot, ItemPointer tupleid, - EState *estate); + EState *estate); static TupleTableSlot *EvalPlanQualNext(EState *estate); static void EndEvalPlanQual(EState *estate); static void ExecCheckQueryPerms(CmdType operation, Query *parseTree, @@ -116,9 +116,9 @@ ExecutorStart(QueryDesc *queryDesc, EState *estate) /* * Make our own private copy of the current query snapshot data. * - * This "freezes" our idea of which tuples are good and which are not - * for the life of this query, even if it outlives the current command - * and current snapshot. + * This "freezes" our idea of which tuples are good and which are not for + * the life of this query, even if it outlives the current command and + * current snapshot. */ estate->es_snapshot = CopyQuerySnapshot(); @@ -353,12 +353,13 @@ ExecCheckRTEPerms(RangeTblEntry *rte, CmdType operation) Oid userid; AclResult aclcheck_result; - /* + /* * Only plain-relation RTEs need to be checked here. Subquery RTEs - * will be checked when ExecCheckPlanPerms finds the SubqueryScan node, - * and function RTEs are checked by init_fcache when the function is - * prepared for execution. Join and special RTEs need no checks. - */ + * will be checked when ExecCheckPlanPerms finds the SubqueryScan + * node, and function RTEs are checked by init_fcache when the + * function is prepared for execution. Join and special RTEs need no + * checks. + */ if (rte->rtekind != RTE_RELATION) return; @@ -1071,7 +1072,8 @@ lnext: ; slot = ExecStoreTuple(newTuple, /* tuple to store */ junkfilter->jf_resultSlot, /* dest slot */ - InvalidBuffer, /* this tuple has no buffer */ + InvalidBuffer, /* this tuple has no + * buffer */ true); /* tuple should be pfreed */ } @@ -1083,8 +1085,9 @@ lnext: ; switch (operation) { case CMD_SELECT: - ExecSelect(slot, /* slot containing tuple */ - destfunc, /* destination's tuple-receiver obj */ + ExecSelect(slot, /* slot containing tuple */ + destfunc, /* destination's tuple-receiver + * obj */ estate); result = slot; break; @@ -1357,8 +1360,8 @@ ldelete:; */ static void ExecUpdate(TupleTableSlot *slot, - ItemPointer tupleid, - EState *estate) + ItemPointer tupleid, + EState *estate) { HeapTuple tuple; ResultRelInfo *resultRelInfo; diff --git a/src/backend/executor/execQual.c b/src/backend/executor/execQual.c index 12b2089fd7..5718983ca1 100644 --- a/src/backend/executor/execQual.c +++ b/src/backend/executor/execQual.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.107 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execQual.c,v 1.108 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -55,7 +55,7 @@ static Datum ExecEvalVar(Var *variable, ExprContext *econtext, bool *isNull); static Datum ExecEvalOper(Expr *opClause, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalDistinct(Expr *opClause, ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalFunc(Expr *funcClause, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static ExprDoneCond ExecEvalFuncArgs(FunctionCallInfo fcinfo, @@ -70,8 +70,8 @@ static Datum ExecEvalNullTest(NullTest *ntest, ExprContext *econtext, static Datum ExecEvalBooleanTest(BooleanTest *btest, ExprContext *econtext, bool *isNull, ExprDoneCond *isDone); static Datum ExecEvalConstraintTest(ConstraintTest *constraint, - ExprContext *econtext, - bool *isNull, ExprDoneCond *isDone); + ExprContext *econtext, + bool *isNull, ExprDoneCond *isDone); /*---------- @@ -848,7 +848,7 @@ ExecMakeFunctionResult(FunctionCachePtr fcache, * ExecMakeTableFunctionResult * * Evaluate a table function, producing a materialized result in a Tuplestore - * object. (If function returns an empty set, we just return NULL instead.) + * object. (If function returns an empty set, we just return NULL instead.) */ Tuplestorestate * ExecMakeTableFunctionResult(Expr *funcexpr, @@ -871,13 +871,14 @@ ExecMakeTableFunctionResult(Expr *funcexpr, bool returnsTuple = false; /* Extract data from function-call expression node */ - if (!funcexpr || !IsA(funcexpr, Expr) || funcexpr->opType != FUNC_EXPR) + if (!funcexpr || !IsA(funcexpr, Expr) ||funcexpr->opType != FUNC_EXPR) elog(ERROR, "ExecMakeTableFunctionResult: expression is not a function call"); func = (Func *) funcexpr->oper; argList = funcexpr->args; /* - * get the fcache from the Func node. If it is NULL, then initialize it + * get the fcache from the Func node. If it is NULL, then initialize + * it */ fcache = func->func_fcache; if (fcache == NULL) @@ -892,7 +893,7 @@ ExecMakeTableFunctionResult(Expr *funcexpr, * * Note: ideally, we'd do this in the per-tuple context, but then the * argument values would disappear when we reset the context in the - * inner loop. So do it in caller context. Perhaps we should make a + * inner loop. So do it in caller context. Perhaps we should make a * separate context just to hold the evaluated arguments? */ MemSet(&fcinfo, 0, sizeof(fcinfo)); @@ -921,8 +922,9 @@ ExecMakeTableFunctionResult(Expr *funcexpr, } /* - * Prepare a resultinfo node for communication. We always do this even - * if not expecting a set result, so that we can pass expectedDesc. + * Prepare a resultinfo node for communication. We always do this + * even if not expecting a set result, so that we can pass + * expectedDesc. */ fcinfo.resultinfo = (Node *) &rsinfo; rsinfo.type = T_ReturnSetInfo; @@ -948,8 +950,9 @@ ExecMakeTableFunctionResult(Expr *funcexpr, HeapTuple tuple; /* - * reset per-tuple memory context before each call of the function. - * This cleans up any local memory the function may leak when called. + * reset per-tuple memory context before each call of the + * function. This cleans up any local memory the function may leak + * when called. */ ResetExprContext(econtext); @@ -964,18 +967,20 @@ ExecMakeTableFunctionResult(Expr *funcexpr, /* * Check for end of result set. * - * Note: if function returns an empty set, we don't build a + * Note: if function returns an empty set, we don't build a * tupdesc or tuplestore (since we can't get a tupdesc in the * function-returning-tuple case) */ if (rsinfo.isDone == ExprEndResult) break; + /* - * If first time through, build tupdesc and tuplestore for result + * If first time through, build tupdesc and tuplestore for + * result */ if (first_time) { - Oid funcrettype = funcexpr->typeOid; + Oid funcrettype = funcexpr->typeOid; oldcontext = MemoryContextSwitchTo(econtext->ecxt_per_query_memory); if (funcrettype == RECORDOID || @@ -1006,7 +1011,7 @@ ExecMakeTableFunctionResult(Expr *funcexpr, 0, false); } - tupstore = tuplestore_begin_heap(true, /* randomAccess */ + tupstore = tuplestore_begin_heap(true, /* randomAccess */ SortMem); MemoryContextSwitchTo(oldcontext); rsinfo.setResult = tupstore; @@ -1026,7 +1031,7 @@ ExecMakeTableFunctionResult(Expr *funcexpr, } else { - char nullflag; + char nullflag; nullflag = fcinfo.isnull ? 'n' : ' '; tuple = heap_formtuple(tupdesc, &result, &nullflag); @@ -1180,7 +1185,7 @@ ExecEvalDistinct(Expr *opClause, bool *isNull, ExprDoneCond *isDone) { - bool result; + bool result; FunctionCachePtr fcache; FunctionCallInfoData fcinfo; ExprDoneCond argDone; diff --git a/src/backend/executor/execTuples.c b/src/backend/executor/execTuples.c index e07fd8719a..1a5f835be1 100644 --- a/src/backend/executor/execTuples.c +++ b/src/backend/executor/execTuples.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.58 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execTuples.c,v 1.59 2002/09/04 20:31:17 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -681,7 +681,7 @@ ExecTypeFromTL(List *targetList, bool hasoid) TupleTableSlot * TupleDescGetSlot(TupleDesc tupdesc) { - TupleTableSlot *slot; + TupleTableSlot *slot; /* Make a standalone slot */ slot = MakeTupleTableSlot(); @@ -701,19 +701,20 @@ TupleDescGetSlot(TupleDesc tupdesc) AttInMetadata * TupleDescGetAttInMetadata(TupleDesc tupdesc) { - int natts = tupdesc->natts; - int i; - Oid atttypeid; - Oid attinfuncid; - FmgrInfo *attinfuncinfo; - Oid *attelems; - int32 *atttypmods; - AttInMetadata *attinmeta; + int natts = tupdesc->natts; + int i; + Oid atttypeid; + Oid attinfuncid; + FmgrInfo *attinfuncinfo; + Oid *attelems; + int32 *atttypmods; + AttInMetadata *attinmeta; attinmeta = (AttInMetadata *) palloc(sizeof(AttInMetadata)); /* - * Gather info needed later to call the "in" function for each attribute + * Gather info needed later to call the "in" function for each + * attribute */ attinfuncinfo = (FmgrInfo *) palloc(natts * sizeof(FmgrInfo)); attelems = (Oid *) palloc(natts * sizeof(Oid)); @@ -741,14 +742,14 @@ TupleDescGetAttInMetadata(TupleDesc tupdesc) HeapTuple BuildTupleFromCStrings(AttInMetadata *attinmeta, char **values) { - TupleDesc tupdesc = attinmeta->tupdesc; - int natts = tupdesc->natts; - Datum *dvalues; - char *nulls; - int i; - Oid attelem; - int32 atttypmod; - HeapTuple tuple; + TupleDesc tupdesc = attinmeta->tupdesc; + int natts = tupdesc->natts; + Datum *dvalues; + char *nulls; + int i; + Oid attelem; + int32 atttypmod; + HeapTuple tuple; dvalues = (Datum *) palloc(natts * sizeof(Datum)); nulls = (char *) palloc(natts * sizeof(char)); @@ -843,13 +844,14 @@ do_text_output_multiline(TupOutputState *tstate, char *text) { while (*text) { - char *eol; + char *eol; eol = strchr(text, '\n'); if (eol) *eol++ = '\0'; else - eol = text + strlen(text); + eol = text +strlen(text); + do_tup_output(tstate, &text); text = eol; } diff --git a/src/backend/executor/execUtils.c b/src/backend/executor/execUtils.c index 3e8cf203b1..86440d10f9 100644 --- a/src/backend/executor/execUtils.c +++ b/src/backend/executor/execUtils.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.89 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/execUtils.c,v 1.90 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -297,19 +297,19 @@ ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate) /* * This is pretty grotty: we need to ensure that result tuples have * space for an OID iff they are going to be stored into a relation - * that has OIDs. We assume that estate->es_result_relation_info - * is already set up to describe the target relation. One reason - * this is ugly is that all plan nodes in the plan tree will emit - * tuples with space for an OID, though we really only need the topmost - * plan to do so. + * that has OIDs. We assume that estate->es_result_relation_info is + * already set up to describe the target relation. One reason this is + * ugly is that all plan nodes in the plan tree will emit tuples with + * space for an OID, though we really only need the topmost plan to do + * so. * * It would be better to have InitPlan adjust the topmost plan node's * output descriptor after plan tree initialization. However, that * doesn't quite work because in an UPDATE that spans an inheritance - * tree, some of the target relations may have OIDs and some not. - * We have to make the decision on a per-relation basis as we initialize - * each of the child plans of the topmost Append plan. So, this is ugly - * but it works, for now ... + * tree, some of the target relations may have OIDs and some not. We + * have to make the decision on a per-relation basis as we initialize + * each of the child plans of the topmost Append plan. So, this is + * ugly but it works, for now ... */ ri = node->state->es_result_relation_info; if (ri != NULL) @@ -319,7 +319,7 @@ ExecAssignResultTypeFromTL(Plan *node, CommonState *commonstate) if (rel != NULL) hasoid = rel->rd_rel->relhasoids; } - + tupDesc = ExecTypeFromTL(node->targetlist, hasoid); ExecAssignResultType(commonstate, tupDesc, true); } @@ -696,7 +696,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot, nullv); /* - * The index AM does the rest. Note we suppress unique-index + * The index AM does the rest. Note we suppress unique-index * checks if we are being called from VACUUM, since VACUUM may * need to move dead tuples that have the same keys as live ones. */ @@ -705,7 +705,7 @@ ExecInsertIndexTuples(TupleTableSlot *slot, nullv, /* info on nulls */ &(heapTuple->t_self), /* tid of heap tuple */ heapRelation, - relationDescs[i]->rd_index->indisunique && !is_vacuum); + relationDescs[i]->rd_index->indisunique && !is_vacuum); /* * keep track of index inserts for debugging @@ -753,7 +753,7 @@ RegisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg) { - ExprContext_CB *ecxt_callback; + ExprContext_CB *ecxt_callback; /* Save the info in appropriate memory context */ ecxt_callback = (ExprContext_CB *) @@ -779,8 +779,8 @@ UnregisterExprContextCallback(ExprContext *econtext, ExprContextCallbackFunction function, Datum arg) { - ExprContext_CB **prev_callback; - ExprContext_CB *ecxt_callback; + ExprContext_CB **prev_callback; + ExprContext_CB *ecxt_callback; prev_callback = &econtext->ecxt_callbacks; @@ -792,9 +792,7 @@ UnregisterExprContextCallback(ExprContext *econtext, pfree(ecxt_callback); } else - { prev_callback = &ecxt_callback->next; - } } } @@ -807,7 +805,7 @@ UnregisterExprContextCallback(ExprContext *econtext, static void ShutdownExprContext(ExprContext *econtext) { - ExprContext_CB *ecxt_callback; + ExprContext_CB *ecxt_callback; /* * Call each callback function in reverse registration order. diff --git a/src/backend/executor/functions.c b/src/backend/executor/functions.c index fe473404b9..b8bf811a5e 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.56 2002/08/29 00:17:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/functions.c,v 1.57 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -269,7 +269,7 @@ postquel_start(execution_state *es) static TupleTableSlot * postquel_getnext(execution_state *es) { - long count; + long count; if (es->qd->operation == CMD_UTILITY) { @@ -566,8 +566,8 @@ fmgr_sql(PG_FUNCTION_ARGS) elog(ERROR, "Set-valued function called in context that cannot accept a set"); /* - * Ensure we will get shut down cleanly if the exprcontext is - * not run to completion. + * Ensure we will get shut down cleanly if the exprcontext is not + * run to completion. */ if (!fcache->shutdown_reg) { diff --git a/src/backend/executor/nodeAgg.c b/src/backend/executor/nodeAgg.c index de839269cc..1a9239c57b 100644 --- a/src/backend/executor/nodeAgg.c +++ b/src/backend/executor/nodeAgg.c @@ -46,7 +46,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.85 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeAgg.c,v 1.86 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -877,8 +877,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) &peraggstate->transtypeByVal); /* - * initval is potentially null, so don't try to access it as a struct - * field. Must do it the hard way with SysCacheGetAttr. + * initval is potentially null, so don't try to access it as a + * struct field. Must do it the hard way with SysCacheGetAttr. */ textInitVal = SysCacheGetAttr(AGGFNOID, aggTuple, Anum_pg_aggregate_agginitval, @@ -907,8 +907,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) if (peraggstate->transfn.fn_strict && peraggstate->initValueIsNull) { /* - * Note: use the type from the input expression here, not - * from pg_proc.proargtypes, because the latter might be 0. + * Note: use the type from the input expression here, not from + * pg_proc.proargtypes, because the latter might be 0. * (Consider COUNT(*).) */ Oid inputType = exprType(aggref->target); @@ -921,8 +921,8 @@ ExecInitAgg(Agg *node, EState *estate, Plan *parent) if (aggref->aggdistinct) { /* - * Note: use the type from the input expression here, not - * from pg_proc.proargtypes, because the latter might be 0. + * Note: use the type from the input expression here, not from + * pg_proc.proargtypes, because the latter might be 0. * (Consider COUNT(*).) */ Oid inputType = exprType(aggref->target); diff --git a/src/backend/executor/nodeFunctionscan.c b/src/backend/executor/nodeFunctionscan.c index 8a9ac848e7..cf8d74a06f 100644 --- a/src/backend/executor/nodeFunctionscan.c +++ b/src/backend/executor/nodeFunctionscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.11 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeFunctionscan.c,v 1.12 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -50,13 +50,13 @@ static bool tupledesc_mismatch(TupleDesc tupdesc1, TupleDesc tupdesc2); static TupleTableSlot * FunctionNext(FunctionScan *node) { - TupleTableSlot *slot; - EState *estate; - ScanDirection direction; - Tuplestorestate *tuplestorestate; - FunctionScanState *scanstate; - bool should_free; - HeapTuple heapTuple; + TupleTableSlot *slot; + EState *estate; + ScanDirection direction; + Tuplestorestate *tuplestorestate; + FunctionScanState *scanstate; + bool should_free; + HeapTuple heapTuple; /* * get information from the estate and scan state @@ -69,12 +69,13 @@ FunctionNext(FunctionScan *node) /* * If first time through, read all tuples from function and put them - * in a tuplestore. Subsequent calls just fetch tuples from tuplestore. + * in a tuplestore. Subsequent calls just fetch tuples from + * tuplestore. */ if (tuplestorestate == NULL) { - ExprContext *econtext = scanstate->csstate.cstate.cs_ExprContext; - TupleDesc funcTupdesc; + ExprContext *econtext = scanstate->csstate.cstate.cs_ExprContext; + TupleDesc funcTupdesc; scanstate->tuplestorestate = tuplestorestate = ExecMakeTableFunctionResult((Expr *) scanstate->funcexpr, @@ -83,9 +84,9 @@ FunctionNext(FunctionScan *node) &funcTupdesc); /* - * If function provided a tupdesc, cross-check it. We only really - * need to do this for functions returning RECORD, but might as well - * do it always. + * If function provided a tupdesc, cross-check it. We only really + * need to do this for functions returning RECORD, but might as + * well do it always. */ if (funcTupdesc && tupledesc_mismatch(scanstate->tupdesc, funcTupdesc)) @@ -98,7 +99,7 @@ FunctionNext(FunctionScan *node) slot = scanstate->csstate.css_ScanTupleSlot; if (tuplestorestate) heapTuple = tuplestore_getheaptuple(tuplestorestate, - ScanDirectionIsForward(direction), + ScanDirectionIsForward(direction), &should_free); else { @@ -135,11 +136,11 @@ ExecFunctionScan(FunctionScan *node) bool ExecInitFunctionScan(FunctionScan *node, EState *estate, Plan *parent) { - FunctionScanState *scanstate; - RangeTblEntry *rte; - Oid funcrettype; - char functyptype; - TupleDesc tupdesc = NULL; + FunctionScanState *scanstate; + RangeTblEntry *rte; + Oid funcrettype; + char functyptype; + TupleDesc tupdesc = NULL; /* * FunctionScan should not have any children. @@ -266,8 +267,8 @@ ExecCountSlotsFunctionScan(FunctionScan *node) void ExecEndFunctionScan(FunctionScan *node) { - FunctionScanState *scanstate; - EState *estate; + FunctionScanState *scanstate; + EState *estate; /* * get information from node @@ -308,7 +309,7 @@ ExecEndFunctionScan(FunctionScan *node) void ExecFunctionMarkPos(FunctionScan *node) { - FunctionScanState *scanstate; + FunctionScanState *scanstate; scanstate = (FunctionScanState *) node->scan.scanstate; @@ -330,7 +331,7 @@ ExecFunctionMarkPos(FunctionScan *node) void ExecFunctionRestrPos(FunctionScan *node) { - FunctionScanState *scanstate; + FunctionScanState *scanstate; scanstate = (FunctionScanState *) node->scan.scanstate; @@ -352,7 +353,7 @@ ExecFunctionRestrPos(FunctionScan *node) void ExecFunctionReScan(FunctionScan *node, ExprContext *exprCtxt, Plan *parent) { - FunctionScanState *scanstate; + FunctionScanState *scanstate; /* * get information from node diff --git a/src/backend/executor/nodeHash.c b/src/backend/executor/nodeHash.c index 466452df8e..8bb5bde84c 100644 --- a/src/backend/executor/nodeHash.c +++ b/src/backend/executor/nodeHash.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * - * $Id: nodeHash.c,v 1.65 2002/09/02 02:47:02 momjian Exp $ + * $Id: nodeHash.c,v 1.66 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,7 +31,7 @@ #include "utils/lsyscache.h" -static uint32 hashFunc(Datum key, int typLen, bool byVal); +static uint32 hashFunc(Datum key, int typLen, bool byVal); /* ---------------------------------------------------------------- * ExecHash @@ -639,11 +639,11 @@ hashFunc(Datum key, int typLen, bool byVal) { /* * If it's a by-value data type, just hash the whole Datum value. - * This assumes that datatypes narrower than Datum are consistently - * padded (either zero-extended or sign-extended, but not random - * bits) to fill Datum; see the XXXGetDatum macros in postgres.h. - * NOTE: it would not work to do hash_any(&key, len) since this - * would get the wrong bytes on a big-endian machine. + * This assumes that datatypes narrower than Datum are + * consistently padded (either zero-extended or sign-extended, but + * not random bits) to fill Datum; see the XXXGetDatum macros in + * postgres.h. NOTE: it would not work to do hash_any(&key, len) + * since this would get the wrong bytes on a big-endian machine. */ k = (unsigned char *) &key; typLen = sizeof(Datum); @@ -658,14 +658,14 @@ hashFunc(Datum key, int typLen, bool byVal) else if (typLen == -1) { /* - * It's a varlena type, so 'key' points to a - * "struct varlena". NOTE: VARSIZE returns the - * "real" data length plus the sizeof the "vl_len" attribute of - * varlena (the length information). 'key' points to the beginning - * of the varlena struct, so we have to use "VARDATA" to find the - * beginning of the "real" data. Also, we have to be careful to - * detoast the datum if it's toasted. (We don't worry about - * freeing the detoasted copy; that happens for free when the + * It's a varlena type, so 'key' points to a "struct varlena". + * NOTE: VARSIZE returns the "real" data length plus the + * sizeof the "vl_len" attribute of varlena (the length + * information). 'key' points to the beginning of the varlena + * struct, so we have to use "VARDATA" to find the beginning + * of the "real" data. Also, we have to be careful to detoast + * the datum if it's toasted. (We don't worry about freeing + * the detoasted copy; that happens for free when the * per-tuple memory context is reset in ExecHashGetBucket.) */ struct varlena *vkey = PG_DETOAST_DATUM(key); diff --git a/src/backend/executor/nodeIndexscan.c b/src/backend/executor/nodeIndexscan.c index 5eb15f7f5c..78f5ad0ba2 100644 --- a/src/backend/executor/nodeIndexscan.c +++ b/src/backend/executor/nodeIndexscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.70 2002/06/23 21:29:32 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeIndexscan.c,v 1.71 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -165,22 +165,21 @@ IndexNext(IndexScan *node) while ((tuple = index_getnext(scandesc, direction)) != NULL) { /* - * store the scanned tuple in the scan tuple slot of the - * scan state. Note: we pass 'false' because tuples - * returned by amgetnext are pointers onto disk pages and - * must not be pfree()'d. + * store the scanned tuple in the scan tuple slot of the scan + * state. Note: we pass 'false' because tuples returned by + * amgetnext are pointers onto disk pages and must not be + * pfree()'d. */ - ExecStoreTuple(tuple, /* tuple to store */ + ExecStoreTuple(tuple, /* tuple to store */ slot, /* slot to store in */ - scandesc->xs_cbuf, /* buffer containing tuple */ - false); /* don't pfree */ + scandesc->xs_cbuf, /* buffer containing tuple */ + false); /* don't pfree */ /* * We must check to see if the current tuple was already - * matched by an earlier index, so we don't double-report - * it. We do this by passing the tuple through ExecQual - * and checking for failure with all previous - * qualifications. + * matched by an earlier index, so we don't double-report it. + * We do this by passing the tuple through ExecQual and + * checking for failure with all previous qualifications. */ if (indexstate->iss_IndexPtr > 0) { @@ -485,8 +484,9 @@ ExecEndIndexScan(IndexScan *node) * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by - * ExecInitIndexScan. This lock should be held till end of transaction. - * (There is a faction that considers this too much locking, however.) + * ExecInitIndexScan. This lock should be held till end of + * transaction. (There is a faction that considers this too much + * locking, however.) */ heap_close(relation, NoLock); @@ -1009,7 +1009,7 @@ ExecInitIndexScan(IndexScan *node, EState *estate, Plan *parent) elog(ERROR, "indexes of the relation %u was inactivated", reloid); scanstate->css_currentRelation = currentRelation; - scanstate->css_currentScanDesc = NULL; /* no heap scan here */ + scanstate->css_currentScanDesc = NULL; /* no heap scan here */ /* * get the scan type from the relation descriptor. diff --git a/src/backend/executor/nodeMergejoin.c b/src/backend/executor/nodeMergejoin.c index 4467fef9e1..4237618b0e 100644 --- a/src/backend/executor/nodeMergejoin.c +++ b/src/backend/executor/nodeMergejoin.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.50 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeMergejoin.c,v 1.51 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -93,7 +93,7 @@ static bool MergeCompare(List *eqQual, List *compareQual, ExprContext *econtext) * This takes the mergeclause which is a qualification of the * form ((= expr expr) (= expr expr) ...) and forms new lists * of the forms ((< expr expr) (< expr expr) ...) and - * ((> expr expr) (> expr expr) ...). These lists will be used + * ((> expr expr) (> expr expr) ...). These lists will be used * by ExecMergeJoin() to determine if we should skip tuples. * (We expect there to be suitable operators because the "=" operators * were marked mergejoinable; however, there might be a different diff --git a/src/backend/executor/nodeSeqscan.c b/src/backend/executor/nodeSeqscan.c index ddfcd3b8da..074a52731c 100644 --- a/src/backend/executor/nodeSeqscan.c +++ b/src/backend/executor/nodeSeqscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.36 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeSeqscan.c,v 1.37 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -284,8 +284,9 @@ ExecEndSeqScan(SeqScan *node) * close the heap relation. * * Currently, we do not release the AccessShareLock acquired by - * InitScanRelation. This lock should be held till end of transaction. - * (There is a faction that considers this too much locking, however.) + * InitScanRelation. This lock should be held till end of + * transaction. (There is a faction that considers this too much + * locking, however.) */ heap_close(relation, NoLock); diff --git a/src/backend/executor/nodeTidscan.c b/src/backend/executor/nodeTidscan.c index 300735fff0..f5e477663b 100644 --- a/src/backend/executor/nodeTidscan.c +++ b/src/backend/executor/nodeTidscan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.25 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/nodeTidscan.c,v 1.26 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -109,8 +109,8 @@ TidNext(TidScan *node) return slot; /* return empty slot */ /* - * XXX shouldn't we check here to make sure tuple matches TID list? - * In runtime-key case this is not certain, is it? + * XXX shouldn't we check here to make sure tuple matches TID + * list? In runtime-key case this is not certain, is it? */ ExecStoreTuple(estate->es_evTuple[node->scan.scanrelid - 1], @@ -468,7 +468,7 @@ ExecInitTidScan(TidScan *node, EState *estate, Plan *parent) currentRelation = heap_open(reloid, AccessShareLock); scanstate->css_currentRelation = currentRelation; - scanstate->css_currentScanDesc = NULL; /* no heap scan here */ + scanstate->css_currentScanDesc = NULL; /* no heap scan here */ /* * get the scan type from the relation descriptor. diff --git a/src/backend/executor/spi.c b/src/backend/executor/spi.c index f0cc3fe17a..273fe6fee1 100644 --- a/src/backend/executor/spi.c +++ b/src/backend/executor/spi.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.73 2002/09/02 01:05:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/executor/spi.c,v 1.74 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -433,6 +433,7 @@ SPI_modifytuple(Relation rel, HeapTuple tuple, int natts, int *attnum, if (i == natts) /* no errors in *attnum */ { mtuple = heap_formtuple(rel->rd_att, v, n); + /* * copy the identification info of the old tuple: t_ctid, t_self, * and OID (if any) @@ -1098,7 +1099,7 @@ _SPI_execute_plan(_SPI_plan *plan, Datum *Values, char *Nulls, int tcount) ParamListInfo paramLI; paramLI = (ParamListInfo) palloc((nargs + 1) * - sizeof(ParamListInfoData)); + sizeof(ParamListInfoData)); MemSet(paramLI, 0, (nargs + 1) * sizeof(ParamListInfoData)); state->es_param_list_info = paramLI; @@ -1266,9 +1267,9 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, ExecutorRun(querydesc, estate, direction, (long) count); if (estate->es_processed > 0) - portal->atStart = false; /* OK to back up now */ + portal->atStart = false; /* OK to back up now */ if (count <= 0 || (int) estate->es_processed < count) - portal->atEnd = true; /* we retrieved 'em all */ + portal->atEnd = true; /* we retrieved 'em all */ } else { @@ -1280,9 +1281,9 @@ _SPI_cursor_operation(Portal portal, bool forward, int count, ExecutorRun(querydesc, estate, direction, (long) count); if (estate->es_processed > 0) - portal->atEnd = false; /* OK to go forward now */ + portal->atEnd = false; /* OK to go forward now */ if (count <= 0 || (int) estate->es_processed < count) - portal->atStart = true; /* we retrieved 'em all */ + portal->atStart = true; /* we retrieved 'em all */ } _SPI_current->processed = estate->es_processed; diff --git a/src/backend/lib/stringinfo.c b/src/backend/lib/stringinfo.c index 62f63a547f..9b9fc3d180 100644 --- a/src/backend/lib/stringinfo.c +++ b/src/backend/lib/stringinfo.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: stringinfo.c,v 1.31 2002/06/20 20:29:28 momjian Exp $ + * $Id: stringinfo.c,v 1.32 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -120,7 +120,7 @@ appendStringInfo(StringInfo str, const char *fmt,...) * an example of a platform with such a bug. */ #ifdef USE_ASSERT_CHECKING - str->data[str->maxlen-1] = '\0'; + str->data[str->maxlen - 1] = '\0'; #endif va_start(args, fmt); @@ -128,7 +128,7 @@ appendStringInfo(StringInfo str, const char *fmt,...) fmt, args); va_end(args); - Assert(str->data[str->maxlen-1] == '\0'); + Assert(str->data[str->maxlen - 1] == '\0'); /* * Note: some versions of vsnprintf return the number of chars diff --git a/src/backend/libpq/auth.c b/src/backend/libpq/auth.c index 09129dd13e..7be74c58a7 100644 --- a/src/backend/libpq/auth.c +++ b/src/backend/libpq/auth.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.89 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/auth.c,v 1.90 2002/09/04 20:31:18 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -130,7 +130,6 @@ pg_krb4_recvauth(Port *port) elog(LOG, "pg_krb4_recvauth: Kerberos not implemented on this server"); return STATUS_ERROR; } - #endif /* KRB4 */ @@ -310,7 +309,6 @@ pg_krb5_recvauth(Port *port) elog(LOG, "pg_krb5_recvauth: Kerberos not implemented on this server"); return STATUS_ERROR; } - #endif /* KRB5 */ @@ -416,7 +414,7 @@ ClientAuthentication(Port *port) if (port->raddr.sa.sa_family == AF_INET) hostinfo = inet_ntoa(port->raddr.in.sin_addr); elog(FATAL, - "No pg_hba.conf entry for host %s, user %s, database %s", + "No pg_hba.conf entry for host %s, user %s, database %s", hostinfo, port->user, port->database); break; } @@ -513,8 +511,8 @@ sendAuthRequest(Port *port, AuthRequest areq) pq_endmessage(&buf); /* - * Flush message so client will see it, except for AUTH_REQ_OK, - * which need not be sent until we are ready for queries. + * Flush message so client will see it, except for AUTH_REQ_OK, which + * need not be sent until we are ready for queries. */ if (areq != AUTH_REQ_OK) pq_flush(); @@ -688,7 +686,7 @@ CheckPAMAuth(Port *port, char *user, char *password) pam_strerror(pamh, retval)); } - pam_passwd = NULL; /* Unset pam_passwd */ + pam_passwd = NULL; /* Unset pam_passwd */ return (retval == PAM_SUCCESS ? STATUS_OK : STATUS_ERROR); } @@ -714,13 +712,14 @@ recv_and_check_password_packet(Port *port) pfree(buf.data); return STATUS_EOF; } + /* - * We don't actually use the password packet length the frontend - * sent us; however, it's a reasonable sanity check to ensure that - * we actually read as much data as we expected to. + * We don't actually use the password packet length the frontend sent + * us; however, it's a reasonable sanity check to ensure that we + * actually read as much data as we expected to. * - * The password packet size is the length of the buffer, plus the - * size field itself (4 bytes), plus a 1-byte terminator. + * The password packet size is the length of the buffer, plus the size + * field itself (4 bytes), plus a 1-byte terminator. */ if (len != (buf.len + 4 + 1)) elog(LOG, "unexpected password packet size: read %d, expected %d", diff --git a/src/backend/libpq/be-secure.c b/src/backend/libpq/be-secure.c index 7b895de227..d7dca96528 100644 --- a/src/backend/libpq/be-secure.c +++ b/src/backend/libpq/be-secure.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.12 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/be-secure.c,v 1.13 2002/09/04 20:31:19 momjian Exp $ * * Since the server static private key ($DataDir/server.key) * will normally be stored unencrypted so that the database @@ -30,13 +30,13 @@ * impersonations. * * Another benefit of EDH is that it allows the backend and - * clients to use DSA keys. DSA keys can only provide digital + * clients to use DSA keys. DSA keys can only provide digital * signatures, not encryption, and are often acceptable in * jurisdictions where RSA keys are unacceptable. * * The downside to EDH is that it makes it impossible to * use ssldump(1) if there's a problem establishing an SSL - * session. In this case you'll need to temporarily disable + * session. In this case you'll need to temporarily disable * EDH by commenting out the callback. * * ... @@ -49,7 +49,7 @@ * milestone 1: fix basic coding errors * [*] existing SSL code pulled out of existing files. * [*] SSL_get_error() after SSL_read() and SSL_write(), - * SSL_shutdown(), default to TLSv1. + * SSL_shutdown(), default to TLSv1. * * milestone 2: provide endpoint authentication (server) * [*] client verifies server cert @@ -112,22 +112,22 @@ extern void ExitPostmaster(int); extern void postmaster_error(const char *fmt,...); -int secure_initialize(void); -void secure_destroy(void); -int secure_open_server(Port *); -void secure_close(Port *); -ssize_t secure_read(Port *, void *ptr, size_t len); -ssize_t secure_write(Port *, const void *ptr, size_t len); +int secure_initialize(void); +void secure_destroy(void); +int secure_open_server(Port *); +void secure_close(Port *); +ssize_t secure_read(Port *, void *ptr, size_t len); +ssize_t secure_write(Port *, const void *ptr, size_t len); #ifdef USE_SSL -static DH *load_dh_file(int keylength); -static DH *load_dh_buffer(const char *, size_t); -static DH *tmp_dh_cb(SSL *s, int is_export, int keylength); -static int verify_cb(int, X509_STORE_CTX *); +static DH *load_dh_file(int keylength); +static DH *load_dh_buffer(const char *, size_t); +static DH *tmp_dh_cb(SSL *s, int is_export, int keylength); +static int verify_cb(int, X509_STORE_CTX *); static void info_cb(SSL *ssl, int type, int args); -static int initialize_SSL(void); +static int initialize_SSL(void); static void destroy_SSL(void); -static int open_server_SSL(Port *); +static int open_server_SSL(Port *); static void close_SSL(Port *); static const char *SSLerrmessage(void); #endif @@ -137,13 +137,13 @@ static const char *SSLerrmessage(void); * How much data can be sent across a secure connection * (total in both directions) before we require renegotiation. */ -#define RENEGOTIATION_LIMIT (64 * 1024) -#define CA_PATH NULL +#define RENEGOTIATION_LIMIT (64 * 1024) +#define CA_PATH NULL static SSL_CTX *SSL_context = NULL; #endif /* ------------------------------------------------------------ */ -/* Hardcoded values */ +/* Hardcoded values */ /* ------------------------------------------------------------ */ /* @@ -207,16 +207,16 @@ KWbuHn491xNO25CQWMtem80uKw+pTnisBRF/454n1Jnhub144YRBoN8CAQI=\n\ -----END DH PARAMETERS-----\n"; /* ------------------------------------------------------------ */ -/* Procedures common to all secure sessions */ +/* Procedures common to all secure sessions */ /* ------------------------------------------------------------ */ /* * Initialize global context */ int -secure_initialize (void) +secure_initialize(void) { - int r = 0; + int r = 0; #ifdef USE_SSL r = initialize_SSL(); @@ -229,7 +229,7 @@ secure_initialize (void) * Destroy global context */ void -secure_destroy (void) +secure_destroy(void) { #ifdef USE_SSL destroy_SSL(); @@ -240,9 +240,9 @@ secure_destroy (void) * Attempt to negotiate secure session. */ int -secure_open_server (Port *port) +secure_open_server(Port *port) { - int r = 0; + int r = 0; #ifdef USE_SSL r = open_server_SSL(port); @@ -255,7 +255,7 @@ secure_open_server (Port *port) * Close secure session. */ void -secure_close (Port *port) +secure_close(Port *port) { #ifdef USE_SSL if (port->ssl) @@ -267,9 +267,9 @@ secure_close (Port *port) * Read data from a secure connection. */ ssize_t -secure_read (Port *port, void *ptr, size_t len) +secure_read(Port *port, void *ptr, size_t len) { - ssize_t n; + ssize_t n; #ifdef USE_SSL if (port->ssl) @@ -283,28 +283,28 @@ secure_read (Port *port, void *ptr, size_t len) n = SSL_read(port->ssl, ptr, len); switch (SSL_get_error(port->ssl, n)) { - case SSL_ERROR_NONE: - port->count += n; - break; - case SSL_ERROR_WANT_READ: - break; - case SSL_ERROR_SYSCALL: - errno = get_last_socket_error(); - elog(ERROR, "SSL SYSCALL error: %s", strerror(errno)); - break; - case SSL_ERROR_SSL: - elog(ERROR, "SSL error: %s", SSLerrmessage()); - /* fall through */ - case SSL_ERROR_ZERO_RETURN: - secure_close(port); - errno = ECONNRESET; - n = -1; - break; + case SSL_ERROR_NONE: + port->count += n; + break; + case SSL_ERROR_WANT_READ: + break; + case SSL_ERROR_SYSCALL: + errno = get_last_socket_error(); + elog(ERROR, "SSL SYSCALL error: %s", strerror(errno)); + break; + case SSL_ERROR_SSL: + elog(ERROR, "SSL error: %s", SSLerrmessage()); + /* fall through */ + case SSL_ERROR_ZERO_RETURN: + secure_close(port); + errno = ECONNRESET; + n = -1; + break; } } else #endif - n = recv(port->sock, ptr, len, 0); + n = recv(port->sock, ptr, len, 0); return n; } @@ -313,12 +313,12 @@ secure_read (Port *port, void *ptr, size_t len) * Write data to a secure connection. */ ssize_t -secure_write (Port *port, const void *ptr, size_t len) +secure_write(Port *port, const void *ptr, size_t len) { - ssize_t n; + ssize_t n; #ifndef WIN32 - pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); + pqsigfunc oldsighandler = pqsignal(SIGPIPE, SIG_IGN); #endif #ifdef USE_SSL @@ -333,28 +333,28 @@ secure_write (Port *port, const void *ptr, size_t len) n = SSL_write(port->ssl, ptr, len); switch (SSL_get_error(port->ssl, n)) { - case SSL_ERROR_NONE: - port->count += n; - break; - case SSL_ERROR_WANT_WRITE: - break; - case SSL_ERROR_SYSCALL: - errno = get_last_socket_error(); - elog(ERROR, "SSL SYSCALL error: %s", strerror(errno)); - break; - case SSL_ERROR_SSL: - elog(ERROR, "SSL error: %s", SSLerrmessage()); - /* fall through */ - case SSL_ERROR_ZERO_RETURN: - secure_close(port); - errno = ECONNRESET; - n = -1; - break; + case SSL_ERROR_NONE: + port->count += n; + break; + case SSL_ERROR_WANT_WRITE: + break; + case SSL_ERROR_SYSCALL: + errno = get_last_socket_error(); + elog(ERROR, "SSL SYSCALL error: %s", strerror(errno)); + break; + case SSL_ERROR_SSL: + elog(ERROR, "SSL error: %s", SSLerrmessage()); + /* fall through */ + case SSL_ERROR_ZERO_RETURN: + secure_close(port); + errno = ECONNRESET; + n = -1; + break; } } else #endif - n = send(port->sock, ptr, len, 0); + n = send(port->sock, ptr, len, 0); #ifndef WIN32 pqsignal(SIGPIPE, oldsighandler); @@ -364,7 +364,7 @@ secure_write (Port *port, const void *ptr, size_t len) } /* ------------------------------------------------------------ */ -/* SSL specific code */ +/* SSL specific code */ /* ------------------------------------------------------------ */ #ifdef USE_SSL /* @@ -374,13 +374,13 @@ secure_write (Port *port, const void *ptr, size_t len) * to verify that the DBA-generated DH parameters file contains * what we expect it to contain. */ -static DH * -load_dh_file (int keylength) +static DH * +load_dh_file(int keylength) { - FILE *fp; - char fnbuf[2048]; - DH *dh = NULL; - int codes; + FILE *fp; + char fnbuf[2048]; + DH *dh = NULL; + int codes; /* attempt to open file. It's not an error if it doesn't exist. */ snprintf(fnbuf, sizeof fnbuf, "%s/dh%d.pem", DataDir, keylength); @@ -393,10 +393,10 @@ load_dh_file (int keylength) fclose(fp); /* is the prime the correct size? */ - if (dh != NULL && 8*DH_size(dh) < keylength) + if (dh != NULL && 8 * DH_size(dh) < keylength) { elog(LOG, "DH errors (%s): %d bits expected, %d bits found", - fnbuf, keylength, 8*DH_size(dh)); + fnbuf, keylength, 8 * DH_size(dh)); dh = NULL; } @@ -417,8 +417,8 @@ load_dh_file (int keylength) (codes & DH_CHECK_P_NOT_SAFE_PRIME)) { elog(LOG, - "DH error (%s): neither suitable generator or safe prime", - fnbuf); + "DH error (%s): neither suitable generator or safe prime", + fnbuf); return NULL; } } @@ -432,11 +432,11 @@ load_dh_file (int keylength) * To prevent problems if the DH parameters files don't even * exist, we can load DH parameters hardcoded into this file. */ -static DH * -load_dh_buffer (const char *buffer, size_t len) +static DH * +load_dh_buffer(const char *buffer, size_t len) { - BIO *bio; - DH *dh = NULL; + BIO *bio; + DH *dh = NULL; bio = BIO_new_mem_buf((char *) buffer, len); if (bio == NULL) @@ -462,58 +462,58 @@ load_dh_buffer (const char *buffer, size_t len) * the OpenSSL library can efficiently generate random keys from * the information provided. */ -static DH * -tmp_dh_cb (SSL *s, int is_export, int keylength) +static DH * +tmp_dh_cb(SSL *s, int is_export, int keylength) { - DH *r = NULL; - static DH *dh = NULL; - static DH *dh512 = NULL; - static DH *dh1024 = NULL; - static DH *dh2048 = NULL; - static DH *dh4096 = NULL; + DH *r = NULL; + static DH *dh = NULL; + static DH *dh512 = NULL; + static DH *dh1024 = NULL; + static DH *dh2048 = NULL; + static DH *dh4096 = NULL; switch (keylength) { - case 512: - if (dh512 == NULL) - dh512 = load_dh_file(keylength); - if (dh512 == NULL) - dh512 = load_dh_buffer(file_dh512, sizeof file_dh512); - r = dh512; - break; - - case 1024: - if (dh1024 == NULL) - dh1024 = load_dh_file(keylength); - if (dh1024 == NULL) - dh1024 = load_dh_buffer(file_dh1024, sizeof file_dh1024); - r = dh1024; - break; - - case 2048: - if (dh2048 == NULL) - dh2048 = load_dh_file(keylength); - if (dh2048 == NULL) - dh2048 = load_dh_buffer(file_dh2048, sizeof file_dh2048); - r = dh2048; - break; - - case 4096: - if (dh4096 == NULL) - dh4096 = load_dh_file(keylength); - if (dh4096 == NULL) - dh4096 = load_dh_buffer(file_dh4096, sizeof file_dh4096); - r = dh4096; - break; - - default: - if (dh == NULL) - dh = load_dh_file(keylength); - r = dh; + case 512: + if (dh512 == NULL) + dh512 = load_dh_file(keylength); + if (dh512 == NULL) + dh512 = load_dh_buffer(file_dh512, sizeof file_dh512); + r = dh512; + break; + + case 1024: + if (dh1024 == NULL) + dh1024 = load_dh_file(keylength); + if (dh1024 == NULL) + dh1024 = load_dh_buffer(file_dh1024, sizeof file_dh1024); + r = dh1024; + break; + + case 2048: + if (dh2048 == NULL) + dh2048 = load_dh_file(keylength); + if (dh2048 == NULL) + dh2048 = load_dh_buffer(file_dh2048, sizeof file_dh2048); + r = dh2048; + break; + + case 4096: + if (dh4096 == NULL) + dh4096 = load_dh_file(keylength); + if (dh4096 == NULL) + dh4096 = load_dh_buffer(file_dh4096, sizeof file_dh4096); + r = dh4096; + break; + + default: + if (dh == NULL) + dh = load_dh_file(keylength); + r = dh; } /* this may take a long time, but it may be necessary... */ - if (r == NULL || 8*DH_size(r) < keylength) + if (r == NULL || 8 * DH_size(r) < keylength) { elog(DEBUG1, "DH: generating parameters (%d bits)....", keylength); r = DH_generate_parameters(keylength, DH_GENERATOR_2, NULL, NULL); @@ -534,7 +534,7 @@ tmp_dh_cb (SSL *s, int is_export, int keylength) * for now we accept the default checks. */ static int -verify_cb (int ok, X509_STORE_CTX *ctx) +verify_cb(int ok, X509_STORE_CTX *ctx) { return ok; } @@ -544,7 +544,7 @@ verify_cb (int ok, X509_STORE_CTX *ctx) * into the PostgreSQL log. */ static void -info_cb (SSL *ssl, int type, int args) +info_cb(SSL *ssl, int type, int args) { switch (type) { @@ -579,9 +579,9 @@ info_cb (SSL *ssl, int type, int args) * Initialize global SSL context. */ static int -initialize_SSL (void) +initialize_SSL(void) { - char fnbuf[2048]; + char fnbuf[2048]; struct stat buf; if (!SSL_context) @@ -597,7 +597,7 @@ initialize_SSL (void) } /* - * Load and verify certificate and private key + * Load and verify certificate and private key */ snprintf(fnbuf, sizeof(fnbuf), "%s/server.crt", DataDir); if (!SSL_CTX_use_certificate_file(SSL_context, fnbuf, SSL_FILETYPE_PEM)) @@ -647,7 +647,7 @@ initialize_SSL (void) ExitPostmaster(1); } SSL_CTX_set_verify(SSL_context, - SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, verify_cb); + SSL_VERIFY_PEER | SSL_VERIFY_CLIENT_ONCE, verify_cb); return 0; } @@ -656,7 +656,7 @@ initialize_SSL (void) * Destroy global SSL context. */ static void -destroy_SSL (void) +destroy_SSL(void) { if (SSL_context) { @@ -669,7 +669,7 @@ destroy_SSL (void) * Attempt to negotiate SSL connection. */ static int -open_server_SSL (Port *port) +open_server_SSL(Port *port) { if (!(port->ssl = SSL_new(SSL_context)) || !SSL_set_fd(port->ssl, port->sock) || @@ -685,17 +685,17 @@ open_server_SSL (Port *port) port->peer = SSL_get_peer_certificate(port->ssl); if (port->peer == NULL) { - strncpy(port->peer_dn, "(anonymous)", sizeof (port->peer_dn)); - strncpy(port->peer_cn, "(anonymous)", sizeof (port->peer_cn)); + strncpy(port->peer_dn, "(anonymous)", sizeof(port->peer_dn)); + strncpy(port->peer_cn, "(anonymous)", sizeof(port->peer_cn)); } else { X509_NAME_oneline(X509_get_subject_name(port->peer), - port->peer_dn, sizeof (port->peer_dn)); - port->peer_dn[sizeof(port->peer_dn)-1] = '\0'; + port->peer_dn, sizeof(port->peer_dn)); + port->peer_dn[sizeof(port->peer_dn) - 1] = '\0'; X509_NAME_get_text_by_NID(X509_get_subject_name(port->peer), - NID_commonName, port->peer_cn, sizeof (port->peer_cn)); - port->peer_cn[sizeof(port->peer_cn)-1] = '\0'; + NID_commonName, port->peer_cn, sizeof(port->peer_cn)); + port->peer_cn[sizeof(port->peer_cn) - 1] = '\0'; } elog(DEBUG1, "secure connection from '%s'", port->peer_cn); @@ -709,7 +709,7 @@ open_server_SSL (Port *port) * Close SSL connection. */ static void -close_SSL (Port *port) +close_SSL(Port *port) { if (port->ssl) { @@ -729,9 +729,9 @@ close_SSL (Port *port) static const char * SSLerrmessage(void) { - unsigned long errcode; - const char *errreason; - static char errbuf[32]; + unsigned long errcode; + const char *errreason; + static char errbuf[32]; errcode = ERR_get_error(); if (errcode == 0) @@ -743,4 +743,4 @@ SSLerrmessage(void) return errbuf; } -#endif /* USE_SSL */ +#endif /* USE_SSL */ diff --git a/src/backend/libpq/crypt.c b/src/backend/libpq/crypt.c index 9636a067c7..9cc6b483ed 100644 --- a/src/backend/libpq/crypt.c +++ b/src/backend/libpq/crypt.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.48 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/crypt.c,v 1.49 2002/09/04 20:31:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -35,9 +35,9 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) *valuntil = NULL, *crypt_pwd; int retval = STATUS_ERROR; - List **line; - List *token; - + List **line; + List *token; + if ((line = get_user_line(user)) == NULL) return STATUS_ERROR; @@ -50,7 +50,7 @@ md5_crypt_verify(const Port *port, const char *user, const char *pgpass) if (token) valuntil = lfirst(token); } - + if (passwd == NULL || *passwd == '\0') return STATUS_ERROR; diff --git a/src/backend/libpq/hba.c b/src/backend/libpq/hba.c index 0bf6371ff9..cda4bc93ae 100644 --- a/src/backend/libpq/hba.c +++ b/src/backend/libpq/hba.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.86 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/hba.c,v 1.87 2002/09/04 20:31:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,7 +41,7 @@ /* Max size of username ident server can return */ /* This is used to separate values in multi-valued column strings */ -#define MULTI_VALUE_SEP "\001" +#define MULTI_VALUE_SEP "\001" /* * These variables hold the pre-parsed contents of the hba and ident @@ -54,14 +54,16 @@ */ static List *hba_lines = NIL; /* pre-parsed contents of hba file */ static List *ident_lines = NIL; /* pre-parsed contents of ident file */ -static List *group_lines = NIL; /* pre-parsed contents of group file */ -static List *user_lines = NIL; /* pre-parsed contents of user password file */ +static List *group_lines = NIL; /* pre-parsed contents of group file */ +static List *user_lines = NIL; /* pre-parsed contents of user password + * file */ /* sorted entries so we can do binary search lookups */ -static List **user_sorted = NULL; /* sorted user list, for bsearch() */ -static List **group_sorted = NULL; /* sorted group list, for bsearch() */ -static int user_length; -static int group_length; +static List **user_sorted = NULL; /* sorted user list, for bsearch() */ +static List **group_sorted = NULL; /* sorted group list, for + * bsearch() */ +static int user_length; +static int group_length; static List *tokenize_file(FILE *file); static char *tokenize_inc_file(const char *inc_filename); @@ -78,14 +80,14 @@ isblank(const char c) /* - * Grab one token out of fp. Tokens are strings of non-blank - * characters bounded by blank characters, beginning of line, and - * end of line. Blank means space or tab. Return the token as - * *buf. Leave file positioned to character immediately after the - * token or EOF, whichever comes first. If no more tokens on line, - * return null string as *buf and position file to beginning of - * next line or EOF, whichever comes first. Allow spaces in quoted - * strings. Terminate on unquoted commas. Handle comments. + * Grab one token out of fp. Tokens are strings of non-blank + * characters bounded by blank characters, beginning of line, and + * end of line. Blank means space or tab. Return the token as + * *buf. Leave file positioned to character immediately after the + * token or EOF, whichever comes first. If no more tokens on line, + * return null string as *buf and position file to beginning of + * next line or EOF, whichever comes first. Allow spaces in quoted + * strings. Terminate on unquoted commas. Handle comments. */ void next_token(FILE *fp, char *buf, const int bufsz) @@ -102,8 +104,8 @@ next_token(FILE *fp, char *buf, const int bufsz) if (c != EOF && c != '\n') { /* - * Build a token in buf of next characters up to EOF, EOL, unquoted - * comma, or unquoted whitespace. + * Build a token in buf of next characters up to EOF, EOL, + * unquoted comma, or unquoted whitespace. */ while (c != EOF && c != '\n' && (!isblank(c) || in_quote == true)) @@ -156,9 +158,9 @@ next_token(FILE *fp, char *buf, const int bufsz) } /* - * Tokenize file and handle file inclusion and comma lists. We have - * to break apart the commas to expand any file names then - * reconstruct with commas. + * Tokenize file and handle file inclusion and comma lists. We have + * to break apart the commas to expand any file names then + * reconstruct with commas. */ static char * next_token_expand(FILE *file) @@ -174,17 +176,17 @@ next_token_expand(FILE *file) if (!*buf) break; - if (buf[strlen(buf)-1] == ',') + if (buf[strlen(buf) - 1] == ',') { trailing_comma = true; - buf[strlen(buf)-1] = '\0'; + buf[strlen(buf) - 1] = '\0'; } else trailing_comma = false; /* Is this referencing a file? */ if (buf[0] == '@') - incbuf = tokenize_inc_file(buf+1); + incbuf = tokenize_inc_file(buf + 1); else incbuf = pstrdup(buf); @@ -238,7 +240,7 @@ tokenize_inc_file(const char *inc_filename) { char *inc_fullname; FILE *inc_file; - List *inc_lines; + List *inc_lines; List *line; char *comma_str = pstrdup(""); @@ -279,7 +281,7 @@ tokenize_inc_file(const char *inc_filename) strcat(comma_str, MULTI_VALUE_SEP); } comma_str = repalloc(comma_str, - strlen(comma_str) + strlen(lfirst(token)) + 1); + strlen(comma_str) + strlen(lfirst(token)) + 1); strcat(comma_str, lfirst(token)); } } @@ -341,9 +343,9 @@ tokenize_file(FILE *file) static int user_group_qsort_cmp(const void *list1, const void *list2) { - /* first node is line number */ - char *user1 = lfirst(lnext(*(List **)list1)); - char *user2 = lfirst(lnext(*(List **)list2)); + /* first node is line number */ + char *user1 = lfirst(lnext(*(List **) list1)); + char *user2 = lfirst(lnext(*(List **) list2)); return strcmp(user1, user2); } @@ -357,8 +359,8 @@ user_group_qsort_cmp(const void *list1, const void *list2) static int user_group_bsearch_cmp(const void *user, const void *list) { - /* first node is line number */ - char *user2 = lfirst(lnext(*(List **)list)); + /* first node is line number */ + char *user2 = lfirst(lnext(*(List **) list)); return strcmp(user, user2); } @@ -371,24 +373,24 @@ static List ** get_group_line(const char *group) { return (List **) bsearch((void *) group, - (void *) group_sorted, - group_length, - sizeof(List *), - user_group_bsearch_cmp); + (void *) group_sorted, + group_length, + sizeof(List *), + user_group_bsearch_cmp); } /* * Lookup a user name in the pg_shadow file */ -List ** +List ** get_user_line(const char *user) { return (List **) bsearch((void *) user, - (void *) user_sorted, - user_length, - sizeof(List *), - user_group_bsearch_cmp); + (void *) user_sorted, + user_length, + sizeof(List *), + user_group_bsearch_cmp); } @@ -398,13 +400,14 @@ get_user_line(const char *user) static int check_group(char *group, char *user) { - List **line, *l; + List **line, + *l; if ((line = get_group_line(group)) != NULL) { foreach(l, lnext(lnext(*line))) if (strcmp(lfirst(l), user) == 0) - return 1; + return 1; } return 0; @@ -416,17 +419,17 @@ check_group(char *group, char *user) static int check_user(char *user, char *param_str) { - char *tok; + char *tok; for (tok = strtok(param_str, MULTI_VALUE_SEP); tok != NULL; tok = strtok(NULL, MULTI_VALUE_SEP)) { if (tok[0] == '+') { - if (check_group(tok+1, user)) + if (check_group(tok + 1, user)) return 1; } else if (strcmp(tok, user) == 0 || - strcmp(tok, "all") == 0) + strcmp(tok, "all") == 0) return 1; } @@ -439,7 +442,7 @@ check_user(char *user, char *param_str) static int check_db(char *dbname, char *user, char *param_str) { - char *tok; + char *tok; for (tok = strtok(param_str, MULTI_VALUE_SEP); tok != NULL; tok = strtok(NULL, MULTI_VALUE_SEP)) { @@ -744,7 +747,7 @@ void load_group() { FILE *group_file; - List *line; + List *line; if (group_lines) free_lines(&group_lines); @@ -761,7 +764,7 @@ load_group() group_length = length(group_lines); if (group_length) { - int i = 0; + int i = 0; group_sorted = palloc(group_length * sizeof(List *)); @@ -799,7 +802,7 @@ load_user() user_length = length(user_lines); if (user_length) { - int i = 0; + int i = 0; user_sorted = palloc(user_length * sizeof(List *)); @@ -825,7 +828,7 @@ load_hba(void) { int bufsize; FILE *file; /* The config file we have to read */ - char *conf_file; /* The name of the config file */ + char *conf_file; /* The name of the config file */ if (hba_lines) free_lines(&hba_lines); @@ -935,8 +938,8 @@ check_ident_usermap(const char *usermap_name, if (usermap_name[0] == '\0') { elog(LOG, "check_ident_usermap: hba configuration file does not " - "have the usermap field filled in in the entry that pertains " - "to this connection. That field is essential for Ident-based " + "have the usermap field filled in in the entry that pertains " + "to this connection. That field is essential for Ident-based " "authentication."); found_entry = false; } @@ -999,7 +1002,7 @@ load_ident(void) /* * Parse the string "*ident_response" as a response from a query to an Ident * server. If it's a normal response indicating a user name, return true - * and store the user name at *ident_user. If it's anything else, + * and store the user name at *ident_user. If it's anything else, * return false. */ static bool @@ -1140,7 +1143,7 @@ ident_inet(const struct in_addr remote_ip_addr, if (rc != 0) { /* save_errno is in case inet_ntoa changes errno */ - int save_errno = errno; + int save_errno = errno; elog(LOG, "Unable to connect to Ident server on the host which is " "trying to connect to Postgres " @@ -1157,12 +1160,13 @@ ident_inet(const struct in_addr remote_ip_addr, snprintf(ident_query, 80, "%d,%d\n", ntohs(remote_port), ntohs(local_port)); /* loop in case send is interrupted */ - do { + do + { rc = send(sock_fd, ident_query, strlen(ident_query), 0); } while (rc < 0 && errno == EINTR); if (rc < 0) { - int save_errno = errno; + int save_errno = errno; elog(LOG, "Unable to send query to Ident server on the host which is " "trying to connect to Postgres (Host %s, Port %d), " @@ -1179,11 +1183,11 @@ ident_inet(const struct in_addr remote_ip_addr, sizeof(ident_response) - 1, 0); if (rc < 0) { - int save_errno = errno; + int save_errno = errno; elog(LOG, "Unable to receive response from Ident server " "on the host which is " - "trying to connect to Postgres (Host %s, Port %d), " + "trying to connect to Postgres (Host %s, Port %d), " "even though we successfully sent our query to it: %s", inet_ntoa(remote_ip_addr), IDENT_PORT, strerror(save_errno)); @@ -1369,4 +1373,3 @@ hba_getauthmethod(hbaPort *port) else return STATUS_ERROR; } - diff --git a/src/backend/libpq/md5.c b/src/backend/libpq/md5.c index 0ecf839657..5c12e70c7f 100644 --- a/src/backend/libpq/md5.c +++ b/src/backend/libpq/md5.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.17 2002/06/20 20:29:28 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/libpq/md5.c,v 1.18 2002/09/04 20:31:19 momjian Exp $ */ @@ -22,10 +22,10 @@ * NOTE: * * There are two copies of this file, one in backend/libpq and another - * in interfaces/odbc. They should be identical. This is done so ODBC + * in interfaces/odbc. They should be identical. This is done so ODBC * can be compiled stand-alone. */ - + #ifndef MD5_ODBC #include "postgres.h" #include "libpq/crypt.h" diff --git a/src/backend/libpq/pqcomm.c b/src/backend/libpq/pqcomm.c index b8d3b8b7c2..c0d832bd3d 100644 --- a/src/backend/libpq/pqcomm.c +++ b/src/backend/libpq/pqcomm.c @@ -29,7 +29,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: pqcomm.c,v 1.139 2002/09/03 21:45:42 petere Exp $ + * $Id: pqcomm.c,v 1.140 2002/09/04 20:31:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -469,10 +469,9 @@ pq_recvbuf(void) continue; /* Ok if interrupted */ /* - * Careful: an elog() that tries to write to the client - * would cause recursion to here, leading to stack overflow - * and core dump! This message must go *only* to the postmaster - * log. + * Careful: an elog() that tries to write to the client would + * cause recursion to here, leading to stack overflow and core + * dump! This message must go *only* to the postmaster log. */ elog(COMMERROR, "pq_recvbuf: recv() failed: %m"); return EOF; @@ -574,12 +573,12 @@ pq_getstring(StringInfo s) s->data[0] = '\0'; /* Read until we get the terminating '\0' */ - for(;;) + for (;;) { while (PqRecvPointer >= PqRecvLength) { - if (pq_recvbuf()) /* If nothing in buffer, then recv some */ - return EOF; /* Failed to recv data */ + if (pq_recvbuf()) /* If nothing in buffer, then recv some */ + return EOF; /* Failed to recv data */ } for (i = PqRecvPointer; i < PqRecvLength; i++) @@ -589,7 +588,7 @@ pq_getstring(StringInfo s) /* does not copy the \0 */ appendBinaryStringInfo(s, PqRecvBuffer + PqRecvPointer, i - PqRecvPointer); - PqRecvPointer = i + 1; /* advance past \0 */ + PqRecvPointer = i + 1; /* advance past \0 */ return 0; } } @@ -639,7 +638,7 @@ pq_putbytes(const char *s, size_t len) int pq_flush(void) { - static int last_reported_send_errno = 0; + static int last_reported_send_errno = 0; unsigned char *bufptr = PqSendBuffer; unsigned char *bufend = PqSendBuffer + PqSendPointer; @@ -656,13 +655,12 @@ pq_flush(void) continue; /* Ok if we were interrupted */ /* - * Careful: an elog() that tries to write to the client - * would cause recursion to here, leading to stack overflow - * and core dump! This message must go *only* to the postmaster - * log. + * Careful: an elog() that tries to write to the client would + * cause recursion to here, leading to stack overflow and core + * dump! This message must go *only* to the postmaster log. * - * If a client disconnects while we're in the midst of output, - * we might write quite a bit of data before we get to a safe + * If a client disconnects while we're in the midst of output, we + * might write quite a bit of data before we get to a safe * query abort point. So, suppress duplicate log messages. */ if (errno != last_reported_send_errno) @@ -679,7 +677,7 @@ pq_flush(void) return EOF; } - last_reported_send_errno = 0; /* reset after any successful send */ + last_reported_send_errno = 0; /* reset after any successful send */ bufptr += r; } diff --git a/src/backend/main/main.c b/src/backend/main/main.c index 595052a91c..52edda5aee 100644 --- a/src/backend/main/main.c +++ b/src/backend/main/main.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.53 2002/08/09 22:52:04 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/main/main.c,v 1.54 2002/09/04 20:31:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -121,21 +121,24 @@ main(int argc, char *argv[]) new_argv[argc] = NULL; /* - * Set up locale information from environment. Note that CTYPE - * and COLLATE will be overridden later from pg_control if we are - * in an already-initialized database. We set them here so that - * they will be available to fill pg_control during initdb. The - * other ones will get reset later in InitializeGUCOptions, but we set - * them here to get already localized behavior during startup - * (e.g., error messages). + * Set up locale information from environment. Note that CTYPE and + * COLLATE will be overridden later from pg_control if we are in an + * already-initialized database. We set them here so that they will + * be available to fill pg_control during initdb. The other ones will + * get reset later in InitializeGUCOptions, but we set them here to + * get already localized behavior during startup (e.g., error + * messages). */ setlocale(LC_COLLATE, ""); setlocale(LC_CTYPE, ""); #ifdef LC_MESSAGES setlocale(LC_MESSAGES, ""); #endif - /* We don't use these during startup. See also pg_locale.c about - * why these are set to "C". */ + + /* + * We don't use these during startup. See also pg_locale.c about why + * these are set to "C". + */ setlocale(LC_MONETARY, "C"); setlocale(LC_NUMERIC, "C"); setlocale(LC_TIME, "C"); diff --git a/src/backend/nodes/copyfuncs.c b/src/backend/nodes/copyfuncs.c index 8a69af3de5..2964085e0a 100644 --- a/src/backend/nodes/copyfuncs.c +++ b/src/backend/nodes/copyfuncs.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.210 2002/09/02 02:13:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/copyfuncs.c,v 1.211 2002/09/04 20:31:19 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1518,7 +1518,7 @@ _copyAExpr(A_Expr *from) static ColumnRef * _copyColumnRef(ColumnRef *from) { - ColumnRef *newnode = makeNode(ColumnRef); + ColumnRef *newnode = makeNode(ColumnRef); Node_Copy(from, newnode, fields); Node_Copy(from, newnode, indirection); @@ -1529,7 +1529,7 @@ _copyColumnRef(ColumnRef *from) static ParamRef * _copyParamRef(ParamRef *from) { - ParamRef *newnode = makeNode(ParamRef); + ParamRef *newnode = makeNode(ParamRef); newnode->number = from->number; Node_Copy(from, newnode, fields); @@ -1595,7 +1595,7 @@ _copyAIndices(A_Indices *from) static ExprFieldSelect * _copyExprFieldSelect(ExprFieldSelect *from) { - ExprFieldSelect *newnode = makeNode(ExprFieldSelect); + ExprFieldSelect *newnode = makeNode(ExprFieldSelect); Node_Copy(from, newnode, arg); Node_Copy(from, newnode, fields); @@ -1688,7 +1688,7 @@ _copyRangeSubselect(RangeSubselect *from) static RangeFunction * _copyRangeFunction(RangeFunction *from) { - RangeFunction *newnode = makeNode(RangeFunction); + RangeFunction *newnode = makeNode(RangeFunction); Node_Copy(from, newnode, funccallnode); Node_Copy(from, newnode, alias); @@ -2223,7 +2223,7 @@ _copyTransactionStmt(TransactionStmt *from) static CompositeTypeStmt * _copyCompositeTypeStmt(CompositeTypeStmt *from) { - CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt); + CompositeTypeStmt *newnode = makeNode(CompositeTypeStmt); Node_Copy(from, newnode, typevar); Node_Copy(from, newnode, coldeflist); diff --git a/src/backend/nodes/makefuncs.c b/src/backend/nodes/makefuncs.c index ee716a5a84..8363fccfa6 100644 --- a/src/backend/nodes/makefuncs.c +++ b/src/backend/nodes/makefuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.33 2002/06/20 20:29:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/makefuncs.c,v 1.34 2002/09/04 20:31:19 momjian Exp $ */ #include "postgres.h" @@ -233,7 +233,7 @@ makeRelabelType(Node *arg, Oid rtype, int32 rtypmod) RangeVar * makeRangeVar(char *schemaname, char *relname) { - RangeVar *r = makeNode(RangeVar); + RangeVar *r = makeNode(RangeVar); r->catalogname = NULL; r->schemaname = schemaname; diff --git a/src/backend/nodes/outfuncs.c b/src/backend/nodes/outfuncs.c index 8c25505806..8873c4e3d2 100644 --- a/src/backend/nodes/outfuncs.c +++ b/src/backend/nodes/outfuncs.c @@ -5,7 +5,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.172 2002/08/31 22:10:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/outfuncs.c,v 1.173 2002/09/04 20:31:19 momjian Exp $ * * NOTES * Every (plan) node in POSTGRES has an associated "out" routine which @@ -232,10 +232,10 @@ _outQuery(StringInfo str, Query *node) /* * Hack to work around missing outfuncs routines for a lot of the - * utility-statement node types. (The only one we actually *need* - * for rules support is NotifyStmt.) Someday we ought to support - * 'em all, but for the meantime do this to avoid getting lots of - * warnings when running with debug_print_parse on. + * utility-statement node types. (The only one we actually *need* for + * rules support is NotifyStmt.) Someday we ought to support 'em all, + * but for the meantime do this to avoid getting lots of warnings when + * running with debug_print_parse on. */ if (node->utilityStmt) { @@ -832,13 +832,13 @@ static void _outArrayRef(StringInfo str, ArrayRef *node) { appendStringInfo(str, - " ARRAYREF :refrestype %u :refattrlength %d :refelemlength %d ", + " ARRAYREF :refrestype %u :refattrlength %d :refelemlength %d ", node->refrestype, node->refattrlength, node->refelemlength); appendStringInfo(str, - ":refelembyval %s :refelemalign %c :refupperindexpr ", + ":refelembyval %s :refelemalign %c :refupperindexpr ", booltostr(node->refelembyval), node->refelemalign); _outNode(str, node->refupperindexpr); @@ -860,7 +860,7 @@ static void _outFunc(StringInfo str, Func *node) { appendStringInfo(str, - " FUNC :funcid %u :funcresulttype %u :funcretset %s ", + " FUNC :funcid %u :funcresulttype %u :funcretset %s ", node->funcid, node->funcresulttype, booltostr(node->funcretset)); @@ -873,7 +873,7 @@ static void _outOper(StringInfo str, Oper *node) { appendStringInfo(str, - " OPER :opno %u :opid %u :opresulttype %u :opretset %s ", + " OPER :opno %u :opid %u :opresulttype %u :opretset %s ", node->opno, node->opid, node->opresulttype, @@ -1324,6 +1324,7 @@ static void _outRangeVar(StringInfo str, RangeVar *node) { appendStringInfo(str, " RANGEVAR :relation "); + /* * we deliberately ignore catalogname here, since it is presently not * semantically meaningful @@ -1332,8 +1333,8 @@ _outRangeVar(StringInfo str, RangeVar *node) appendStringInfo(str, " . "); _outToken(str, node->relname); appendStringInfo(str, " :inhopt %d :istemp %s", - (int) node->inhOpt, - booltostr(node->istemp)); + (int) node->inhOpt, + booltostr(node->istemp)); appendStringInfo(str, " :alias "); _outNode(str, node->alias); } diff --git a/src/backend/nodes/print.c b/src/backend/nodes/print.c index 4e81ed14f2..e8afda6b20 100644 --- a/src/backend/nodes/print.c +++ b/src/backend/nodes/print.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.56 2002/06/20 20:29:29 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/print.c,v 1.57 2002/09/04 20:31:20 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -97,7 +97,7 @@ char * format_node_dump(const char *dump) { #define LINELEN 78 - char line[LINELEN+1]; + char line[LINELEN + 1]; StringInfoData str; int i; int j; @@ -118,13 +118,13 @@ format_node_dump(const char *dump) } else { - for (k = j-1; k > 0; k--) + for (k = j - 1; k > 0; k--) if (line[k] == ' ') break; if (k > 0) { /* back up; will reprint all after space */ - i -= (j-k-1); + i -= (j - k - 1); j = k; } } @@ -153,7 +153,7 @@ pretty_format_node_dump(const char *dump) #define INDENTSTOP 3 #define MAXINDENT 60 #define LINELEN 78 - char line[LINELEN+1]; + char line[LINELEN + 1]; StringInfoData str; int indentLev; int indentDist; @@ -182,7 +182,7 @@ pretty_format_node_dump(const char *dump) } /* print the } at indentDist */ line[indentDist] = '}'; - line[indentDist+1] = '\0'; + line[indentDist + 1] = '\0'; appendStringInfo(&str, "%s\n", line); /* outdent */ if (indentLev > 0) diff --git a/src/backend/nodes/readfuncs.c b/src/backend/nodes/readfuncs.c index 4d4001d213..14edd8e3d1 100644 --- a/src/backend/nodes/readfuncs.c +++ b/src/backend/nodes/readfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.131 2002/08/31 22:10:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/nodes/readfuncs.c,v 1.132 2002/09/04 20:31:20 momjian Exp $ * * NOTES * Most of the read functions for plan nodes are tested. (In fact, they @@ -1459,7 +1459,8 @@ _readRangeVar(void) local_node = makeNode(RangeVar); - local_node->catalogname = NULL; /* not currently saved in output format */ + local_node->catalogname = NULL; /* not currently saved in output + * format */ token = pg_strtok(&length); /* eat :relation */ token = pg_strtok(&length); /* get schemaname */ @@ -1468,11 +1469,11 @@ _readRangeVar(void) token = pg_strtok(&length); /* eat "." */ token = pg_strtok(&length); /* get relname */ local_node->relname = nullable_string(token, length); - + token = pg_strtok(&length); /* eat :inhopt */ token = pg_strtok(&length); /* get inhopt */ local_node->inhOpt = (InhOption) atoi(token); - + token = pg_strtok(&length); /* eat :istemp */ token = pg_strtok(&length); /* get istemp */ local_node->istemp = strtobool(token); @@ -1493,10 +1494,10 @@ _readColumnRef(void) local_node = makeNode(ColumnRef); token = pg_strtok(&length); /* eat :fields */ - local_node->fields = nodeRead(true); /* now read it */ + local_node->fields = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :indirection */ - local_node->indirection = nodeRead(true); /* now read it */ + local_node->indirection = nodeRead(true); /* now read it */ return local_node; } @@ -1515,7 +1516,7 @@ _readColumnDef(void) local_node->colname = nullable_string(token, length); token = pg_strtok(&length); /* eat :typename */ - local_node->typename = nodeRead(true); /* now read it */ + local_node->typename = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :is_inherited */ token = pg_strtok(&length); /* get :is_inherited */ @@ -1526,7 +1527,7 @@ _readColumnDef(void) local_node->is_not_null = strtobool(token); token = pg_strtok(&length); /* eat :raw_default */ - local_node->raw_default = nodeRead(true); /* now read it */ + local_node->raw_default = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :cooked_default */ token = pg_strtok(&length); /* now read it */ @@ -1536,7 +1537,7 @@ _readColumnDef(void) local_node->constraints = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :support */ - local_node->support = nodeRead(true); /* now read it */ + local_node->support = nodeRead(true); /* now read it */ return local_node; } @@ -1544,7 +1545,7 @@ _readColumnDef(void) static TypeName * _readTypeName(void) { - TypeName *local_node; + TypeName *local_node; char *token; int length; @@ -1574,7 +1575,7 @@ _readTypeName(void) local_node->typmod = atoi(token); token = pg_strtok(&length); /* eat :arrayBounds */ - local_node->arrayBounds = nodeRead(true); /* now read it */ + local_node->arrayBounds = nodeRead(true); /* now read it */ return local_node; } @@ -1582,20 +1583,20 @@ _readTypeName(void) static ExprFieldSelect * _readExprFieldSelect(void) { - ExprFieldSelect *local_node; + ExprFieldSelect *local_node; char *token; int length; local_node = makeNode(ExprFieldSelect); token = pg_strtok(&length); /* eat :arg */ - local_node->arg = nodeRead(true); /* now read it */ + local_node->arg = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :fields */ - local_node->fields = nodeRead(true); /* now read it */ + local_node->fields = nodeRead(true); /* now read it */ token = pg_strtok(&length); /* eat :indirection */ - local_node->indirection = nodeRead(true); /* now read it */ + local_node->indirection = nodeRead(true); /* now read it */ return local_node; } @@ -1614,7 +1615,7 @@ _readAlias(void) local_node->aliasname = debackslash(token, length); token = pg_strtok(&length); /* eat :colnames */ - local_node->colnames = nodeRead(true); /* now read it */ + local_node->colnames = nodeRead(true); /* now read it */ return local_node; } @@ -1671,7 +1672,7 @@ _readRangeTblEntry(void) local_node->jointype = (JoinType) atoi(token); token = pg_strtok(&length); /* eat :joinaliasvars */ - local_node->joinaliasvars = nodeRead(true); /* now read it */ + local_node->joinaliasvars = nodeRead(true); /* now read it */ break; default: diff --git a/src/backend/optimizer/geqo/geqo_misc.c b/src/backend/optimizer/geqo/geqo_misc.c index 6ffc02b1c5..ef7b489f59 100644 --- a/src/backend/optimizer/geqo/geqo_misc.c +++ b/src/backend/optimizer/geqo/geqo_misc.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: geqo_misc.c,v 1.33 2002/07/20 04:59:10 momjian Exp $ + * $Id: geqo_misc.c,v 1.34 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -250,4 +250,4 @@ geqo_print_rel(Query *root, RelOptInfo *rel) geqo_print_path(root, rel->cheapest_total_path, 1); } -#endif /* GEQO_DEBUG */ +#endif /* GEQO_DEBUG */ diff --git a/src/backend/optimizer/path/allpaths.c b/src/backend/optimizer/path/allpaths.c index c1ee656b51..7d8d6a6beb 100644 --- a/src/backend/optimizer/path/allpaths.c +++ b/src/backend/optimizer/path/allpaths.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.87 2002/08/29 16:03:48 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/allpaths.c,v 1.88 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -43,14 +43,14 @@ static void set_inherited_rel_pathlist(Query *root, RelOptInfo *rel, static void set_subquery_pathlist(Query *root, RelOptInfo *rel, Index rti, RangeTblEntry *rte); static void set_function_pathlist(Query *root, RelOptInfo *rel, - RangeTblEntry *rte); + RangeTblEntry *rte); static RelOptInfo *make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels); static bool subquery_is_pushdown_safe(Query *subquery, Query *topquery); static bool recurse_pushdown_safe(Node *setOp, Query *topquery); static void subquery_push_qual(Query *subquery, Index rti, Node *qual); static void recurse_push_qual(Node *setOp, Query *topquery, - Index rti, Node *qual); + Index rti, Node *qual); /* @@ -304,9 +304,10 @@ set_subquery_pathlist(Query *root, RelOptInfo *rel, * * There are several cases where we cannot push down clauses. * Restrictions involving the subquery are checked by - * subquery_is_pushdown_safe(). Also, we do not push down clauses that - * contain subselects, mainly because I'm not sure it will work correctly - * (the subplan hasn't yet transformed sublinks to subselects). + * subquery_is_pushdown_safe(). Also, we do not push down clauses + * that contain subselects, mainly because I'm not sure it will work + * correctly (the subplan hasn't yet transformed sublinks to + * subselects). * * Non-pushed-down clauses will get evaluated as qpquals of the * SubqueryScan node. @@ -542,7 +543,7 @@ make_one_rel_by_joins(Query *root, int levels_needed, List *initial_rels) * quals into it, because that would change the results. For subqueries * using UNION/UNION ALL/INTERSECT/INTERSECT ALL, we can push the quals * into each component query, so long as all the component queries share - * identical output types. (That restriction could probably be relaxed, + * identical output types. (That restriction could probably be relaxed, * but it would take much more code to include type coercion code into * the quals, and I'm also concerned about possible semantic gotchas.) */ @@ -633,14 +634,14 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual) else { /* - * We need to replace Vars in the qual (which must refer - * to outputs of the subquery) with copies of the - * subquery's targetlist expressions. Note that at this - * point, any uplevel Vars in the qual should have been - * replaced with Params, so they need no work. + * We need to replace Vars in the qual (which must refer to + * outputs of the subquery) with copies of the subquery's + * targetlist expressions. Note that at this point, any uplevel + * Vars in the qual should have been replaced with Params, so they + * need no work. * - * This step also ensures that when we are pushing into a setop - * tree, each component query gets its own copy of the qual. + * This step also ensures that when we are pushing into a setop tree, + * each component query gets its own copy of the qual. */ qual = ResolveNew(qual, rti, 0, subquery->targetList, @@ -649,10 +650,9 @@ subquery_push_qual(Query *subquery, Index rti, Node *qual) qual); /* - * We need not change the subquery's hasAggs or - * hasSublinks flags, since we can't be pushing down any - * aggregates that weren't there before, and we don't push - * down subselects at all. + * We need not change the subquery's hasAggs or hasSublinks flags, + * since we can't be pushing down any aggregates that weren't + * there before, and we don't push down subselects at all. */ } } diff --git a/src/backend/optimizer/path/costsize.c b/src/backend/optimizer/path/costsize.c index 11e18c3d0b..9f987a4395 100644 --- a/src/backend/optimizer/path/costsize.c +++ b/src/backend/optimizer/path/costsize.c @@ -42,7 +42,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.89 2002/07/04 15:23:56 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/costsize.c,v 1.90 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -408,8 +408,8 @@ cost_functionscan(Path *path, Query *root, RelOptInfo *baserel) /* * For now, estimate function's cost at one operator eval per function - * call. Someday we should revive the function cost estimate columns in - * pg_proc... + * call. Someday we should revive the function cost estimate columns + * in pg_proc... */ cpu_per_tuple = cpu_operator_cost; @@ -607,7 +607,7 @@ cost_mergejoin(Path *path, Query *root, double outer_rows, inner_rows; double ntuples; - Selectivity outerscansel, + Selectivity outerscansel, innerscansel; Path sort_path; /* dummy for result of cost_sort */ @@ -617,15 +617,15 @@ cost_mergejoin(Path *path, Query *root, /* * A merge join will stop as soon as it exhausts either input stream. * Estimate fraction of the left and right inputs that will actually - * need to be scanned. We use only the first (most significant) - * merge clause for this purpose. + * need to be scanned. We use only the first (most significant) merge + * clause for this purpose. * - * Since this calculation is somewhat expensive, and will be the same - * for all mergejoin paths associated with the merge clause, we cache - * the results in the RestrictInfo node. + * Since this calculation is somewhat expensive, and will be the same for + * all mergejoin paths associated with the merge clause, we cache the + * results in the RestrictInfo node. */ firstclause = (RestrictInfo *) lfirst(mergeclauses); - if (firstclause->left_mergescansel < 0) /* not computed yet? */ + if (firstclause->left_mergescansel < 0) /* not computed yet? */ mergejoinscansel(root, (Node *) firstclause->clause, &firstclause->left_mergescansel, &firstclause->right_mergescansel); @@ -697,10 +697,10 @@ cost_mergejoin(Path *path, Query *root, /* * The number of tuple comparisons needed depends drastically on the * number of equal keys in the two source relations, which we have no - * good way of estimating. (XXX could the MCV statistics help?) - * Somewhat arbitrarily, we charge one tuple - * comparison (one cpu_operator_cost) for each tuple in the two source - * relations. This is probably a lower bound. + * good way of estimating. (XXX could the MCV statistics help?) + * Somewhat arbitrarily, we charge one tuple comparison (one + * cpu_operator_cost) for each tuple in the two source relations. + * This is probably a lower bound. */ run_cost += cpu_operator_cost * (outer_rows + inner_rows); diff --git a/src/backend/optimizer/path/indxpath.c b/src/backend/optimizer/path/indxpath.c index 3d9ec2eb23..5595e1aec9 100644 --- a/src/backend/optimizer/path/indxpath.c +++ b/src/backend/optimizer/path/indxpath.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.121 2002/09/02 06:22:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/indxpath.c,v 1.122 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1332,7 +1332,7 @@ pred_test_simple_clause(Expr *predicate, Node *clause) test_oper = makeOper(test_op, /* opno */ InvalidOid, /* opid */ BOOLOID, /* opresulttype */ - false); /* opretset */ + false); /* opretset */ replace_opid(test_oper); test_expr = make_opclause(test_oper, (Var *) clause_const, @@ -1712,7 +1712,7 @@ match_special_index_operator(Expr *clause, Oid opclass, case OID_BYTEA_LIKE_OP: isIndexable = pattern_fixed_prefix(patt, Pattern_Type_Like, - &prefix, &rest) != Pattern_Prefix_None; + &prefix, &rest) != Pattern_Prefix_None; break; case OID_TEXT_ICLIKE_OP: @@ -1922,7 +1922,7 @@ expand_indexqual_conditions(List *indexquals) case OID_CIDR_SUBEQ_OP: resultquals = nconc(resultquals, network_prefix_quals(leftop, expr_op, - patt->constvalue)); + patt->constvalue)); break; default: diff --git a/src/backend/optimizer/path/joinpath.c b/src/backend/optimizer/path/joinpath.c index f1e2acac81..8e73bd2f41 100644 --- a/src/backend/optimizer/path/joinpath.c +++ b/src/backend/optimizer/path/joinpath.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.70 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/joinpath.c,v 1.71 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -171,7 +171,7 @@ sort_inner_and_outer(Query *root, default: elog(ERROR, "sort_inner_and_outer: unexpected join type %d", (int) jointype); - useallclauses = false; /* keep compiler quiet */ + useallclauses = false; /* keep compiler quiet */ break; } diff --git a/src/backend/optimizer/path/pathkeys.c b/src/backend/optimizer/path/pathkeys.c index 5e4aff3247..fc33d5296a 100644 --- a/src/backend/optimizer/path/pathkeys.c +++ b/src/backend/optimizer/path/pathkeys.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.39 2002/06/20 20:29:30 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/path/pathkeys.c,v 1.40 2002/09/04 20:31:20 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -519,7 +519,7 @@ build_index_pathkeys(Query *root, funcnode->funcid = index->indproc; funcnode->funcresulttype = get_func_rettype(index->indproc); - funcnode->funcretset = false; /* can never be a set */ + funcnode->funcretset = false; /* can never be a set */ funcnode->func_fcache = NULL; while (*indexkeys != 0) @@ -769,22 +769,22 @@ find_mergeclauses_for_pathkeys(Query *root, /* * We can match a pathkey against either left or right side of any - * mergejoin clause. (We examine both sides since we aren't told if - * the given pathkeys are for inner or outer input path; no confusion - * is possible.) Furthermore, if there are multiple matching - * clauses, take them all. In plain inner-join scenarios we expect - * only one match, because redundant-mergeclause elimination will - * have removed any redundant mergeclauses from the input list. - * However, in outer-join scenarios there might be multiple matches. - * An example is + * mergejoin clause. (We examine both sides since we aren't told + * if the given pathkeys are for inner or outer input path; no + * confusion is possible.) Furthermore, if there are multiple + * matching clauses, take them all. In plain inner-join scenarios + * we expect only one match, because redundant-mergeclause + * elimination will have removed any redundant mergeclauses from + * the input list. However, in outer-join scenarios there might be + * multiple matches. An example is * - * select * from a full join b on - * a.v1 = b.v1 and a.v2 = b.v2 and a.v1 = b.v2; + * select * from a full join b on a.v1 = b.v1 and a.v2 = b.v2 and + * a.v1 = b.v2; * - * Given the pathkeys ((a.v1), (a.v2)) it is okay to return all - * three clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2) - * and indeed we *must* do so or we will be unable to form a - * valid plan. + * Given the pathkeys ((a.v1), (a.v2)) it is okay to return all three + * clauses (in the order a.v1=b.v1, a.v1=b.v2, a.v2=b.v2) and + * indeed we *must* do so or we will be unable to form a valid + * plan. */ foreach(j, restrictinfos) { @@ -812,8 +812,8 @@ find_mergeclauses_for_pathkeys(Query *root, break; /* - * If we did find usable mergeclause(s) for this sort-key position, - * add them to result list. + * If we did find usable mergeclause(s) for this sort-key + * position, add them to result list. */ mergeclauses = nconc(mergeclauses, matched_restrictinfos); } diff --git a/src/backend/optimizer/plan/createplan.c b/src/backend/optimizer/plan/createplan.c index 908d36bccc..da3568bbd7 100644 --- a/src/backend/optimizer/plan/createplan.c +++ b/src/backend/optimizer/plan/createplan.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.117 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/createplan.c,v 1.118 2002/09/04 20:31:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,7 +79,7 @@ static IndexScan *make_indexscan(List *qptlist, List *qpqual, Index scanrelid, static TidScan *make_tidscan(List *qptlist, List *qpqual, Index scanrelid, List *tideval); static FunctionScan *make_functionscan(List *qptlist, List *qpqual, - Index scanrelid); + Index scanrelid); static NestLoop *make_nestloop(List *tlist, List *joinclauses, List *otherclauses, Plan *lefttree, Plan *righttree, @@ -206,8 +206,8 @@ create_scan_plan(Query *root, Path *best_path) case T_FunctionScan: plan = (Scan *) create_functionscan_plan(best_path, - tlist, - scan_clauses); + tlist, + scan_clauses); break; default: @@ -1346,8 +1346,8 @@ make_functionscan(List *qptlist, List *qpqual, Index scanrelid) { - FunctionScan *node = makeNode(FunctionScan); - Plan *plan = &node->scan.plan; + FunctionScan *node = makeNode(FunctionScan); + Plan *plan = &node->scan.plan; /* cost should be inserted by caller */ plan->state = (EState *) NULL; diff --git a/src/backend/optimizer/plan/initsplan.c b/src/backend/optimizer/plan/initsplan.c index 0187c21d29..e06282c126 100644 --- a/src/backend/optimizer/plan/initsplan.c +++ b/src/backend/optimizer/plan/initsplan.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.74 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/initsplan.c,v 1.75 2002/09/04 20:31:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -108,12 +108,15 @@ add_base_rels_to_query(Query *root, Node *jtnode) add_base_rels_to_query(root, j->rarg)); /* the join's own rtindex is NOT added to result */ jrel = build_other_rel(root, j->rtindex); + /* - * Mark the join's otherrel with outerjoinset = list of baserel ids - * included in the join. Note we must copy here because result list - * is destructively modified by nconcs at higher levels. + * Mark the join's otherrel with outerjoinset = list of baserel + * ids included in the join. Note we must copy here because + * result list is destructively modified by nconcs at higher + * levels. */ jrel->outerjoinset = listCopy(result); + /* * Safety check: join RTEs should not be SELECT FOR UPDATE targets */ @@ -172,8 +175,8 @@ add_vars_to_targetlist(Query *root, List *vars) if (rel->reloptkind == RELOPT_OTHER_JOIN_REL) { /* Var is an alias */ - Node *expansion; - List *varsused; + Node *expansion; + List *varsused; expansion = flatten_join_alias_vars((Node *) var, root->rtable, true); @@ -196,7 +199,7 @@ add_vars_to_targetlist(Query *root, List *vars) * distribute_quals_to_rels * Recursively scan the query's join tree for WHERE and JOIN/ON qual * clauses, and add these to the appropriate RestrictInfo and JoinInfo - * lists belonging to base RelOptInfos. Also, base RelOptInfos are marked + * lists belonging to base RelOptInfos. Also, base RelOptInfos are marked * with outerjoinset information, to aid in proper positioning of qual * clauses that appear above outer joins. * @@ -400,7 +403,8 @@ distribute_qual_to_rels(Query *root, Node *clause, restrictinfo->right_sortop = InvalidOid; restrictinfo->left_pathkey = NIL; /* not computable yet */ restrictinfo->right_pathkey = NIL; - restrictinfo->left_mergescansel = -1; /* not computed until needed */ + restrictinfo->left_mergescansel = -1; /* not computed until + * needed */ restrictinfo->right_mergescansel = -1; restrictinfo->hashjoinoperator = InvalidOid; restrictinfo->left_bucketsize = -1; /* not computed until needed */ @@ -419,7 +423,7 @@ distribute_qual_to_rels(Query *root, Node *clause, * earlier by add_base_rels_to_query. * * We can combine this step with a cross-check that the clause contains - * no relids not within its scope. If the first crosscheck succeeds, + * no relids not within its scope. If the first crosscheck succeeds, * the clause contains no aliases and we needn't look more closely. */ if (!is_subseti(relids, qualscope)) @@ -763,10 +767,10 @@ process_implied_equality(Query *root, Node *item1, Node *item2, clause = makeNode(Expr); clause->typeOid = BOOLOID; clause->opType = OP_EXPR; - clause->oper = (Node *) makeOper(oprid(eq_operator),/* opno */ + clause->oper = (Node *) makeOper(oprid(eq_operator), /* opno */ InvalidOid, /* opid */ - BOOLOID, /* opresulttype */ - false); /* opretset */ + BOOLOID, /* opresulttype */ + false); /* opretset */ clause->args = makeList2(item1, item2); ReleaseSysCache(eq_operator); diff --git a/src/backend/optimizer/plan/planner.c b/src/backend/optimizer/plan/planner.c index b55f8380d4..5510a74957 100644 --- a/src/backend/optimizer/plan/planner.c +++ b/src/backend/optimizer/plan/planner.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.123 2002/08/28 20:46:23 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/planner.c,v 1.124 2002/09/04 20:31:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ static Node *pull_up_subqueries(Query *parse, Node *jtnode, - bool below_outer_join); + bool below_outer_join); static bool is_simple_subquery(Query *subquery); static bool has_nullable_targetlist(Query *subquery); static void resolvenew_in_jointree(Node *jtnode, int varno, List *subtlist); @@ -301,16 +301,16 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) * * If we are inside an outer join, only pull up subqueries whose * targetlists are nullable --- otherwise substituting their tlist - * entries for upper Var references would do the wrong thing - * (the results wouldn't become NULL when they're supposed to). - * XXX This could be improved by generating pseudo-variables for - * such expressions; we'd have to figure out how to get the pseudo- - * variables evaluated at the right place in the modified plan tree. - * Fix it someday. + * entries for upper Var references would do the wrong thing (the + * results wouldn't become NULL when they're supposed to). XXX + * This could be improved by generating pseudo-variables for such + * expressions; we'd have to figure out how to get the pseudo- + * variables evaluated at the right place in the modified plan + * tree. Fix it someday. * * Note: even if the subquery itself is simple enough, we can't pull - * it up if there is a reference to its whole tuple result. Perhaps - * a pseudo-variable is the answer here too. + * it up if there is a reference to its whole tuple result. + * Perhaps a pseudo-variable is the answer here too. */ if (rte->rtekind == RTE_SUBQUERY && is_simple_subquery(subquery) && (!below_outer_join || has_nullable_targetlist(subquery)) && @@ -336,8 +336,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) below_outer_join); /* - * Now make a modifiable copy of the subquery that we can - * run OffsetVarNodes on. + * Now make a modifiable copy of the subquery that we can run + * OffsetVarNodes on. */ subquery = copyObject(subquery); @@ -352,7 +352,8 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) * Replace all of the top query's references to the subquery's * outputs with copies of the adjusted subtlist items, being * careful not to replace any of the jointree structure. - * (This'd be a lot cleaner if we could use query_tree_mutator.) + * (This'd be a lot cleaner if we could use + * query_tree_mutator.) */ subtlist = subquery->targetList; parse->targetList = (List *) @@ -375,15 +376,16 @@ pull_up_subqueries(Query *parse, Node *jtnode, bool below_outer_join) } /* - * Now append the adjusted rtable entries to upper query. - * (We hold off until after fixing the upper rtable entries; - * no point in running that code on the subquery ones too.) + * Now append the adjusted rtable entries to upper query. (We + * hold off until after fixing the upper rtable entries; no + * point in running that code on the subquery ones too.) */ parse->rtable = nconc(parse->rtable, subquery->rtable); /* * Pull up any FOR UPDATE markers, too. (OffsetVarNodes - * already adjusted the marker values, so just nconc the list.) + * already adjusted the marker values, so just nconc the + * list.) */ parse->rowMarks = nconc(parse->rowMarks, subquery->rowMarks); @@ -500,9 +502,9 @@ is_simple_subquery(Query *subquery) /* * Don't pull up a subquery that has any set-returning functions in - * its targetlist. Otherwise we might well wind up inserting - * set-returning functions into places where they mustn't go, - * such as quals of higher queries. + * its targetlist. Otherwise we might well wind up inserting + * set-returning functions into places where they mustn't go, such as + * quals of higher queries. */ if (expression_returns_set((Node *) subquery->targetList)) return false; @@ -724,8 +726,8 @@ preprocess_expression(Query *parse, Node *expr, int kind) /* * If the query has any join RTEs, try to replace join alias variables - * with base-relation variables, to allow quals to be pushed down. - * We must do this after sublink processing, since it does not recurse + * with base-relation variables, to allow quals to be pushed down. We + * must do this after sublink processing, since it does not recurse * into sublinks. * * The flattening pass is expensive enough that it seems worthwhile to diff --git a/src/backend/optimizer/plan/setrefs.c b/src/backend/optimizer/plan/setrefs.c index b685cfa3ba..66998b036f 100644 --- a/src/backend/optimizer/plan/setrefs.c +++ b/src/backend/optimizer/plan/setrefs.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.80 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/setrefs.c,v 1.81 2002/09/04 20:31:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -423,7 +423,7 @@ join_references_mutator(Node *node, resdom = tlist_member((Node *) var, context->outer_tlist); if (resdom) { - Var *newvar = (Var *) copyObject(var); + Var *newvar = (Var *) copyObject(var); newvar->varno = OUTER; newvar->varattno = resdom->resno; @@ -432,7 +432,7 @@ join_references_mutator(Node *node, resdom = tlist_member((Node *) var, context->inner_tlist); if (resdom) { - Var *newvar = (Var *) copyObject(var); + Var *newvar = (Var *) copyObject(var); newvar->varno = INNER; newvar->varattno = resdom->resno; diff --git a/src/backend/optimizer/plan/subselect.c b/src/backend/optimizer/plan/subselect.c index c1ab186b01..1dcebba2e7 100644 --- a/src/backend/optimizer/plan/subselect.c +++ b/src/backend/optimizer/plan/subselect.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.54 2002/06/20 20:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/plan/subselect.c,v 1.55 2002/09/04 20:31:21 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -369,7 +369,7 @@ make_subplan(SubLink *slink) } if (use_material) { - Plan *matplan; + Plan *matplan; matplan = (Plan *) make_material(plan->targetlist, plan); /* kluge --- see comments above */ @@ -663,8 +663,8 @@ SS_finalize_plan(Plan *plan, List *rtable) case T_Append: foreach(lst, ((Append *) plan)->appendplans) results.paramids = set_unioni(results.paramids, - SS_finalize_plan((Plan *) lfirst(lst), - rtable)); + SS_finalize_plan((Plan *) lfirst(lst), + rtable)); break; case T_NestLoop: diff --git a/src/backend/optimizer/prep/preptlist.c b/src/backend/optimizer/prep/preptlist.c index 41f9b2f947..5b930e2b5e 100644 --- a/src/backend/optimizer/prep/preptlist.c +++ b/src/backend/optimizer/prep/preptlist.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.55 2002/08/31 22:10:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/preptlist.c,v 1.56 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -128,7 +128,8 @@ expand_targetlist(List *tlist, int command_type, /* * The rewriter should have already ensured that the TLEs are in - * correct order; but we have to insert TLEs for any missing attributes. + * correct order; but we have to insert TLEs for any missing + * attributes. * * Scan the tuple description in the relation's relcache entry to make * sure we have all the user attributes in the right order. @@ -161,14 +162,14 @@ expand_targetlist(List *tlist, int command_type, /* * Didn't find a matching tlist entry, so make one. * - * For INSERT, generate a NULL constant. (We assume the - * rewriter would have inserted any available default value.) - * Also, if the column isn't dropped, apply any domain constraints - * that might exist --- this is to catch domain NOT NULL. + * For INSERT, generate a NULL constant. (We assume the rewriter + * would have inserted any available default value.) Also, if + * the column isn't dropped, apply any domain constraints that + * might exist --- this is to catch domain NOT NULL. * * For UPDATE, generate a Var reference to the existing value of - * the attribute, so that it gets copied to the new tuple. - * But generate a NULL for dropped columns (we want to drop any + * the attribute, so that it gets copied to the new tuple. But + * generate a NULL for dropped columns (we want to drop any * old values). */ Oid atttype = att_tup->atttypid; @@ -181,13 +182,13 @@ expand_targetlist(List *tlist, int command_type, new_expr = (Node *) makeConst(atttype, att_tup->attlen, (Datum) 0, - true, /* isnull */ + true, /* isnull */ att_tup->attbyval, - false, /* not a set */ + false, /* not a set */ false); if (!att_tup->attisdropped) new_expr = coerce_type_constraints(NULL, new_expr, - atttype, false); + atttype, false); break; case CMD_UPDATE: /* Insert NULLs for dropped columns */ @@ -215,7 +216,7 @@ expand_targetlist(List *tlist, int command_type, new_tle = makeTargetEntry(makeResdom(attrno, atttype, atttypmod, - pstrdup(NameStr(att_tup->attname)), + pstrdup(NameStr(att_tup->attname)), false), new_expr); } diff --git a/src/backend/optimizer/prep/prepunion.c b/src/backend/optimizer/prep/prepunion.c index 492492b9f7..fb4fd3e1d3 100644 --- a/src/backend/optimizer/prep/prepunion.c +++ b/src/backend/optimizer/prep/prepunion.c @@ -14,7 +14,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.77 2002/09/02 02:47:02 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/prep/prepunion.c,v 1.78 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ static List *generate_setop_tlist(List *colTypes, int flag, List *input_tlist, List *refnames_tlist); static List *generate_append_tlist(List *colTypes, bool flag, - List *input_plans, - List *refnames_tlist); + List *input_plans, + List *refnames_tlist); static Node *adjust_inherited_attrs_mutator(Node *node, adjust_inherited_attrs_context *context); @@ -172,8 +172,9 @@ recurse_set_operations(Node *setOp, Query *parse, * This would fail if the Vars generated by generate_setop_tlist() * were not exactly equal() to the corresponding tlist entries of * the subplan. However, since the subplan was generated by - * generate_union_plan() or generate_nonunion_plan(), and hence its - * tlist was generated by generate_append_tlist(), this will work. + * generate_union_plan() or generate_nonunion_plan(), and hence + * its tlist was generated by generate_append_tlist(), this will + * work. */ if (flag >= 0 || !tlist_same_datatypes(plan->targetlist, colTypes, junkOK)) @@ -485,15 +486,15 @@ generate_append_tlist(List *colTypes, bool flag, /* * First extract typmods to use. * - * If the inputs all agree on type and typmod of a particular column, - * use that typmod; else use -1. + * If the inputs all agree on type and typmod of a particular column, use + * that typmod; else use -1. */ colTypmods = (int32 *) palloc(length(colTypes) * sizeof(int32)); foreach(planl, input_plans) { - Plan *subplan = (Plan *) lfirst(planl); - List *subtlist; + Plan *subplan = (Plan *) lfirst(planl); + List *subtlist; curColType = colTypes; colindex = 0; @@ -796,8 +797,8 @@ adjust_inherited_attrs_mutator(Node *node, var->varno = context->new_rt_index; if (var->varattno > 0) { - char *attname = get_attname(context->old_relid, - var->varattno); + char *attname = get_attname(context->old_relid, + var->varattno); var->varattno = get_attnum(context->new_relid, attname); if (var->varattno == InvalidAttrNumber) @@ -819,10 +820,10 @@ adjust_inherited_attrs_mutator(Node *node, if (IsA(node, JoinExpr)) { /* Copy the JoinExpr node with correct mutation of subnodes */ - JoinExpr *j; + JoinExpr *j; j = (JoinExpr *) expression_tree_mutator(node, - adjust_inherited_attrs_mutator, + adjust_inherited_attrs_mutator, (void *) context); /* now fix JoinExpr's rtindex */ if (j->rtindex == context->old_rt_index) diff --git a/src/backend/optimizer/util/clauses.c b/src/backend/optimizer/util/clauses.c index 3b5e698839..edf77faff0 100644 --- a/src/backend/optimizer/util/clauses.c +++ b/src/backend/optimizer/util/clauses.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.107 2002/08/31 22:10:43 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/clauses.c,v 1.108 2002/09/04 20:31:22 momjian Exp $ * * HISTORY * AUTHOR DATE MAJOR EVENT @@ -43,7 +43,7 @@ typedef struct { Query *query; List *groupClauses; -} check_subplans_for_ungrouped_vars_context; +} check_subplans_for_ungrouped_vars_context; static bool contain_agg_clause_walker(Node *node, void *context); static bool pull_agg_clause_walker(Node *node, List **listptr); @@ -51,7 +51,7 @@ static bool expression_returns_set_walker(Node *node, void *context); static bool contain_subplans_walker(Node *node, void *context); static bool pull_subplans_walker(Node *node, List **listptr); static bool check_subplans_for_ungrouped_vars_walker(Node *node, - check_subplans_for_ungrouped_vars_context * context); + check_subplans_for_ungrouped_vars_context *context); static bool contain_mutable_functions_walker(Node *node, void *context); static bool contain_volatile_functions_walker(Node *node, void *context); static Node *eval_const_expressions_mutator(Node *node, void *context); @@ -479,7 +479,7 @@ expression_returns_set_walker(Node *node, void *context) return false; if (IsA(node, Expr)) { - Expr *expr = (Expr *) node; + Expr *expr = (Expr *) node; switch (expr->opType) { @@ -633,7 +633,7 @@ check_subplans_for_ungrouped_vars(Query *query) static bool check_subplans_for_ungrouped_vars_walker(Node *node, - check_subplans_for_ungrouped_vars_context * context) + check_subplans_for_ungrouped_vars_context *context) { List *gl; @@ -786,11 +786,11 @@ contain_mutable_functions_walker(Node *node, void *context) * Recursively search for volatile functions within a clause. * * Returns true if any volatile function (or operator implemented by a - * volatile function) is found. This test prevents invalid conversions + * volatile function) is found. This test prevents invalid conversions * of volatile expressions into indexscan quals. * * XXX we do not examine sublinks/subplans to see if they contain uses of - * volatile functions. It's not real clear if that is correct or not... + * volatile functions. It's not real clear if that is correct or not... */ bool contain_volatile_functions(Node *clause) @@ -837,7 +837,7 @@ contain_volatile_functions_walker(Node *node, void *context) * of the current query level and no uses of volatile functions. * Such a clause is not necessarily a true constant: it can still contain * Params and outer-level Vars, not to mention functions whose results - * may vary from one statement to the next. However, the clause's value + * may vary from one statement to the next. However, the clause's value * will be constant over any one scan of the current query, so it can be * used as an indexscan key or (if a top-level qual) can be pushed up to * become a gating qual. @@ -1143,7 +1143,7 @@ eval_const_expressions_mutator(Node *node, void *context) * expression_tree_mutator directly rather than recursing to self. */ args = (List *) expression_tree_mutator((Node *) expr->args, - eval_const_expressions_mutator, + eval_const_expressions_mutator, (void *) context); switch (expr->opType) @@ -1166,13 +1166,14 @@ eval_const_expressions_mutator(Node *node, void *context) break; case DISTINCT_EXPR: { - List *arg; - bool has_null_input = false; - bool all_null_input = true; - bool has_nonconst_input = false; + List *arg; + bool has_null_input = false; + bool all_null_input = true; + bool has_nonconst_input = false; /* - * Check for constant inputs and especially constant-NULL inputs. + * Check for constant inputs and especially + * constant-NULL inputs. */ Assert(length(args) == 2); foreach(arg, args) @@ -1183,9 +1184,7 @@ eval_const_expressions_mutator(Node *node, void *context) all_null_input &= ((Const *) lfirst(arg))->constisnull; } else - { has_nonconst_input = true; - } } /* all nulls? then not distinct */ if (all_null_input) @@ -1206,18 +1205,23 @@ eval_const_expressions_mutator(Node *node, void *context) bool const_is_null; Oper *oper = (Oper *) expr->oper; - replace_opid(oper); /* OK to scribble on input to this extent */ + + replace_opid(oper); /* OK to scribble on input + * to this extent */ result_typeid = oper->opresulttype; /* - * OK, looks like we can simplify this operator/function. + * OK, looks like we can simplify this + * operator/function. * - * We use the executor's routine ExecEvalExpr() to avoid duplication of - * code and ensure we get the same result as the executor would get. + * We use the executor's routine ExecEvalExpr() to + * avoid duplication of code and ensure we get the + * same result as the executor would get. * - * Build a new Expr node containing the already-simplified arguments. The - * only other setup needed here is the replace_opid() that we already - * did for the OP_EXPR case. + * Build a new Expr node containing the + * already-simplified arguments. The only other + * setup needed here is the replace_opid() that we + * already did for the OP_EXPR case. */ newexpr = makeNode(Expr); newexpr->typeOid = expr->typeOid; @@ -1229,17 +1233,22 @@ eval_const_expressions_mutator(Node *node, void *context) get_typlenbyval(result_typeid, &resultTypLen, &resultTypByVal); /* - * It is OK to pass a dummy econtext because none of the - * ExecEvalExpr() code used in this situation will use econtext. That - * might seem fortuitous, but it's not so unreasonable --- a constant - * expression does not depend on context, by definition, n'est ce pas? + * It is OK to pass a dummy econtext because none + * of the ExecEvalExpr() code used in this + * situation will use econtext. That might seem + * fortuitous, but it's not so unreasonable --- a + * constant expression does not depend on context, + * by definition, n'est ce pas? */ econtext = MakeExprContext(NULL, CurrentMemoryContext); const_val = ExecEvalExprSwitchContext((Node *) newexpr, econtext, - &const_is_null, NULL); + &const_is_null, NULL); - /* Must copy result out of sub-context used by expression eval */ + /* + * Must copy result out of sub-context used by + * expression eval + */ if (!const_is_null) const_val = datumCopy(const_val, resultTypByVal, resultTypLen); @@ -1250,8 +1259,8 @@ eval_const_expressions_mutator(Node *node, void *context) * Make the constant result node. */ return (Node *) makeConst(result_typeid, resultTypLen, - const_val, const_is_null, - resultTypByVal, false, false); + const_val, const_is_null, + resultTypByVal, false, false); } break; } @@ -1952,6 +1961,7 @@ expression_tree_walker(Node *node, return true; if (walker(join->quals, context)) return true; + /* * alias clause, using list are deemed uninteresting. */ diff --git a/src/backend/optimizer/util/plancat.c b/src/backend/optimizer/util/plancat.c index b9a91d1862..3aee668448 100644 --- a/src/backend/optimizer/util/plancat.c +++ b/src/backend/optimizer/util/plancat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.73 2002/06/20 20:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/plancat.c,v 1.74 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -163,7 +163,7 @@ find_secondary_indexes(Oid relationObjectId) MemSet(info->ordering, 0, sizeof(Oid) * (INDEX_MAX_KEYS + 1)); if (amorderstrategy != 0) { - int oprindex = amorderstrategy - 1; + int oprindex = amorderstrategy - 1; for (i = 0; i < info->ncolumns; i++) { diff --git a/src/backend/optimizer/util/relnode.c b/src/backend/optimizer/util/relnode.c index 978d9f0b30..49e2f1f0a2 100644 --- a/src/backend/optimizer/util/relnode.c +++ b/src/backend/optimizer/util/relnode.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.38 2002/06/20 20:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/relnode.c,v 1.39 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -157,16 +157,16 @@ make_base_rel(Query *root, int relid) switch (rte->rtekind) { case RTE_RELATION: - { - /* Table --- retrieve statistics from the system catalogs */ - bool indexed; - - get_relation_info(rte->relid, - &indexed, &rel->pages, &rel->tuples); - if (indexed) - rel->indexlist = find_secondary_indexes(rte->relid); - break; - } + { + /* Table --- retrieve statistics from the system catalogs */ + bool indexed; + + get_relation_info(rte->relid, + &indexed, &rel->pages, &rel->tuples); + if (indexed) + rel->indexlist = find_secondary_indexes(rte->relid); + break; + } case RTE_SUBQUERY: case RTE_FUNCTION: /* Subquery or function --- nothing to do here */ @@ -379,11 +379,11 @@ build_join_rel(Query *root, * of the outer and inner join relations and then merging the results * together. * - * XXX right now we don't remove any irrelevant elements, we just - * append the two tlists together. Someday consider pruning vars from the + * XXX right now we don't remove any irrelevant elements, we just append + * the two tlists together. Someday consider pruning vars from the * join's targetlist if they are needed only to evaluate restriction - * clauses of this join, and will never be accessed at higher levels of - * the plantree. + * clauses of this join, and will never be accessed at higher levels + * of the plantree. * * NOTE: the tlist order for a join rel will depend on which pair of * outer and inner rels we first try to build it from. But the @@ -396,12 +396,12 @@ build_join_rel(Query *root, /* * If there are any alias variables attached to the matching join RTE, - * attach them to the tlist too, so that they will be evaluated for use - * at higher plan levels. + * attach them to the tlist too, so that they will be evaluated for + * use at higher plan levels. */ if (joinrterel) { - List *jrtetl; + List *jrtetl; foreach(jrtetl, joinrterel->targetlist) { diff --git a/src/backend/optimizer/util/var.c b/src/backend/optimizer/util/var.c index 776636ff59..ccccdbf180 100644 --- a/src/backend/optimizer/util/var.c +++ b/src/backend/optimizer/util/var.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.38 2002/06/20 20:29:31 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/optimizer/util/var.c,v 1.39 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -53,7 +53,7 @@ static bool contain_var_clause_walker(Node *node, void *context); static bool pull_var_clause_walker(Node *node, pull_var_clause_context *context); static Node *flatten_join_alias_vars_mutator(Node *node, - flatten_join_alias_vars_context *context); + flatten_join_alias_vars_context *context); /* @@ -317,7 +317,7 @@ pull_var_clause_walker(Node *node, pull_var_clause_context *context) * If force is TRUE then we will reduce all JOIN alias Vars to non-alias Vars * or expressions thereof (there may be COALESCE and/or type conversions * involved). If force is FALSE we will not expand a Var to a non-Var - * expression. This is a hack to avoid confusing mergejoin planning, which + * expression. This is a hack to avoid confusing mergejoin planning, which * currently cannot cope with non-Var join items --- we leave the join vars * as Vars till after planning is done, then expand them during setrefs.c. * @@ -346,9 +346,9 @@ flatten_join_alias_vars_mutator(Node *node, return NULL; if (IsA(node, Var)) { - Var *var = (Var *) node; + Var *var = (Var *) node; RangeTblEntry *rte; - Node *newvar; + Node *newvar; if (var->varlevelsup != 0) return node; /* no need to copy, really */ @@ -357,7 +357,7 @@ flatten_join_alias_vars_mutator(Node *node, return node; Assert(var->varattno > 0); newvar = (Node *) nth(var->varattno - 1, rte->joinaliasvars); - if (IsA(newvar, Var) || context->force) + if (IsA(newvar, Var) ||context->force) { /* expand it; recurse in case join input is itself a join */ return flatten_join_alias_vars_mutator(newvar, context); diff --git a/src/backend/parser/analyze.c b/src/backend/parser/analyze.c index 9896011df3..97b242b9b6 100644 --- a/src/backend/parser/analyze.c +++ b/src/backend/parser/analyze.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.247 2002/09/02 06:11:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/analyze.c,v 1.248 2002/09/04 20:31:22 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,7 +54,8 @@ typedef struct List *tables; /* CREATE TABLE items */ List *views; /* CREATE VIEW items */ List *grants; /* GRANT items */ - List *fwconstraints; /* Forward referencing FOREIGN KEY constraints */ + List *fwconstraints; /* Forward referencing FOREIGN KEY + * constraints */ List *alters; /* Generated ALTER items (from the above) */ List *ixconstraints; /* index-creating constraints */ List *blist; /* "before list" of things to do before @@ -84,13 +85,13 @@ typedef struct static Query *transformStmt(ParseState *pstate, Node *stmt, - List **extras_before, List **extras_after); + List **extras_before, List **extras_after); static Query *transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt); static Query *transformInsertStmt(ParseState *pstate, InsertStmt *stmt, - List **extras_before, List **extras_after); + List **extras_before, List **extras_after); static Query *transformIndexStmt(ParseState *pstate, IndexStmt *stmt); static Query *transformRuleStmt(ParseState *query, RuleStmt *stmt, - List **extras_before, List **extras_after); + List **extras_before, List **extras_after); static Query *transformSelectStmt(ParseState *pstate, SelectStmt *stmt); static Query *transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt); static Node *transformSetOperationTree(ParseState *pstate, SelectStmt *stmt); @@ -98,7 +99,7 @@ static Query *transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt); static Query *transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt); static Query *transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt); static Query *transformCreateStmt(ParseState *pstate, CreateStmt *stmt, - List **extras_before, List **extras_after); + List **extras_before, List **extras_after); static Query *transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, List **extras_before, List **extras_after); static void transformColumnDefinition(ParseState *pstate, @@ -139,6 +140,7 @@ parse_analyze(Node *parseTree, ParseState *parentParseState) { List *result = NIL; ParseState *pstate = make_parsestate(parentParseState); + /* Lists to return extra commands from transformation */ List *extras_before = NIL; List *extras_after = NIL; @@ -163,13 +165,13 @@ parse_analyze(Node *parseTree, ParseState *parentParseState) } /* - * Make sure that only the original query is marked original. - * We have to do this explicitly since recursive calls of parse_analyze - * will have set originalQuery in some of the added-on queries. + * Make sure that only the original query is marked original. We have + * to do this explicitly since recursive calls of parse_analyze will + * have set originalQuery in some of the added-on queries. */ foreach(listscan, result) { - Query *q = lfirst(listscan); + Query *q = lfirst(listscan); q->originalQuery = (q == query); } @@ -194,7 +196,7 @@ release_pstate_resources(ParseState *pstate) */ static Query * transformStmt(ParseState *pstate, Node *parseTree, - List **extras_before, List **extras_after) + List **extras_before, List **extras_after) { Query *result = NULL; @@ -205,7 +207,7 @@ transformStmt(ParseState *pstate, Node *parseTree, */ case T_CreateStmt: result = transformCreateStmt(pstate, (CreateStmt *) parseTree, - extras_before, extras_after); + extras_before, extras_after); break; case T_IndexStmt: @@ -214,7 +216,7 @@ transformStmt(ParseState *pstate, Node *parseTree, case T_RuleStmt: result = transformRuleStmt(pstate, (RuleStmt *) parseTree, - extras_before, extras_after); + extras_before, extras_after); break; case T_ViewStmt: @@ -222,7 +224,7 @@ transformStmt(ParseState *pstate, Node *parseTree, ViewStmt *n = (ViewStmt *) parseTree; n->query = transformStmt(pstate, (Node *) n->query, - extras_before, extras_after); + extras_before, extras_after); /* * If a list of column names was given, run through and @@ -270,14 +272,14 @@ transformStmt(ParseState *pstate, Node *parseTree, result = makeNode(Query); result->commandType = CMD_UTILITY; n->query = transformStmt(pstate, (Node *) n->query, - extras_before, extras_after); + extras_before, extras_after); result->utilityStmt = (Node *) parseTree; } break; case T_AlterTableStmt: result = transformAlterTableStmt(pstate, (AlterTableStmt *) parseTree, - extras_before, extras_after); + extras_before, extras_after); break; case T_PrepareStmt: @@ -293,7 +295,7 @@ transformStmt(ParseState *pstate, Node *parseTree, */ case T_InsertStmt: result = transformInsertStmt(pstate, (InsertStmt *) parseTree, - extras_before, extras_after); + extras_before, extras_after); break; case T_DeleteStmt: @@ -341,7 +343,7 @@ transformDeleteStmt(ParseState *pstate, DeleteStmt *stmt) /* set up range table with just the result rel */ qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true); qry->distinctClause = NIL; @@ -434,10 +436,11 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, /* * Note: we are not expecting that extras_before and extras_after - * are going to be used by the transformation of the SELECT statement. + * are going to be used by the transformation of the SELECT + * statement. */ selectQuery = transformStmt(sub_pstate, stmt->selectStmt, - extras_before, extras_after); + extras_before, extras_after); release_pstate_resources(sub_pstate); pfree(sub_pstate); @@ -525,7 +528,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, foreach(tl, qry->targetList) { TargetEntry *tle = (TargetEntry *) lfirst(tl); - ResTarget *col; + ResTarget *col; if (icolumns == NIL || attnos == NIL) elog(ERROR, "INSERT has more expressions than target columns"); @@ -541,7 +544,7 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, Assert(IsA(col, ResTarget)); Assert(!tle->resdom->resjunk); updateTargetListEntry(pstate, tle, col->name, lfirsti(attnos), - col->indirection); + col->indirection); } else { @@ -555,9 +558,9 @@ transformInsertStmt(ParseState *pstate, InsertStmt *stmt, } /* - * Ensure that the targetlist has the same number of entries - * that were present in the columns list. Don't do the check - * for select statements. + * Ensure that the targetlist has the same number of entries that + * were present in the columns list. Don't do the check for select + * statements. */ if (stmt->cols != NIL && (icolumns != NIL || attnos != NIL)) elog(ERROR, "INSERT has more target columns than expressions"); @@ -780,8 +783,8 @@ transformCreateStmt(ParseState *pstate, CreateStmt *stmt, q->utilityStmt = (Node *) stmt; stmt->tableElts = cxt.columns; stmt->constraints = cxt.ckconstraints; - *extras_before = nconc (*extras_before, cxt.blist); - *extras_after = nconc (cxt.alist, *extras_after); + *extras_before = nconc(*extras_before, cxt.blist); + *extras_after = nconc(cxt.alist, *extras_after); return q; } @@ -839,7 +842,7 @@ transformColumnDefinition(ParseState *pstate, CreateStmtContext *cxt, snamespace = get_namespace_name(RangeVarGetCreationNamespace(cxt->relation)); elog(NOTICE, "%s will create implicit sequence '%s' for SERIAL column '%s.%s'", - cxt->stmtType, sname, cxt->relation->relname, column->colname); + cxt->stmtType, sname, cxt->relation->relname, column->colname); /* * Build a CREATE SEQUENCE command to create the sequence object, @@ -1213,9 +1216,10 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) /* * Scan the index list and remove any redundant index specifications. - * This can happen if, for instance, the user writes UNIQUE PRIMARY KEY. - * A strict reading of SQL92 would suggest raising an error instead, - * but that strikes me as too anal-retentive. - tgl 2001-02-14 + * This can happen if, for instance, the user writes UNIQUE PRIMARY + * KEY. A strict reading of SQL92 would suggest raising an error + * instead, but that strikes me as too anal-retentive. - tgl + * 2001-02-14 * * XXX in ALTER TABLE case, it'd be nice to look for duplicate * pre-existing indexes, too. @@ -1279,7 +1283,7 @@ transformIndexConstraints(ParseState *pstate, CreateStmtContext *cxt) iparam = lfirst(index->indexParams); index->idxname = CreateIndexName(cxt->relation->relname, iparam->name ? iparam->name : - strVal(llast(iparam->funcname)), + strVal(llast(iparam->funcname)), "key", cxt->alist); } if (index->idxname == NULL) /* should not happen */ @@ -1352,7 +1356,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) IndexElem *ielem = lfirst(attr); char *iname = ielem->name; - Assert(iname); /* no func index here */ + Assert(iname); /* no func index here */ fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs, makeString(iname)); if (attnum >= INDEX_MAX_KEYS) @@ -1417,7 +1421,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) elog(ERROR, "Can only have %d keys in a foreign key", INDEX_MAX_KEYS); pktypoid[attnum++] = transformFkeyGetColType(cxt, - pkattr); + pkattr); } if (found) break; @@ -1444,8 +1448,8 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) * fktypoid[i] is the foreign key table's i'th element's type * pktypoid[i] is the primary key table's i'th element's type * - * We let oper() do our work for us, including elog(ERROR) if - * the types don't compare with = + * We let oper() do our work for us, including elog(ERROR) if the + * types don't compare with = */ Operator o = oper(makeList1(makeString("=")), fktypoid[i], pktypoid[i], false); @@ -1462,7 +1466,7 @@ transformFKConstraints(ParseState *pstate, CreateStmtContext *cxt) { AlterTableStmt *alterstmt = makeNode(AlterTableStmt); - alterstmt->subtype = 'c'; /* preprocessed add constraint */ + alterstmt->subtype = 'c'; /* preprocessed add constraint */ alterstmt->relation = cxt->relation; alterstmt->name = NULL; alterstmt->def = (Node *) makeList1(fkconstraint); @@ -1528,7 +1532,7 @@ transformIndexStmt(ParseState *pstate, IndexStmt *stmt) */ static Query * transformRuleStmt(ParseState *pstate, RuleStmt *stmt, - List **extras_before, List **extras_after) + List **extras_before, List **extras_after) { Query *qry; RangeTblEntry *oldrte; @@ -1658,7 +1662,7 @@ transformRuleStmt(ParseState *pstate, RuleStmt *stmt, /* Transform the rule action statement */ top_subqry = transformStmt(sub_pstate, action, - extras_before, extras_after); + extras_before, extras_after); /* * We cannot support utility-statement actions (eg NOTIFY) @@ -2015,8 +2019,8 @@ transformSetOperationStmt(ParseState *pstate, SelectStmt *stmt) } /* - * Any column names from CREATE TABLE AS need to be attached to both the - * top level and the leftmost subquery. We do not do this earlier + * Any column names from CREATE TABLE AS need to be attached to both + * the top level and the leftmost subquery. We do not do this earlier * because we do *not* want the targetnames list to be affected. */ if (intoColNames) @@ -2299,7 +2303,7 @@ transformUpdateStmt(ParseState *pstate, UpdateStmt *stmt) pstate->p_is_update = true; qry->resultRelation = setTargetTable(pstate, stmt->relation, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), true); /* @@ -2445,6 +2449,7 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, break; case 'c': + /* * Already-transformed ADD CONSTRAINT, so just make it look * like the standard case. @@ -2466,12 +2471,12 @@ transformAlterTableStmt(ParseState *pstate, AlterTableStmt *stmt, static Query * transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt) { - Query *result = makeNode(Query); - List *extras_before = NIL, - *extras_after = NIL; - List *argtype_oids = NIL; /* argtype OIDs in a list */ - Oid *argtoids = NULL; /* as an array for parser_param_set */ - int nargs; + Query *result = makeNode(Query); + List *extras_before = NIL, + *extras_after = NIL; + List *argtype_oids = NIL; /* argtype OIDs in a list */ + Oid *argtoids = NULL; /* as an array for parser_param_set */ + int nargs; result->commandType = CMD_UTILITY; result->utilityStmt = (Node *) stmt; @@ -2481,15 +2486,15 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt) if (nargs) { - List *l; - int i = 0; + List *l; + int i = 0; argtoids = (Oid *) palloc(nargs * sizeof(Oid)); - foreach (l, stmt->argtypes) + foreach(l, stmt->argtypes) { - TypeName *tn = lfirst(l); - Oid toid = typenameTypeId(tn); + TypeName *tn = lfirst(l); + Oid toid = typenameTypeId(tn); argtype_oids = lappendi(argtype_oids, toid); argtoids[i++] = toid; @@ -2499,12 +2504,12 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt) stmt->argtype_oids = argtype_oids; /* - * We need to adjust the parameters expected by the - * rest of the system, so that $1, ... $n are parsed properly. + * We need to adjust the parameters expected by the rest of the + * system, so that $1, ... $n are parsed properly. * - * This is somewhat of a hack; however, the main parser interface - * only allows parameters to be specified when working with a - * raw query string, which is not helpful here. + * This is somewhat of a hack; however, the main parser interface only + * allows parameters to be specified when working with a raw query + * string, which is not helpful here. */ parser_param_set(argtoids, nargs); @@ -2524,8 +2529,8 @@ transformPrepareStmt(ParseState *pstate, PrepareStmt *stmt) static Query * transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) { - Query *result = makeNode(Query); - List *paramtypes; + Query *result = makeNode(Query); + List *paramtypes; result->commandType = CMD_UTILITY; result->utilityStmt = (Node *) stmt; @@ -2534,20 +2539,20 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (stmt->params || paramtypes) { - int nparams = length(stmt->params); - int nexpected = length(paramtypes); - List *l; - int i = 1; + int nparams = length(stmt->params); + int nexpected = length(paramtypes); + List *l; + int i = 1; if (nparams != nexpected) elog(ERROR, "Wrong number of parameters, expected %d but got %d", nexpected, nparams); - foreach (l, stmt->params) + foreach(l, stmt->params) { - Node *expr = lfirst(l); - Oid expected_type_id, - given_type_id; + Node *expr = lfirst(l); + Oid expected_type_id, + given_type_id; expr = transformExpr(pstate, expr); @@ -2571,7 +2576,7 @@ transformExecuteStmt(ParseState *pstate, ExecuteStmt *stmt) if (!expr) elog(ERROR, "Parameter $%d of type %s cannot be coerced into the expected type %s" - "\n\tYou will need to rewrite or cast the expression", + "\n\tYou will need to rewrite or cast the expression", i, format_type_be(given_type_id), format_type_be(expected_type_id)); @@ -2833,7 +2838,7 @@ transformFkeyGetPrimaryKey(FkConstraint *fkconstraint, Oid *pktypoid) pktypoid[attnum++] = attnumTypeId(pkrel, pkattno); fkconstraint->pk_attrs = lappend(fkconstraint->pk_attrs, - makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno))))); + makeString(pstrdup(NameStr(*attnumAttName(pkrel, pkattno))))); } ReleaseSysCache(indexTuple); @@ -3145,8 +3150,8 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) elp->relation->schemaname = cxt.schemaname; else if (strcmp(cxt.schemaname, elp->relation->schemaname) != 0) elog(ERROR, "New table specifies a schema (%s)" - " different from the one being created (%s)", - elp->relation->schemaname, cxt.schemaname); + " different from the one being created (%s)", + elp->relation->schemaname, cxt.schemaname); /* * XXX todo: deal with constraints @@ -3158,14 +3163,14 @@ analyzeCreateSchemaStmt(CreateSchemaStmt *stmt) case T_ViewStmt: { - ViewStmt *elp = (ViewStmt *) element; + ViewStmt *elp = (ViewStmt *) element; if (elp->view->schemaname == NULL) elp->view->schemaname = cxt.schemaname; else if (strcmp(cxt.schemaname, elp->view->schemaname) != 0) elog(ERROR, "New view specifies a schema (%s)" - " different from the one being created (%s)", - elp->view->schemaname, cxt.schemaname); + " different from the one being created (%s)", + elp->view->schemaname, cxt.schemaname); /* * XXX todo: deal with references between views diff --git a/src/backend/parser/parse_clause.c b/src/backend/parser/parse_clause.c index 95f45a942a..a46ff5e2fc 100644 --- a/src/backend/parser/parse_clause.c +++ b/src/backend/parser/parse_clause.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.96 2002/08/18 18:46:15 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_clause.c,v 1.97 2002/09/04 20:31:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -41,8 +41,8 @@ static char *clauseText[] = {"ORDER BY", "GROUP BY", "DISTINCT ON"}; static void extractRemainingColumns(List *common_colnames, - List *src_colnames, List *src_colvars, - List **res_colnames, List **res_colvars); + List *src_colnames, List *src_colvars, + List **res_colnames, List **res_colvars); static Node *transformJoinUsingClause(ParseState *pstate, List *leftVars, List *rightVars); static Node *transformJoinOnClause(ParseState *pstate, JoinExpr *j, @@ -51,11 +51,11 @@ static RangeTblRef *transformTableEntry(ParseState *pstate, RangeVar *r); static RangeTblRef *transformRangeSubselect(ParseState *pstate, RangeSubselect *r); static RangeTblRef *transformRangeFunction(ParseState *pstate, - RangeFunction *r); + RangeFunction *r); static Node *transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels); static Node *buildMergedJoinVar(JoinType jointype, - Var *l_colvar, Var *r_colvar); + Var *l_colvar, Var *r_colvar); static TargetEntry *findTargetlistEntry(ParseState *pstate, Node *node, List *tlist, int clause); static List *addTargetToSortList(TargetEntry *tle, List *sortlist, @@ -85,9 +85,9 @@ transformFromClause(ParseState *pstate, List *frmList) /* * The grammar will have produced a list of RangeVars, - * RangeSubselects, RangeFunctions, and/or JoinExprs. Transform each one - * (possibly adding entries to the rtable), check for duplicate refnames, - * and then add it to the joinlist and namespace. + * RangeSubselects, RangeFunctions, and/or JoinExprs. Transform each + * one (possibly adding entries to the rtable), check for duplicate + * refnames, and then add it to the joinlist and namespace. */ foreach(fl, frmList) { @@ -466,13 +466,14 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) funcname = strVal(llast(((FuncCall *) r->funccallnode)->funcname)); /* - * Transform the raw FuncCall node. This is a bit tricky because we don't - * want the function expression to be able to see any FROM items already - * created in the current query (compare to transformRangeSubselect). - * But it does need to be able to see any further-up parent states. - * So, temporarily make the current query level have an empty namespace. - * NOTE: this code is OK only because the expression can't legally alter - * the namespace by causing implicit relation refs to be added. + * Transform the raw FuncCall node. This is a bit tricky because we + * don't want the function expression to be able to see any FROM items + * already created in the current query (compare to + * transformRangeSubselect). But it does need to be able to see any + * further-up parent states. So, temporarily make the current query + * level have an empty namespace. NOTE: this code is OK only because + * the expression can't legally alter the namespace by causing + * implicit relation refs to be added. */ save_namespace = pstate->p_namespace; pstate->p_namespace = NIL; @@ -482,18 +483,18 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) pstate->p_namespace = save_namespace; /* - * We still need to check that the function parameters don't refer - * to any other rels. That could happen despite our hack on the namespace - * if fully-qualified names are used. So, check there are no local - * Var references in the transformed expression. (Outer references - * are OK, and are ignored here.) + * We still need to check that the function parameters don't refer to + * any other rels. That could happen despite our hack on the + * namespace if fully-qualified names are used. So, check there are + * no local Var references in the transformed expression. (Outer + * references are OK, and are ignored here.) */ if (pull_varnos(funcexpr) != NIL) elog(ERROR, "FROM function expression may not refer to other relations of same query level"); /* - * Disallow aggregate functions in the expression. (No reason to postpone - * this check until parseCheckAggregates.) + * Disallow aggregate functions in the expression. (No reason to + * postpone this check until parseCheckAggregates.) */ if (pstate->p_hasAggs) { @@ -503,8 +504,9 @@ transformRangeFunction(ParseState *pstate, RangeFunction *r) /* * Insist we have a bare function call (explain.c is the only place - * that depends on this, I think). If this fails, it's probably because - * transformExpr interpreted the function notation as a type coercion. + * that depends on this, I think). If this fails, it's probably + * because transformExpr interpreted the function notation as a type + * coercion. */ if (!funcexpr || !IsA(funcexpr, Expr) || @@ -596,8 +598,8 @@ transformFromClauseItem(ParseState *pstate, Node *n, List **containedRels) j->rarg = transformFromClauseItem(pstate, j->rarg, &r_containedRels); /* - * Generate combined list of relation indexes for possible use - * by transformJoinOnClause below. + * Generate combined list of relation indexes for possible use by + * transformJoinOnClause below. */ my_containedRels = nconc(l_containedRels, r_containedRels); @@ -893,6 +895,7 @@ buildMergedJoinVar(JoinType jointype, Var *l_colvar, Var *r_colvar) switch (jointype) { case JOIN_INNER: + /* * We can use either var; prefer non-coerced one if available. */ @@ -912,25 +915,25 @@ buildMergedJoinVar(JoinType jointype, Var *l_colvar, Var *r_colvar) res_node = r_node; break; case JOIN_FULL: - { - /* - * Here we must build a COALESCE expression to ensure that - * the join output is non-null if either input is. - */ - CaseExpr *c = makeNode(CaseExpr); - CaseWhen *w = makeNode(CaseWhen); - NullTest *n = makeNode(NullTest); - - n->arg = l_node; - n->nulltesttype = IS_NOT_NULL; - w->expr = (Node *) n; - w->result = l_node; - c->casetype = outcoltype; - c->args = makeList1(w); - c->defresult = r_node; - res_node = (Node *) c; - break; - } + { + /* + * Here we must build a COALESCE expression to ensure that + * the join output is non-null if either input is. + */ + CaseExpr *c = makeNode(CaseExpr); + CaseWhen *w = makeNode(CaseWhen); + NullTest *n = makeNode(NullTest); + + n->arg = l_node; + n->nulltesttype = IS_NOT_NULL; + w->expr = (Node *) n; + w->result = l_node; + c->casetype = outcoltype; + c->args = makeList1(w); + c->defresult = r_node; + res_node = (Node *) c; + break; + } default: elog(ERROR, "buildMergedJoinVar: unexpected jointype %d", (int) jointype); diff --git a/src/backend/parser/parse_coerce.c b/src/backend/parser/parse_coerce.c index 18224a7e3f..d57e18f232 100644 --- a/src/backend/parser/parse_coerce.c +++ b/src/backend/parser/parse_coerce.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.82 2002/09/01 02:27:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_coerce.c,v 2.83 2002/09/04 20:31:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,8 +29,8 @@ static Oid PreferredType(CATEGORY category, Oid type); static bool find_coercion_pathway(Oid targetTypeId, Oid sourceTypeId, - bool isExplicit, - Oid *funcid); + bool isExplicit, + Oid *funcid); static Oid find_typmod_coercion_function(Oid typeId); static Node *build_func_call(Oid funcid, Oid rettype, List *args); @@ -71,8 +71,8 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, * XXX if the typinput function is not cachable, we really ought to * postpone evaluation of the function call until runtime. But * there is no way to represent a typinput function call as an - * expression tree, because C-string values are not Datums. - * (XXX This *is* possible as of 7.3, do we want to do it?) + * expression tree, because C-string values are not Datums. (XXX + * This *is* possible as of 7.3, do we want to do it?) */ Const *con = (Const *) node; Const *newcon = makeNode(Const); @@ -91,10 +91,11 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, con->constvalue)); /* - * If target is a domain, use the typmod it applies to the base - * type. Note that we call stringTypeDatum using the domain's - * pg_type row, though. This works because the domain row has - * the same typinput and typelem as the base type --- ugly... + * If target is a domain, use the typmod it applies to the + * base type. Note that we call stringTypeDatum using the + * domain's pg_type row, though. This works because the + * domain row has the same typinput and typelem as the base + * type --- ugly... */ if (targetTyptype == 'd') atttypmod = getBaseTypeMod(targetTypeId, atttypmod); @@ -127,11 +128,12 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, if (OidIsValid(funcId)) { /* - * Generate an expression tree representing run-time application - * of the conversion function. If we are dealing with a domain - * target type, the conversion function will yield the base type. + * Generate an expression tree representing run-time + * application of the conversion function. If we are dealing + * with a domain target type, the conversion function will + * yield the base type. */ - Oid baseTypeId = getBaseType(targetTypeId); + Oid baseTypeId = getBaseType(targetTypeId); result = build_func_call(funcId, baseTypeId, makeList1(node)); @@ -147,19 +149,20 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, } /* - * If the input is a constant, apply the type conversion function - * now instead of delaying to runtime. (We could, of course, just - * leave this to be done during planning/optimization; but it's a - * very frequent special case, and we save cycles in the rewriter - * if we fold the expression now.) + * If the input is a constant, apply the type conversion + * function now instead of delaying to runtime. (We could, of + * course, just leave this to be done during + * planning/optimization; but it's a very frequent special + * case, and we save cycles in the rewriter if we fold the + * expression now.) * * Note that no folding will occur if the conversion function is * not marked 'immutable'. * * HACK: if constant is NULL, don't fold it here. This is needed * by make_subplan(), which calls this routine on placeholder - * Const nodes that mustn't be collapsed. (It'd be a lot cleaner - * to make a separate node type for that purpose...) + * Const nodes that mustn't be collapsed. (It'd be a lot + * cleaner to make a separate node type for that purpose...) */ if (IsA(node, Const) && !((Const *) node)->constisnull) @@ -168,21 +171,23 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, else { /* - * We don't need to do a physical conversion, but we do need to - * attach a RelabelType node so that the expression will be seen - * to have the intended type when inspected by higher-level code. + * We don't need to do a physical conversion, but we do need + * to attach a RelabelType node so that the expression will be + * seen to have the intended type when inspected by + * higher-level code. * * Also, domains may have value restrictions beyond the base type * that must be accounted for. */ result = coerce_type_constraints(pstate, node, targetTypeId, true); + /* * XXX could we label result with exprTypmod(node) instead of - * default -1 typmod, to save a possible length-coercion later? - * Would work if both types have same interpretation of typmod, - * which is likely but not certain (wrong if target is a domain, - * in any case). + * default -1 typmod, to save a possible length-coercion + * later? Would work if both types have same interpretation of + * typmod, which is likely but not certain (wrong if target is + * a domain, in any case). */ result = (Node *) makeRelabelType(result, targetTypeId, -1); } @@ -190,9 +195,9 @@ coerce_type(ParseState *pstate, Node *node, Oid inputTypeId, else if (typeInheritsFrom(inputTypeId, targetTypeId)) { /* - * Input class type is a subclass of target, so nothing to do - * --- except relabel the type. This is binary compatibility - * for complex types. + * Input class type is a subclass of target, so nothing to do --- + * except relabel the type. This is binary compatibility for + * complex types. */ result = (Node *) makeRelabelType(node, targetTypeId, -1); } @@ -254,12 +259,15 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids, if (targetTypeId == ANYOID) continue; - /* if target is ANYARRAY and source is a varlena array type, accept */ + /* + * if target is ANYARRAY and source is a varlena array type, + * accept + */ if (targetTypeId == ANYARRAYOID) { - Oid typOutput; - Oid typElem; - bool typIsVarlena; + Oid typOutput; + Oid typElem; + bool typIsVarlena; if (getTypeOutputInfo(inputTypeId, &typOutput, &typElem, &typIsVarlena)) @@ -267,10 +275,11 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids, if (OidIsValid(typElem) && typIsVarlena) continue; } + /* - * Otherwise reject; this assumes there are no explicit coercions - * to ANYARRAY. If we don't reject then parse_coerce would have - * to repeat the above test. + * Otherwise reject; this assumes there are no explicit + * coercions to ANYARRAY. If we don't reject then + * parse_coerce would have to repeat the above test. */ return false; } @@ -301,15 +310,15 @@ can_coerce_type(int nargs, Oid *input_typeids, Oid *func_typeids, /* * Create an expression tree to enforce the constraints (if any) - * that should be applied by the type. Currently this is only + * that should be applied by the type. Currently this is only * interesting for domain types. */ Node * coerce_type_constraints(ParseState *pstate, Node *arg, Oid typeId, bool applyTypmod) { - char *notNull = NULL; - int32 typmod = -1; + char *notNull = NULL; + int32 typmod = -1; for (;;) { @@ -351,9 +360,9 @@ coerce_type_constraints(ParseState *pstate, Node *arg, arg = coerce_type_typmod(pstate, arg, typeId, typmod); /* - * Only need to add one NOT NULL check regardless of how many - * domains in the stack request it. The topmost domain that - * requested it is used as the constraint name. + * Only need to add one NOT NULL check regardless of how many domains + * in the stack request it. The topmost domain that requested it is + * used as the constraint name. */ if (notNull) { @@ -361,11 +370,11 @@ coerce_type_constraints(ParseState *pstate, Node *arg, r->arg = arg; r->testtype = CONSTR_TEST_NOTNULL; - r->name = notNull; + r->name = notNull; r->check_expr = NULL; arg = (Node *) r; - } + } return arg; } @@ -904,7 +913,7 @@ build_func_call(Oid funcid, Oid rettype, List *args) funcnode = makeNode(Func); funcnode->funcid = funcid; funcnode->funcresulttype = rettype; - funcnode->funcretset = false; /* only possible case here */ + funcnode->funcretset = false; /* only possible case here */ funcnode->func_fcache = NULL; expr = makeNode(Expr); diff --git a/src/backend/parser/parse_expr.c b/src/backend/parser/parse_expr.c index de07d39b4d..7be413f6b5 100644 --- a/src/backend/parser/parse_expr.c +++ b/src/backend/parser/parse_expr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.127 2002/08/31 22:10:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_expr.c,v 1.128 2002/09/04 20:31:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -194,7 +194,7 @@ transformExpr(ParseState *pstate, Node *expr) */ if (Transform_null_equals && length(a->name) == 1 && - strcmp(strVal(lfirst(a->name)), "=") == 0 && + strcmp(strVal(lfirst(a->name)), "=") == 0 && (exprIsNullConstant(a->lexpr) || exprIsNullConstant(a->rexpr))) { @@ -213,9 +213,9 @@ transformExpr(ParseState *pstate, Node *expr) else { Node *lexpr = transformExpr(pstate, - a->lexpr); + a->lexpr); Node *rexpr = transformExpr(pstate, - a->rexpr); + a->rexpr); result = (Node *) make_op(a->name, lexpr, @@ -277,41 +277,48 @@ transformExpr(ParseState *pstate, Node *expr) a->lexpr); Node *rexpr = transformExpr(pstate, a->rexpr); + result = (Node *) make_op(a->name, lexpr, rexpr); - ((Expr *)result)->opType = DISTINCT_EXPR; + ((Expr *) result)->opType = DISTINCT_EXPR; } break; case OF: { - List *telem; - A_Const *n; - Oid ltype, rtype; - bool matched = FALSE; + List *telem; + A_Const *n; + Oid ltype, + rtype; + bool matched = FALSE; - /* Checking an expression for match to type. + /* + * Checking an expression for match to type. * Will result in a boolean constant node. */ Node *lexpr = transformExpr(pstate, a->lexpr); + ltype = exprType(lexpr); foreach(telem, (List *) a->rexpr) { rtype = LookupTypeName(lfirst(telem)); matched = (rtype == ltype); - if (matched) break; + if (matched) + break; } - /* Expect two forms: equals or not equals. - * Flip the sense of the result for not equals. + /* + * Expect two forms: equals or not equals. + * Flip the sense of the result for not + * equals. */ if (strcmp(strVal(lfirst(a->name)), "!=") == 0) - matched = (! matched); + matched = (!matched); n = makeNode(A_Const); n->val.type = T_String; - n->val.val.str = (matched? "t": "f"); + n->val.val.str = (matched ? "t" : "f"); n->typename = SystemTypeName("bool"); result = transformExpr(pstate, (Node *) n); @@ -411,7 +418,7 @@ transformExpr(ParseState *pstate, Node *expr) /* Combining operators other than =/<> is dubious... */ if (length(left_list) != 1 && - strcmp(opname, "=") != 0 && strcmp(opname, "<>") != 0) + strcmp(opname, "=") != 0 && strcmp(opname, "<>") != 0) elog(ERROR, "Row comparison cannot use operator %s", opname); @@ -453,7 +460,7 @@ transformExpr(ParseState *pstate, Node *expr) if (opform->oprresult != BOOLOID) elog(ERROR, "%s has result type of %s, but must return %s" " to be used with quantified predicate subquery", - opname, format_type_be(opform->oprresult), + opname, format_type_be(opform->oprresult), format_type_be(BOOLOID)); if (get_func_retset(opform->oprcode)) @@ -613,7 +620,7 @@ transformExpr(ParseState *pstate, Node *expr) default: elog(ERROR, "transformExpr: unexpected booltesttype %d", (int) b->booltesttype); - clausename = NULL; /* keep compiler quiet */ + clausename = NULL; /* keep compiler quiet */ } b->arg = transformExpr(pstate, b->arg); @@ -624,14 +631,14 @@ transformExpr(ParseState *pstate, Node *expr) break; } - /********************************************* - * Quietly accept node types that may be presented when we are - * called on an already-transformed tree. - * - * Do any other node types need to be accepted? For now we are - * taking a conservative approach, and only accepting node - * types that are demonstrably necessary to accept. - *********************************************/ + /********************************************* + * Quietly accept node types that may be presented when we are + * called on an already-transformed tree. + * + * Do any other node types need to be accepted? For now we are + * taking a conservative approach, and only accepting node + * types that are demonstrably necessary to accept. + *********************************************/ case T_Expr: case T_Var: case T_Const: @@ -705,146 +712,148 @@ transformColumnRef(ParseState *pstate, ColumnRef *cref) switch (numnames) { case 1: - { - char *name = strVal(lfirst(cref->fields)); + { + char *name = strVal(lfirst(cref->fields)); - /* Try to identify as an unqualified column */ - node = colnameToVar(pstate, name); + /* Try to identify as an unqualified column */ + node = colnameToVar(pstate, name); + + if (node == NULL) + { + /* + * Not known as a column of any range-table entry, so + * try to find the name as a relation ... but not if + * subscripts appear. Note also that only relations + * already entered into the rangetable will be + * recognized. + * + * This is a hack for backwards compatibility with + * PostQUEL- inspired syntax. The preferred form now + * is "rel.*". + */ + int levels_up; - if (node == NULL) + if (cref->indirection == NIL && + refnameRangeTblEntry(pstate, NULL, name, + &levels_up) != NULL) + { + rv = makeNode(RangeVar); + rv->relname = name; + rv->inhOpt = INH_DEFAULT; + node = (Node *) rv; + } + else + elog(ERROR, "Attribute \"%s\" not found", name); + } + break; + } + case 2: { - /* - * Not known as a column of any range-table entry, so - * try to find the name as a relation ... but not if - * subscripts appear. Note also that only relations - * already entered into the rangetable will be recognized. - * - * This is a hack for backwards compatibility with PostQUEL- - * inspired syntax. The preferred form now is "rel.*". - */ - int levels_up; + char *name1 = strVal(lfirst(cref->fields)); + char *name2 = strVal(lsecond(cref->fields)); - if (cref->indirection == NIL && - refnameRangeTblEntry(pstate, NULL, name, - &levels_up) != NULL) + /* Whole-row reference? */ + if (strcmp(name2, "*") == 0) { rv = makeNode(RangeVar); - rv->relname = name; + rv->relname = name1; rv->inhOpt = INH_DEFAULT; node = (Node *) rv; + break; } - else - elog(ERROR, "Attribute \"%s\" not found", name); - } - break; - } - case 2: - { - char *name1 = strVal(lfirst(cref->fields)); - char *name2 = strVal(lsecond(cref->fields)); - /* Whole-row reference? */ - if (strcmp(name2, "*") == 0) - { - rv = makeNode(RangeVar); - rv->relname = name1; - rv->inhOpt = INH_DEFAULT; - node = (Node *) rv; + /* Try to identify as a once-qualified column */ + node = qualifiedNameToVar(pstate, NULL, name1, name2, true); + if (node == NULL) + { + /* + * Not known as a column of any range-table entry, so + * try it as a function call. Here, we will create an + * implicit RTE for tables not already entered. + */ + rv = makeNode(RangeVar); + rv->relname = name1; + rv->inhOpt = INH_DEFAULT; + node = ParseFuncOrColumn(pstate, + makeList1(makeString(name2)), + makeList1(rv), + false, false, true); + } break; } - - /* Try to identify as a once-qualified column */ - node = qualifiedNameToVar(pstate, NULL, name1, name2, true); - if (node == NULL) - { - /* - * Not known as a column of any range-table entry, so - * try it as a function call. Here, we will create an - * implicit RTE for tables not already entered. - */ - rv = makeNode(RangeVar); - rv->relname = name1; - rv->inhOpt = INH_DEFAULT; - node = ParseFuncOrColumn(pstate, - makeList1(makeString(name2)), - makeList1(rv), - false, false, true); - } - break; - } case 3: - { - char *name1 = strVal(lfirst(cref->fields)); - char *name2 = strVal(lsecond(cref->fields)); - char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); - - /* Whole-row reference? */ - if (strcmp(name3, "*") == 0) { - rv = makeNode(RangeVar); - rv->schemaname = name1; - rv->relname = name2; - rv->inhOpt = INH_DEFAULT; - node = (Node *) rv; - break; - } + char *name1 = strVal(lfirst(cref->fields)); + char *name2 = strVal(lsecond(cref->fields)); + char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); - /* Try to identify as a twice-qualified column */ - node = qualifiedNameToVar(pstate, name1, name2, name3, true); - if (node == NULL) - { - /* Try it as a function call */ - rv = makeNode(RangeVar); - rv->schemaname = name1; - rv->relname = name2; - rv->inhOpt = INH_DEFAULT; - node = ParseFuncOrColumn(pstate, - makeList1(makeString(name3)), - makeList1(rv), - false, false, true); + /* Whole-row reference? */ + if (strcmp(name3, "*") == 0) + { + rv = makeNode(RangeVar); + rv->schemaname = name1; + rv->relname = name2; + rv->inhOpt = INH_DEFAULT; + node = (Node *) rv; + break; + } + + /* Try to identify as a twice-qualified column */ + node = qualifiedNameToVar(pstate, name1, name2, name3, true); + if (node == NULL) + { + /* Try it as a function call */ + rv = makeNode(RangeVar); + rv->schemaname = name1; + rv->relname = name2; + rv->inhOpt = INH_DEFAULT; + node = ParseFuncOrColumn(pstate, + makeList1(makeString(name3)), + makeList1(rv), + false, false, true); + } + break; } - break; - } case 4: - { - char *name1 = strVal(lfirst(cref->fields)); - char *name2 = strVal(lsecond(cref->fields)); - char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); - char *name4 = strVal(lfirst(lnext(lnext(lnext(cref->fields))))); - - /* - * We check the catalog name and then ignore it. - */ - if (strcmp(name1, DatabaseName) != 0) - elog(ERROR, "Cross-database references are not implemented"); - - /* Whole-row reference? */ - if (strcmp(name4, "*") == 0) { - rv = makeNode(RangeVar); - rv->schemaname = name2; - rv->relname = name3; - rv->inhOpt = INH_DEFAULT; - node = (Node *) rv; - break; - } + char *name1 = strVal(lfirst(cref->fields)); + char *name2 = strVal(lsecond(cref->fields)); + char *name3 = strVal(lfirst(lnext(lnext(cref->fields)))); + char *name4 = strVal(lfirst(lnext(lnext(lnext(cref->fields))))); - /* Try to identify as a twice-qualified column */ - node = qualifiedNameToVar(pstate, name2, name3, name4, true); - if (node == NULL) - { - /* Try it as a function call */ - rv = makeNode(RangeVar); - rv->schemaname = name2; - rv->relname = name3; - rv->inhOpt = INH_DEFAULT; - node = ParseFuncOrColumn(pstate, - makeList1(makeString(name4)), - makeList1(rv), - false, false, true); + /* + * We check the catalog name and then ignore it. + */ + if (strcmp(name1, DatabaseName) != 0) + elog(ERROR, "Cross-database references are not implemented"); + + /* Whole-row reference? */ + if (strcmp(name4, "*") == 0) + { + rv = makeNode(RangeVar); + rv->schemaname = name2; + rv->relname = name3; + rv->inhOpt = INH_DEFAULT; + node = (Node *) rv; + break; + } + + /* Try to identify as a twice-qualified column */ + node = qualifiedNameToVar(pstate, name2, name3, name4, true); + if (node == NULL) + { + /* Try it as a function call */ + rv = makeNode(RangeVar); + rv->schemaname = name2; + rv->relname = name3; + rv->inhOpt = INH_DEFAULT; + node = ParseFuncOrColumn(pstate, + makeList1(makeString(name4)), + makeList1(rv), + false, false, true); + } + break; } - break; - } default: elog(ERROR, "Invalid qualified name syntax (too many names)"); node = NULL; /* keep compiler quiet */ @@ -1095,8 +1104,9 @@ exprIsLengthCoercion(Node *expr, int32 *coercedTypmod) } /* - * Furthermore, the name and namespace of the function must be the same - * as its result type's name/namespace (cf. find_coercion_function). + * Furthermore, the name and namespace of the function must be the + * same as its result type's name/namespace (cf. + * find_coercion_function). */ typeTuple = SearchSysCache(TYPEOID, ObjectIdGetDatum(procStruct->prorettype), @@ -1206,7 +1216,7 @@ parser_typecast_expression(ParseState *pstate, { expr = CoerceTargetExpr(pstate, expr, inputType, targetType, typename->typmod, - true); /* explicit coercion */ + true); /* explicit coercion */ if (expr == NULL) elog(ERROR, "Cannot cast type '%s' to '%s'", format_type_be(inputType), diff --git a/src/backend/parser/parse_func.c b/src/backend/parser/parse_func.c index 87e432b7cf..648ddfbaf0 100644 --- a/src/backend/parser/parse_func.c +++ b/src/backend/parser/parse_func.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.135 2002/08/22 00:01:42 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_func.c,v 1.136 2002/09/04 20:31:23 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -45,14 +45,14 @@ static void make_arguments(ParseState *pstate, Oid *input_typeids, Oid *function_typeids); static int match_argtypes(int nargs, - Oid *input_typeids, - FuncCandidateList function_typeids, - FuncCandidateList *candidates); + Oid *input_typeids, + FuncCandidateList function_typeids, + FuncCandidateList *candidates); static FieldSelect *setup_field_select(Node *input, char *attname, Oid relid); static FuncCandidateList func_select_candidate(int nargs, Oid *input_typeids, - FuncCandidateList candidates); + FuncCandidateList candidates); static void unknown_attribute(const char *schemaname, const char *relname, - const char *attname); + const char *attname); /* @@ -111,8 +111,8 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * check for column projection: if function has one argument, and that * argument is of complex type, and function name is not qualified, - * then the "function call" could be a projection. We also check - * that there wasn't any aggregate decoration. + * then the "function call" could be a projection. We also check that + * there wasn't any aggregate decoration. */ if (nargs == 1 && !agg_star && !agg_distinct && length(funcname) == 1) { @@ -123,7 +123,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, { /* First arg is a relation. This could be a projection. */ retval = qualifiedNameToVar(pstate, - ((RangeVar *) first_arg)->schemaname, + ((RangeVar *) first_arg)->schemaname, ((RangeVar *) first_arg)->relname, cname, true); @@ -144,9 +144,9 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, } /* - * Okay, it's not a column projection, so it must really be a function. - * Extract arg type info and transform RangeVar arguments into varnodes - * of the appropriate form. + * Okay, it's not a column projection, so it must really be a + * function. Extract arg type info and transform RangeVar arguments + * into varnodes of the appropriate form. */ MemSet(oid_array, 0, FUNC_MAX_ARGS * sizeof(Oid)); @@ -199,6 +199,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, toid = exprType(rte->funcexpr); break; default: + /* * RTE is a join or subselect; must fail for lack of a * named tuple type @@ -209,7 +210,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, else elog(ERROR, "Cannot pass result of sub-select or join %s to a function", relname); - toid = InvalidOid; /* keep compiler quiet */ + toid = InvalidOid; /* keep compiler quiet */ break; } @@ -228,10 +229,10 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * func_get_detail looks up the function in the catalogs, does - * disambiguation for polymorphic functions, handles inheritance, - * and returns the funcid and type and set or singleton status of - * the function's return value. it also returns the true argument - * types to the function. + * disambiguation for polymorphic functions, handles inheritance, and + * returns the funcid and type and set or singleton status of the + * function's return value. it also returns the true argument types + * to the function. */ fdresult = func_get_detail(funcname, fargs, nargs, oid_array, &funcid, &rettype, &retset, @@ -263,13 +264,13 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, /* * Oops. Time to die. * - * If we are dealing with the attribute notation rel.function, - * give an error message that is appropriate for that case. + * If we are dealing with the attribute notation rel.function, give + * an error message that is appropriate for that case. */ if (is_column) { - char *colname = strVal(lfirst(funcname)); - Oid relTypeId; + char *colname = strVal(lfirst(funcname)); + Oid relTypeId; Assert(nargs == 1); if (IsA(first_arg, RangeVar)) @@ -284,6 +285,7 @@ ParseFuncOrColumn(ParseState *pstate, List *funcname, List *fargs, elog(ERROR, "Attribute \"%s\" not found in datatype %s", colname, format_type_be(relTypeId)); } + /* * Else generate a detailed complaint for a function */ @@ -351,7 +353,7 @@ static int match_argtypes(int nargs, Oid *input_typeids, FuncCandidateList function_typeids, - FuncCandidateList *candidates) /* return value */ + FuncCandidateList *candidates) /* return value */ { FuncCandidateList current_candidate; FuncCandidateList next_candidate; @@ -863,7 +865,7 @@ func_get_detail(List *funcname, ftup = SearchSysCache(PROCOID, ObjectIdGetDatum(best_candidate->oid), 0, 0, 0); - if (!HeapTupleIsValid(ftup)) /* should not happen */ + if (!HeapTupleIsValid(ftup)) /* should not happen */ elog(ERROR, "function %u not found", best_candidate->oid); pform = (Form_pg_proc) GETSTRUCT(ftup); *rettype = pform->prorettype; @@ -1172,7 +1174,7 @@ setup_field_select(Node *input, char *attname, Oid relid) * ParseComplexProjection - * handles function calls with a single argument that is of complex type. * If the function call is actually a column projection, return a suitably - * transformed expression tree. If not, return NULL. + * transformed expression tree. If not, return NULL. * * NB: argument is expected to be transformed already, ie, not a RangeVar. */ @@ -1194,7 +1196,8 @@ ParseComplexProjection(ParseState *pstate, return NULL; /* funcname does not match any column */ /* - * Check for special cases where we don't want to return a FieldSelect. + * Check for special cases where we don't want to return a + * FieldSelect. */ switch (nodeTag(first_arg)) { @@ -1208,8 +1211,8 @@ ParseComplexProjection(ParseState *pstate, */ if (var->varattno == InvalidAttrNumber) { - Oid vartype; - int32 vartypmod; + Oid vartype; + int32 vartypmod; get_atttypetypmod(argrelid, attnum, &vartype, &vartypmod); @@ -1313,7 +1316,7 @@ find_aggregate_func(const char *caller, List *aggname, Oid basetype) ftup = SearchSysCache(PROCOID, ObjectIdGetDatum(oid), 0, 0, 0); - if (!HeapTupleIsValid(ftup)) /* should not happen */ + if (!HeapTupleIsValid(ftup)) /* should not happen */ elog(ERROR, "function %u not found", oid); pform = (Form_pg_proc) GETSTRUCT(ftup); @@ -1367,10 +1370,10 @@ LookupFuncName(List *funcname, int nargs, const Oid *argtypes) Oid LookupFuncNameTypeNames(List *funcname, List *argtypes, const char *caller) { - Oid funcoid; - Oid argoids[FUNC_MAX_ARGS]; - int argcount; - int i; + Oid funcoid; + Oid argoids[FUNC_MAX_ARGS]; + int argcount; + int i; MemSet(argoids, 0, FUNC_MAX_ARGS * sizeof(Oid)); argcount = length(argtypes); diff --git a/src/backend/parser/parse_node.c b/src/backend/parser/parse_node.c index 33ee300fb2..391694fa19 100644 --- a/src/backend/parser/parse_node.c +++ b/src/backend/parser/parse_node.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.67 2002/08/26 17:53:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_node.c,v 1.68 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -135,8 +135,8 @@ make_op(List *opname, Node *ltree, Node *rtree) newop = makeOper(oprid(tup), /* opno */ InvalidOid, /* opid */ - opform->oprresult, /* opresulttype */ - get_func_retset(opform->oprcode)); /* opretset */ + opform->oprresult, /* opresulttype */ + get_func_retset(opform->oprcode)); /* opretset */ result = makeNode(Expr); result->typeOid = opform->oprresult; diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c index 78128b4f69..ecf1a2abec 100644 --- a/src/backend/parser/parse_oper.c +++ b/src/backend/parser/parse_oper.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.58 2002/07/20 05:16:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_oper.c,v 1.59 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -29,10 +29,10 @@ #include "utils/fmgroids.h" #include "utils/syscache.h" -static Oid binary_oper_exact(Oid arg1, Oid arg2, - FuncCandidateList candidates); -static Oid oper_select_candidate(int nargs, Oid *input_typeids, - FuncCandidateList candidates); +static Oid binary_oper_exact(Oid arg1, Oid arg2, + FuncCandidateList candidates); +static Oid oper_select_candidate(int nargs, Oid *input_typeids, + FuncCandidateList candidates); static void op_error(List *op, Oid arg1, Oid arg2); static void unary_op_error(List *op, Oid arg, bool is_left_op); @@ -52,7 +52,7 @@ Oid LookupOperName(List *opername, Oid oprleft, Oid oprright) { FuncCandidateList clist; - char oprkind; + char oprkind; if (!OidIsValid(oprleft)) oprkind = 'l'; @@ -85,9 +85,9 @@ Oid LookupOperNameTypeNames(List *opername, TypeName *oprleft, TypeName *oprright, const char *caller) { - Oid operoid; - Oid leftoid, - rightoid; + Oid operoid; + Oid leftoid, + rightoid; if (oprleft == NULL) leftoid = InvalidOid; @@ -652,7 +652,10 @@ oper(List *opname, Oid ltypeId, Oid rtypeId, bool noError) * Otherwise, search for the most suitable candidate. */ - /* Unspecified type for one of the arguments? then use the other */ + /* + * Unspecified type for one of the arguments? then use the + * other + */ if (rtypeId == InvalidOid) rtypeId = ltypeId; else if (ltypeId == InvalidOid) diff --git a/src/backend/parser/parse_relation.c b/src/backend/parser/parse_relation.c index 174c05790d..65c386a937 100644 --- a/src/backend/parser/parse_relation.c +++ b/src/backend/parser/parse_relation.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.78 2002/08/29 00:17:04 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_relation.c,v 1.79 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,14 +36,14 @@ static Node *scanNameSpaceForRefname(ParseState *pstate, Node *nsnode, const char *refname); static Node *scanNameSpaceForRelid(ParseState *pstate, Node *nsnode, - Oid relid); + Oid relid); static void scanNameSpaceForConflict(ParseState *pstate, Node *nsnode, RangeTblEntry *rte1, const char *aliasname1); static Node *scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname); static bool isForUpdate(ParseState *pstate, char *refname); static bool get_rte_attribute_is_dropped(RangeTblEntry *rte, - AttrNumber attnum); + AttrNumber attnum); static int specialAttNum(const char *attname); static void warnAutoRange(ParseState *pstate, RangeVar *relation); @@ -64,7 +64,7 @@ static void warnAutoRange(ParseState *pstate, RangeVar *relation); * * A qualified refname (schemaname != NULL) can only match a relation RTE * that (a) has no alias and (b) is for the same relation identified by - * schemaname.refname. In this case we convert schemaname.refname to a + * schemaname.refname. In this case we convert schemaname.refname to a * relation OID and search by relid, rather than by alias name. This is * peculiar, but it's what SQL92 says to do. */ @@ -189,7 +189,7 @@ scanNameSpaceForRefname(ParseState *pstate, Node *nsnode, /* * Recursively search a namespace for a relation RTE matching the - * given relation OID. Return the node if a unique match, or NULL + * given relation OID. Return the node if a unique match, or NULL * if no match. Raise error if multiple matches (which shouldn't * happen if the namespace was checked correctly when it was created). * @@ -313,9 +313,7 @@ checkNameSpaceConflicts(ParseState *pstate, Node *namespace1, List *l; foreach(l, (List *) namespace1) - { checkNameSpaceConflicts(pstate, lfirst(l), namespace2); - } } else elog(ERROR, "checkNameSpaceConflicts: unexpected node type %d", @@ -353,6 +351,7 @@ scanNameSpaceForConflict(ParseState *pstate, Node *nsnode, if (strcmp(j->alias->aliasname, aliasname1) == 0) elog(ERROR, "Table name \"%s\" specified more than once", aliasname1); + /* * Tables within an aliased join are invisible from outside * the join, according to the scope rules of SQL92 (the join @@ -368,9 +367,7 @@ scanNameSpaceForConflict(ParseState *pstate, Node *nsnode, List *l; foreach(l, (List *) nsnode) - { scanNameSpaceForConflict(pstate, lfirst(l), rte1, aliasname1); - } } else elog(ERROR, "scanNameSpaceForConflict: unexpected node type %d", @@ -438,16 +435,16 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname) * Scan the user column names (or aliases) for a match. Complain if * multiple matches. * - * Note: because eref->colnames may include names of dropped columns, - * we need to check for non-droppedness before accepting a match. - * This takes an extra cache lookup, but we can skip the lookup most - * of the time by exploiting the knowledge that dropped columns are - * assigned dummy names starting with '.', which is an unusual choice - * for actual column names. + * Note: because eref->colnames may include names of dropped columns, we + * need to check for non-droppedness before accepting a match. This + * takes an extra cache lookup, but we can skip the lookup most of the + * time by exploiting the knowledge that dropped columns are assigned + * dummy names starting with '.', which is an unusual choice for + * actual column names. * - * Should the user try to fool us by altering pg_attribute.attname - * for a dropped column, we'll still catch it by virtue of the checks - * in get_rte_attribute_type(), which is called by make_var(). That + * Should the user try to fool us by altering pg_attribute.attname for a + * dropped column, we'll still catch it by virtue of the checks in + * get_rte_attribute_type(), which is called by make_var(). That * routine has to do a cache lookup anyway, so the check there is * cheap. */ @@ -456,7 +453,7 @@ scanRTEForColumn(ParseState *pstate, RangeTblEntry *rte, char *colname) attnum++; if (strcmp(strVal(lfirst(c)), colname) == 0) { - if (colname[0] == '.' && /* see note above */ + if (colname[0] == '.' && /* see note above */ get_rte_attribute_is_dropped(rte, attnum)) continue; if (result) @@ -903,8 +900,8 @@ addRangeTableEntryForFunction(ParseState *pstate, if (coldeflist != NIL) { /* - * we *only* allow a coldeflist for functions returning a - * RECORD pseudo-type + * we *only* allow a coldeflist for functions returning a RECORD + * pseudo-type */ if (funcrettype != RECORDOID) elog(ERROR, "A column definition list is only allowed for functions returning RECORD"); @@ -935,14 +932,14 @@ addRangeTableEntryForFunction(ParseState *pstate, funcrettype); /* - * Get the rel's relcache entry. This access ensures that we have an - * up-to-date relcache entry for the rel. + * Get the rel's relcache entry. This access ensures that we have + * an up-to-date relcache entry for the rel. */ rel = relation_open(funcrelid, AccessShareLock); /* - * Since the rel is open anyway, let's check that the number of column - * aliases is reasonable. + * Since the rel is open anyway, let's check that the number of + * column aliases is reasonable. */ maxattrs = RelationGetNumberOfAttributes(rel); if (maxattrs < numaliases) @@ -960,16 +957,16 @@ addRangeTableEntryForFunction(ParseState *pstate, /* * Drop the rel refcount, but keep the access lock till end of - * transaction so that the table can't be deleted or have its schema - * modified underneath us. + * transaction so that the table can't be deleted or have its + * schema modified underneath us. */ relation_close(rel, NoLock); } else if (functyptype == 'b' || functyptype == 'd') { /* - * Must be a base data type, i.e. scalar. - * Just add one alias column named for the function. + * Must be a base data type, i.e. scalar. Just add one alias + * column named for the function. */ if (numaliases > 1) elog(ERROR, "Too many column aliases specified for function %s", @@ -1270,17 +1267,17 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte, case RTE_FUNCTION: { /* Function RTE */ - Oid funcrettype = exprType(rte->funcexpr); - char functyptype = get_typtype(funcrettype); - List *coldeflist = rte->coldeflist; + Oid funcrettype = exprType(rte->funcexpr); + char functyptype = get_typtype(funcrettype); + List *coldeflist = rte->coldeflist; if (functyptype == 'c') { /* - * Composite data type, i.e. a table's row type - * Same as ordinary relation RTE + * Composite data type, i.e. a table's row type Same + * as ordinary relation RTE */ - Oid funcrelid = typeidTypeRelid(funcrettype); + Oid funcrelid = typeidTypeRelid(funcrettype); Relation rel; int maxattrs; int numaliases; @@ -1373,10 +1370,10 @@ expandRTE(ParseState *pstate, RangeTblEntry *rte, atttypid = typenameTypeId(colDef->typename); varnode = makeVar(rtindex, - attnum, - atttypid, - -1, - sublevels_up); + attnum, + atttypid, + -1, + sublevels_up); *colvars = lappend(*colvars, varnode); } @@ -1495,9 +1492,9 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum) /* * If the RTE is a relation, go to the system catalogs not the - * eref->colnames list. This is a little slower but it will give - * the right answer if the column has been renamed since the eref - * list was built (which can easily happen for rules). + * eref->colnames list. This is a little slower but it will give the + * right answer if the column has been renamed since the eref list was + * built (which can easily happen for rules). */ if (rte->rtekind == RTE_RELATION) { @@ -1509,7 +1506,8 @@ get_rte_attribute_name(RangeTblEntry *rte, AttrNumber attnum) } /* - * Otherwise use the column name from eref. There should always be one. + * Otherwise use the column name from eref. There should always be + * one. */ if (attnum > 0 && attnum <= length(rte->eref->colnames)) return strVal(nth(attnum - 1, rte->eref->colnames)); @@ -1544,13 +1542,14 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, elog(ERROR, "Relation \"%s\" does not have attribute %d", get_rel_name(rte->relid), attnum); att_tup = (Form_pg_attribute) GETSTRUCT(tp); + /* * If dropped column, pretend it ain't there. See notes * in scanRTEForColumn. */ if (att_tup->attisdropped) elog(ERROR, "Relation \"%s\" has no column \"%s\"", - get_rel_name(rte->relid), NameStr(att_tup->attname)); + get_rel_name(rte->relid), NameStr(att_tup->attname)); *vartype = att_tup->atttypid; *vartypmod = att_tup->atttypmod; ReleaseSysCache(tp); @@ -1579,19 +1578,19 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, case RTE_FUNCTION: { /* Function RTE */ - Oid funcrettype = exprType(rte->funcexpr); - char functyptype = get_typtype(funcrettype); - List *coldeflist = rte->coldeflist; + Oid funcrettype = exprType(rte->funcexpr); + char functyptype = get_typtype(funcrettype); + List *coldeflist = rte->coldeflist; if (functyptype == 'c') { /* - * Composite data type, i.e. a table's row type - * Same as ordinary relation RTE + * Composite data type, i.e. a table's row type Same + * as ordinary relation RTE */ - Oid funcrelid = typeidTypeRelid(funcrettype); - HeapTuple tp; - Form_pg_attribute att_tup; + Oid funcrelid = typeidTypeRelid(funcrettype); + HeapTuple tp; + Form_pg_attribute att_tup; if (!OidIsValid(funcrelid)) elog(ERROR, "Invalid typrelid for complex type %u", @@ -1606,9 +1605,10 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, elog(ERROR, "Relation \"%s\" does not have attribute %d", get_rel_name(funcrelid), attnum); att_tup = (Form_pg_attribute) GETSTRUCT(tp); + /* - * If dropped column, pretend it ain't there. See notes - * in scanRTEForColumn. + * If dropped column, pretend it ain't there. See + * notes in scanRTEForColumn. */ if (att_tup->attisdropped) elog(ERROR, "Relation \"%s\" has no column \"%s\"", @@ -1639,11 +1639,14 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, break; case RTE_JOIN: { - /* Join RTE --- get type info from join RTE's alias variable */ - Node *aliasvar; + /* + * Join RTE --- get type info from join RTE's alias + * variable + */ + Node *aliasvar; Assert(attnum > 0 && attnum <= length(rte->joinaliasvars)); - aliasvar = (Node *) nth(attnum-1, rte->joinaliasvars); + aliasvar = (Node *) nth(attnum - 1, rte->joinaliasvars); *vartype = exprType(aliasvar); *vartypmod = exprTypmod(aliasvar); } @@ -1661,7 +1664,7 @@ get_rte_attribute_type(RangeTblEntry *rte, AttrNumber attnum, static bool get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) { - bool result; + bool result; switch (rte->rtekind) { @@ -1698,11 +1701,11 @@ get_rte_attribute_is_dropped(RangeTblEntry *rte, AttrNumber attnum) if (OidIsValid(funcrelid)) { /* - * Composite data type, i.e. a table's row type - * Same as ordinary relation RTE + * Composite data type, i.e. a table's row type Same + * as ordinary relation RTE */ - HeapTuple tp; - Form_pg_attribute att_tup; + HeapTuple tp; + Form_pg_attribute att_tup; tp = SearchSysCache(ATTNUM, ObjectIdGetDatum(funcrelid), @@ -1748,7 +1751,7 @@ attnameAttNum(Relation rd, const char *attname, bool sysColOK) for (i = 0; i < rd->rd_rel->relnatts; i++) { - Form_pg_attribute att = rd->rd_att->attrs[i]; + Form_pg_attribute att = rd->rd_att->attrs[i]; if (namestrcmp(&(att->attname), attname) == 0 && !att->attisdropped) return i + 1; diff --git a/src/backend/parser/parse_target.c b/src/backend/parser/parse_target.c index 26983c48cf..b9c5b6cb13 100644 --- a/src/backend/parser/parse_target.c +++ b/src/backend/parser/parse_target.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.88 2002/08/19 15:08:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_target.c,v 1.89 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -114,7 +114,7 @@ transformTargetList(ParseState *pstate, List *targetlist) p_target = nconc(p_target, ExpandAllTables(pstate)); } - else if (strcmp(strVal(nth(numnames-1, fields)), "*") == 0) + else if (strcmp(strVal(nth(numnames - 1, fields)), "*") == 0) { /* * Target item is relation.*, expand that table (eg. @@ -136,21 +136,22 @@ transformTargetList(ParseState *pstate, List *targetlist) relname = strVal(lsecond(fields)); break; case 4: - { - char *name1 = strVal(lfirst(fields)); - - /* - * We check the catalog name and then ignore it. - */ - if (strcmp(name1, DatabaseName) != 0) - elog(ERROR, "Cross-database references are not implemented"); - schemaname = strVal(lsecond(fields)); - relname = strVal(lfirst(lnext(lnext(fields)))); - break; - } + { + char *name1 = strVal(lfirst(fields)); + + /* + * We check the catalog name and then ignore + * it. + */ + if (strcmp(name1, DatabaseName) != 0) + elog(ERROR, "Cross-database references are not implemented"); + schemaname = strVal(lsecond(fields)); + relname = strVal(lfirst(lnext(lnext(fields)))); + break; + } default: elog(ERROR, "Invalid qualified name syntax (too many names)"); - schemaname = NULL; /* keep compiler quiet */ + schemaname = NULL; /* keep compiler quiet */ relname = NULL; break; } @@ -180,8 +181,8 @@ transformTargetList(ParseState *pstate, List *targetlist) InsertDefault *newnode = makeNode(InsertDefault); /* - * If this is a DEFAULT element, we make a junk entry - * which will get dropped on return to transformInsertStmt(). + * If this is a DEFAULT element, we make a junk entry which + * will get dropped on return to transformInsertStmt(). */ p_target = lappend(p_target, newnode); } @@ -385,7 +386,7 @@ checkInsertTargets(ParseState *pstate, List *cols, List **attrnos) for (i = 0; i < numcol; i++) { - ResTarget *col; + ResTarget *col; if (attr[i]->attisdropped) continue; @@ -503,7 +504,7 @@ FigureColnameInternal(Node *node, char **name) { case T_ColumnRef: { - char *cname = strVal(llast(((ColumnRef *) node)->fields)); + char *cname = strVal(llast(((ColumnRef *) node)->fields)); if (strcmp(cname, "*") != 0) { @@ -514,7 +515,7 @@ FigureColnameInternal(Node *node, char **name) break; case T_ExprFieldSelect: { - char *fname = strVal(llast(((ExprFieldSelect *) node)->fields)); + char *fname = strVal(llast(((ExprFieldSelect *) node)->fields)); if (strcmp(fname, "*") != 0) { diff --git a/src/backend/parser/parse_type.c b/src/backend/parser/parse_type.c index e75c193eff..26ae3c2743 100644 --- a/src/backend/parser/parse_type.c +++ b/src/backend/parser/parse_type.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.49 2002/08/31 22:10:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parse_type.c,v 1.50 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -112,7 +112,7 @@ LookupTypeName(const TypeName *typename) if (schemaname) { /* Look in specific schema only */ - Oid namespaceId; + Oid namespaceId; namespaceId = LookupExplicitNamespace(schemaname); restype = GetSysCacheOid(TYPENAMENSP, @@ -147,7 +147,7 @@ TypeNameToString(const TypeName *typename) if (typename->names != NIL) { /* Emit possibly-qualified name as-is */ - List *l; + List *l; foreach(l, typename->names) { @@ -218,7 +218,7 @@ typenameType(const TypeName *typename) if (!HeapTupleIsValid(tup)) elog(ERROR, "Type \"%s\" does not exist", TypeNameToString(typename)); - if (! ((Form_pg_type) GETSTRUCT(tup))->typisdefined) + if (!((Form_pg_type) GETSTRUCT(tup))->typisdefined) elog(ERROR, "Type \"%s\" is only a shell", TypeNameToString(typename)); return (Type) tup; @@ -431,7 +431,7 @@ parseTypeString(const char *str, Oid *type_id, int32 *typmod) List *raw_parsetree_list; SelectStmt *stmt; ResTarget *restarget; - TypeCast *typecast; + TypeCast *typecast; TypeName *typename; initStringInfo(&buf); diff --git a/src/backend/parser/parser.c b/src/backend/parser/parser.c index 8c129cb916..c8614b5731 100644 --- a/src/backend/parser/parser.c +++ b/src/backend/parser/parser.c @@ -14,7 +14,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.54 2002/08/27 04:55:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/parser/parser.c,v 1.55 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,7 +30,7 @@ List *parsetree; /* result of parsing is left here */ -static Oid *param_type_info; /* state for param_type() */ +static Oid *param_type_info; /* state for param_type() */ static int param_count; static int lookahead_token; /* one-token lookahead */ diff --git a/src/backend/port/dynloader/bsdi.h b/src/backend/port/dynloader/bsdi.h index 79a707a64a..6a76ad01ff 100644 --- a/src/backend/port/dynloader/bsdi.h +++ b/src/backend/port/dynloader/bsdi.h @@ -6,7 +6,7 @@ * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * Portions Copyright (c) 1994, Regents of the University of California * - * $Id: bsdi.h,v 1.16 2002/06/20 20:29:33 momjian Exp $ + * $Id: bsdi.h,v 1.17 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -46,7 +46,6 @@ do { \ dld_unlink_by_file(handle, 1); \ free(handle); \ } while (0) - #endif /* not HAVE_DLOPEN */ #endif /* PORT_PROTOS_H */ diff --git a/src/backend/port/ipc_test.c b/src/backend/port/ipc_test.c index 2421a7e5a0..ee1ed186cb 100644 --- a/src/backend/port/ipc_test.c +++ b/src/backend/port/ipc_test.c @@ -21,7 +21,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.4 2002/08/10 20:29:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/ipc_test.c,v 1.5 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ int MaxBackends = DEF_MAXBACKENDS; int NBuffers = DEF_NBUFFERS; #ifndef assert_enabled -bool assert_enabled = true; +bool assert_enabled = true; #endif @@ -87,7 +87,7 @@ shmem_exit(int code) } void -on_shmem_exit(void (*function) (), Datum arg) + on_shmem_exit(void (*function) (), Datum arg) { if (on_shmem_exit_index >= MAX_ON_EXITS) elog(FATAL, "Out of on_shmem_exit slots"); @@ -144,17 +144,17 @@ elog(int lev, const char *fmt,...) typedef struct MyStorage { - PGShmemHeader header; - int flag; - PGSemaphoreData sem; -} MyStorage; + PGShmemHeader header; + int flag; + PGSemaphoreData sem; +} MyStorage; int main(int argc, char **argv) { - MyStorage *storage; - int cpid; + MyStorage *storage; + int cpid; printf("Creating shared memory ... "); fflush(stdout); diff --git a/src/backend/port/posix_sema.c b/src/backend/port/posix_sema.c index 207a5fba96..21af7d3ac2 100644 --- a/src/backend/port/posix_sema.c +++ b/src/backend/port/posix_sema.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.5 2002/06/20 20:29:33 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/posix_sema.c,v 1.6 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -95,15 +95,15 @@ PosixSemaphoreCreate(void) } /* - * Unlink the semaphore immediately, so it can't be accessed externally. - * This also ensures that it will go away if we crash. + * Unlink the semaphore immediately, so it can't be accessed + * externally. This also ensures that it will go away if we crash. */ sem_unlink(semname); return mySem; } -#else /* !USE_NAMED_POSIX_SEMAPHORES */ +#else /* !USE_NAMED_POSIX_SEMAPHORES */ /* * PosixSemaphoreCreate @@ -111,7 +111,7 @@ PosixSemaphoreCreate(void) * Attempt to create a new unnamed semaphore. */ static void -PosixSemaphoreCreate(sem_t *sem) +PosixSemaphoreCreate(sem_t * sem) { if (sem_init(sem, 1, 1) < 0) { @@ -120,15 +120,14 @@ PosixSemaphoreCreate(sem_t *sem) proc_exit(1); } } - -#endif /* USE_NAMED_POSIX_SEMAPHORES */ +#endif /* USE_NAMED_POSIX_SEMAPHORES */ /* * PosixSemaphoreKill - removes a semaphore */ static void -PosixSemaphoreKill(sem_t *sem) +PosixSemaphoreKill(sem_t * sem) { #ifdef USE_NAMED_POSIX_SEMAPHORES /* Got to use sem_close for named semaphores */ @@ -149,7 +148,7 @@ PosixSemaphoreKill(sem_t *sem) * * This is called during postmaster start or shared memory reinitialization. * It should do whatever is needed to be able to support up to maxSemas - * subsequent PGSemaphoreCreate calls. Also, if any system resources + * subsequent PGSemaphoreCreate calls. Also, if any system resources * are acquired here or in PGSemaphoreCreate, register an on_shmem_exit * callback to release them. * @@ -197,7 +196,7 @@ ReleaseSemaphores(int status, Datum arg) void PGSemaphoreCreate(PGSemaphore sema) { - sem_t *newsem; + sem_t *newsem; /* Can't do this in a backend, because static state is postmaster's */ Assert(!IsUnderPostmaster); @@ -260,21 +259,21 @@ PGSemaphoreLock(PGSemaphore sema, bool interruptOK) * * Each time around the loop, we check for a cancel/die interrupt. We * assume that if such an interrupt comes in while we are waiting, it - * will cause the sem_wait() call to exit with errno == EINTR, so that we - * will be able to service the interrupt (if not in a critical section - * already). + * will cause the sem_wait() call to exit with errno == EINTR, so that + * we will be able to service the interrupt (if not in a critical + * section already). * * Once we acquire the lock, we do NOT check for an interrupt before * returning. The caller needs to be able to record ownership of the * lock before any interrupt can be accepted. * * There is a window of a few instructions between CHECK_FOR_INTERRUPTS - * and entering the sem_wait() call. If a cancel/die interrupt occurs in - * that window, we would fail to notice it until after we acquire the - * lock (or get another interrupt to escape the sem_wait()). We can - * avoid this problem by temporarily setting ImmediateInterruptOK to - * true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt in - * this interval will execute directly. However, there is a huge + * and entering the sem_wait() call. If a cancel/die interrupt occurs + * in that window, we would fail to notice it until after we acquire + * the lock (or get another interrupt to escape the sem_wait()). We + * can avoid this problem by temporarily setting ImmediateInterruptOK + * to true before we do CHECK_FOR_INTERRUPTS; then, a die() interrupt + * in this interval will execute directly. However, there is a huge * pitfall: there is another window of a few instructions after the * sem_wait() before we are able to reset ImmediateInterruptOK. If an * interrupt occurs then, we'll lose control, which means that the diff --git a/src/backend/port/qnx4/tstsem.c b/src/backend/port/qnx4/tstsem.c index 0d69a76b48..ebc6abe7d0 100644 --- a/src/backend/port/qnx4/tstsem.c +++ b/src/backend/port/qnx4/tstsem.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.7 2001/11/11 22:12:00 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/qnx4/Attic/tstsem.c,v 1.8 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -26,7 +26,7 @@ #define SEMMAX 16 #define OPSMAX 1 -int MaxBackends = SEMMAX; +int MaxBackends = SEMMAX; static int semid; diff --git a/src/backend/port/sysv_sema.c b/src/backend/port/sysv_sema.c index dc34786422..cef6cc0646 100644 --- a/src/backend/port/sysv_sema.c +++ b/src/backend/port/sysv_sema.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.3 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/sysv_sema.c,v 1.4 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,19 +58,20 @@ typedef int IpcSemaphoreId; /* semaphore ID returned by semget(2) */ #define PGSemaMagic 537 /* must be less than SEMVMX */ -static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so far */ +static IpcSemaphoreId *mySemaSets; /* IDs of sema sets acquired so + * far */ static int numSemaSets; /* number of sema sets acquired so far */ static int maxSemaSets; /* allocated size of mySemaSets array */ -static IpcSemaphoreKey nextSemaKey; /* next key to try using */ +static IpcSemaphoreKey nextSemaKey; /* next key to try using */ static int nextSemaNumber; /* next free sem num in last sema set */ static IpcSemaphoreId InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, - int numSems); + int numSems); static void IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, - int value); + int value); static void IpcSemaphoreKill(IpcSemaphoreId semId); -static int IpcSemaphoreGetValue(IpcSemaphoreId semId, int semNum); +static int IpcSemaphoreGetValue(IpcSemaphoreId semId, int semNum); static pid_t IpcSemaphoreGetLastPID(IpcSemaphoreId semId, int semNum); static IpcSemaphoreId IpcSemaphoreCreate(int numSems); static void ReleaseSemaphores(int status, Datum arg); @@ -113,7 +114,7 @@ InternalIpcSemaphoreCreate(IpcSemaphoreKey semKey, int numSems) * Else complain and abort */ fprintf(stderr, "IpcSemaphoreCreate: semget(key=%d, num=%d, 0%o) failed: %s\n", - (int) semKey, numSems, (IPC_CREAT | IPC_EXCL | IPCProtection), + (int) semKey, numSems, (IPC_CREAT | IPC_EXCL | IPCProtection), strerror(errno)); if (errno == ENOSPC) @@ -154,7 +155,7 @@ IpcSemaphoreInitialize(IpcSemaphoreId semId, int semNum, int value) if (errno == ERANGE) fprintf(stderr, "You possibly need to raise your kernel's SEMVMX value to be at least\n" - "%d. Look into the PostgreSQL documentation for details.\n", + "%d. Look into the PostgreSQL documentation for details.\n", value); proc_exit(1); @@ -221,7 +222,7 @@ IpcSemaphoreCreate(int numSems) PGSemaphoreData mysema; /* Loop till we find a free IPC key */ - for (nextSemaKey++; ; nextSemaKey++) + for (nextSemaKey++;; nextSemaKey++) { pid_t creatorPID; @@ -296,12 +297,12 @@ IpcSemaphoreCreate(int numSems) * * This is called during postmaster start or shared memory reinitialization. * It should do whatever is needed to be able to support up to maxSemas - * subsequent PGSemaphoreCreate calls. Also, if any system resources + * subsequent PGSemaphoreCreate calls. Also, if any system resources * are acquired here or in PGSemaphoreCreate, register an on_shmem_exit * callback to release them. * * The port number is passed for possible use as a key (for SysV, we use - * it to generate the starting semaphore key). In a standalone backend, + * it to generate the starting semaphore key). In a standalone backend, * zero will be passed. * * In the SysV implementation, we acquire semaphore sets on-demand; the @@ -311,14 +312,15 @@ IpcSemaphoreCreate(int numSems) void PGReserveSemaphores(int maxSemas, int port) { - maxSemaSets = (maxSemas + SEMAS_PER_SET-1) / SEMAS_PER_SET; + maxSemaSets = (maxSemas + SEMAS_PER_SET - 1) / SEMAS_PER_SET; mySemaSets = (IpcSemaphoreId *) malloc(maxSemaSets * sizeof(IpcSemaphoreId)); if (mySemaSets == NULL) elog(PANIC, "Out of memory in PGReserveSemaphores"); numSemaSets = 0; nextSemaKey = port * 1000; - nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st call */ + nextSemaNumber = SEMAS_PER_SET; /* force sema set alloc on 1st + * call */ on_shmem_exit(ReleaseSemaphores, 0); } @@ -359,7 +361,7 @@ PGSemaphoreCreate(PGSemaphore sema) nextSemaNumber = 0; } /* Assign the next free semaphore in the current set */ - sema->semId = mySemaSets[numSemaSets-1]; + sema->semId = mySemaSets[numSemaSets - 1]; sema->semNum = nextSemaNumber++; /* Initialize it to count 1 */ IpcSemaphoreInitialize(sema->semId, sema->semNum, 1); diff --git a/src/backend/port/sysv_shmem.c b/src/backend/port/sysv_shmem.c index aadf3da202..60e5d0b478 100644 --- a/src/backend/port/sysv_shmem.c +++ b/src/backend/port/sysv_shmem.c @@ -10,7 +10,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.3 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/port/sysv_shmem.c,v 1.4 2002/09/04 20:31:24 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -88,7 +88,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size) * Else complain and abort */ fprintf(stderr, "IpcMemoryCreate: shmget(key=%d, size=%u, 0%o) failed: %s\n", - (int) memKey, size, (IPC_CREAT | IPC_EXCL | IPCProtection), + (int) memKey, size, (IPC_CREAT | IPC_EXCL | IPCProtection), strerror(errno)); if (errno == EINVAL) @@ -147,7 +147,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, uint32 size) /* use intimate shared memory on SPARC Solaris */ memAddress = shmat(shmid, 0, SHM_SHARE_MMU); #else - memAddress = shmat(shmid, 0, 0); + memAddress = shmat(shmid, 0, 0); #endif if (memAddress == (void *) -1) @@ -283,11 +283,11 @@ PrivateMemoryDelete(int status, Datum memaddr) * the storage. * * Dead Postgres segments are recycled if found, but we do not fail upon - * collision with non-Postgres shmem segments. The idea here is to detect and + * collision with non-Postgres shmem segments. The idea here is to detect and * re-use keys that may have been assigned by a crashed postmaster or backend. * * The port number is passed for possible use as a key (for SysV, we use - * it to generate the starting shmem key). In a standalone backend, + * it to generate the starting shmem key). In a standalone backend, * zero will be passed. */ PGShmemHeader * @@ -328,7 +328,7 @@ PGSharedMemoryCreate(uint32 size, bool makePrivate, int port) /* use intimate shared memory on SPARC Solaris */ memAddress = shmat(shmid, 0, SHM_SHARE_MMU); #else - memAddress = shmat(shmid, 0, 0); + memAddress = shmat(shmid, 0, 0); #endif if (memAddress == (void *) -1) diff --git a/src/backend/postmaster/pgstat.c b/src/backend/postmaster/pgstat.c index 9492cb6ee5..4959550867 100644 --- a/src/backend/postmaster/pgstat.c +++ b/src/backend/postmaster/pgstat.c @@ -16,7 +16,7 @@ * * Copyright (c) 2001, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.26 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/pgstat.c,v 1.27 2002/09/04 20:31:24 momjian Exp $ * ---------- */ #include "postgres.h" @@ -431,7 +431,7 @@ pgstat_report_activity(char *what) return; len = strlen(what); - len = pg_mbcliplen((const unsigned char *)what, len, PGSTAT_ACTIVITY_SIZE - 1); + len = pg_mbcliplen((const unsigned char *) what, len, PGSTAT_ACTIVITY_SIZE - 1); memcpy(msg.m_what, what, len); msg.m_what[len] = '\0'; @@ -581,7 +581,7 @@ pgstat_vacuum_tabstat(void) if (msg.m_nentries >= PGSTAT_NUM_TABPURGE) { len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) - + msg.m_nentries * sizeof(Oid); + +msg.m_nentries * sizeof(Oid); pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE); pgstat_send(&msg, len); @@ -596,7 +596,7 @@ pgstat_vacuum_tabstat(void) if (msg.m_nentries > 0) { len = offsetof(PgStat_MsgTabpurge, m_tableid[0]) - + msg.m_nentries * sizeof(Oid); + +msg.m_nentries * sizeof(Oid); pgstat_setheader(&msg.m_hdr, PGSTAT_MTYPE_TABPURGE); pgstat_send(&msg, len); @@ -1793,7 +1793,7 @@ pgstat_add_backend(PgStat_MsgHdr *msg) if (dbentry->tables == NULL) { elog(LOG, "PGSTAT: failed to initialize hash table for " - "new database entry"); + "new database entry"); exit(1); } } @@ -1918,7 +1918,7 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { elog(LOG, "PGSTAT: database hash table corrupted " - "during cleanup - abort"); + "during cleanup - abort"); exit(1); } } @@ -1954,9 +1954,9 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { elog(LOG, "PGSTAT: tables hash table for " - "database %d corrupted during " - "cleanup - abort", - dbentry->databaseid); + "database %d corrupted during " + "cleanup - abort", + dbentry->databaseid); exit(1); } } @@ -2029,7 +2029,7 @@ pgstat_write_statsfile(void) HASH_REMOVE, NULL) == NULL) { elog(LOG, "PGSTAT: dead backend hash table corrupted " - "during cleanup - abort"); + "during cleanup - abort"); exit(1); } } @@ -2520,7 +2520,7 @@ pgstat_recv_tabstat(PgStat_MsgTabstat *msg, int len) if (tabentry == NULL) { elog(LOG, "PGSTAT: tables hash table out of memory for " - "database %d - abort", dbentry->databaseid); + "database %d - abort", dbentry->databaseid); exit(1); } @@ -2700,7 +2700,7 @@ pgstat_recv_resetcounter(PgStat_MsgResetcounter *msg, int len) if (dbentry->tables == NULL) { elog(LOG, "PGSTAT: failed to reinitialize hash table for " - "database entry"); + "database entry"); exit(1); } } diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 2217fbbe19..85139188b2 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -37,7 +37,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.287 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/postmaster/postmaster.c,v 1.288 2002/09/04 20:31:24 momjian Exp $ * * NOTES * @@ -115,6 +115,7 @@ sigset_t UnBlockSig, BlockSig, AuthBlockSig; + #else int UnBlockSig, BlockSig, @@ -218,7 +219,8 @@ static int Shutdown = NoShutdown; static bool FatalError = false; /* T if recovering from backend crash */ -bool ClientAuthInProgress = false; /* T during new-client authentication */ +bool ClientAuthInProgress = false; /* T during new-client + * authentication */ /* * State for assigning random salts and cancel keys. @@ -250,9 +252,9 @@ static void sigusr1_handler(SIGNAL_ARGS); static void dummy_handler(SIGNAL_ARGS); static void CleanupProc(int pid, int exitstatus); static void LogChildExit(int lev, const char *procname, - int pid, int exitstatus); + int pid, int exitstatus); static int DoBackend(Port *port); - void ExitPostmaster(int status); +void ExitPostmaster(int status); static void usage(const char *); static int ServerLoop(void); static int BackendStartup(Port *port); @@ -271,7 +273,7 @@ static void SignalChildren(int signal); static int CountChildren(void); static bool CreateOptsFile(int argc, char *argv[]); static pid_t SSDataBase(int xlop); - void +void postmaster_error(const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 1, 2))); @@ -281,11 +283,11 @@ __attribute__((format(printf, 1, 2))); #define ShutdownDataBase() SSDataBase(BS_XLOG_SHUTDOWN) #ifdef USE_SSL -extern int secure_initialize(void); +extern int secure_initialize(void); extern void secure_destroy(void); -extern int secure_open_server(Port *); +extern int secure_open_server(Port *); extern void secure_close(Port *); -#endif /* USE_SSL */ +#endif /* USE_SSL */ static void @@ -293,6 +295,7 @@ checkDataDir(const char *checkdir) { char path[MAXPGPATH]; FILE *fp; + #ifndef __CYGWIN__ struct stat stat_buf; #endif @@ -311,9 +314,9 @@ checkDataDir(const char *checkdir) /* * Check if the directory has group or world access. If so, reject. * - * XXX temporarily suppress check when on Windows, because there may - * not be proper support for Unix-y file permissions. Need to think - * of a reasonable check to apply on Windows. + * XXX temporarily suppress check when on Windows, because there may not + * be proper support for Unix-y file permissions. Need to think of a + * reasonable check to apply on Windows. */ #ifndef __CYGWIN__ @@ -329,8 +332,7 @@ checkDataDir(const char *checkdir) if (stat_buf.st_mode & (S_IRWXG | S_IRWXO)) elog(FATAL, "data directory %s has group or world access; permissions should be u=rwx (0700)", checkdir); - -#endif /* !__CYGWIN__ */ +#endif /* !__CYGWIN__ */ /* Look for PG_VERSION before looking for pg_control */ ValidatePgVersion(checkdir); @@ -442,15 +444,16 @@ PostmasterMain(int argc, char *argv[]) potential_DataDir = optarg; break; case 'd': - { - /* Turn on debugging for the postmaster. */ - char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); - sprintf(debugstr, "debug%s", optarg); - SetConfigOption("server_min_messages", debugstr, - PGC_POSTMASTER, PGC_S_ARGV); - pfree(debugstr); - break; - } + { + /* Turn on debugging for the postmaster. */ + char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); + + sprintf(debugstr, "debug%s", optarg); + SetConfigOption("server_min_messages", debugstr, + PGC_POSTMASTER, PGC_S_ARGV); + pfree(debugstr); + break; + } case 'F': SetConfigOption("fsync", "false", PGC_POSTMASTER, PGC_S_ARGV); break; @@ -582,7 +585,7 @@ PostmasterMain(int argc, char *argv[]) * Force an exit if ReservedBackends is not less than MaxBackends. */ if (ReservedBackends >= MaxBackends) - elog(FATAL,"superuser_reserved_connections must be less than max_connections."); + elog(FATAL, "superuser_reserved_connections must be less than max_connections."); /* * Now that we are done processing the postmaster arguments, reset @@ -598,7 +601,7 @@ PostmasterMain(int argc, char *argv[]) extern char **environ; char **p; - elog(DEBUG2, "%s: PostmasterMain: initial environ dump:", progname); + elog(DEBUG2, "%s: PostmasterMain: initial environ dump:", progname); elog(DEBUG2, "-----------------------------------------"); for (p = environ; *p; ++p) elog(DEBUG2, "\t%s", *p); @@ -705,8 +708,8 @@ PostmasterMain(int argc, char *argv[]) /* * Set up signal handlers for the postmaster process. * - * CAUTION: when changing this list, check for side-effects on the - * signal handling setup of child processes. See tcop/postgres.c, + * CAUTION: when changing this list, check for side-effects on the signal + * handling setup of child processes. See tcop/postgres.c, * bootstrap/bootstrap.c, and postmaster/pgstat.c. */ pqinitmask(); @@ -737,8 +740,9 @@ PostmasterMain(int argc, char *argv[]) /* * On many platforms, the first call of localtime() incurs significant * overhead to load timezone info from the system configuration files. - * By doing it once in the postmaster, we avoid having to do it in every - * started child process. The savings are not huge, but they add up... + * By doing it once in the postmaster, we avoid having to do it in + * every started child process. The savings are not huge, but they + * add up... */ { time_t now = time(NULL); @@ -783,6 +787,7 @@ pmdaemonize(int argc, char *argv[]) { int i; pid_t pid; + #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif @@ -1128,7 +1133,7 @@ ProcessStartupPacket(Port *port, bool SSLdone) #ifdef USE_SSL if (SSLok == 'S' && secure_open_server(port) == -1) - return STATUS_ERROR; + return STATUS_ERROR; #endif /* regular startup packet, cancel, etc packet should follow... */ /* but not another SSL negotiation request */ @@ -1174,20 +1179,21 @@ ProcessStartupPacket(Port *port, bool SSLdone) elog(FATAL, "no PostgreSQL user name specified in startup packet"); if (Db_user_namespace) - { + { /* - * If user@, it is a global user, remove '@'. - * We only want to do this if there is an '@' at the end and no - * earlier in the user string or they may fake as a local user - * of another database attaching to this database. + * If user@, it is a global user, remove '@'. We only want to do + * this if there is an '@' at the end and no earlier in the user + * string or they may fake as a local user of another database + * attaching to this database. */ - if (strchr(port->user, '@') == port->user + strlen(port->user)-1) + if (strchr(port->user, '@') == port->user + strlen(port->user) - 1) *strchr(port->user, '@') = '\0'; else { /* Append '@' and dbname */ - char hold_user[SM_DATABASE_USER+1]; - snprintf(hold_user, SM_DATABASE_USER+1, "%s@%s", port->user, + char hold_user[SM_DATABASE_USER + 1]; + + snprintf(hold_user, SM_DATABASE_USER + 1, "%s@%s", port->user, port->database); strcpy(port->user, hold_user); } @@ -1263,7 +1269,7 @@ processCancelRequest(Port *port, void *pkt) else /* Right PID, wrong key: no way, Jose */ elog(DEBUG1, "bad key in cancel request for process %d", - backendPID); + backendPID); return; } } @@ -1388,8 +1394,8 @@ reset_shared(unsigned short port) * * Note: in each "cycle of life" we will normally assign the same IPC * keys (if using SysV shmem and/or semas), since the port number is - * used to determine IPC keys. This helps ensure that we will clean up - * dead IPC objects if the postmaster crashes and is restarted. + * used to determine IPC keys. This helps ensure that we will clean + * up dead IPC objects if the postmaster crashes and is restarted. */ CreateSharedMemoryAndSemaphores(false, MaxBackends, port); } @@ -1832,6 +1838,7 @@ BackendStartup(Port *port) { Backend *bn; /* for backend cleanup */ pid_t pid; + #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif @@ -1866,11 +1873,13 @@ BackendStartup(Port *port) fflush(stderr); #ifdef LINUX_PROFILE + /* - * Linux's fork() resets the profiling timer in the child process. - * If we want to profile child processes then we need to save and restore - * the timer setting. This is a waste of time if not profiling, however, - * so only do it if commanded by specific -DLINUX_PROFILE switch. + * Linux's fork() resets the profiling timer in the child process. If + * we want to profile child processes then we need to save and restore + * the timer setting. This is a waste of time if not profiling, + * however, so only do it if commanded by specific -DLINUX_PROFILE + * switch. */ getitimer(ITIMER_PROF, &prof_itimer); #endif @@ -1924,7 +1933,7 @@ BackendStartup(Port *port) /* in parent, normal */ elog(DEBUG1, "BackendStartup: forked pid=%d socket=%d", (int) pid, - port->sock); + port->sock); /* * Everything's been successful, it's safe to add this backend to our @@ -1940,7 +1949,7 @@ BackendStartup(Port *port) /* * Try to report backend fork() failure to client before we close the - * connection. Since we do not care to risk blocking the postmaster on + * connection. Since we do not care to risk blocking the postmaster on * this connection, we set the connection to non-blocking and try only once. * * This is grungy special-purpose code; we cannot use backend libpq since @@ -1950,6 +1959,7 @@ static void report_fork_failure_to_client(Port *port, int errnum) { char buffer[1000]; + #ifdef __BEOS__ int on = 1; #endif @@ -1968,7 +1978,7 @@ report_fork_failure_to_client(Port *port, int errnum) return; #endif - send(port->sock, buffer, strlen(buffer)+1, 0); + send(port->sock, buffer, strlen(buffer) + 1, 0); } @@ -2033,7 +2043,7 @@ DoBackend(Port *port) IsUnderPostmaster = true; /* we are a postmaster subprocess now */ - ClientAuthInProgress = true; /* limit visibility of log messages */ + ClientAuthInProgress = true; /* limit visibility of log messages */ /* We don't want the postmaster's proc_exit() handlers */ on_exit_reset(); @@ -2260,7 +2270,8 @@ DoBackend(Port *port) elog(DEBUG2, "\t%s", av[i]); elog(DEBUG2, ")"); - ClientAuthInProgress = false; /* client_min_messages is active now */ + ClientAuthInProgress = false; /* client_min_messages is active + * now */ return (PostgresMain(ac, av, port->user)); } @@ -2459,6 +2470,7 @@ SSDataBase(int xlop) { pid_t pid; Backend *bn; + #ifdef LINUX_PROFILE struct itimerval prof_itimer; #endif @@ -2647,7 +2659,7 @@ CreateOptsFile(int argc, char *argv[]) /* * This should be used only for reporting "interactive" errors (ie, errors - * during startup. Once the postmaster is launched, use elog. + * during startup. Once the postmaster is launched, use elog. */ void postmaster_error(const char *fmt,...) diff --git a/src/backend/regex/regcomp.c b/src/backend/regex/regcomp.c index 2e2d7c6ab2..71e69dea61 100644 --- a/src/backend/regex/regcomp.c +++ b/src/backend/regex/regcomp.c @@ -51,12 +51,12 @@ struct cclass { - char *name; - char *chars; - char *multis; + char *name; + char *chars; + char *multis; }; -static struct cclass* cclasses = NULL; -static struct cclass* cclass_init(void); +static struct cclass *cclasses = NULL; +static struct cclass *cclass_init(void); /* * parse structure, passed up and down to avoid global variables and @@ -179,8 +179,8 @@ pg_regcomp(regex_t *preg, const char *pattern, int cflags) size_t len; pg_wchar *wcp; - if ( cclasses == NULL ) - cclasses = cclass_init(); + if (cclasses == NULL) + cclasses = cclass_init(); #ifdef REDEBUG #define GOODFLAGS(f) (f) @@ -862,7 +862,7 @@ p_b_cclass(struct parse * p, cset *cs) struct cclass *cp; size_t len; char *u; - unsigned char c; + unsigned char c; while (MORE() && pg_isalpha(PEEK())) NEXT(); @@ -1684,77 +1684,105 @@ pg_ispunct(int c) static struct cclass * cclass_init(void) { - static struct cclass cclasses_C[] = { - { "alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", "" }, - { "alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", "" }, - { "blank", " \t", "" }, - { "cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177", "" }, - { "digit", "0123456789", "" }, - { "graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", "" }, - { "lower", "abcdefghijklmnopqrstuvwxyz", "" }, - { "print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", "" }, - { "punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", "" }, - { "space", "\t\n\v\f\r ", "" }, - { "upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", "" }, - { "xdigit", "0123456789ABCDEFabcdef", "" }, - { NULL, NULL, "" } - }; - struct cclass *cp = NULL; - struct cclass *classes = NULL; - struct cclass_factory - { - char *name; - int (*func)(int); - char *chars; - } cclass_factories [] = - { - { "alnum", pg_isalnum, NULL }, - { "alpha", pg_isalpha, NULL }, - { "blank", NULL, " \t" }, - { "cntrl", pg_iscntrl, NULL }, - { "digit", NULL, "0123456789" }, - { "graph", pg_isgraph, NULL }, - { "lower", pg_islower, NULL }, - { "print", pg_isprint, NULL }, - { "punct", pg_ispunct, NULL }, - { "space", NULL, "\t\n\v\f\r " }, - { "upper", pg_isupper, NULL }, - { "xdigit", NULL, "0123456789ABCDEFabcdef" }, - { NULL, NULL, NULL } - }; - struct cclass_factory *cf = NULL; - - if ( strcmp( setlocale( LC_CTYPE, NULL ), "C" ) == 0 ) - return cclasses_C; - - classes = malloc(sizeof(struct cclass) * (sizeof(cclass_factories) / sizeof(struct cclass_factory))); - if (classes == NULL) - elog(ERROR,"cclass_init: out of memory"); - - cp = classes; - for(cf = cclass_factories; cf->name != NULL; cf++) - { - cp->name = strdup(cf->name); - if ( cf->chars ) - cp->chars = strdup(cf->chars); - else - { - int x = 0, y = 0; - cp->chars = malloc(sizeof(char) * 256); - if (cp->chars == NULL) - elog(ERROR,"cclass_init: out of memory"); - for (x = 0; x < 256; x++) - { - if((cf->func)(x)) - *(cp->chars + y++) = x; - } - *(cp->chars + y) = '\0'; - } - cp->multis = ""; - cp++; - } - cp->name = cp->chars = NULL; - cp->multis = ""; - - return classes; + static struct cclass cclasses_C[] = { + {"alnum", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789", ""}, + {"alpha", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz", ""}, + {"blank", " \t", ""}, + {"cntrl", "\007\b\t\n\v\f\r\1\2\3\4\5\6\16\17\20\21\22\23\24\25\26\27\30\31\32\33\34\35\36\37\177", ""}, + {"digit", "0123456789", ""}, + {"graph", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""}, + {"lower", "abcdefghijklmnopqrstuvwxyz", ""}, + {"print", "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~ ", ""}, + {"punct", "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~", ""}, + {"space", "\t\n\v\f\r ", ""}, + {"upper", "ABCDEFGHIJKLMNOPQRSTUVWXYZ", ""}, + {"xdigit", "0123456789ABCDEFabcdef", ""}, + {NULL, NULL, ""} + }; + struct cclass *cp = NULL; + struct cclass *classes = NULL; + struct cclass_factory + { + char *name; + int (*func) (int); + char *chars; + } cclass_factories[] = + { + { + "alnum", pg_isalnum, NULL + }, + { + "alpha", pg_isalpha, NULL + }, + { + "blank", NULL, " \t" + }, + { + "cntrl", pg_iscntrl, NULL + }, + { + "digit", NULL, "0123456789" + }, + { + "graph", pg_isgraph, NULL + }, + { + "lower", pg_islower, NULL + }, + { + "print", pg_isprint, NULL + }, + { + "punct", pg_ispunct, NULL + }, + { + "space", NULL, "\t\n\v\f\r " + }, + { + "upper", pg_isupper, NULL + }, + { + "xdigit", NULL, "0123456789ABCDEFabcdef" + }, + { + NULL, NULL, NULL + } + }; + struct cclass_factory *cf = NULL; + + if (strcmp(setlocale(LC_CTYPE, NULL), "C") == 0) + return cclasses_C; + + classes = malloc(sizeof(struct cclass) * (sizeof(cclass_factories) / sizeof(struct cclass_factory))); + if (classes == NULL) + elog(ERROR, "cclass_init: out of memory"); + + cp = classes; + for (cf = cclass_factories; cf->name != NULL; cf++) + { + cp->name = strdup(cf->name); + if (cf->chars) + cp->chars = strdup(cf->chars); + else + { + int x = 0, + y = 0; + + cp->chars = malloc(sizeof(char) * 256); + if (cp->chars == NULL) + elog(ERROR, "cclass_init: out of memory"); + for (x = 0; x < 256; x++) + { + if ((cf->func) (x)) + *(cp->chars + y++) = x; + } + *(cp->chars + y) = '\0'; + } + cp->multis = ""; + cp++; + } + cp->name = cp->chars = NULL; + cp->multis = ""; + + return classes; } diff --git a/src/backend/rewrite/rewriteDefine.c b/src/backend/rewrite/rewriteDefine.c index f276189426..2aa4fdd892 100644 --- a/src/backend/rewrite/rewriteDefine.c +++ b/src/backend/rewrite/rewriteDefine.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.78 2002/09/02 02:13:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteDefine.c,v 1.79 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,8 +62,8 @@ InsertRule(char *rulname, HeapTuple tup, oldtup; Oid rewriteObjectId; - ObjectAddress myself, - referenced; + ObjectAddress myself, + referenced; bool is_update = false; /* @@ -73,13 +73,13 @@ InsertRule(char *rulname, i = 0; namestrcpy(&rname, rulname); - values[i++] = NameGetDatum(&rname); /* rulename */ - values[i++] = ObjectIdGetDatum(eventrel_oid); /* ev_class */ - values[i++] = Int16GetDatum(evslot_index); /* ev_attr */ - values[i++] = CharGetDatum(evtype + '0'); /* ev_type */ - values[i++] = BoolGetDatum(evinstead); /* is_instead */ - values[i++] = DirectFunctionCall1(textin, CStringGetDatum(evqual)); /* ev_qual */ - values[i++] = DirectFunctionCall1(textin, CStringGetDatum(actiontree)); /* ev_action */ + values[i++] = NameGetDatum(&rname); /* rulename */ + values[i++] = ObjectIdGetDatum(eventrel_oid); /* ev_class */ + values[i++] = Int16GetDatum(evslot_index); /* ev_attr */ + values[i++] = CharGetDatum(evtype + '0'); /* ev_type */ + values[i++] = BoolGetDatum(evinstead); /* is_instead */ + values[i++] = DirectFunctionCall1(textin, CStringGetDatum(evqual)); /* ev_qual */ + values[i++] = DirectFunctionCall1(textin, CStringGetDatum(actiontree)); /* ev_action */ /* * Ready to store new pg_rewrite tuple @@ -97,7 +97,7 @@ InsertRule(char *rulname, if (HeapTupleIsValid(oldtup)) { if (!replace) - elog(ERROR,"Attempt to insert rule \"%s\" failed: already exists", + elog(ERROR, "Attempt to insert rule \"%s\" failed: already exists", rulname); /* @@ -138,8 +138,8 @@ InsertRule(char *rulname, rewriteObjectId); /* - * Install dependency on rule's relation to ensure it will go away - * on relation deletion. If the rule is ON SELECT, make the dependency + * Install dependency on rule's relation to ensure it will go away on + * relation deletion. If the rule is ON SELECT, make the dependency * implicit --- this prevents deleting a view's SELECT rule. Other * kinds of rules can be AUTO. */ @@ -152,7 +152,7 @@ InsertRule(char *rulname, referenced.objectSubId = 0; recordDependencyOn(&myself, &referenced, - (evtype == CMD_SELECT) ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); + (evtype == CMD_SELECT) ? DEPENDENCY_INTERNAL : DEPENDENCY_AUTO); /* * Also install dependencies on objects referenced in action and qual. @@ -163,7 +163,7 @@ InsertRule(char *rulname, if (event_qual != NULL) { /* Find query containing OLD/NEW rtable entries */ - Query *qry = (Query *) lfirst(action); + Query *qry = (Query *) lfirst(action); qry = getInsertSelectQuery(qry, NULL); recordDependencyOnExpr(&myself, event_qual, qry->rtable, @@ -272,7 +272,7 @@ DefineQueryRewrite(RuleStmt *stmt) * event relation, ... */ i = 0; - foreach (tllist, query->targetList) + foreach(tllist, query->targetList) { TargetEntry *tle = (TargetEntry *) lfirst(tllist); Resdom *resdom = tle->resdom; @@ -289,11 +289,12 @@ DefineQueryRewrite(RuleStmt *stmt) attname = NameStr(attr->attname); /* - * Disallow dropped columns in the relation. This won't happen - * in the cases we actually care about (namely creating a view - * via CREATE TABLE then CREATE RULE). Trying to cope with it - * is much more trouble than it's worth, because we'd have to - * modify the rule to insert dummy NULLs at the right positions. + * Disallow dropped columns in the relation. This won't + * happen in the cases we actually care about (namely creating + * a view via CREATE TABLE then CREATE RULE). Trying to cope + * with it is much more trouble than it's worth, because we'd + * have to modify the rule to insert dummy NULLs at the right + * positions. */ if (attr->attisdropped) elog(ERROR, "cannot convert relation containing dropped columns to view"); @@ -343,11 +344,11 @@ DefineQueryRewrite(RuleStmt *stmt) /* * In versions before 7.3, the expected name was _RETviewname. * For backwards compatibility with old pg_dump output, accept - * that and silently change it to _RETURN. Since this is just + * that and silently change it to _RETURN. Since this is just * a quick backwards-compatibility hack, limit the number of * characters checked to a few less than NAMEDATALEN; this - * saves having to worry about where a multibyte character might - * have gotten truncated. + * saves having to worry about where a multibyte character + * might have gotten truncated. */ if (strncmp(stmt->rulename, "_RET", 4) != 0 || strncmp(stmt->rulename + 4, event_obj->relname, diff --git a/src/backend/rewrite/rewriteHandler.c b/src/backend/rewrite/rewriteHandler.c index b183f85f08..d434e9e2fb 100644 --- a/src/backend/rewrite/rewriteHandler.c +++ b/src/backend/rewrite/rewriteHandler.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.107 2002/08/29 06:05:27 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteHandler.c,v 1.108 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,7 +42,7 @@ static Query *rewriteRuleAction(Query *parsetree, static List *adjustJoinTreeList(Query *parsetree, bool removert, int rt_index); static void rewriteTargetList(Query *parsetree, Relation target_relation); static TargetEntry *process_matched_tle(TargetEntry *src_tle, - TargetEntry *prior_tle); + TargetEntry *prior_tle); static void markQueryForUpdate(Query *qry, bool skipOldNew); static List *matchLocks(CmdType event, RuleLock *rulelocks, int varno, Query *parsetree); @@ -239,7 +239,7 @@ adjustJoinTreeList(Query *parsetree, bool removert, int rt_index) * then junk fields (these in no particular order). * * We must do items 1 and 2 before firing rewrite rules, else rewritten - * references to NEW.foo will produce wrong or incomplete results. Item 3 + * references to NEW.foo will produce wrong or incomplete results. Item 3 * is not needed for rewriting, but will be needed by the planner, and we * can do it essentially for free while handling items 1 and 2. */ @@ -261,7 +261,7 @@ rewriteTargetList(Query *parsetree, Relation target_relation) for (attrno = 1; attrno <= numattrs; attrno++) { - Form_pg_attribute att_tup = target_relation->rd_att->attrs[attrno-1]; + Form_pg_attribute att_tup = target_relation->rd_att->attrs[attrno - 1]; TargetEntry *new_tle = NULL; /* We can ignore deleted attributes */ @@ -269,7 +269,7 @@ rewriteTargetList(Query *parsetree, Relation target_relation) continue; /* - * Look for targetlist entries matching this attr. We match by + * Look for targetlist entries matching this attr. We match by * resno, but the resname should match too. * * Junk attributes are not candidates to be matched. @@ -291,9 +291,9 @@ rewriteTargetList(Query *parsetree, Relation target_relation) if (new_tle == NULL && commandType == CMD_INSERT) { /* - * Didn't find a matching tlist entry; if it's an INSERT, - * look for a default value, and add a tlist entry computing - * the default if we find one. + * Didn't find a matching tlist entry; if it's an INSERT, look + * for a default value, and add a tlist entry computing the + * default if we find one. */ Node *new_expr; @@ -303,7 +303,7 @@ rewriteTargetList(Query *parsetree, Relation target_relation) new_tle = makeTargetEntry(makeResdom(attrno, att_tup->atttypid, att_tup->atttypmod, - pstrdup(NameStr(att_tup->attname)), + pstrdup(NameStr(att_tup->attname)), false), new_expr); } @@ -448,30 +448,28 @@ build_column_default(Relation rel, int attrno) if (expr == NULL) { /* - * No per-column default, so look for a default for the type itself. + * No per-column default, so look for a default for the type + * itself. */ if (att_tup->attisset) { /* - * Set attributes are represented as OIDs no matter what the set - * element type is, and the element type's default is irrelevant - * too. + * Set attributes are represented as OIDs no matter what the + * set element type is, and the element type's default is + * irrelevant too. */ } else - { expr = get_typdefault(atttype); - } } if (expr == NULL) return NULL; /* No default anywhere */ /* - * Make sure the value is coerced to the target column - * type (might not be right type yet if it's not a - * constant!) This should match the parser's processing of - * non-defaulted expressions --- see + * Make sure the value is coerced to the target column type (might not + * be right type yet if it's not a constant!) This should match the + * parser's processing of non-defaulted expressions --- see * updateTargetListEntry(). */ exprtype = exprType(expr); @@ -482,8 +480,8 @@ build_column_default(Relation rel, int attrno) atttype, atttypmod, false); /* - * This really shouldn't fail; should have checked the - * default's type when it was created ... + * This really shouldn't fail; should have checked the default's + * type when it was created ... */ if (expr == NULL) elog(ERROR, "Column \"%s\" is of type %s" @@ -495,8 +493,8 @@ build_column_default(Relation rel, int attrno) } /* - * If the column is a fixed-length type, it may need a - * length coercion as well as a type coercion. + * If the column is a fixed-length type, it may need a length coercion + * as well as a type coercion. */ expr = coerce_type_typmod(NULL, expr, atttype, atttypmod); diff --git a/src/backend/rewrite/rewriteManip.c b/src/backend/rewrite/rewriteManip.c index 87fe1c9526..16eef1bfb8 100644 --- a/src/backend/rewrite/rewriteManip.c +++ b/src/backend/rewrite/rewriteManip.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.64 2002/06/20 20:29:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteManip.c,v 1.65 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -142,7 +142,7 @@ OffsetVarNodes_walker(Node *node, OffsetVarNodes_context *context) } if (IsA(node, JoinExpr)) { - JoinExpr *j = (JoinExpr *) node; + JoinExpr *j = (JoinExpr *) node; if (context->sublevels_up == 0) j->rtindex += context->offset; @@ -251,7 +251,7 @@ ChangeVarNodes_walker(Node *node, ChangeVarNodes_context *context) } if (IsA(node, JoinExpr)) { - JoinExpr *j = (JoinExpr *) node; + JoinExpr *j = (JoinExpr *) node; if (context->sublevels_up == 0 && j->rtindex == context->rt_index) @@ -429,7 +429,7 @@ rangeTableEntry_used_walker(Node *node, } if (IsA(node, JoinExpr)) { - JoinExpr *j = (JoinExpr *) node; + JoinExpr *j = (JoinExpr *) node; if (j->rtindex == context->rt_index && context->sublevels_up == 0) @@ -573,10 +573,10 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) * they've been pushed down to the SELECT. */ if (length(parsetree->rtable) >= 2 && - strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->aliasname, - "*OLD*") == 0 && - strcmp(rt_fetch(PRS2_NEW_VARNO, parsetree->rtable)->eref->aliasname, - "*NEW*") == 0) + strcmp(rt_fetch(PRS2_OLD_VARNO, parsetree->rtable)->eref->aliasname, + "*OLD*") == 0 && + strcmp(rt_fetch(PRS2_NEW_VARNO, parsetree->rtable)->eref->aliasname, + "*NEW*") == 0) return parsetree; Assert(parsetree->jointree && IsA(parsetree->jointree, FromExpr)); if (length(parsetree->jointree->fromlist) != 1) @@ -589,10 +589,10 @@ getInsertSelectQuery(Query *parsetree, Query ***subquery_ptr) selectquery->commandType == CMD_SELECT)) elog(ERROR, "getInsertSelectQuery: expected to find SELECT subquery"); if (length(selectquery->rtable) >= 2 && - strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname, - "*OLD*") == 0 && - strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->aliasname, - "*NEW*") == 0) + strcmp(rt_fetch(PRS2_OLD_VARNO, selectquery->rtable)->eref->aliasname, + "*OLD*") == 0 && + strcmp(rt_fetch(PRS2_NEW_VARNO, selectquery->rtable)->eref->aliasname, + "*NEW*") == 0) { if (subquery_ptr) *subquery_ptr = &(selectrte->subquery); diff --git a/src/backend/rewrite/rewriteRemove.c b/src/backend/rewrite/rewriteRemove.c index 1fd5f36ce5..deb46128ca 100644 --- a/src/backend/rewrite/rewriteRemove.c +++ b/src/backend/rewrite/rewriteRemove.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.52 2002/07/20 05:16:58 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/rewrite/rewriteRemove.c,v 1.53 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -85,8 +85,8 @@ void RemoveRewriteRuleById(Oid ruleOid) { Relation RewriteRelation; - ScanKeyData skey[1]; - SysScanDesc rcscan; + ScanKeyData skey[1]; + SysScanDesc rcscan; Relation event_relation; HeapTuple tuple; Oid eventRelationOid; diff --git a/src/backend/storage/buffer/buf_init.c b/src/backend/storage/buffer/buf_init.c index 5e6650dc96..dd6478c195 100644 --- a/src/backend/storage/buffer/buf_init.c +++ b/src/backend/storage/buffer/buf_init.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.51 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/buf_init.c,v 1.52 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -231,6 +231,7 @@ InitBufferPoolAccess(void) BufferBlockPointers = (Block *) calloc(NBuffers, sizeof(Block)); PrivateRefCount = (long *) calloc(NBuffers, sizeof(long)); BufferLocks = (bits8 *) calloc(NBuffers, sizeof(bits8)); + /* * Convert shmem offsets into addresses as seen by this process. This * is just to speed up the BufferGetBlock() macro. diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index bea4854bb7..b6c9112030 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.131 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/bufmgr.c,v 1.132 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -75,6 +75,7 @@ static Buffer ReadBufferInternal(Relation reln, BlockNumber blockNum, static BufferDesc *BufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr); static int BufferReplace(BufferDesc *bufHdr); + #ifdef NOT_USED void PrintBufferDescs(void); #endif @@ -552,7 +553,7 @@ BufferAlloc(Relation reln, /* * write_buffer -- common functionality for - * WriteBuffer and WriteNoReleaseBuffer + * WriteBuffer and WriteNoReleaseBuffer */ static void write_buffer(Buffer buffer, bool release) @@ -870,14 +871,14 @@ ShowBufferUsage(void) localhitrate = (float) LocalBufferHitCount *100.0 / ReadLocalBufferCount; appendStringInfo(&str, - "!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", + "!\tShared blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", ReadBufferCount - BufferHitCount, BufferFlushCount, hitrate); appendStringInfo(&str, - "!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", - ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate); + "!\tLocal blocks: %10ld read, %10ld written, buffer hit rate = %.2f%%\n", + ReadLocalBufferCount - LocalBufferHitCount, LocalBufferFlushCount, localhitrate); appendStringInfo(&str, - "!\tDirect blocks: %10ld read, %10ld written\n", - NDirectFileRead, NDirectFileWrite); + "!\tDirect blocks: %10ld read, %10ld written\n", + NDirectFileRead, NDirectFileWrite); return str.data; } @@ -917,7 +918,7 @@ AtEOXact_Buffers(bool isCommit) if (isCommit) elog(WARNING, "Buffer Leak: [%03d] (freeNext=%d, freePrev=%d, " - "rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)", + "rel=%u/%u, blockNum=%u, flags=0x%x, refcount=%d %ld)", i, buf->freeNext, buf->freePrev, buf->tag.rnode.tblNode, buf->tag.rnode.relNode, buf->tag.blockNum, buf->flags, diff --git a/src/backend/storage/buffer/localbuf.c b/src/backend/storage/buffer/localbuf.c index 50168c8b30..5f4033b583 100644 --- a/src/backend/storage/buffer/localbuf.c +++ b/src/backend/storage/buffer/localbuf.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.45 2002/08/06 02:36:34 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/buffer/localbuf.c,v 1.46 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -83,8 +83,8 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) elog(ERROR, "no empty local buffer."); /* - * this buffer is not referenced but it might still be dirty. - * if that's the case, write it out before reusing it! + * this buffer is not referenced but it might still be dirty. if + * that's the case, write it out before reusing it! */ if (bufHdr->flags & BM_DIRTY || bufHdr->cntxDirty) { @@ -108,9 +108,9 @@ LocalBufferAlloc(Relation reln, BlockNumber blockNum, bool *foundPtr) /* * lazy memory allocation: allocate space on first use of a buffer. * - * Note this path cannot be taken for a buffer that was previously - * in use, so it's okay to do it (and possibly error out) before - * marking the buffer as valid. + * Note this path cannot be taken for a buffer that was previously in + * use, so it's okay to do it (and possibly error out) before marking + * the buffer as valid. */ if (bufHdr->data == (SHMEM_OFFSET) 0) { diff --git a/src/backend/storage/freespace/freespace.c b/src/backend/storage/freespace/freespace.c index 2c0eb3ced8..7dc91a4e80 100644 --- a/src/backend/storage/freespace/freespace.c +++ b/src/backend/storage/freespace/freespace.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.12 2002/06/20 20:29:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/freespace/freespace.c,v 1.13 2002/09/04 20:31:25 momjian Exp $ * * * NOTES: @@ -850,7 +850,7 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail, FSMChunk *newChunk; if ((newChunk = FreeSpaceMap->freeChunks) == NULL) - return false; /* can't do it */ + return false; /* can't do it */ FreeSpaceMap->freeChunks = newChunk->next; FreeSpaceMap->numFreeChunks--; newChunk->next = NULL; @@ -874,21 +874,25 @@ insert_fsm_page_entry(FSMRelation *fsmrel, BlockNumber page, Size spaceAvail, } } - /* Try to insert it the easy way, ie, just move down subsequent data */ + /* + * Try to insert it the easy way, ie, just move down subsequent + * data + */ if (chunk && push_fsm_page_entry(page, spaceAvail, chunk, chunkRelIndex)) { fsmrel->numPages++; - fsmrel->nextPage++; /* don't return same page twice running */ + fsmrel->nextPage++; /* don't return same page twice running */ return true; } /* - * There is space available, but evidently it's before the place where - * the page entry needs to go. Compact the list and try again. This - * will require us to redo the search for the appropriate place. - * Furthermore, compact_fsm_page_list deletes empty end chunks, so - * we may need to repeat the action of grabbing a new end chunk. + * There is space available, but evidently it's before the place + * where the page entry needs to go. Compact the list and try + * again. This will require us to redo the search for the + * appropriate place. Furthermore, compact_fsm_page_list deletes + * empty end chunks, so we may need to repeat the action of + * grabbing a new end chunk. */ compact_fsm_page_list(fsmrel); if (lookup_fsm_page_entry(fsmrel, page, &chunk, &chunkRelIndex)) diff --git a/src/backend/storage/ipc/ipc.c b/src/backend/storage/ipc/ipc.c index e71bb0c17a..989ee1bcb6 100644 --- a/src/backend/storage/ipc/ipc.c +++ b/src/backend/storage/ipc/ipc.c @@ -4,7 +4,7 @@ * POSTGRES inter-process communication definitions. * * This file is misnamed, as it no longer has much of anything directly - * to do with IPC. The functionality here is concerned with managing + * to do with IPC. The functionality here is concerned with managing * exit-time cleanup for either a postmaster or a backend. * * @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.80 2002/06/20 20:29:34 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/ipc.c,v 1.81 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ diff --git a/src/backend/storage/ipc/shmem.c b/src/backend/storage/ipc/shmem.c index 70dfb83375..ff9a83a684 100644 --- a/src/backend/storage/ipc/shmem.c +++ b/src/backend/storage/ipc/shmem.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.66 2002/06/20 20:29:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/shmem.c,v 1.67 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -133,6 +133,7 @@ ShmemAlloc(Size size) { uint32 newFree; void *newSpace; + /* use volatile pointer to prevent code rearrangement */ volatile PGShmemHeader *shmemseghdr = ShmemSegHdr; diff --git a/src/backend/storage/ipc/sinval.c b/src/backend/storage/ipc/sinval.c index a328ea4830..87f7a29245 100644 --- a/src/backend/storage/ipc/sinval.c +++ b/src/backend/storage/ipc/sinval.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.51 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/ipc/sinval.c,v 1.52 2002/09/04 20:31:25 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -96,7 +96,8 @@ ReceiveSharedInvalidMessages( * The routines later in this file that use shared mode are okay with * this, because they aren't looking at the ProcState fields * associated with SI message transfer; they only use the - * ProcState array as an easy way to find all the PGPROC structures. + * ProcState array as an easy way to find all the PGPROC + * structures. */ LWLockAcquire(SInvalLock, LW_SHARED); getResult = SIGetDataEntry(shmInvalBuffer, MyBackendId, &data); @@ -380,9 +381,9 @@ GetSnapshotData(bool serializable) * running a transaction, and xacts started since we read the * next transaction ID. There's no need to store XIDs above * what we got from ReadNewTransactionId, since we'll treat - * them as running anyway. We also assume that such xacts can't - * compute an xmin older than ours, so they needn't be considered - * in computing globalxmin. + * them as running anyway. We also assume that such xacts + * can't compute an xmin older than ours, so they needn't be + * considered in computing globalxmin. */ if (proc == MyProc || !TransactionIdIsNormal(xid) || @@ -411,9 +412,9 @@ GetSnapshotData(bool serializable) Assert(TransactionIdIsValid(MyProc->xmin)); /* - * Update globalxmin to include actual process xids. This is a slightly - * different way of computing it than GetOldestXmin uses, but should give - * the same result. + * Update globalxmin to include actual process xids. This is a + * slightly different way of computing it than GetOldestXmin uses, but + * should give the same result. */ if (TransactionIdPrecedes(xmin, globalxmin)) globalxmin = xmin; @@ -551,7 +552,7 @@ BackendIdGetProc(BackendId procId) int CountEmptyBackendSlots(void) { - int count; + int count; LWLockAcquire(SInvalLock, LW_SHARED); diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index cf6838cbb6..155b1a42ea 100644 --- a/src/backend/storage/lmgr/deadlock.c +++ b/src/backend/storage/lmgr/deadlock.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.12 2002/07/19 00:17:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.13 2002/09/04 20:31:25 momjian Exp $ * * Interface: * @@ -66,7 +66,7 @@ static void PrintLockQueue(LOCK *lock, const char *info); */ /* Workspace for FindLockCycle */ -static PGPROC **visitedProcs; /* Array of visited procs */ +static PGPROC **visitedProcs; /* Array of visited procs */ static int nVisitedProcs; /* Workspace for TopoSort */ @@ -77,7 +77,7 @@ static int *afterConstraints; /* List head for after-constraints */ /* Output area for ExpandConstraints */ static WAIT_ORDER *waitOrders; /* Array of proposed queue rearrangements */ static int nWaitOrders; -static PGPROC **waitOrderProcs; /* Space for waitOrders queue contents */ +static PGPROC **waitOrderProcs; /* Space for waitOrders queue contents */ /* Current list of constraints being considered */ static EDGE *curConstraints; @@ -377,7 +377,7 @@ FindLockCycleRecurse(PGPROC *checkProc, { PGPROC *proc; LOCK *lock; - PROCLOCK *holder; + PROCLOCK *holder; SHM_QUEUE *lockHolders; LOCKMETHODTABLE *lockMethodTable; PROC_QUEUE *waitQueue; @@ -428,7 +428,7 @@ FindLockCycleRecurse(PGPROC *checkProc, lockHolders = &(lock->lockHolders); holder = (PROCLOCK *) SHMQueueNext(lockHolders, lockHolders, - offsetof(PROCLOCK, lockLink)); + offsetof(PROCLOCK, lockLink)); while (holder) { @@ -452,7 +452,7 @@ FindLockCycleRecurse(PGPROC *checkProc, } holder = (PROCLOCK *) SHMQueueNext(lockHolders, &holder->lockLink, - offsetof(PROCLOCK, lockLink)); + offsetof(PROCLOCK, lockLink)); } /* diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index fd300a4c9e..03d16d60ae 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.114 2002/09/02 02:47:03 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.115 2002/09/04 20:31:25 momjian Exp $ * * NOTES * Outside modules can create a lock table and acquire/release @@ -127,9 +127,9 @@ inline static void PROCLOCK_PRINT(const char *where, const PROCLOCK *holderP) { if ( - (((PROCLOCK_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks) - || (PROCLOCK_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks)) - && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin)) + (((PROCLOCK_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks) + || (PROCLOCK_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks)) + && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin)) || (Trace_lock_table && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId == Trace_lock_table)) ) elog(LOG, @@ -310,7 +310,7 @@ LockMethodTableInit(char *tabName, Assert(lockMethodTable->lockHash->hash == tag_hash); /* - * allocate a hash table for PROCLOCK structs. This is used to store + * allocate a hash table for PROCLOCK structs. This is used to store * per-lock-holder information. */ info.keysize = sizeof(PROCLOCKTAG); @@ -434,8 +434,8 @@ bool LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, TransactionId xid, LOCKMODE lockmode, bool dontWait) { - PROCLOCK *holder; - PROCLOCKTAG holdertag; + PROCLOCK *holder; + PROCLOCKTAG holdertag; HTAB *holderTable; bool found; LOCK *lock; @@ -507,7 +507,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, /* * Create the hash key for the holder table. */ - MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding, + MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding, * needed */ holdertag.lock = MAKE_OFFSET(lock); holdertag.proc = MAKE_OFFSET(MyProc); @@ -518,8 +518,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, */ holderTable = lockMethodTable->holderHash; holder = (PROCLOCK *) hash_search(holderTable, - (void *) &holdertag, - HASH_ENTER, &found); + (void *) &holdertag, + HASH_ENTER, &found); if (!holder) { LWLockRelease(masterLock); @@ -645,8 +645,8 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag, SHMQueueDelete(&holder->lockLink); SHMQueueDelete(&holder->procLink); holder = (PROCLOCK *) hash_search(holderTable, - (void *) holder, - HASH_REMOVE, NULL); + (void *) holder, + HASH_REMOVE, NULL); if (!holder) elog(WARNING, "LockAcquire: remove holder, table corrupted"); } @@ -808,13 +808,13 @@ static void LockCountMyLocks(SHMEM_OFFSET lockOffset, PGPROC *proc, int *myHolding) { SHM_QUEUE *procHolders = &(proc->procHolders); - PROCLOCK *holder; + PROCLOCK *holder; int i; MemSet(myHolding, 0, MAX_LOCKMODES * sizeof(int)); holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); while (holder) { @@ -825,7 +825,7 @@ LockCountMyLocks(SHMEM_OFFSET lockOffset, PGPROC *proc, int *myHolding) } holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); } } @@ -978,8 +978,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, LOCK *lock; LWLockId masterLock; LOCKMETHODTABLE *lockMethodTable; - PROCLOCK *holder; - PROCLOCKTAG holdertag; + PROCLOCK *holder; + PROCLOCKTAG holdertag; HTAB *holderTable; bool wakeupNeeded = false; @@ -1025,7 +1025,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, /* * Find the holder entry for this holder. */ - MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding, + MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding, * needed */ holdertag.lock = MAKE_OFFSET(lock); holdertag.proc = MAKE_OFFSET(MyProc); @@ -1033,8 +1033,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, holderTable = lockMethodTable->holderHash; holder = (PROCLOCK *) hash_search(holderTable, - (void *) &holdertag, - HASH_FIND_SAVE, NULL); + (void *) &holdertag, + HASH_FIND_SAVE, NULL); if (!holder) { LWLockRelease(masterLock); @@ -1135,8 +1135,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag, SHMQueueDelete(&holder->lockLink); SHMQueueDelete(&holder->procLink); holder = (PROCLOCK *) hash_search(holderTable, - (void *) &holder, - HASH_REMOVE_SAVED, NULL); + (void *) &holder, + HASH_REMOVE_SAVED, NULL); if (!holder) { LWLockRelease(masterLock); @@ -1171,8 +1171,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc, bool allxids, TransactionId xid) { SHM_QUEUE *procHolders = &(proc->procHolders); - PROCLOCK *holder; - PROCLOCK *nextHolder; + PROCLOCK *holder; + PROCLOCK *nextHolder; LWLockId masterLock; LOCKMETHODTABLE *lockMethodTable; int i, @@ -1199,7 +1199,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc, LWLockAcquire(masterLock, LW_EXCLUSIVE); holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); while (holder) { @@ -1207,7 +1207,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc, /* Get link first, since we may unlink/delete this holder */ nextHolder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); Assert(holder->tag.proc == MAKE_OFFSET(proc)); @@ -1249,7 +1249,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc, * Read comments in LockRelease */ if (!wakeupNeeded && - lockMethodTable->conflictTab[i] & lock->waitMask) + lockMethodTable->conflictTab[i] & lock->waitMask) wakeupNeeded = true; } } @@ -1287,9 +1287,9 @@ LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc, * remove the holder entry from the hashtable */ holder = (PROCLOCK *) hash_search(lockMethodTable->holderHash, - (void *) holder, - HASH_REMOVE, - NULL); + (void *) holder, + HASH_REMOVE, + NULL); if (!holder) { LWLockRelease(masterLock); @@ -1340,8 +1340,7 @@ LockShmemSize(int maxBackends) size += MAXALIGN(sizeof(PROC_HDR)); /* ProcGlobal */ size += maxBackends * MAXALIGN(sizeof(PGPROC)); /* each MyProc */ - size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODTABLE)); /* each - * lockMethodTable */ + size += MAX_LOCK_METHODS * MAXALIGN(sizeof(LOCKMETHODTABLE)); /* each lockMethodTable */ /* lockHash table */ size += hash_estimate_size(max_table_size, sizeof(LOCK)); @@ -1375,11 +1374,11 @@ LockShmemSize(int maxBackends) LockData * GetLockStatusData(void) { - LockData *data; - HTAB *holderTable; - PROCLOCK *holder; + LockData *data; + HTAB *holderTable; + PROCLOCK *holder; HASH_SEQ_STATUS seqstat; - int i; + int i; data = (LockData *) palloc(sizeof(LockData)); @@ -1400,10 +1399,10 @@ GetLockStatusData(void) hash_seq_init(&seqstat, holderTable); i = 0; - while ( (holder = hash_seq_search(&seqstat)) ) + while ((holder = hash_seq_search(&seqstat))) { - PGPROC *proc = (PGPROC *) MAKE_PTR(holder->tag.proc); - LOCK *lock = (LOCK *) MAKE_PTR(holder->tag.lock); + PGPROC *proc = (PGPROC *) MAKE_PTR(holder->tag.proc); + LOCK *lock = (LOCK *) MAKE_PTR(holder->tag.lock); data->holderaddrs[i] = MAKE_OFFSET(holder); memcpy(&(data->holders[i]), holder, sizeof(PROCLOCK)); @@ -1439,7 +1438,7 @@ DumpLocks(void) { PGPROC *proc; SHM_QUEUE *procHolders; - PROCLOCK *holder; + PROCLOCK *holder; LOCK *lock; int lockmethod = DEFAULT_LOCKMETHOD; LOCKMETHODTABLE *lockMethodTable; @@ -1459,7 +1458,7 @@ DumpLocks(void) LOCK_PRINT("DumpLocks: waiting on", proc->waitLock, 0); holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); while (holder) { @@ -1471,7 +1470,7 @@ DumpLocks(void) LOCK_PRINT("DumpLocks", lock, 0); holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink, - offsetof(PROCLOCK, procLink)); + offsetof(PROCLOCK, procLink)); } } @@ -1482,7 +1481,7 @@ void DumpAllLocks(void) { PGPROC *proc; - PROCLOCK *holder; + PROCLOCK *holder; LOCK *lock; int lockmethod = DEFAULT_LOCKMETHOD; LOCKMETHODTABLE *lockMethodTable; diff --git a/src/backend/storage/lmgr/lwlock.c b/src/backend/storage/lmgr/lwlock.c index 10f666aadc..e2559be0e6 100644 --- a/src/backend/storage/lmgr/lwlock.c +++ b/src/backend/storage/lmgr/lwlock.c @@ -15,7 +15,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.12 2002/06/20 20:29:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lwlock.c,v 1.13 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -211,21 +211,21 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) HOLD_INTERRUPTS(); /* - * Loop here to try to acquire lock after each time we are signaled - * by LWLockRelease. + * Loop here to try to acquire lock after each time we are signaled by + * LWLockRelease. * - * NOTE: it might seem better to have LWLockRelease actually grant us - * the lock, rather than retrying and possibly having to go back to - * sleep. But in practice that is no good because it means a process - * swap for every lock acquisition when two or more processes are - * contending for the same lock. Since LWLocks are normally used to - * protect not-very-long sections of computation, a process needs to - * be able to acquire and release the same lock many times during a - * single CPU time slice, even in the presence of contention. The - * efficiency of being able to do that outweighs the inefficiency of - * sometimes wasting a process dispatch cycle because the lock is not - * free when a released waiter finally gets to run. See pgsql-hackers - * archives for 29-Dec-01. + * NOTE: it might seem better to have LWLockRelease actually grant us the + * lock, rather than retrying and possibly having to go back to sleep. + * But in practice that is no good because it means a process swap for + * every lock acquisition when two or more processes are contending + * for the same lock. Since LWLocks are normally used to protect + * not-very-long sections of computation, a process needs to be able + * to acquire and release the same lock many times during a single CPU + * time slice, even in the presence of contention. The efficiency of + * being able to do that outweighs the inefficiency of sometimes + * wasting a process dispatch cycle because the lock is not free when + * a released waiter finally gets to run. See pgsql-hackers archives + * for 29-Dec-01. */ for (;;) { @@ -290,12 +290,12 @@ LWLockAcquire(LWLockId lockid, LWLockMode mode) * * Since we share the process wait semaphore with the regular lock * manager and ProcWaitForSignal, and we may need to acquire an - * LWLock while one of those is pending, it is possible that we get - * awakened for a reason other than being signaled by LWLockRelease. - * If so, loop back and wait again. Once we've gotten the LWLock, - * re-increment the sema by the number of additional signals - * received, so that the lock manager or signal manager will see - * the received signal when it next waits. + * LWLock while one of those is pending, it is possible that we + * get awakened for a reason other than being signaled by + * LWLockRelease. If so, loop back and wait again. Once we've + * gotten the LWLock, re-increment the sema by the number of + * additional signals received, so that the lock manager or signal + * manager will see the received signal when it next waits. */ LOG_LWDEBUG("LWLockAcquire", lockid, "waiting"); @@ -455,9 +455,7 @@ LWLockRelease(LWLockId lockid) { while (proc->lwWaitLink != NULL && !proc->lwWaitLink->lwExclusive) - { proc = proc->lwWaitLink; - } } /* proc is now the last PGPROC to be released */ lock->head = proc->lwWaitLink; diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index c64b865876..5dceb721ab 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.124 2002/07/19 00:17:40 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.125 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -131,11 +131,12 @@ InitProcGlobal(int maxBackends) ProcGlobal->freeProcs = INVALID_OFFSET; /* - * Pre-create the PGPROC structures and create a semaphore for each. + * Pre-create the PGPROC structures and create a semaphore for + * each. */ for (i = 0; i < maxBackends; i++) { - PGPROC *proc; + PGPROC *proc; proc = (PGPROC *) ShmemAlloc(sizeof(PGPROC)); if (!proc) @@ -147,8 +148,9 @@ InitProcGlobal(int maxBackends) } /* - * Pre-allocate a PGPROC structure for dummy (checkpoint) processes, - * too. This does not get linked into the freeProcs list. + * Pre-allocate a PGPROC structure for dummy (checkpoint) + * processes, too. This does not get linked into the freeProcs + * list. */ DummyProc = (PGPROC *) ShmemAlloc(sizeof(PGPROC)); if (!DummyProc) @@ -170,6 +172,7 @@ void InitProcess(void) { SHMEM_OFFSET myOffset; + /* use volatile pointer to prevent code rearrangement */ volatile PROC_HDR *procglobal = ProcGlobal; @@ -184,8 +187,8 @@ InitProcess(void) elog(ERROR, "InitProcess: you already exist"); /* - * Try to get a proc struct from the free list. If this fails, - * we must be out of PGPROC structures (not to mention semaphores). + * Try to get a proc struct from the free list. If this fails, we + * must be out of PGPROC structures (not to mention semaphores). */ SpinLockAcquire(ProcStructLock); @@ -209,8 +212,8 @@ InitProcess(void) } /* - * Initialize all fields of MyProc, except for the semaphore which - * was prepared for us by InitProcGlobal. + * Initialize all fields of MyProc, except for the semaphore which was + * prepared for us by InitProcGlobal. */ SHMQueueElemInit(&(MyProc->links)); MyProc->errType = STATUS_OK; @@ -638,7 +641,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable, /* * If someone wakes us between LWLockRelease and PGSemaphoreLock, - * PGSemaphoreLock will not block. The wakeup is "saved" by the + * PGSemaphoreLock will not block. The wakeup is "saved" by the * semaphore implementation. Note also that if CheckDeadLock is * invoked but does not detect a deadlock, PGSemaphoreLock() will * continue to wait. There used to be a loop here, but it was useless @@ -930,12 +933,18 @@ bool enable_sig_alarm(int delayms, bool is_statement_timeout) { #ifndef __BEOS__ - struct itimerval timeval, remaining; + struct itimerval timeval, + remaining; + #else - bigtime_t time_interval, remaining; + bigtime_t time_interval, + remaining; #endif - /* Don't set timer if the statement timeout scheduled before next alarm. */ + /* + * Don't set timer if the statement timeout scheduled before next + * alarm. + */ if (alarm_is_statement_timeout && !is_statement_timeout && RemainingStatementTimeout <= delayms) @@ -964,7 +973,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) #ifndef __BEOS__ /* We lose precision here because we convert to milliseconds */ RemainingStatementTimeout = remaining.it_value.tv_sec * 1000 + - remaining.it_value.tv_usec / 1000; + remaining.it_value.tv_usec / 1000; #else RemainingStatementTimeout = remaining / 1000; #endif @@ -983,7 +992,7 @@ enable_sig_alarm(int delayms, bool is_statement_timeout) #ifndef __BEOS__ remaining.it_value.tv_sec = RemainingStatementTimeout / 1000; remaining.it_value.tv_usec = (RemainingStatementTimeout % 1000) * 1000; - if (setitimer(ITIMER_REAL, &remaining, &timeval)) + if (setitimer(ITIMER_REAL, &remaining, &timeval)) return false; else return true; @@ -1020,10 +1029,12 @@ bool disable_sig_alarm(bool is_statement_timeout) { #ifndef __BEOS__ - struct itimerval timeval, remaining; + struct itimerval timeval, + remaining; + MemSet(&timeval, 0, sizeof(struct itimerval)); #else - bigtime_t time_interval = 0; + bigtime_t time_interval = 0; #endif if (!is_statement_timeout && RemainingStatementTimeout) @@ -1034,7 +1045,7 @@ disable_sig_alarm(bool is_statement_timeout) return false; /* Add remaining time back because the timer didn't complete */ RemainingStatementTimeout += remaining.it_value.tv_sec * 1000 + - remaining.it_value.tv_usec / 1000; + remaining.it_value.tv_usec / 1000; /* Prepare to set timer */ timeval.it_value.tv_sec = RemainingStatementTimeout / 1000; timeval.it_value.tv_usec = (RemainingStatementTimeout % 1000) * 1000; @@ -1048,9 +1059,10 @@ disable_sig_alarm(bool is_statement_timeout) /* Restore remaining statement timeout value */ alarm_is_statement_timeout = true; } + /* - * Optimization: is_statement_timeout && RemainingStatementTimeout == 0 - * does nothing. This is for cases where no timeout was set. + * Optimization: is_statement_timeout && RemainingStatementTimeout == + * 0 does nothing. This is for cases where no timeout was set. */ if (!is_statement_timeout || RemainingStatementTimeout) { @@ -1097,4 +1109,3 @@ handle_sig_alarm(SIGNAL_ARGS) disable_sig_alarm(false); } } - diff --git a/src/backend/storage/lmgr/spin.c b/src/backend/storage/lmgr/spin.c index ae199597a6..d7963b7755 100644 --- a/src/backend/storage/lmgr/spin.c +++ b/src/backend/storage/lmgr/spin.c @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.9 2002/06/20 20:29:35 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/lmgr/spin.c,v 1.10 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,11 +52,11 @@ int SpinlockSemas(void) { /* - * It would be cleaner to distribute this logic into the affected modules, - * similar to the way shmem space estimation is handled. + * It would be cleaner to distribute this logic into the affected + * modules, similar to the way shmem space estimation is handled. * - * For now, though, we just need a few spinlocks (10 should be - * plenty) plus one for each LWLock. + * For now, though, we just need a few spinlocks (10 should be plenty) + * plus one for each LWLock. */ return NumLWLocks() + 10; } diff --git a/src/backend/storage/page/bufpage.c b/src/backend/storage/page/bufpage.c index 5f263205f1..83e0c33722 100644 --- a/src/backend/storage/page/bufpage.c +++ b/src/backend/storage/page/bufpage.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.49 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/page/bufpage.c,v 1.50 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -117,7 +117,7 @@ PageAddItem(Page page, else { if (offsetNumber < limit) - needshuffle = true; /* need to move existing linp's */ + needshuffle = true; /* need to move existing linp's */ } } else @@ -378,8 +378,8 @@ PageGetFreeSpace(Page page) int space; /* - * Use signed arithmetic here so that we behave sensibly if - * pd_lower > pd_upper. + * Use signed arithmetic here so that we behave sensibly if pd_lower > + * pd_upper. */ space = (int) ((PageHeader) page)->pd_upper - (int) ((PageHeader) page)->pd_lower; @@ -440,9 +440,9 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) /* * First, we want to get rid of the pd_linp entry for the index tuple. - * We copy all subsequent linp's back one slot in the array. - * We don't use PageGetItemId, because we are manipulating the _array_, - * not individual linp's. + * We copy all subsequent linp's back one slot in the array. We don't + * use PageGetItemId, because we are manipulating the _array_, not + * individual linp's. */ nbytes = phdr->pd_lower - ((char *) &phdr->pd_linp[offidx + 1] - (char *) phdr); @@ -480,7 +480,7 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum) if (!PageIsEmpty(page)) { nline--; /* there's one less than when we started */ - for (i = nline; --i >= 0; ) + for (i = nline; --i >= 0;) { if (PageGetItemId(phdr, i + 1)->lp_off <= offset) PageGetItemId(phdr, i + 1)->lp_off += size; diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c index dab9b5dcbb..8b05fdf11b 100644 --- a/src/backend/storage/smgr/smgr.c +++ b/src/backend/storage/smgr/smgr.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.59 2002/08/15 16:36:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/storage/smgr/smgr.c,v 1.60 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -66,7 +66,7 @@ static f_smgr smgrsw[] = { /* main memory */ {mminit, mmshutdown, mmcreate, mmunlink, mmextend, mmopen, mmclose, mmread, mmwrite, mmblindwrt, - mmnblocks, NULL, mmcommit, mmabort, NULL}, + mmnblocks, NULL, mmcommit, mmabort, NULL}, #endif }; diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index a1acc24297..01d810088c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.290 2002/09/02 05:25:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.291 2002/09/04 20:31:26 momjian Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -69,12 +69,13 @@ extern int optind; extern char *optarg; -char *debug_query_string; /* for pgmonitor and log_min_error_statement*/ +char *debug_query_string; /* for pgmonitor and + * log_min_error_statement */ /* Note: whereToSendOutput is initialized for the bootstrap/standalone case */ CommandDest whereToSendOutput = Debug; -extern int StatementTimeout; +extern int StatementTimeout; static bool dontExecute = false; @@ -551,7 +552,7 @@ pg_plan_query(Query *querytree) */ void -pg_exec_query_string(StringInfo query_string, /* string to execute */ +pg_exec_query_string(StringInfo query_string, /* string to execute */ CommandDest dest, /* where results should go */ MemoryContext parse_context) /* context for * parsetrees */ @@ -561,14 +562,15 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ List *parsetree_list, *parsetree_item; struct timezone tz; - struct timeval start_t, stop_t; + struct timeval start_t, + stop_t; bool save_Log_duration = Log_duration; debug_query_string = query_string->data; /* - * We use save_Log_duration so setting Log_duration to true doesn't - * report incorrect time because gettimeofday() wasn't called. + * We use save_Log_duration so setting Log_duration to true doesn't + * report incorrect time because gettimeofday() wasn't called. */ if (save_Log_duration) gettimeofday(&start_t, &tz); @@ -627,9 +629,9 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ isTransactionStmt = IsA(parsetree, TransactionStmt); /* - * First we set the command-completion tag to the main query - * (as opposed to each of the others that may be generated by - * analyze and rewrite). Also set ps_status and do any special + * First we set the command-completion tag to the main query (as + * opposed to each of the others that may be generated by analyze + * and rewrite). Also set ps_status and do any special * start-of-SQL-command processing needed by the destination. */ commandTag = CreateCommandTag(parsetree); @@ -807,15 +809,16 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ finish_xact_command(); xact_started = false; } - } /* end loop over queries generated from a parsetree */ + } /* end loop over queries generated from a + * parsetree */ /* * If this is the last parsetree of the query string, close down - * transaction statement before reporting command-complete. This is - * so that any end-of-transaction errors are reported before the - * command-complete message is issued, to avoid confusing clients - * who will expect either a command-complete message or an error, - * not one and then the other. But for compatibility with + * transaction statement before reporting command-complete. This + * is so that any end-of-transaction errors are reported before + * the command-complete message is issued, to avoid confusing + * clients who will expect either a command-complete message or an + * error, not one and then the other. But for compatibility with * historical Postgres behavior, we do not force a transaction * boundary between queries appearing in a single query string. */ @@ -826,12 +829,11 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ } /* - * It is possible that the original query was removed due to - * a DO INSTEAD rewrite rule. In that case we will still have - * the default completion tag, which is fine for most purposes, - * but it may confuse clients if it's INSERT/UPDATE/DELETE. - * Clients expect those tags to have counts after them (cf. - * ProcessQuery). + * It is possible that the original query was removed due to a DO + * INSTEAD rewrite rule. In that case we will still have the + * default completion tag, which is fine for most purposes, but it + * may confuse clients if it's INSERT/UPDATE/DELETE. Clients + * expect those tags to have counts after them (cf. ProcessQuery). */ if (strcmp(commandTag, "INSERT") == 0) commandTag = "INSERT 0 0"; @@ -842,10 +844,10 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ /* * Tell client that we're done with this query. Note we emit - * exactly one EndCommand report for each raw parsetree, thus - * one for each SQL command the client sent, regardless of - * rewriting. (But a command aborted by error will not send - * an EndCommand report at all.) + * exactly one EndCommand report for each raw parsetree, thus one + * for each SQL command the client sent, regardless of rewriting. + * (But a command aborted by error will not send an EndCommand + * report at all.) */ EndCommand(commandTag, dest); } /* end loop over parsetrees */ @@ -853,8 +855,8 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ disable_sig_alarm(true); /* - * Close down transaction statement, if one is open. - * (Note that this will only happen if the querystring was empty.) + * Close down transaction statement, if one is open. (Note that this + * will only happen if the querystring was empty.) */ if (xact_started) finish_xact_command(); @@ -868,8 +870,8 @@ pg_exec_query_string(StringInfo query_string, /* string to execute */ stop_t.tv_usec += 1000000; } elog(LOG, "duration: %ld.%06ld sec", - (long int) stop_t.tv_sec - start_t.tv_sec, - (long int) stop_t.tv_usec - start_t.tv_usec); + (long int) stop_t.tv_sec - start_t.tv_sec, + (long int) stop_t.tv_usec - start_t.tv_usec); } debug_query_string = NULL; @@ -1165,9 +1167,7 @@ PostgresMain(int argc, char *argv[], const char *username) * If we are running under the postmaster, this is done already. */ if (!IsUnderPostmaster) - { MemoryContextInit(); - } set_ps_display("startup"); @@ -1244,14 +1244,16 @@ PostgresMain(int argc, char *argv[], const char *username) /* Set server debugging level. */ if (atoi(optarg) != 0) { - char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); + char *debugstr = palloc(strlen("debug") + strlen(optarg) + 1); sprintf(debugstr, "debug%s", optarg); SetConfigOption("server_min_messages", debugstr, ctx, gucsource); pfree(debugstr); + /* - * -d is not the same as setting client_min_messages - * because it enables other output options. + * -d is not the same as setting + * client_min_messages because it enables other + * output options. */ if (atoi(optarg) >= 1) SetConfigOption("log_connections", "true", ctx, gucsource); @@ -1265,9 +1267,10 @@ PostgresMain(int argc, char *argv[], const char *username) SetConfigOption("debug_print_rewritten", "true", ctx, gucsource); } else + /* - * -d 0 allows user to prevent postmaster debug from - * propagating to backend. + * -d 0 allows user to prevent postmaster debug + * from propagating to backend. */ SetConfigOption("server_min_messages", "notice", ctx, gucsource); @@ -1543,17 +1546,17 @@ PostgresMain(int argc, char *argv[], const char *username) * Also note: it's best not to use any signals that are SIG_IGNored in * the postmaster. If such a signal arrives before we are able to * change the handler to non-SIG_IGN, it'll get dropped. Instead, - * make a dummy handler in the postmaster to reserve the signal. - * (Of course, this isn't an issue for signals that are locally generated, + * make a dummy handler in the postmaster to reserve the signal. (Of + * course, this isn't an issue for signals that are locally generated, * such as SIGALRM and SIGPIPE.) */ pqsignal(SIGHUP, SigHupHandler); /* set flag to read config file */ - pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */ + pqsignal(SIGINT, StatementCancelHandler); /* cancel current query */ pqsignal(SIGTERM, die); /* cancel current query and exit */ pqsignal(SIGQUIT, quickdie); /* hard crash time */ - pqsignal(SIGALRM, handle_sig_alarm); /* check for deadlock after - * timeout */ + pqsignal(SIGALRM, handle_sig_alarm); /* check for deadlock + * after timeout */ /* * Ignore failure to write to frontend. Note: if frontend closes @@ -1686,7 +1689,7 @@ PostgresMain(int argc, char *argv[], const char *username) if (!IsUnderPostmaster) { puts("\nPOSTGRES backend interactive interface "); - puts("$Revision: 1.290 $ $Date: 2002/09/02 05:25:37 $\n"); + puts("$Revision: 1.291 $ $Date: 2002/09/04 20:31:26 $\n"); } /* @@ -1873,9 +1876,10 @@ PostgresMain(int argc, char *argv[], const char *username) if (HandleFunctionRequest() == EOF) { /* lost frontend connection during F message input */ + /* - * Reset whereToSendOutput to prevent elog from attempting - * to send any more messages to client. + * Reset whereToSendOutput to prevent elog from + * attempting to send any more messages to client. */ if (whereToSendOutput == Remote) whereToSendOutput = None; @@ -1924,12 +1928,13 @@ PostgresMain(int argc, char *argv[], const char *username) break; /* - * 'X' means that the frontend is closing down the socket. - * EOF means unexpected loss of frontend connection. - * Either way, perform normal shutdown. + * 'X' means that the frontend is closing down the socket. + * EOF means unexpected loss of frontend connection. + * Either way, perform normal shutdown. */ case 'X': case EOF: + /* * Reset whereToSendOutput to prevent elog from attempting * to send any more messages to client. @@ -1995,7 +2000,7 @@ ShowUsage(const char *title) struct timeval elapse_t; struct timezone tz; struct rusage r; - char *bufusage; + char *bufusage; getrusage(RUSAGE_SELF, &r); gettimeofday(&elapse_t, &tz); @@ -2030,45 +2035,45 @@ ShowUsage(const char *title) appendStringInfo(&str, "! system usage stats:\n"); appendStringInfo(&str, "!\t%ld.%06ld elapsed %ld.%06ld user %ld.%06ld system sec\n", - (long int) elapse_t.tv_sec - Save_t.tv_sec, - (long int) elapse_t.tv_usec - Save_t.tv_usec, - (long int) r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec, - (long int) r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec, - (long int) r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec, - (long int) r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec); + (long int) elapse_t.tv_sec - Save_t.tv_sec, + (long int) elapse_t.tv_usec - Save_t.tv_usec, + (long int) r.ru_utime.tv_sec - Save_r.ru_utime.tv_sec, + (long int) r.ru_utime.tv_usec - Save_r.ru_utime.tv_usec, + (long int) r.ru_stime.tv_sec - Save_r.ru_stime.tv_sec, + (long int) r.ru_stime.tv_usec - Save_r.ru_stime.tv_usec); appendStringInfo(&str, - "!\t[%ld.%06ld user %ld.%06ld sys total]\n", - (long int) user.tv_sec, - (long int) user.tv_usec, - (long int) sys.tv_sec, - (long int) sys.tv_usec); + "!\t[%ld.%06ld user %ld.%06ld sys total]\n", + (long int) user.tv_sec, + (long int) user.tv_usec, + (long int) sys.tv_sec, + (long int) sys.tv_usec); /* BeOS has rusage but only has some fields, and not these... */ #if defined(HAVE_GETRUSAGE) appendStringInfo(&str, - "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n", - r.ru_inblock - Save_r.ru_inblock, + "!\t%ld/%ld [%ld/%ld] filesystem blocks in/out\n", + r.ru_inblock - Save_r.ru_inblock, /* they only drink coffee at dec */ - r.ru_oublock - Save_r.ru_oublock, - r.ru_inblock, r.ru_oublock); + r.ru_oublock - Save_r.ru_oublock, + r.ru_inblock, r.ru_oublock); appendStringInfo(&str, "!\t%ld/%ld [%ld/%ld] page faults/reclaims, %ld [%ld] swaps\n", - r.ru_majflt - Save_r.ru_majflt, - r.ru_minflt - Save_r.ru_minflt, - r.ru_majflt, r.ru_minflt, - r.ru_nswap - Save_r.ru_nswap, - r.ru_nswap); + r.ru_majflt - Save_r.ru_majflt, + r.ru_minflt - Save_r.ru_minflt, + r.ru_majflt, r.ru_minflt, + r.ru_nswap - Save_r.ru_nswap, + r.ru_nswap); appendStringInfo(&str, "!\t%ld [%ld] signals rcvd, %ld/%ld [%ld/%ld] messages rcvd/sent\n", - r.ru_nsignals - Save_r.ru_nsignals, - r.ru_nsignals, - r.ru_msgrcv - Save_r.ru_msgrcv, - r.ru_msgsnd - Save_r.ru_msgsnd, - r.ru_msgrcv, r.ru_msgsnd); + r.ru_nsignals - Save_r.ru_nsignals, + r.ru_nsignals, + r.ru_msgrcv - Save_r.ru_msgrcv, + r.ru_msgsnd - Save_r.ru_msgsnd, + r.ru_msgrcv, r.ru_msgsnd); appendStringInfo(&str, "!\t%ld/%ld [%ld/%ld] voluntary/involuntary context switches\n", - r.ru_nvcsw - Save_r.ru_nvcsw, - r.ru_nivcsw - Save_r.ru_nivcsw, - r.ru_nvcsw, r.ru_nivcsw); + r.ru_nvcsw - Save_r.ru_nvcsw, + r.ru_nivcsw - Save_r.ru_nivcsw, + r.ru_nvcsw, r.ru_nivcsw); #endif /* HAVE_GETRUSAGE */ bufusage = ShowBufferUsage(); @@ -2076,7 +2081,7 @@ ShowUsage(const char *title) pfree(bufusage); /* remove trailing newline */ - if (str.data[str.len-1] == '\n') + if (str.data[str.len - 1] == '\n') str.data[--str.len] = '\0'; elog(LOG, "%s\n%s", title, str.data); @@ -2094,7 +2099,7 @@ ShowUsage(const char *title) static const char * CreateCommandTag(Node *parsetree) { - const char *tag; + const char *tag; switch (nodeTag(parsetree)) { @@ -2150,6 +2155,7 @@ CreateCommandTag(Node *parsetree) case T_FetchStmt: { FetchStmt *stmt = (FetchStmt *) parsetree; + tag = (stmt->ismove) ? "MOVE" : "FETCH"; } break; @@ -2211,7 +2217,7 @@ CreateCommandTag(Node *parsetree) break; case T_RenameStmt: - if (((RenameStmt *)parsetree)->renameType == RENAME_TRIGGER) + if (((RenameStmt *) parsetree)->renameType == RENAME_TRIGGER) tag = "ALTER TRIGGER"; else tag = "ALTER TABLE"; @@ -2224,6 +2230,7 @@ CreateCommandTag(Node *parsetree) case T_GrantStmt: { GrantStmt *stmt = (GrantStmt *) parsetree; + tag = (stmt->is_grant) ? "GRANT" : "REVOKE"; } break; diff --git a/src/backend/tcop/pquery.c b/src/backend/tcop/pquery.c index fb1ff76dff..29909295f5 100644 --- a/src/backend/tcop/pquery.c +++ b/src/backend/tcop/pquery.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.54 2002/06/20 20:29:36 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/pquery.c,v 1.55 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,7 +39,7 @@ CreateQueryDesc(Query *parsetree, qd->parsetree = parsetree; /* parse tree */ qd->plantree = plantree; /* plan */ qd->dest = dest; /* output dest */ - qd->portalName = portalName; /* name, if dest is a portal */ + qd->portalName = portalName; /* name, if dest is a portal */ qd->tupDesc = NULL; /* until set by ExecutorStart */ return qd; @@ -168,8 +168,8 @@ ProcessQuery(Query *parsetree, * SELECT INTO table (a/k/a CREATE AS ... SELECT). * * Override the normal communication destination; execMain.c - * special-cases this case. (Perhaps would be cleaner to - * have an additional destination type?) + * special-cases this case. (Perhaps would be cleaner to have + * an additional destination type?) */ dest = None; } @@ -186,7 +186,8 @@ ProcessQuery(Query *parsetree, oldContext = MemoryContextSwitchTo(PortalGetHeapMemory(portal)); parsetree = copyObject(parsetree); plan = copyObject(plan); - intoName = parsetree->into->relname; /* use copied name in QueryDesc */ + intoName = parsetree->into->relname; /* use copied name in + * QueryDesc */ /* * We stay in portal's memory context for now, so that query desc, @@ -225,7 +226,7 @@ ProcessQuery(Query *parsetree, /* Now we can return to caller's memory context. */ MemoryContextSwitchTo(oldContext); - /* Set completion tag. SQL calls this operation DECLARE CURSOR */ + /* Set completion tag. SQL calls this operation DECLARE CURSOR */ if (completionTag) strcpy(completionTag, "DECLARE CURSOR"); @@ -243,7 +244,7 @@ ProcessQuery(Query *parsetree, */ if (completionTag) { - Oid lastOid; + Oid lastOid; switch (operation) { diff --git a/src/backend/tcop/utility.c b/src/backend/tcop/utility.c index 40dec9d68b..92d876b265 100644 --- a/src/backend/tcop/utility.c +++ b/src/backend/tcop/utility.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.176 2002/09/02 02:13:01 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/tcop/utility.c,v 1.177 2002/09/04 20:31:26 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -207,17 +207,19 @@ ProcessUtility(Node *parsetree, BeginTransactionBlock(); break; - /* - * START TRANSACTION, as defined by SQL99: Identical to BEGIN, - * except that it takes a few additional options. - */ + /* + * START TRANSACTION, as defined by SQL99: + * Identical to BEGIN, except that it takes a few + * additional options. + */ case START: { BeginTransactionBlock(); /* - * Currently, the only option that can be set by - * START TRANSACTION is the isolation level. + * Currently, the only option that can be set + * by START TRANSACTION is the isolation + * level. */ if (stmt->options) { @@ -285,8 +287,8 @@ ProcessUtility(Node *parsetree, RELKIND_RELATION); /* - * Let AlterTableCreateToastTable decide if this one needs a - * secondary relation too. + * Let AlterTableCreateToastTable decide if this one needs + * a secondary relation too. */ CommandCounterIncrement(); AlterTableCreateToastTable(relOid, true); @@ -300,7 +302,7 @@ ProcessUtility(Node *parsetree, foreach(arg, stmt->objects) { - List *names = (List *) lfirst(arg); + List *names = (List *) lfirst(arg); RangeVar *rel; switch (stmt->removeType) @@ -335,7 +337,11 @@ ProcessUtility(Node *parsetree, break; case DROP_DOMAIN: - /* RemoveDomain does its own permissions checks */ + + /* + * RemoveDomain does its own permissions + * checks + */ RemoveDomain(names, stmt->behavior); break; @@ -344,7 +350,11 @@ ProcessUtility(Node *parsetree, break; case DROP_SCHEMA: - /* RemoveSchema does its own permissions checks */ + + /* + * RemoveSchema does its own permissions + * checks + */ RemoveSchema(names, stmt->behavior); break; } @@ -359,7 +369,7 @@ ProcessUtility(Node *parsetree, case T_TruncateStmt: { - TruncateStmt *stmt = (TruncateStmt *) parsetree; + TruncateStmt *stmt = (TruncateStmt *) parsetree; TruncateRelation(stmt->relation); } @@ -398,7 +408,7 @@ ProcessUtility(Node *parsetree, case T_RenameStmt: { RenameStmt *stmt = (RenameStmt *) parsetree; - Oid relid; + Oid relid; CheckOwnership(stmt->relation, true); @@ -407,44 +417,44 @@ ProcessUtility(Node *parsetree, switch (stmt->renameType) { case RENAME_TABLE: - { - /* - * RENAME TABLE requires that we (still) hold CREATE - * rights on the containing namespace, as well as - * ownership of the table. - */ - Oid namespaceId = get_rel_namespace(relid); - AclResult aclresult; + { + /* + * RENAME TABLE requires that we (still) hold + * CREATE rights on the containing namespace, + * as well as ownership of the table. + */ + Oid namespaceId = get_rel_namespace(relid); + AclResult aclresult; - aclresult = pg_namespace_aclcheck(namespaceId, - GetUserId(), - ACL_CREATE); - if (aclresult != ACLCHECK_OK) - aclcheck_error(aclresult, - get_namespace_name(namespaceId)); + aclresult = pg_namespace_aclcheck(namespaceId, + GetUserId(), + ACL_CREATE); + if (aclresult != ACLCHECK_OK) + aclcheck_error(aclresult, + get_namespace_name(namespaceId)); - renamerel(relid, stmt->newname); - break; - } + renamerel(relid, stmt->newname); + break; + } case RENAME_COLUMN: renameatt(relid, - stmt->oldname, /* old att name */ - stmt->newname, /* new att name */ - interpretInhOption(stmt->relation->inhOpt), /* recursive? */ - false); /* recursing already? */ + stmt->oldname, /* old att name */ + stmt->newname, /* new att name */ + interpretInhOption(stmt->relation->inhOpt), /* recursive? */ + false); /* recursing already? */ break; case RENAME_TRIGGER: renametrig(relid, - stmt->oldname, /* old att name */ - stmt->newname); /* new att name */ + stmt->oldname, /* old att name */ + stmt->newname); /* new att name */ break; case RENAME_RULE: elog(ERROR, "ProcessUtility: Invalid target for RENAME: %d", - stmt->renameType); + stmt->renameType); break; default: elog(ERROR, "ProcessUtility: Invalid target for RENAME: %d", - stmt->renameType); + stmt->renameType); } } break; @@ -454,7 +464,7 @@ ProcessUtility(Node *parsetree, case T_AlterTableStmt: { AlterTableStmt *stmt = (AlterTableStmt *) parsetree; - Oid relid; + Oid relid; relid = RangeVarGetRelid(stmt->relation, false); @@ -465,74 +475,80 @@ ProcessUtility(Node *parsetree, switch (stmt->subtype) { case 'A': /* ADD COLUMN */ + /* - * Recursively add column to table and, - * if requested, to descendants + * Recursively add column to table and, if + * requested, to descendants */ AlterTableAddColumn(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), false, (ColumnDef *) stmt->def); break; case 'T': /* ALTER COLUMN DEFAULT */ + /* * Recursively alter column default for table and, * if requested, for descendants */ AlterTableAlterColumnDefault(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), stmt->name, stmt->def); break; case 'N': /* ALTER COLUMN DROP NOT NULL */ AlterTableAlterColumnDropNotNull(relid, - interpretInhOption(stmt->relation->inhOpt), - stmt->name); + interpretInhOption(stmt->relation->inhOpt), + stmt->name); break; case 'O': /* ALTER COLUMN SET NOT NULL */ AlterTableAlterColumnSetNotNull(relid, - interpretInhOption(stmt->relation->inhOpt), - stmt->name); + interpretInhOption(stmt->relation->inhOpt), + stmt->name); break; case 'S': /* ALTER COLUMN STATISTICS */ - case 'M': /* ALTER COLUMN STORAGE */ + case 'M': /* ALTER COLUMN STORAGE */ + /* - * Recursively alter column statistics for table and, - * if requested, for descendants + * Recursively alter column statistics for table + * and, if requested, for descendants */ AlterTableAlterColumnFlags(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), stmt->name, stmt->def, &(stmt->subtype)); break; case 'D': /* DROP COLUMN */ - /* - * Recursively drop column from table and, - * if requested, from descendants + + /* + * Recursively drop column from table and, if + * requested, from descendants */ AlterTableDropColumn(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), false, stmt->name, stmt->behavior); break; case 'C': /* ADD CONSTRAINT */ + /* - * Recursively add constraint to table and, - * if requested, to descendants + * Recursively add constraint to table and, if + * requested, to descendants */ AlterTableAddConstraint(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), (List *) stmt->def); break; case 'X': /* DROP CONSTRAINT */ + /* - * Recursively drop constraint from table and, - * if requested, from descendants + * Recursively drop constraint from table and, if + * requested, from descendants */ AlterTableDropConstraint(relid, - interpretInhOption(stmt->relation->inhOpt), + interpretInhOption(stmt->relation->inhOpt), stmt->name, stmt->behavior); break; @@ -585,7 +601,7 @@ ProcessUtility(Node *parsetree, case T_CompositeTypeStmt: /* CREATE TYPE (composite) */ { - CompositeTypeStmt *stmt = (CompositeTypeStmt *) parsetree; + CompositeTypeStmt *stmt = (CompositeTypeStmt *) parsetree; DefineCompositeType(stmt->typevar, stmt->coldeflist); } @@ -599,7 +615,7 @@ ProcessUtility(Node *parsetree, } break; - case T_CreateFunctionStmt: /* CREATE FUNCTION */ + case T_CreateFunctionStmt: /* CREATE FUNCTION */ CreateFunction((CreateFunctionStmt *) parsetree); break; @@ -609,10 +625,10 @@ ProcessUtility(Node *parsetree, CheckOwnership(stmt->relation, true); - DefineIndex(stmt->relation, /* relation */ - stmt->idxname, /* index name */ - stmt->accessMethod, /* am name */ - stmt->indexParams, /* parameters */ + DefineIndex(stmt->relation, /* relation */ + stmt->idxname, /* index name */ + stmt->accessMethod, /* am name */ + stmt->indexParams, /* parameters */ stmt->unique, stmt->primary, stmt->isconstraint, @@ -740,7 +756,7 @@ ProcessUtility(Node *parsetree, case T_DropPropertyStmt: { DropPropertyStmt *stmt = (DropPropertyStmt *) parsetree; - Oid relId; + Oid relId; relId = RangeVarGetRelid(stmt->relation, false); diff --git a/src/backend/utils/adt/acl.c b/src/backend/utils/adt/acl.c index aa65bd650b..02d2e6746b 100644 --- a/src/backend/utils/adt/acl.c +++ b/src/backend/utils/adt/acl.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.78 2002/09/03 22:17:35 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/acl.c,v 1.79 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -36,15 +36,15 @@ static const char *aclparse(const char *s, AclItem *aip, unsigned *modechg); static bool aclitemeq(const AclItem *a1, const AclItem *a2); static bool aclitemgt(const AclItem *a1, const AclItem *a2); -static Oid convert_table_name(text *tablename); +static Oid convert_table_name(text *tablename); static AclMode convert_table_priv_string(text *priv_type_text); -static Oid convert_database_name(text *databasename); +static Oid convert_database_name(text *databasename); static AclMode convert_database_priv_string(text *priv_type_text); -static Oid convert_function_name(text *functionname); +static Oid convert_function_name(text *functionname); static AclMode convert_function_priv_string(text *priv_type_text); -static Oid convert_language_name(text *languagename); +static Oid convert_language_name(text *languagename); static AclMode convert_language_priv_string(text *priv_type_text); -static Oid convert_schema_name(text *schemaname); +static Oid convert_schema_name(text *schemaname); static AclMode convert_schema_priv_string(text *priv_type_text); @@ -413,7 +413,7 @@ acldefault(GrantObjectType objtype, AclId ownerid) owner_default = ACL_ALL_RIGHTS_RELATION; break; case ACL_OBJECT_DATABASE: - world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */ + world_default = ACL_CREATE_TEMP; /* not NO_RIGHTS! */ owner_default = ACL_ALL_RIGHTS_DATABASE; break; case ACL_OBJECT_FUNCTION: @@ -430,7 +430,7 @@ acldefault(GrantObjectType objtype, AclId ownerid) break; default: elog(ERROR, "acldefault: bogus objtype %d", (int) objtype); - world_default = ACL_NO_RIGHTS; /* keep compiler quiet */ + world_default = ACL_NO_RIGHTS; /* keep compiler quiet */ owner_default = ACL_NO_RIGHTS; break; } @@ -819,7 +819,7 @@ convert_table_name(text *tablename) RangeVar *relrv; relrv = makeRangeVarFromNameList(textToQualifiedNameList(tablename, - "has_table_privilege")); + "has_table_privilege")); return RangeVarGetRelid(relrv, false); } @@ -834,7 +834,7 @@ convert_table_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1030,7 +1030,7 @@ convert_database_name(text *databasename) Oid oid; dbname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(databasename))); + PointerGetDatum(databasename))); oid = get_database_oid(dbname); if (!OidIsValid(oid)) @@ -1049,7 +1049,7 @@ convert_database_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1233,10 +1233,10 @@ convert_function_name(text *functionname) Oid oid; funcname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(functionname))); + PointerGetDatum(functionname))); oid = DatumGetObjectId(DirectFunctionCall1(regprocedurein, - CStringGetDatum(funcname))); + CStringGetDatum(funcname))); if (!OidIsValid(oid)) elog(ERROR, "function \"%s\" does not exist", funcname); @@ -1254,7 +1254,7 @@ convert_function_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1432,7 +1432,7 @@ convert_language_name(text *languagename) Oid oid; langname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(languagename))); + PointerGetDatum(languagename))); oid = GetSysCacheOid(LANGNAME, CStringGetDatum(langname), @@ -1453,7 +1453,7 @@ convert_language_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string @@ -1631,7 +1631,7 @@ convert_schema_name(text *schemaname) Oid oid; nspname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(schemaname))); + PointerGetDatum(schemaname))); oid = GetSysCacheOid(NAMESPACENAME, CStringGetDatum(nspname), @@ -1652,7 +1652,7 @@ convert_schema_priv_string(text *priv_type_text) char *priv_type; priv_type = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(priv_type_text))); + PointerGetDatum(priv_type_text))); /* * Return mode from priv_type string diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c index 53a4c83d63..5d53eca999 100644 --- a/src/backend/utils/adt/arrayfuncs.c +++ b/src/backend/utils/adt/arrayfuncs.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.79 2002/08/26 17:53:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/arrayfuncs.c,v 1.80 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -80,27 +80,27 @@ 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 int ArrayCastAndSet(Datum src, - int typlen, bool typbyval, char typalign, - char *dest); -static int array_nelems_size(char *ptr, int nitems, - int typlen, bool typbyval, char typalign); +static int ArrayCastAndSet(Datum src, + int typlen, bool typbyval, char typalign, + char *dest); +static int array_nelems_size(char *ptr, int nitems, + int typlen, bool typbyval, char typalign); static char *array_seek(char *ptr, int nitems, - int typlen, bool typbyval, char typalign); -static int array_copy(char *destptr, int nitems, char *srcptr, - int typlen, bool typbyval, char typalign); + int typlen, bool typbyval, char typalign); +static int array_copy(char *destptr, int nitems, char *srcptr, + int typlen, bool typbyval, char typalign); static int array_slice_size(int ndim, int *dim, int *lb, char *arraydataptr, - int *st, int *endp, - int typlen, bool typbyval, char typalign); + int *st, int *endp, + int typlen, bool typbyval, char typalign); static void array_extract_slice(int ndim, int *dim, int *lb, - char *arraydataptr, - int *st, int *endp, char *destPtr, - int typlen, bool typbyval, char typalign); + char *arraydataptr, + int *st, int *endp, char *destPtr, + int typlen, bool typbyval, char typalign); static void array_insert_slice(int ndim, int *dim, int *lb, - char *origPtr, int origdatasize, - char *destPtr, - int *st, int *endp, char *srcPtr, - int typlen, bool typbyval, char typalign); + char *origPtr, int origdatasize, + char *destPtr, + int *st, int *endp, char *srcPtr, + int typlen, bool typbyval, char typalign); /*--------------------------------------------------------------------- @@ -422,28 +422,28 @@ ReadArrayStr(char *arrayStr, elog(ERROR, "malformed array constant: %s", arrayStr); break; case '\\': - { - char *cptr; - - /* Crunch the string on top of the backslash. */ - for (cptr = ptr; *cptr != '\0'; cptr++) - *cptr = *(cptr + 1); - if (*ptr == '\0') - elog(ERROR, "malformed array constant: %s", arrayStr); - break; - } + { + char *cptr; + + /* Crunch the string on top of the backslash. */ + for (cptr = ptr; *cptr != '\0'; cptr++) + *cptr = *(cptr + 1); + if (*ptr == '\0') + elog(ERROR, "malformed array constant: %s", arrayStr); + break; + } case '\"': - { - char *cptr; - - scanning_string = !scanning_string; - /* Crunch the string on top of the quote. */ - for (cptr = ptr; *cptr != '\0'; cptr++) - *cptr = *(cptr + 1); - /* Back up to not miss following character. */ - ptr--; - break; - } + { + char *cptr; + + scanning_string = !scanning_string; + /* Crunch the string on top of the quote. */ + for (cptr = ptr; *cptr != '\0'; cptr++) + *cptr = *(cptr + 1); + /* Back up to not miss following character. */ + ptr--; + break; + } case '{': if (!scanning_string) { @@ -452,9 +452,9 @@ ReadArrayStr(char *arrayStr, nest_level++; indx[nest_level - 1] = 0; /* skip leading whitespace */ - while (isspace((unsigned char) *(ptr+1))) + while (isspace((unsigned char) *(ptr + 1))) ptr++; - itemstart = ptr+1; + itemstart = ptr + 1; } break; case '}': @@ -471,11 +471,11 @@ ReadArrayStr(char *arrayStr, else { /* - * tricky coding: terminate item value string at - * first '}', but don't process it till we see - * a typdelim char or end of array. This handles - * case where several '}'s appear successively - * in a multidimensional array. + * tricky coding: terminate item value string + * at first '}', but don't process it till we + * see a typdelim char or end of array. This + * handles case where several '}'s appear + * successively in a multidimensional array. */ *ptr = '\0'; indx[nest_level - 1]++; @@ -641,8 +641,8 @@ array_out(PG_FUNCTION_ARGS) /* * Convert all values to string form, count total space needed - * (including any overhead such as escaping backslashes), - * and detect whether each item needs double quotes. + * (including any overhead such as escaping backslashes), and detect + * whether each item needs double quotes. */ values = (char **) palloc(nitems * sizeof(char *)); needquotes = (bool *) palloc(nitems * sizeof(bool)); @@ -665,7 +665,7 @@ array_out(PG_FUNCTION_ARGS) nq = (values[i][0] == '\0'); /* force quotes for empty string */ for (tmp = values[i]; *tmp; tmp++) { - char ch = *tmp; + char ch = *tmp; overall_length += 1; if (ch == '"' || ch == '\\') @@ -716,7 +716,7 @@ array_out(PG_FUNCTION_ARGS) #ifndef TCL_ARRAYS for (tmp = values[k]; *tmp; tmp++) { - char ch = *tmp; + char ch = *tmp; if (ch == '"' || ch == '\\') *p++ = '\\'; @@ -919,8 +919,8 @@ array_get_slice(ArrayType *array, elog(ERROR, "Slices of fixed-length arrays not implemented"); /* - * fixed-length arrays -- these are assumed to be 1-d, 0-based - * XXX where would we get the correct ELEMTYPE from? + * fixed-length arrays -- these are assumed to be 1-d, 0-based XXX + * where would we get the correct ELEMTYPE from? */ ndim = 1; fixedDim[0] = arraylen / elmlen; @@ -980,8 +980,9 @@ array_get_slice(ArrayType *array, newarray->flags = 0; newarray->elemtype = ARR_ELEMTYPE(array); memcpy(ARR_DIMS(newarray), span, ndim * sizeof(int)); + /* - * Lower bounds of the new array are set to 1. Formerly (before 7.3) + * Lower bounds of the new array are set to 1. Formerly (before 7.3) * we copied the given lowerIndx values ... but that seems confusing. */ newlb = ARR_LBOUND(newarray); @@ -1513,9 +1514,7 @@ construct_array(Datum *elems, int nelems, /* compute required space */ if (elmlen > 0) - { nbytes = nelems * att_align(elmlen, elmalign); - } else { Assert(!elmbyval); diff --git a/src/backend/utils/adt/cash.c b/src/backend/utils/adt/cash.c index 3664a6053f..c33bca654e 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.55 2002/09/03 21:45:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/cash.c,v 1.56 2002/09/04 20:31:27 momjian Exp $ */ #include "postgres.h" @@ -662,8 +662,8 @@ cash_words(PG_FUNCTION_ARGS) m0 = val % 100; /* cents */ m1 = (val / 100) % 1000; /* hundreds */ - m2 = (val / 100000) % 1000; /* thousands */ - m3 = val / 100000000 % 1000; /* millions */ + m2 = (val / 100000) % 1000; /* thousands */ + m3 = val / 100000000 % 1000; /* millions */ if (m3) { diff --git a/src/backend/utils/adt/date.c b/src/backend/utils/adt/date.c index f02dee4dd8..733b8fb304 100644 --- a/src/backend/utils/adt/date.c +++ b/src/backend/utils/adt/date.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.71 2002/09/03 19:41:28 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/date.c,v 1.72 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -28,10 +28,10 @@ #include "utils/timestamp.h" -int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec); -int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp); -int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result); -int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result); +int time2tm(TimeADT time, struct tm * tm, fsec_t *fsec); +int timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp); +int tm2time(struct tm * tm, fsec_t fsec, TimeADT *result); +int tm2timetz(struct tm * tm, fsec_t fsec, int tz, TimeTzADT *result); static void AdjustTimeForTypmod(TimeADT *time, int32 typmod); /***************************************************************************** @@ -343,7 +343,7 @@ date_timestamptz(PG_FUNCTION_ARGS) if (IS_VALID_UTIME(tm->tm_year, tm->tm_mon, tm->tm_mday)) { - int tz; + int tz; tm->tm_hour = 0; tm->tm_min = 0; @@ -494,6 +494,7 @@ Datum time_in(PG_FUNCTION_ARGS) { char *str = PG_GETARG_CSTRING(0); + #ifdef NOT_USED Oid typelem = PG_GETARG_OID(1); #endif @@ -529,7 +530,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result) { #ifdef HAVE_INT64_TIMESTAMP *result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec) - * INT64CONST(1000000)) + fsec); + * INT64CONST(1000000)) + fsec); #else *result = ((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec + fsec); #endif @@ -542,7 +543,7 @@ tm2time(struct tm * tm, fsec_t fsec, TimeADT *result) * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 */ int -time2tm(TimeADT time, struct tm *tm, fsec_t *fsec) +time2tm(TimeADT time, struct tm * tm, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP tm->tm_hour = (time / INT64CONST(3600000000)); @@ -610,7 +611,7 @@ static void AdjustTimeForTypmod(TimeADT *time, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP - static const int64 TimeScales[MAX_TIMESTAMP_PRECISION+1] = { + static const int64 TimeScales[MAX_TIMESTAMP_PRECISION + 1] = { INT64CONST(1000000), INT64CONST(100000), INT64CONST(10000), @@ -620,7 +621,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) INT64CONST(1) }; - static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = { + static const int64 TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = { INT64CONST(-500000), INT64CONST(-50000), INT64CONST(-5000), @@ -629,8 +630,9 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) INT64CONST(-5), INT64CONST(0) }; + #else - static const double TimeScales[MAX_TIMESTAMP_PRECISION+1] = { + static const double TimeScales[MAX_TIMESTAMP_PRECISION + 1] = { 1, 10, 100, @@ -640,7 +642,7 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) 1000000 }; - static const double TimeOffsets[MAX_TIMESTAMP_PRECISION+1] = { + static const double TimeOffsets[MAX_TIMESTAMP_PRECISION + 1] = { 0.5, 0.05, 0.005, @@ -674,7 +676,10 @@ AdjustTimeForTypmod(TimeADT *time, int32 typmod) } else { - /* Scale and truncate first, then add to help the rounding behavior */ + /* + * Scale and truncate first, then add to help the rounding + * behavior + */ *time = (rint((((double) *time) * TimeScales[typmod]) + TimeOffsets[typmod]) / TimeScales[typmod]); } @@ -915,8 +920,10 @@ timestamp_time(PG_FUNCTION_ARGS) elog(ERROR, "Unable to convert timestamp to time"); #ifdef HAVE_INT64_TIMESTAMP - /* Could also do this with - * time = (timestamp / 86400000000 * 86400000000) - timestamp; + + /* + * Could also do this with time = (timestamp / 86400000000 * + * 86400000000) - timestamp; */ result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec) * INT64CONST(1000000)) + fsec); @@ -948,8 +955,10 @@ timestamptz_time(PG_FUNCTION_ARGS) elog(ERROR, "Unable to convert timestamptz to time"); #ifdef HAVE_INT64_TIMESTAMP - /* Could also do this with - * time = (timestamp / 86400000000 * 86400000000) - timestamp; + + /* + * Could also do this with time = (timestamp / 86400000000 * + * 86400000000) - timestamp; */ result = ((((((tm->tm_hour * 60) + tm->tm_min) * 60) + tm->tm_sec) * INT64CONST(1000000)) + fsec); @@ -1349,7 +1358,7 @@ timetz_out(PG_FUNCTION_ARGS) * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 */ int -timetz2tm(TimeTzADT *time, struct tm *tm, fsec_t *fsec, int *tzp) +timetz2tm(TimeTzADT *time, struct tm * tm, fsec_t *fsec, int *tzp) { #ifdef HAVE_INT64_TIMESTAMP tm->tm_hour = (time->time / INT64CONST(3600000000)); @@ -1537,6 +1546,7 @@ timetz_pl_interval(PG_FUNCTION_ARGS) TimeTzADT *time = PG_GETARG_TIMETZADT_P(0); Interval *span = PG_GETARG_INTERVAL_P(1); TimeTzADT *result; + #ifndef HAVE_INT64_TIMESTAMP TimeTzADT time1; #endif @@ -1569,6 +1579,7 @@ timetz_mi_interval(PG_FUNCTION_ARGS) TimeTzADT *time = PG_GETARG_TIMETZADT_P(0); Interval *span = PG_GETARG_INTERVAL_P(1); TimeTzADT *result; + #ifndef HAVE_INT64_TIMESTAMP TimeTzADT time1; #endif @@ -1798,7 +1809,7 @@ datetimetz_timestamptz(PG_FUNCTION_ARGS) #ifdef HAVE_INT64_TIMESTAMP result = (((date * INT64CONST(86400000000)) + time->time) - + (time->zone * INT64CONST(1000000))); + + (time->zone * INT64CONST(1000000))); #else result = (((date * 86400.0) + time->time) + time->zone); #endif diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c index 40d1dbc74c..b4daa35f22 100644 --- a/src/backend/utils/adt/datetime.c +++ b/src/backend/utils/adt/datetime.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.95 2002/09/03 19:46:32 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datetime.c,v 1.96 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -42,13 +42,13 @@ void TrimTrailingZeros(char *str); int day_tab[2][13] = { {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}, - {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}}; +{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31, 0}}; char *months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; +"Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL}; char *days[] = {"Sunday", "Monday", "Tuesday", "Wednesday", - "Thursday", "Friday", "Saturday", NULL}; +"Thursday", "Friday", "Saturday", NULL}; /***************************************************************************** @@ -92,7 +92,7 @@ static datetkn datetktbl[] = { {"acst", DTZ, NEG(16)}, /* Atlantic/Porto Acre */ {"act", TZ, NEG(20)}, /* Atlantic/Porto Acre */ {DA_D, ADBC, AD}, /* "ad" for years >= 0 */ - {"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */ + {"abstime", IGNORE_DTF, 0}, /* for pre-v6.1 "Invalid Abstime" */ {"adt", DTZ, NEG(12)}, /* Atlantic Daylight Time */ {"aesst", DTZ, POS(44)}, /* E. Australia */ {"aest", TZ, POS(40)}, /* Australia Eastern Std Time */ @@ -100,7 +100,7 @@ static datetkn datetktbl[] = { {"ahst", TZ, NEG(40)}, /* Alaska-Hawaii Std Time */ {"akdt", DTZ, NEG(32)}, /* Alaska Daylight Time */ {"akst", DTZ, NEG(36)}, /* Alaska Standard Time */ - {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */ + {"allballs", RESERV, DTK_ZULU}, /* 00:00:00 */ {"almt", TZ, POS(24)}, /* Almaty Time */ {"almst", TZ, POS(28)}, /* Almaty Savings Time */ {"am", AMPM, AM}, @@ -112,14 +112,15 @@ static datetkn datetktbl[] = { {"anast", DTZ, POS(52)}, /* Anadyr Summer Time (Russia) */ {"anat", TZ, POS(48)}, /* Anadyr Time (Russia) */ #if 0 -aqtst -aqtt -arst + aqtst + aqtt + arst #endif {"art", TZ, NEG(12)}, /* Argentina Time */ #if 0 -ashst -ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */ + ashst + ast /* Atlantic Standard Time, Arabia Standard + * Time, Acre Standard Time */ #endif {"apr", MONTH, 4}, {"april", MONTH, 4}, @@ -140,14 +141,14 @@ ast /* Atlantic Standard Time, Arabia Standard Time, Acre Standard Time */ {"bnt", TZ, POS(32)}, /* Brunei Darussalam Time */ {"bort", TZ, POS(32)}, /* Borneo Time (Indonesia) */ #if 0 -bortst -bost + bortst + bost #endif {"bot", TZ, NEG(16)}, /* Bolivia Time */ {"bra", TZ, NEG(12)}, /* Brazil Time */ #if 0 -brst -brt + brst + brt #endif {"bst", DTZ, POS(4)}, /* British Summer Time */ #if 0 @@ -165,23 +166,23 @@ brt #endif {"cdt", DTZ, NEG(20)}, /* Central Daylight Time */ {"cest", DTZ, POS(8)}, /* Central European Dayl.Time */ - {"cet", TZ, POS(4)}, /* Central European Time */ + {"cet", TZ, POS(4)}, /* Central European Time */ {"cetdst", DTZ, POS(8)}, /* Central European Dayl.Time */ - {"chadt", DTZ, POS(55)}, /* Chatham Island Daylight Time (13:45) */ + {"chadt", DTZ, POS(55)}, /* Chatham Island Daylight Time (13:45) */ {"chast", TZ, POS(51)}, /* Chatham Island Time (12:45) */ #if 0 -ckhst + ckhst #endif {"ckt", TZ, POS(48)}, /* Cook Islands Time */ {"clst", DTZ, NEG(12)}, /* Chile Summer Time */ {"clt", TZ, NEG(16)}, /* Chile Time */ #if 0 -cost + cost #endif {"cot", TZ, NEG(20)}, /* Columbia Time */ {"cst", TZ, NEG(24)}, /* Central Standard Time */ #if 0 -cvst + cvst #endif {"cvt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */ {"cxt", TZ, POS(28)}, /* Christmas Island Time (Indian Ocean) */ @@ -214,7 +215,7 @@ cvst {"egst", DTZ, POS(0)}, /* East Greenland Summer Time */ {"egt", TZ, NEG(4)}, /* East Greenland Time */ #if 0 -ehdt + ehdt #endif {EPOCH, RESERV, DTK_EPOCH}, /* "epoch" reserved for system epoch time */ {"est", TZ, NEG(20)}, /* Eastern Standard Time */ @@ -225,8 +226,8 @@ ehdt {"fkst", DTZ, NEG(12)}, /* Falkland Islands Summer Time */ {"fkt", TZ, NEG(8)}, /* Falkland Islands Time */ #if 0 -fnst -fnt + fnst + fnt #endif {"fri", DOW, 5}, {"friday", DOW, 5}, @@ -238,7 +239,7 @@ fnt {"get", TZ, POS(16)}, /* Georgia Time */ {"gft", TZ, NEG(12)}, /* French Guiana Time */ #if 0 -ghst + ghst #endif {"gilt", TZ, POS(48)}, /* Gilbert Islands Time */ {"gmt", TZ, POS(0)}, /* Greenwish Mean Time */ @@ -246,37 +247,37 @@ ghst {"gyt", TZ, NEG(16)}, /* Guyana Time */ {"h", UNITS, DTK_HOUR}, /* "hour" */ #if 0 -hadt -hast + hadt + hast #endif {"hdt", DTZ, NEG(36)}, /* Hawaii/Alaska Daylight Time */ #if 0 -hkst + hkst #endif {"hkt", TZ, POS(32)}, /* Hong Kong Time */ #if 0 {"hmt", TZ, POS(12)}, /* Hellas ? ? */ -hovst -hovt + hovst + hovt #endif {"hst", TZ, NEG(40)}, /* Hawaii Std Time */ #if 0 -hwt + hwt #endif {"ict", TZ, POS(28)}, /* Indochina Time */ {"idle", TZ, POS(48)}, /* Intl. Date Line, East */ {"idlw", TZ, NEG(48)}, /* Intl. Date Line, West */ #if 0 -idt /* Israeli, Iran, Indian Daylight Time */ + idt /* Israeli, Iran, Indian Daylight Time */ #endif {LATE, RESERV, DTK_LATE}, /* "infinity" reserved for "late time" */ - {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */ + {INVALID, RESERV, DTK_INVALID}, /* "invalid" reserved for bad time */ {"iot", TZ, POS(20)}, /* Indian Chagos Time */ {"irkst", DTZ, POS(36)}, /* Irkutsk Summer Time */ {"irkt", TZ, POS(32)}, /* Irkutsk Time */ {"irt", TZ, POS(14)}, /* Iran Time */ #if 0 -isst + isst #endif {"ist", TZ, POS(8)}, /* Israel */ {"it", TZ, POS(14)}, /* Iran Time */ @@ -303,7 +304,8 @@ isst {"lhdt", DTZ, POS(44)}, /* Lord Howe Daylight Time, Australia */ {"lhst", TZ, POS(42)}, /* Lord Howe Standard Time, Australia */ {"ligt", TZ, POS(40)}, /* From Melbourne, Australia */ - {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 hours!) */ + {"lint", TZ, POS(56)}, /* Line Islands Time (Kiribati; +14 + * hours!) */ {"lkt", TZ, POS(24)}, /* Lanka Time */ {"m", UNITS, DTK_MONTH}, /* "month" for ISO input */ {"magst", DTZ, POS(48)}, /* Magadan Summer Time */ @@ -325,7 +327,7 @@ isst {"mon", DOW, 1}, {"monday", DOW, 1}, #if 0 -most + most #endif {"mpt", TZ, POS(40)}, /* North Mariana Islands Time */ {"msd", DTZ, POS(16)}, /* Moscow Summer Time */ @@ -336,7 +338,7 @@ most {"mvt", TZ, POS(20)}, /* Maldives Island Time */ {"myt", TZ, POS(32)}, /* Malaysia Time */ #if 0 -ncst + ncst #endif {"nct", TZ, POS(44)}, /* New Caledonia Time */ {"ndt", DTZ, NEG(10)}, /* Nfld. Daylight Time */ @@ -361,7 +363,7 @@ ncst {"on", IGNORE_DTF, 0}, /* "on" (throwaway) */ {"pdt", DTZ, NEG(28)}, /* Pacific Daylight Time */ #if 0 -pest + pest #endif {"pet", TZ, NEG(20)}, /* Peru Time */ {"petst", DTZ, POS(52)}, /* Petropavlovsk-Kamchatski Summer Time */ @@ -369,14 +371,14 @@ pest {"pgt", TZ, POS(40)}, /* Papua New Guinea Time */ {"phot", TZ, POS(52)}, /* Phoenix Islands (Kiribati) Time */ #if 0 -phst + phst #endif {"pht", TZ, POS(32)}, /* Phillipine Time */ {"pkt", TZ, POS(20)}, /* Pakistan Time */ {"pm", AMPM, PM}, {"pmdt", DTZ, NEG(8)}, /* Pierre & Miquelon Daylight Time */ #if 0 -pmst + pmst #endif {"pont", TZ, POS(44)}, /* Ponape Time (Micronesia) */ {"pst", TZ, NEG(32)}, /* Pacific Standard Time */ @@ -387,14 +389,14 @@ pmst {"s", UNITS, DTK_SECOND}, /* "seconds" for ISO input */ {"sadt", DTZ, POS(42)}, /* S. Australian Dayl. Time */ #if 0 -samst -samt + samst + samt #endif {"sast", TZ, POS(38)}, /* South Australian Std Time */ {"sat", DOW, 6}, {"saturday", DOW, 6}, #if 0 -sbt + sbt #endif {"sct", DTZ, POS(16)}, /* Mahe Island Time */ {"sep", MONTH, 9}, @@ -402,14 +404,14 @@ sbt {"september", MONTH, 9}, {"set", TZ, NEG(4)}, /* Seychelles Time ?? */ #if 0 -sgt + sgt #endif {"sst", DTZ, POS(8)}, /* Swedish Summer Time */ {"sun", DOW, 0}, {"sunday", DOW, 0}, {"swt", TZ, POS(4)}, /* Swedish Winter Time */ #if 0 -syot + syot #endif {"t", ISOTIME, DTK_TIME}, /* Filler for ISO time fields */ {"that", TZ, NEG(40)}, /* Tahiti Time */ @@ -424,11 +426,11 @@ syot {TODAY, RESERV, DTK_TODAY}, /* midnight */ {TOMORROW, RESERV, DTK_TOMORROW}, /* tomorrow midnight */ #if 0 -tost + tost #endif {"tot", TZ, POS(52)}, /* Tonga Time */ #if 0 -tpt + tpt #endif {"truk", TZ, POS(40)}, /* Truk Time */ {"tue", DOW, 2}, @@ -436,7 +438,7 @@ tpt {"tuesday", DOW, 2}, {"tvt", TZ, POS(48)}, /* Tuvalu Time */ #if 0 -uct + uct #endif {"ulast", DTZ, POS(36)}, /* Ulan Bator Summer Time */ {"ulat", TZ, POS(32)}, /* Ulan Bator Time */ @@ -451,13 +453,13 @@ uct {"vlast", DTZ, POS(44)}, /* Vladivostok Summer Time */ {"vlat", TZ, POS(40)}, /* Vladivostok Time */ #if 0 -vust + vust #endif {"vut", TZ, POS(44)}, /* Vanuata Time */ {"wadt", DTZ, POS(32)}, /* West Australian DST */ {"wakt", TZ, POS(48)}, /* Wake Time */ #if 0 -warst + warst #endif {"wast", TZ, POS(28)}, /* West Australian Std Time */ {"wat", TZ, NEG(4)}, /* West Africa Time */ @@ -515,22 +517,22 @@ static datetkn deltatktbl[] = { {"days", UNITS, DTK_DAY}, /* "days" relative */ {"dec", UNITS, DTK_DECADE}, /* "decade" relative */ {"decs", UNITS, DTK_DECADE}, /* "decades" relative */ - {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */ - {"decades", UNITS, DTK_DECADE}, /* "decades" relative */ + {DDECADE, UNITS, DTK_DECADE}, /* "decade" relative */ + {"decades", UNITS, DTK_DECADE}, /* "decades" relative */ {"h", UNITS, DTK_HOUR}, /* "hour" relative */ {DHOUR, UNITS, DTK_HOUR}, /* "hour" relative */ {"hours", UNITS, DTK_HOUR}, /* "hours" relative */ {"hr", UNITS, DTK_HOUR}, /* "hour" relative */ {"hrs", UNITS, DTK_HOUR}, /* "hours" relative */ - {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */ + {INVALID, RESERV, DTK_INVALID}, /* reserved for invalid time */ {"m", UNITS, DTK_MINUTE}, /* "minute" relative */ - {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ - {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ - {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */ - {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ - {"millisecon", UNITS, DTK_MILLISEC}, /* relative */ - {"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */ - {"min", UNITS, DTK_MINUTE}, /* "minute" relative */ + {"microsecon", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ + {"mil", UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ + {"millennia", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */ + {DMILLENNIUM, UNITS, DTK_MILLENNIUM}, /* "millennium" relative */ + {"millisecon", UNITS, DTK_MILLISEC}, /* relative */ + {"mils", UNITS, DTK_MILLENNIUM}, /* "millennia" relative */ + {"min", UNITS, DTK_MINUTE}, /* "minute" relative */ {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */ {"mins", UNITS, DTK_MINUTE}, /* "minutes" relative */ {DMINUTE, UNITS, DTK_MINUTE}, /* "minute" relative */ @@ -545,19 +547,19 @@ static datetkn deltatktbl[] = { {"mseconds", UNITS, DTK_MILLISEC}, {"msecs", UNITS, DTK_MILLISEC}, {"qtr", UNITS, DTK_QUARTER}, /* "quarter" relative */ - {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */ - {"reltime", IGNORE_DTF, 0}, /* pre-v6.1 "Undefined Reltime" */ + {DQUARTER, UNITS, DTK_QUARTER}, /* "quarter" relative */ + {"reltime", IGNORE_DTF, 0}, /* pre-v6.1 "Undefined Reltime" */ {"s", UNITS, DTK_SECOND}, {"sec", UNITS, DTK_SECOND}, {DSECOND, UNITS, DTK_SECOND}, {"seconds", UNITS, DTK_SECOND}, {"secs", UNITS, DTK_SECOND}, - {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ + {DTIMEZONE, UNITS, DTK_TZ}, /* "timezone" time offset */ {"timezone", UNITS, DTK_TZ}, /* "timezone" time offset */ {"timezone_h", UNITS, DTK_TZ_HOUR}, /* timezone hour units */ - {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */ + {"timezone_m", UNITS, DTK_TZ_MINUTE}, /* timezone minutes units */ {"undefined", RESERV, DTK_INVALID}, /* pre-v6.1 invalid time */ - {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ + {"us", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"usec", UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {DMICROSEC, UNITS, DTK_MICROSEC}, /* "microsecond" relative */ {"useconds", UNITS, DTK_MICROSEC}, /* "microseconds" relative */ @@ -679,16 +681,16 @@ TrimTrailingZeros(char *str) /* ParseDateTime() * Break string into tokens based on a date/time context. * Several field types are assigned: - * DTK_NUMBER - digits and (possibly) a decimal point - * DTK_DATE - digits and two delimiters, or digits and text - * DTK_TIME - digits, colon delimiters, and possibly a decimal point - * DTK_STRING - text (no digits) - * DTK_SPECIAL - leading "+" or "-" followed by text - * DTK_TZ - leading "+" or "-" followed by digits + * DTK_NUMBER - digits and (possibly) a decimal point + * DTK_DATE - digits and two delimiters, or digits and text + * DTK_TIME - digits, colon delimiters, and possibly a decimal point + * DTK_STRING - text (no digits) + * DTK_SPECIAL - leading "+" or "-" followed by text + * DTK_TZ - leading "+" or "-" followed by digits * Note that some field types can hold unexpected items: - * DTK_NUMBER can hold date fields (yy.ddd) - * DTK_STRING can hold months (January) and time zones (PST) - * DTK_DATE can hold Posix time zones (GMT-8) + * DTK_NUMBER can hold date fields (yy.ddd) + * DTK_STRING can hold months (January) and time zones (PST) + * DTK_DATE can hold Posix time zones (GMT-8) */ int ParseDateTime(char *timestr, char *lowstr, @@ -723,17 +725,20 @@ ParseDateTime(char *timestr, char *lowstr, else if ((*cp == '-') || (*cp == '/') || (*cp == '.')) { /* save delimiting character to use later */ - char *dp = cp; + char *dp = cp; *lp++ = *cp++; /* second field is all digits? then no embedded text month */ if (isdigit((unsigned char) *cp)) { - ftype[nf] = ((*dp == '.')? DTK_NUMBER: DTK_DATE); + ftype[nf] = ((*dp == '.') ? DTK_NUMBER : DTK_DATE); while (isdigit((unsigned char) *cp)) *lp++ = *cp++; - /* insist that the delimiters match to get a three-field date. */ + /* + * insist that the delimiters match to get a + * three-field date. + */ if (*cp == *dp) { ftype[nf] = DTK_DATE; @@ -749,13 +754,13 @@ ParseDateTime(char *timestr, char *lowstr, *lp++ = tolower((unsigned char) *cp++); } } - /* otherwise, number only and will determine - * year, month, day, or concatenated fields later... + + /* + * otherwise, number only and will determine year, month, day, + * or concatenated fields later... */ else - { ftype[nf] = DTK_NUMBER; - } } /* Leading decimal point? Then fractional seconds... */ else if (*cp == '.') @@ -766,6 +771,7 @@ ParseDateTime(char *timestr, char *lowstr, ftype[nf] = DTK_NUMBER; } + /* * text? then date string, month, day of week, special, or * timezone @@ -783,7 +789,7 @@ ParseDateTime(char *timestr, char *lowstr, */ if ((*cp == '-') || (*cp == '/') || (*cp == '.')) { - char *dp = cp; + char *dp = cp; ftype[nf] = DTK_DATE; *lp++ = *cp++; @@ -823,9 +829,7 @@ ParseDateTime(char *timestr, char *lowstr, } /* otherwise something wrong... */ else - { return -1; - } } /* ignore punctuation but use as delimiter */ else if (ispunct((unsigned char) *cp)) @@ -836,9 +840,7 @@ ParseDateTime(char *timestr, char *lowstr, } /* otherwise, something is not right... */ else - { return -1; - } /* force in a delimiter after each field */ *lp++ = '\0'; @@ -880,7 +882,8 @@ DecodeDateTime(char **field, int *ftype, int nf, int fmask = 0, tmask, type; - int ptype = 0; /* "prefix type" for ISO y2001m02d04 format */ + int ptype = 0; /* "prefix type" for ISO y2001m02d04 + * format */ int i; int val; int mer = HR24; @@ -948,7 +951,7 @@ DecodeDateTime(char **field, int *ftype, int nf, if (isdigit((unsigned char) *field[i]) || ptype != 0) { - char *cp; + char *cp; if (ptype != 0) { @@ -958,8 +961,10 @@ DecodeDateTime(char **field, int *ftype, int nf, ptype = 0; } - /* Starts with a digit but we already have a time field? - * Then we are in trouble with a date and time already... + /* + * Starts with a digit but we already have a time + * field? Then we are in trouble with a date and + * time already... */ if ((fmask & DTK_TIME_M) == DTK_TIME_M) return -1; @@ -972,12 +977,18 @@ DecodeDateTime(char **field, int *ftype, int nf, return -1; *cp = '\0'; - /* Then read the rest of the field as a concatenated time */ + /* + * Then read the rest of the field as a + * concatenated time + */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], fmask, - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; - /* modify tmask after returning from DecodeNumberField() */ + /* + * modify tmask after returning from + * DecodeNumberField() + */ tmask |= DTK_M(TZ); } else @@ -990,9 +1001,7 @@ DecodeDateTime(char **field, int *ftype, int nf, } } else if (DecodeDate(field[i], fmask, &tmask, tm) != 0) - { return -1; - } break; case DTK_TIME: @@ -1009,7 +1018,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TZ: { - int tz; + int tz; if (tzp == NULL) return -1; @@ -1038,6 +1047,7 @@ DecodeDateTime(char **field, int *ftype, int nf, break; case DTK_NUMBER: + /* * Was this an "ISO date" with embedded field labels? An * example is "y2001m02d04" - thomas 2001-02-04 @@ -1048,7 +1058,11 @@ DecodeDateTime(char **field, int *ftype, int nf, int val; val = strtol(field[i], &cp, 10); - /* only a few kinds are allowed to have an embedded decimal */ + + /* + * only a few kinds are allowed to have an embedded + * decimal + */ if (*cp == '.') switch (ptype) { @@ -1071,7 +1085,11 @@ DecodeDateTime(char **field, int *ftype, int nf, break; case DTK_MONTH: - /* already have a month and hour? then assume minutes */ + + /* + * already have a month and hour? then assume + * minutes + */ if (((fmask & DTK_M(MONTH)) != 0) && ((fmask & DTK_M(HOUR)) != 0)) { @@ -1105,7 +1123,8 @@ DecodeDateTime(char **field, int *ftype, int nf, tmask = DTK_M(SECOND); if (*cp == '.') { - double frac; + double frac; + frac = strtod(cp, &cp); if (*cp != '\0') return -1; @@ -1132,7 +1151,7 @@ DecodeDateTime(char **field, int *ftype, int nf, /* fractional Julian Day? */ if (*cp == '.') { - double time; + double time; time = strtod(cp, &cp); if (*cp != '\0') @@ -1140,9 +1159,9 @@ DecodeDateTime(char **field, int *ftype, int nf, tmask |= DTK_TIME_M; #ifdef HAVE_INT64_TIMESTAMP - dt2time((time*86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + dt2time((time * 86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #else - dt2time((time*86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + dt2time((time * 86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #endif } break; @@ -1150,7 +1169,7 @@ DecodeDateTime(char **field, int *ftype, int nf, case DTK_TIME: /* previous field was "t" for ISO time */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M), - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; if (tmask != DTK_TIME_M) @@ -1167,8 +1186,8 @@ DecodeDateTime(char **field, int *ftype, int nf, } else { - char *cp; - int flen; + char *cp; + int flen; flen = strlen(field[i]); cp = strchr(field[i], '.'); @@ -1182,26 +1201,25 @@ DecodeDateTime(char **field, int *ftype, int nf, /* embedded decimal and several digits before? */ else if ((cp != NULL) && ((flen - strlen(cp)) > 2)) { - /* Interpret as a concatenated date or time - * Set the type field to allow decoding other fields later. - * Example: 20011223 or 040506 + /* + * Interpret as a concatenated date or time Set + * the type field to allow decoding other fields + * later. Example: 20011223 or 040506 */ if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; } else if (flen > 4) { if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits)) < 0) - return -1; + &tmask, tm, fsec, &is2digits)) < 0) + return -1; } /* otherwise it is a single date/time field... */ else if (DecodeNumber(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits) != 0) - { + &tmask, tm, fsec, &is2digits) != 0) return -1; - } } break; @@ -1350,9 +1368,11 @@ DecodeDateTime(char **field, int *ftype, int nf, break; case ISOTIME: - /* This is a filler field "t" - * indicating that the next field is time. - * Try to verify that this is sensible. + + /* + * This is a filler field "t" indicating that the + * next field is time. Try to verify that this is + * sensible. */ tmask = 0; @@ -1362,9 +1382,9 @@ DecodeDateTime(char **field, int *ftype, int nf, /*** * We will need one of the following fields: - * DTK_NUMBER should be hhmmss.fff - * DTK_TIME should be hh:mm:ss.fff - * DTK_DATE should be hhmmss-zz + * DTK_NUMBER should be hhmmss.fff + * DTK_TIME should be hh:mm:ss.fff + * DTK_DATE should be hhmmss-zz ***/ if ((i >= (nf - 1)) || ((ftype[i + 1] != DTK_NUMBER) @@ -1522,34 +1542,38 @@ DetermineLocalTimeZone(struct tm * tm) date2j(1970, 1, 1)); mysec = tm->tm_sec + (tm->tm_min + (day * 24 + tm->tm_hour) * 60) * 60; mytime = (time_t) mysec; + /* - * Use localtime to convert that time_t to broken-down time, and - * reassemble to get a representation of local time. + * Use localtime to convert that time_t to broken-down time, + * and reassemble to get a representation of local time. */ tmp = localtime(&mytime); day = (date2j(tmp->tm_year + 1900, tmp->tm_mon + 1, tmp->tm_mday) - date2j(1970, 1, 1)); locsec = tmp->tm_sec + (tmp->tm_min + (day * 24 + tmp->tm_hour) * 60) * 60; + /* - * The local time offset corresponding to that GMT time is - * now computable as mysec - locsec. + * The local time offset corresponding to that GMT time is now + * computable as mysec - locsec. */ delta1 = mysec - locsec; + /* - * However, if that GMT time and the local time we are actually - * interested in are on opposite sides of a daylight-savings-time - * transition, then this is not the time offset we want. So, - * adjust the time_t to be what we think the GMT time corresponding - * to our target local time is, and repeat the localtime() call - * and delta calculation. We may have to do it twice before we - * have a trustworthy delta. + * However, if that GMT time and the local time we are + * actually interested in are on opposite sides of a + * daylight-savings-time transition, then this is not the time + * offset we want. So, adjust the time_t to be what we think + * the GMT time corresponding to our target local time is, and + * repeat the localtime() call and delta calculation. We may + * have to do it twice before we have a trustworthy delta. * * Note: think not to put a loop here, since if we've been given - * an "impossible" local time (in the gap during a spring-forward - * transition) we'd never get out of the loop. Twice is enough - * to give the behavior we want, which is that "impossible" times - * are taken as standard time, while at a fall-back boundary - * ambiguous times are also taken as standard. + * an "impossible" local time (in the gap during a + * spring-forward transition) we'd never get out of the loop. + * Twice is enough to give the behavior we want, which is that + * "impossible" times are taken as standard time, while at a + * fall-back boundary ambiguous times are also taken as + * standard. */ mysec += delta1; mytime = (time_t) mysec; @@ -1604,7 +1628,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, int fmask = 0, tmask, type; - int ptype = 0; /* "prefix type" for ISO h04mm05s06 format */ + int ptype = 0; /* "prefix type" for ISO h04mm05s06 format */ int i; int val; int is2digits = FALSE; @@ -1626,16 +1650,17 @@ DecodeTimeOnly(char **field, int *ftype, int nf, switch (ftype[i]) { case DTK_DATE: - /* Time zone not allowed? - * Then should not accept dates or time zones - * no matter what else! + + /* + * Time zone not allowed? Then should not accept dates or + * time zones no matter what else! */ if (tzp == NULL) return -1; /* Under limited circumstances, we will accept a date... */ if ((i == 0) && (nf >= 2) - && ((ftype[nf-1] == DTK_DATE) + && ((ftype[nf - 1] == DTK_DATE) || (ftype[1] == DTK_TIME))) { if (DecodeDate(field[i], fmask, &tmask, tm) != 0) @@ -1646,15 +1671,20 @@ DecodeTimeOnly(char **field, int *ftype, int nf, { if (isdigit((unsigned char) *field[i])) { - char *cp; + char *cp; - /* Starts with a digit but we already have a time field? - * Then we are in trouble with time already... + /* + * Starts with a digit but we already have a time + * field? Then we are in trouble with time + * already... */ if ((fmask & DTK_TIME_M) == DTK_TIME_M) return -1; - /* Should not get here and fail. Sanity check only... */ + /* + * Should not get here and fail. Sanity check + * only... + */ if ((cp = strchr(field[i], '-')) == NULL) return -1; @@ -1663,9 +1693,12 @@ DecodeTimeOnly(char **field, int *ftype, int nf, return -1; *cp = '\0'; - /* Then read the rest of the field as a concatenated time */ + /* + * Then read the rest of the field as a + * concatenated time + */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M), - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; tmask |= DTK_M(TZ); @@ -1716,6 +1749,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, break; case DTK_NUMBER: + /* * Was this an "ISO time" with embedded field labels? An * example is "h04m05s06" - thomas 2001-02-04 @@ -1739,7 +1773,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf, } val = strtol(field[i], &cp, 10); - /* only a few kinds are allowed to have an embedded decimal */ + + /* + * only a few kinds are allowed to have an embedded + * decimal + */ if (*cp == '.') switch (ptype) { @@ -1762,7 +1800,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf, break; case DTK_MONTH: - /* already have a month and hour? then assume minutes */ + + /* + * already have a month and hour? then assume + * minutes + */ if (((fmask & DTK_M(MONTH)) != 0) && ((fmask & DTK_M(HOUR)) != 0)) { @@ -1816,7 +1858,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, j2date(val, &tm->tm_year, &tm->tm_mon, &tm->tm_mday); if (*cp == '.') { - double time; + double time; time = strtod(cp, &cp); if (*cp != '\0') @@ -1824,9 +1866,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf, tmask |= DTK_TIME_M; #ifdef HAVE_INT64_TIMESTAMP - dt2time((time*86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + dt2time((time * 86400000000), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #else - dt2time((time*86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); + dt2time((time * 86400), &tm->tm_hour, &tm->tm_min, &tm->tm_sec, fsec); #endif } break; @@ -1834,7 +1876,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, case DTK_TIME: /* previous field was "t" for ISO time */ if ((ftype[i] = DecodeNumberField(strlen(field[i]), field[i], (fmask | DTK_DATE_M), - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; if (tmask != DTK_TIME_M) @@ -1851,8 +1893,8 @@ DecodeTimeOnly(char **field, int *ftype, int nf, } else { - char *cp; - int flen; + char *cp; + int flen; flen = strlen(field[i]); cp = strchr(field[i], '.'); @@ -1860,8 +1902,11 @@ DecodeTimeOnly(char **field, int *ftype, int nf, /* Embedded decimal? */ if (cp != NULL) { - /* Under limited circumstances, we will accept a date... */ - if ((i == 0) && ((nf >= 2) && (ftype[nf-1] == DTK_DATE))) + /* + * Under limited circumstances, we will accept a + * date... + */ + if ((i == 0) && ((nf >= 2) && (ftype[nf - 1] == DTK_DATE))) { if (DecodeDate(field[i], fmask, &tmask, tm) != 0) return -1; @@ -1869,31 +1914,28 @@ DecodeTimeOnly(char **field, int *ftype, int nf, /* embedded decimal and several digits before? */ else if ((flen - strlen(cp)) > 2) { - /* Interpret as a concatenated date or time - * Set the type field to allow decoding other fields later. - * Example: 20011223 or 040506 + /* + * Interpret as a concatenated date or time + * Set the type field to allow decoding other + * fields later. Example: 20011223 or 040506 */ if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits)) < 0) + &tmask, tm, fsec, &is2digits)) < 0) return -1; } else - { return -1; - } } else if (flen > 4) { if ((ftype[i] = DecodeNumberField(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits)) < 0) - return -1; + &tmask, tm, fsec, &is2digits)) < 0) + return -1; } /* otherwise it is a single date/time field... */ else if (DecodeNumber(flen, field[i], fmask, - &tmask, tm, fsec, &is2digits) != 0) - { + &tmask, tm, fsec, &is2digits) != 0) return -1; - } } break; @@ -1987,9 +2029,9 @@ DecodeTimeOnly(char **field, int *ftype, int nf, /*** * We will need one of the following fields: - * DTK_NUMBER should be hhmmss.fff - * DTK_TIME should be hh:mm:ss.fff - * DTK_DATE should be hhmmss-zz + * DTK_NUMBER should be hhmmss.fff + * DTK_TIME should be hh:mm:ss.fff + * DTK_DATE should be hhmmss-zz ***/ if ((i >= (nf - 1)) || ((ftype[i + 1] != DTK_NUMBER) @@ -2051,9 +2093,7 @@ DecodeTimeOnly(char **field, int *ftype, int nf, return -1; if ((fmask & DTK_DATE_M) == 0) - { GetCurrentDateTime(tmp); - } else { tmp->tm_year = tm->tm_year; @@ -2221,9 +2261,7 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec) *fsec = 0; } else if (*cp != ':') - { return -1; - } else { str = cp + 1; @@ -2233,15 +2271,16 @@ DecodeTime(char *str, int fmask, int *tmask, struct tm * tm, fsec_t *fsec) else if (*cp == '.') { #ifdef HAVE_INT64_TIMESTAMP - char fstr[MAXDATELEN + 1]; + char fstr[MAXDATELEN + 1]; - /* OK, we have at most six digits to work with. - * Let's construct a string and then do the conversion - * to an integer. + /* + * OK, we have at most six digits to work with. Let's + * construct a string and then do the conversion to an + * integer. */ - strncpy(fstr, (cp+1), 7); - strcpy((fstr+strlen(fstr)), "000000"); - *(fstr+6) = '\0'; + strncpy(fstr, (cp + 1), 7); + strcpy((fstr + strlen(fstr)), "000000"); + *(fstr + 6) = '\0'; *fsec = strtol(fstr, &cp, 10); #else str = cp; @@ -2291,10 +2330,9 @@ DecodeNumber(int flen, char *str, int fmask, if (*cp == '.') { - /* More than two digits? - * Then could be a date or a run-together time: - * 2001.360 - * 20011225 040506.789 + /* + * More than two digits? Then could be a date or a run-together + * time: 2001.360 20011225 040506.789 */ if ((cp - str) > 2) return DecodeNumberField(flen, str, (fmask | DTK_DATE_M), @@ -2305,9 +2343,7 @@ DecodeNumber(int flen, char *str, int fmask, return -1; } else if (*cp != '\0') - { return -1; - } /* Special case day of year? */ if ((flen == 3) && (fmask & DTK_M(YEAR)) @@ -2397,26 +2433,27 @@ DecodeNumber(int flen, char *str, int fmask, */ static int DecodeNumberField(int len, char *str, int fmask, - int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits) + int *tmask, struct tm * tm, fsec_t *fsec, int *is2digits) { char *cp; - /* Have a decimal point? - * Then this is a date or something with a seconds field... + /* + * Have a decimal point? Then this is a date or something with a + * seconds field... */ if ((cp = strchr(str, '.')) != NULL) { #ifdef HAVE_INT64_TIMESTAMP - char fstr[MAXDATELEN + 1]; + char fstr[MAXDATELEN + 1]; - /* OK, we have at most six digits to care about. - * Let's construct a string and then do the conversion - * to an integer. - */ - strcpy(fstr, (cp+1)); - strcpy((fstr+strlen(fstr)), "000000"); - *(fstr+6) = '\0'; - *fsec = strtol(fstr, NULL, 10); + /* + * OK, we have at most six digits to care about. Let's construct a + * string and then do the conversion to an integer. + */ + strcpy(fstr, (cp + 1)); + strcpy((fstr + strlen(fstr)), "000000"); + *(fstr + 6) = '\0'; + *fsec = strtol(fstr, NULL, 10); #else *fsec = strtod(cp, NULL); #endif @@ -2515,9 +2552,7 @@ DecodeTimezone(char *str, int *tzp) /* explicit delimiter? */ if (*cp == ':') - { min = strtol((cp + 1), &cp, 10); - } /* otherwise, might have run things together... */ else if ((*cp == '\0') && ((len = strlen(str)) > 3)) { @@ -2531,9 +2566,7 @@ DecodeTimezone(char *str, int *tzp) return -1; } else - { min = 0; - } tz = (hr * 60 + min) * 60; if (*str == '-') @@ -2794,7 +2827,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_min += val; if (fval != 0) { - int sec; + int sec; + fval *= 60; sec = fval; tm->tm_sec += sec; @@ -2811,7 +2845,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_hour += val; if (fval != 0) { - int sec; + int sec; + fval *= 3600; sec = fval; tm->tm_sec += sec; @@ -2828,7 +2863,8 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_mday += val; if (fval != 0) { - int sec; + int sec; + fval *= 86400; sec = fval; tm->tm_sec += sec; @@ -2845,8 +2881,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_mday += val * 7; if (fval != 0) { - int sec; - fval *= (7*86400); + int sec; + + fval *= (7 * 86400); sec = fval; tm->tm_sec += sec; #ifdef HAVE_INT64_TIMESTAMP @@ -2862,8 +2899,9 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse tm->tm_mon += val; if (fval != 0) { - int sec; - fval *= (30*86400); + int sec; + + fval *= (30 * 86400); sec = fval; tm->tm_sec += sec; #ifdef HAVE_INT64_TIMESTAMP @@ -2947,7 +2985,7 @@ DecodeInterval(char **field, int *ftype, int nf, int *dtype, struct tm * tm, fse if (*fsec != 0) { - int sec; + int sec; #ifdef HAVE_INT64_TIMESTAMP sec = (*fsec / INT64CONST(1000000)); @@ -3175,13 +3213,14 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha int day, hour, min; + #ifndef HAVE_INT64_TIMESTAMP fsec_t sec; #endif - /* Why are we checking only the month field? Change this to an assert... - * if ((tm->tm_mon < 1) || (tm->tm_mon > 12)) - * return -1; + /* + * Why are we checking only the month field? Change this to an + * assert... if ((tm->tm_mon < 1) || (tm->tm_mon > 12)) return -1; */ Assert((tm->tm_mon >= 1) && (tm->tm_mon <= 12)); @@ -3195,16 +3234,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha /* Compatible with ISO-8601 date formats */ sprintf(str, "%04d-%02d-%02d %02d:%02d", - ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)), + ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)), tm->tm_mon, tm->tm_mday, tm->tm_hour, tm->tm_min); /* - * If we have fractional seconds, then include a decimal - * point We will do up to 6 fractional digits, and we have - * rounded any inputs to eliminate anything to the right - * of 6 digits anyway. If there are no fractional seconds, - * then do not bother printing a decimal point at all. - - * thomas 2001-09-29 + * If we have fractional seconds, then include a decimal point + * We will do up to 6 fractional digits, and we have rounded + * any inputs to eliminate anything to the right of 6 digits + * anyway. If there are no fractional seconds, then do not + * bother printing a decimal point at all. - thomas 2001-09-29 */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3219,22 +3257,16 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02d", tm->tm_sec); - } if (tm->tm_year <= 0) - { sprintf((str + strlen(str)), " BC"); - } /* - * tzp == NULL indicates that we don't want *any* time - * zone info in the output string. - * *tzn != NULL indicates that we have alpha time zone - * info available. - * tm_isdst != -1 indicates that we have a valid time zone - * translation. + * tzp == NULL indicates that we don't want *any* time zone + * info in the output string. *tzn != NULL indicates that we + * have alpha time zone info available. tm_isdst != -1 + * indicates that we have a valid time zone translation. */ if ((tzp != NULL) && (tm->tm_isdst >= 0)) { @@ -3253,16 +3285,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha sprintf(str, "%02d/%02d", tm->tm_mon, tm->tm_mday); sprintf((str + 5), "/%04d %02d:%02d", - ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)), + ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)), tm->tm_hour, tm->tm_min); /* - * If we have fractional seconds, then include a decimal - * point We will do up to 6 fractional digits, and we have - * rounded any inputs to eliminate anything to the right - * of 6 digits anyway. If there are no fractional seconds, - * then do not bother printing a decimal point at all. - - * thomas 2001-09-29 + * If we have fractional seconds, then include a decimal point + * We will do up to 6 fractional digits, and we have rounded + * any inputs to eliminate anything to the right of 6 digits + * anyway. If there are no fractional seconds, then do not + * bother printing a decimal point at all. - thomas 2001-09-29 */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3277,14 +3308,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02d", tm->tm_sec); - } if (tm->tm_year <= 0) - { sprintf((str + strlen(str)), " BC"); - } if ((tzp != NULL) && (tm->tm_isdst >= 0)) { @@ -3305,16 +3332,15 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha sprintf(str, "%02d.%02d", tm->tm_mday, tm->tm_mon); sprintf((str + 5), ".%04d %02d:%02d", - ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1)), + ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1)), tm->tm_hour, tm->tm_min); /* - * If we have fractional seconds, then include a decimal - * point We will do up to 6 fractional digits, and we have - * rounded any inputs to eliminate anything to the right - * of 6 digits anyway. If there are no fractional seconds, - * then do not bother printing a decimal point at all. - - * thomas 2001-09-29 + * If we have fractional seconds, then include a decimal point + * We will do up to 6 fractional digits, and we have rounded + * any inputs to eliminate anything to the right of 6 digits + * anyway. If there are no fractional seconds, then do not + * bother printing a decimal point at all. - thomas 2001-09-29 */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3329,14 +3355,10 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02d", tm->tm_sec); - } if (tm->tm_year <= 0) - { sprintf((str + strlen(str)), " BC"); - } if ((tzp != NULL) && (tm->tm_isdst >= 0)) { @@ -3369,12 +3391,11 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha sprintf((str + 10), " %02d:%02d", tm->tm_hour, tm->tm_min); /* - * If we have fractional seconds, then include a decimal - * point We will do up to 6 fractional digits, and we have - * rounded any inputs to eliminate anything to the right - * of 6 digits anyway. If there are no fractional seconds, - * then do not bother printing a decimal point at all. - - * thomas 2001-09-29 + * If we have fractional seconds, then include a decimal point + * We will do up to 6 fractional digits, and we have rounded + * any inputs to eliminate anything to the right of 6 digits + * anyway. If there are no fractional seconds, then do not + * bother printing a decimal point at all. - thomas 2001-09-29 */ #ifdef HAVE_INT64_TIMESTAMP if (fsec != 0) @@ -3389,16 +3410,12 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha TrimTrailingZeros(str); } else - { sprintf((str + strlen(str)), ":%02d", tm->tm_sec); - } sprintf((str + strlen(str)), " %04d", - ((tm->tm_year > 0)? tm->tm_year: -(tm->tm_year - 1))); + ((tm->tm_year > 0) ? tm->tm_year : -(tm->tm_year - 1))); if (tm->tm_year <= 0) - { sprintf((str + strlen(str)), " BC"); - } if ((tzp != NULL) && (tm->tm_isdst >= 0)) { @@ -3407,11 +3424,11 @@ EncodeDateTime(struct tm * tm, fsec_t fsec, int *tzp, char **tzn, int style, cha else { /* - * We have a time zone, but no string version. Use - * the numeric form, but be sure to include a - * leading space to avoid formatting something - * which would be rejected by the date/time parser - * later. - thomas 2001-10-19 + * We have a time zone, but no string version. Use the + * numeric form, but be sure to include a leading + * space to avoid formatting something which would be + * rejected by the date/time parser later. - thomas + * 2001-10-19 */ hour = -(*tzp / 3600); min = ((abs(*tzp) / 60) % 60); @@ -3497,7 +3514,7 @@ EncodeInterval(struct tm * tm, fsec_t fsec, int style, char *str) #ifdef HAVE_INT64_TIMESTAMP sprintf(cp, ":%02d", abs(tm->tm_sec)); cp += strlen(cp); - sprintf(cp, ".%06d", ((fsec >= 0)? fsec: -(fsec))); + sprintf(cp, ".%06d", ((fsec >= 0) ? fsec : -(fsec))); #else fsec += tm->tm_sec; sprintf(cp, ":%013.10f", fabs(fsec)); diff --git a/src/backend/utils/adt/datum.c b/src/backend/utils/adt/datum.c index 0a751ff1df..9519ef2b67 100644 --- a/src/backend/utils/adt/datum.c +++ b/src/backend/utils/adt/datum.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.24 2002/08/24 15:00:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/datum.c,v 1.25 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ datumGetSize(Datum value, bool typByVal, int typLen) else if (typLen == -2) { /* It is a cstring datatype */ - char *s = (char *) DatumGetPointer(value); + char *s = (char *) DatumGetPointer(value); if (!PointerIsValid(s)) elog(ERROR, "datumGetSize: Invalid Datum Pointer"); @@ -175,9 +175,9 @@ datumIsEqual(Datum value1, Datum value2, bool typByVal, int typLen) /* * just compare the two datums. NOTE: just comparing "len" bytes * will not do the work, because we do not know how these bytes - * are aligned inside the "Datum". We assume instead that any - * given datatype is consistent about how it fills extraneous - * bits in the Datum. + * are aligned inside the "Datum". We assume instead that any + * given datatype is consistent about how it fills extraneous bits + * in the Datum. */ res = (value1 == value2); } diff --git a/src/backend/utils/adt/float.c b/src/backend/utils/adt/float.c index 5edea787af..7b1798d75c 100644 --- a/src/backend/utils/adt/float.c +++ b/src/backend/utils/adt/float.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.80 2002/08/26 17:53:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/float.c,v 1.81 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1515,7 +1515,7 @@ float8_accum(PG_FUNCTION_ARGS) result = construct_array(transdatums, 3, FLOAT8OID, - sizeof(float8), false /*float8 byval*/, 'd'); + sizeof(float8), false /* float8 byval */ , 'd'); PG_RETURN_ARRAYTYPE_P(result); } @@ -1551,7 +1551,7 @@ float4_accum(PG_FUNCTION_ARGS) result = construct_array(transdatums, 3, FLOAT8OID, - sizeof(float8), false /*float8 byval*/, 'd'); + sizeof(float8), false /* float8 byval */ , 'd'); PG_RETURN_ARRAYTYPE_P(result); } diff --git a/src/backend/utils/adt/format_type.c b/src/backend/utils/adt/format_type.c index 02e0dc8f27..c852ed26f3 100644 --- a/src/backend/utils/adt/format_type.c +++ b/src/backend/utils/adt/format_type.c @@ -8,7 +8,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.33 2002/08/29 07:22:26 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/format_type.c,v 1.34 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,8 +31,9 @@ #define _textin(str) DirectFunctionCall1(textin, CStringGetDatum(str)) static char *format_type_internal(Oid type_oid, int32 typemod, - bool typemod_given, bool allow_invalid); -static char *psnprintf(size_t len, const char *fmt, ...) + bool typemod_given, bool allow_invalid); +static char * +psnprintf(size_t len, const char *fmt,...) /* This lets gcc check the format string for consistency. */ __attribute__((format(printf, 2, 3))); @@ -47,14 +48,14 @@ __attribute__((format(printf, 2, 3))); * double quoted if it contains funny characters or matches a keyword. * * If typemod is NULL then we are formatting a type name in a context where - * no typemod is available, eg a function argument or result type. This + * no typemod is available, eg a function argument or result type. This * yields a slightly different result from specifying typemod = -1 in some * cases. Given typemod = -1 we feel compelled to produce an output that * the parser will interpret as having typemod -1, so that pg_dump will - * produce CREATE TABLE commands that recreate the original state. But + * produce CREATE TABLE commands that recreate the original state. But * given NULL typemod, we assume that the parser's interpretation of * typemod doesn't matter, and so we are willing to output a slightly - * "prettier" representation of the same type. For example, type = bpchar + * "prettier" representation of the same type. For example, type = bpchar * and typemod = NULL gets you "character", whereas typemod = -1 gets you * "bpchar" --- the former will be interpreted as character(1) by the * parser, which does not yield typemod -1. @@ -77,9 +78,7 @@ format_type(PG_FUNCTION_ARGS) type_oid = PG_GETARG_OID(0); if (PG_ARGISNULL(1)) - { result = format_type_internal(type_oid, -1, false, true); - } else { typemod = PG_GETARG_INT32(1); @@ -141,7 +140,7 @@ format_type_internal(Oid type_oid, int32 typemod, /* * Check if it's an array (and not a domain --- we don't want to show - * the substructure of a domain type). Fixed-length array types such + * the substructure of a domain type). Fixed-length array types such * as "name" shouldn't get deconstructed either. */ array_base_type = typeform->typelem; @@ -171,15 +170,15 @@ format_type_internal(Oid type_oid, int32 typemod, is_array = false; /* - * See if we want to special-case the output for certain built-in types. - * Note that these special cases should all correspond to special - * productions in gram.y, to ensure that the type name will be taken as - * a system type, not a user type of the same name. + * See if we want to special-case the output for certain built-in + * types. Note that these special cases should all correspond to + * special productions in gram.y, to ensure that the type name will be + * taken as a system type, not a user type of the same name. * - * If we do not provide a special-case output here, the type name will - * be handled the same way as a user type name --- in particular, it - * will be double-quoted if it matches any lexer keyword. This behavior - * is essential for some cases, such as types "bit" and "char". + * If we do not provide a special-case output here, the type name will be + * handled the same way as a user type name --- in particular, it will + * be double-quoted if it matches any lexer keyword. This behavior is + * essential for some cases, such as types "bit" and "char". */ buf = NULL; /* flag for no special case */ @@ -277,36 +276,36 @@ format_type_internal(Oid type_oid, int32 typemod, case INTERVAL_MASK(SECOND): fieldstr = " second"; break; - case INTERVAL_MASK(YEAR) - | INTERVAL_MASK(MONTH): + case INTERVAL_MASK(YEAR) + | INTERVAL_MASK(MONTH): fieldstr = " year to month"; break; - case INTERVAL_MASK(DAY) - | INTERVAL_MASK(HOUR): + case INTERVAL_MASK(DAY) + | INTERVAL_MASK(HOUR): fieldstr = " day to hour"; break; - case INTERVAL_MASK(DAY) - | INTERVAL_MASK(HOUR) - | INTERVAL_MASK(MINUTE): + case INTERVAL_MASK(DAY) + | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE): fieldstr = " day to minute"; break; - case INTERVAL_MASK(DAY) - | INTERVAL_MASK(HOUR) - | INTERVAL_MASK(MINUTE) - | INTERVAL_MASK(SECOND): + case INTERVAL_MASK(DAY) + | INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE) + | INTERVAL_MASK(SECOND): fieldstr = " day to second"; break; - case INTERVAL_MASK(HOUR) - | INTERVAL_MASK(MINUTE): + case INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE): fieldstr = " hour to minute"; break; - case INTERVAL_MASK(HOUR) - | INTERVAL_MASK(MINUTE) - | INTERVAL_MASK(SECOND): + case INTERVAL_MASK(HOUR) + | INTERVAL_MASK(MINUTE) + | INTERVAL_MASK(SECOND): fieldstr = " hour to second"; break; - case INTERVAL_MASK(MINUTE) - | INTERVAL_MASK(SECOND): + case INTERVAL_MASK(MINUTE) + | INTERVAL_MASK(SECOND): fieldstr = " minute to second"; break; case INTERVAL_FULL_RANGE: @@ -382,9 +381,9 @@ format_type_internal(Oid type_oid, int32 typemod, { /* * Default handling: report the name as it appears in the catalog. - * Here, we must qualify the name if it is not visible in the search - * path, and we must double-quote it if it's not a standard identifier - * or if it matches any keyword. + * Here, we must qualify the name if it is not visible in the + * search path, and we must double-quote it if it's not a standard + * identifier or if it matches any keyword. */ char *nspname; char *typname; @@ -518,7 +517,7 @@ oidvectortypes(PG_FUNCTION_ARGS) /* snprintf into a palloc'd string */ static char * -psnprintf(size_t len, const char *fmt, ...) +psnprintf(size_t len, const char *fmt,...) { va_list ap; char *buf; diff --git a/src/backend/utils/adt/formatting.c b/src/backend/utils/adt/formatting.c index 7d28d16001..b92a14e72a 100644 --- a/src/backend/utils/adt/formatting.c +++ b/src/backend/utils/adt/formatting.c @@ -1,7 +1,7 @@ /* ----------------------------------------------------------------------- * formatting.c * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.53 2002/04/21 19:48:12 thomas Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/formatting.c,v 1.54 2002/09/04 20:31:27 momjian Exp $ * * * Portions Copyright (c) 1999-2000, PostgreSQL Global Development Group @@ -2438,9 +2438,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) sscanf(inout, "%03d", &tmfc->year); /* - * 3-digit year: - * '100' ... '999' = 1100 ... 1999 - * '000' ... '099' = 2000 ... 2099 + * 3-digit year: '100' ... '999' = 1100 ... 1999 '000' ... + * '099' = 2000 ... 2099 */ if (tmfc->year >= 100) tmfc->year += 1000; @@ -2469,9 +2468,8 @@ dch_date(int arg, char *inout, int suf, int flag, FormatNode *node, void *data) sscanf(inout, "%02d", &tmfc->year); /* - * 2-digit year: - * '00' ... '69' = 2000 ... 2069 - * '70' ... '99' = 1970 ... 1999 + * 2-digit year: '00' ... '69' = 2000 ... 2069 '70' ... + * '99' = 1970 ... 1999 */ if (tmfc->year < 70) tmfc->year += 2000; diff --git a/src/backend/utils/adt/geo_ops.c b/src/backend/utils/adt/geo_ops.c index ec970bbcba..c19cbc42cf 100644 --- a/src/backend/utils/adt/geo_ops.c +++ b/src/backend/utils/adt/geo_ops.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.64 2002/08/29 23:05:44 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/geo_ops.c,v 1.65 2002/09/04 20:31:27 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1236,7 +1236,7 @@ path_in(PG_FUNCTION_ARGS) depth++; } - size = offsetof(PATH, p[0]) + sizeof(path->p[0]) * npts; + size = offsetof(PATH, p[0]) +sizeof(path->p[0]) * npts; path = (PATH *) palloc(size); path->size = size; @@ -2155,8 +2155,8 @@ dist_ps_internal(Point *pt, LSEG *lseg) #endif /* - * Calculate distance to the line segment - * or to the endpoints of the segment. + * Calculate distance to the line segment or to the endpoints of the + * segment. */ /* intersection is on the line segment? */ @@ -2397,9 +2397,7 @@ interpt_sl(LSEG *lseg, LINE *line) #endif } else - { p = NULL; - } } return p; @@ -3610,7 +3608,7 @@ path_add(PG_FUNCTION_ARGS) PG_RETURN_NULL(); base_size = sizeof(p1->p[0]) * (p1->npts + p2->npts); - size = offsetof(PATH, p[0]) + base_size; + size = offsetof(PATH, p[0]) +base_size; /* Check for integer overflow */ if (base_size / sizeof(p1->p[0]) != (p1->npts + p2->npts) || @@ -4436,7 +4434,7 @@ circle_poly(PG_FUNCTION_ARGS) elog(ERROR, "Unable to convert circle to polygon"); base_size = sizeof(poly->p[0]) * npts; - size = offsetof(POLYGON, p[0]) + base_size; + size = offsetof(POLYGON, p[0]) +base_size; /* Check for integer overflow */ if (base_size / npts != sizeof(poly->p[0]) || size <= base_size) diff --git a/src/backend/utils/adt/int8.c b/src/backend/utils/adt/int8.c index 33e0b41fe5..267ad82103 100644 --- a/src/backend/utils/adt/int8.c +++ b/src/backend/utils/adt/int8.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.40 2002/06/20 20:29:37 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/int8.c,v 1.41 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -70,14 +70,16 @@ int8in(PG_FUNCTION_ARGS) { ptr++; sign = -1; + /* - * Do an explicit check for INT64_MIN. Ugly though this is, it's - * cleaner than trying to get the loop below to handle it portably. + * Do an explicit check for INT64_MIN. Ugly though this is, it's + * cleaner than trying to get the loop below to handle it + * portably. */ #ifndef INT64_IS_BUSTED if (strcmp(ptr, "9223372036854775808") == 0) { - result = - INT64CONST(0x7fffffffffffffff) - 1; + result = -INT64CONST(0x7fffffffffffffff) - 1; PG_RETURN_INT64(result); } #endif diff --git a/src/backend/utils/adt/lockfuncs.c b/src/backend/utils/adt/lockfuncs.c index a5dda27f64..ba851793a3 100644 --- a/src/backend/utils/adt/lockfuncs.c +++ b/src/backend/utils/adt/lockfuncs.c @@ -2,11 +2,11 @@ * * lockfuncs.c * Set-returning functions to view the state of locks within the DB. - * + * * Copyright (c) 2002, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.6 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.7 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -33,19 +33,22 @@ typedef struct Datum pg_lock_status(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - PG_Lock_Status *mystatus; + FuncCallContext *funcctx; + PG_Lock_Status *mystatus; LockData *lockData; if (SRF_IS_FIRSTCALL()) { - TupleDesc tupdesc; - MemoryContext oldcontext; + TupleDesc tupdesc; + MemoryContext oldcontext; /* create a function context for cross-call persistence */ funcctx = SRF_FIRSTCALL_INIT(); - /* switch to memory context appropriate for multiple function calls */ + /* + * switch to memory context appropriate for multiple function + * calls + */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* build tupdesc for result tuples */ @@ -67,8 +70,8 @@ pg_lock_status(PG_FUNCTION_ARGS) funcctx->slot = TupleDescGetSlot(tupdesc); /* - * Collect all the locking information that we will format - * and send out as a result set. + * Collect all the locking information that we will format and + * send out as a result set. */ mystatus = (PG_Lock_Status *) palloc(sizeof(PG_Lock_Status)); funcctx->user_fctx = (void *) mystatus; @@ -79,25 +82,25 @@ pg_lock_status(PG_FUNCTION_ARGS) MemoryContextSwitchTo(oldcontext); } - funcctx = SRF_PERCALL_SETUP(); + funcctx = SRF_PERCALL_SETUP(); mystatus = (PG_Lock_Status *) funcctx->user_fctx; lockData = mystatus->lockData; while (mystatus->currIdx < lockData->nelements) { - PROCLOCK *holder; - LOCK *lock; - PGPROC *proc; - bool granted; - LOCKMODE mode; - Datum values[6]; - char nulls[6]; - HeapTuple tuple; - Datum result; - - holder = &(lockData->holders[mystatus->currIdx]); - lock = &(lockData->locks[mystatus->currIdx]); - proc = &(lockData->procs[mystatus->currIdx]); + PROCLOCK *holder; + LOCK *lock; + PGPROC *proc; + bool granted; + LOCKMODE mode; + Datum values[6]; + char nulls[6]; + HeapTuple tuple; + Datum result; + + holder = &(lockData->holders[mystatus->currIdx]); + lock = &(lockData->locks[mystatus->currIdx]); + proc = &(lockData->procs[mystatus->currIdx]); /* * Look to see if there are any held lock modes in this PROCLOCK. @@ -116,8 +119,8 @@ pg_lock_status(PG_FUNCTION_ARGS) } /* - * If no (more) held modes to report, see if PROC is waiting for - * a lock on this lock. + * If no (more) held modes to report, see if PROC is waiting for a + * lock on this lock. */ if (!granted) { @@ -125,6 +128,7 @@ pg_lock_status(PG_FUNCTION_ARGS) { /* Yes, so report it with proper mode */ mode = proc->waitLockMode; + /* * We are now done with this PROCLOCK, so advance pointer * to continue with next one on next call. @@ -134,8 +138,8 @@ pg_lock_status(PG_FUNCTION_ARGS) else { /* - * Okay, we've displayed all the locks associated with this - * PROCLOCK, proceed to the next one. + * Okay, we've displayed all the locks associated with + * this PROCLOCK, proceed to the next one. */ mystatus->currIdx++; continue; @@ -166,7 +170,7 @@ pg_lock_status(PG_FUNCTION_ARGS) values[3] = Int32GetDatum(proc->pid); values[4] = DirectFunctionCall1(textin, - CStringGetDatum(GetLockmodeName(mode))); + CStringGetDatum(GetLockmodeName(mode))); values[5] = BoolGetDatum(granted); tuple = heap_formtuple(funcctx->slot->ttc_tupleDescriptor, diff --git a/src/backend/utils/adt/mac.c b/src/backend/utils/adt/mac.c index c12163921d..e307542bd8 100644 --- a/src/backend/utils/adt/mac.c +++ b/src/backend/utils/adt/mac.c @@ -1,7 +1,7 @@ /* * PostgreSQL type definitions for MAC addresses. * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.25 2002/08/28 20:46:24 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/mac.c,v 1.26 2002/09/04 20:31:28 momjian Exp $ */ #include "postgres.h" @@ -81,7 +81,7 @@ macaddr_out(PG_FUNCTION_ARGS) result = (char *) palloc(32); snprintf(result, 32, "%02x:%02x:%02x:%02x:%02x:%02x", - addr->a, addr->b, addr->c, addr->d, addr->e, addr->f); + addr->a, addr->b, addr->c, addr->d, addr->e, addr->f); PG_RETURN_CSTRING(result); } diff --git a/src/backend/utils/adt/misc.c b/src/backend/utils/adt/misc.c index 363b6ca3ec..6b105fdef4 100644 --- a/src/backend/utils/adt/misc.c +++ b/src/backend/utils/adt/misc.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.26 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/misc.c,v 1.27 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -119,7 +119,7 @@ userfntest(PG_FUNCTION_ARGS) Datum current_database(PG_FUNCTION_ARGS) { - Name db; + Name db; db = (Name) palloc(NAMEDATALEN); diff --git a/src/backend/utils/adt/nabstime.c b/src/backend/utils/adt/nabstime.c index d96f5441c4..3b9c3ac272 100644 --- a/src/backend/utils/adt/nabstime.c +++ b/src/backend/utils/adt/nabstime.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.98 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/nabstime.c,v 1.99 2002/09/04 20:31:28 momjian Exp $ * * NOTES * @@ -980,8 +980,10 @@ interval_reltime(PG_FUNCTION_ARGS) RelativeTime time; int year, month; + #ifdef HAVE_INT64_TIMESTAMP int64 span; + #else double span; #endif diff --git a/src/backend/utils/adt/name.c b/src/backend/utils/adt/name.c index 41eca445f6..63ea829812 100644 --- a/src/backend/utils/adt/name.c +++ b/src/backend/utils/adt/name.c @@ -12,7 +12,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.40 2002/08/26 17:53:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/name.c,v 1.41 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,7 +51,7 @@ namein(PG_FUNCTION_ARGS) if ((ermsg = pg_verifymbstr(s, len))) elog(ERROR, "%s", ermsg); - len = pg_mbcliplen(s, len, NAMEDATALEN-1); + len = pg_mbcliplen(s, len, NAMEDATALEN - 1); result = (NameData *) palloc(NAMEDATALEN); /* always keep it null-padded */ @@ -240,8 +240,8 @@ session_user(PG_FUNCTION_ARGS) Datum current_schema(PG_FUNCTION_ARGS) { - List *search_path = fetch_search_path(false); - char *nspname; + List *search_path = fetch_search_path(false); + char *nspname; if (search_path == NIL) PG_RETURN_NULL(); @@ -252,18 +252,18 @@ current_schema(PG_FUNCTION_ARGS) Datum current_schemas(PG_FUNCTION_ARGS) { - List *search_path = fetch_search_path(PG_GETARG_BOOL(0)); - int nnames = length(search_path); - Datum *names; - int i; - ArrayType *array; + List *search_path = fetch_search_path(PG_GETARG_BOOL(0)); + int nnames = length(search_path); + Datum *names; + int i; + ArrayType *array; /* +1 here is just to avoid palloc(0) error */ names = (Datum *) palloc((nnames + 1) * sizeof(Datum)); i = 0; while (search_path) { - char *nspname; + char *nspname; nspname = get_namespace_name((Oid) lfirsti(search_path)); names[i] = DirectFunctionCall1(namein, CStringGetDatum(nspname)); @@ -273,9 +273,9 @@ current_schemas(PG_FUNCTION_ARGS) array = construct_array(names, nnames, NAMEOID, - NAMEDATALEN, /* sizeof(Name) */ - false, /* Name is not by-val */ - 'i'); /* alignment of Name */ + NAMEDATALEN, /* sizeof(Name) */ + false, /* Name is not by-val */ + 'i'); /* alignment of Name */ PG_RETURN_POINTER(array); } diff --git a/src/backend/utils/adt/not_in.c b/src/backend/utils/adt/not_in.c index 7c6be4533e..ef29e06513 100644 --- a/src/backend/utils/adt/not_in.c +++ b/src/backend/utils/adt/not_in.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.31 2002/08/02 18:15:07 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/not_in.c,v 1.32 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -60,8 +60,8 @@ int4notin(PG_FUNCTION_ARGS) nnames = length(names); if (nnames < 2) elog(ERROR, "int4notin: must provide relationname.attributename"); - attribute = strVal(nth(nnames-1, names)); - names = ltruncate(nnames-1, names); + attribute = strVal(nth(nnames - 1, names)); + names = ltruncate(nnames - 1, names); relrv = makeRangeVarFromNameList(names); /* Open the relation and get a relation descriptor */ diff --git a/src/backend/utils/adt/numeric.c b/src/backend/utils/adt/numeric.c index acbf0bff21..228c43c6c4 100644 --- a/src/backend/utils/adt/numeric.c +++ b/src/backend/utils/adt/numeric.c @@ -5,7 +5,7 @@ * * 1998 Jan Wieck * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.52 2002/09/02 02:47:04 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numeric.c,v 1.53 2002/09/04 20:31:28 momjian Exp $ * * ---------- */ @@ -152,7 +152,7 @@ static void add_var(NumericVar *var1, NumericVar *var2, NumericVar *result); static void sub_var(NumericVar *var1, NumericVar *var2, NumericVar *result); static void mul_var(NumericVar *var1, NumericVar *var2, NumericVar *result); static void div_var(NumericVar *var1, NumericVar *var2, NumericVar *result); -static int select_div_scale(NumericVar *var1, NumericVar *var2); +static int select_div_scale(NumericVar *var1, NumericVar *var2); static void mod_var(NumericVar *var1, NumericVar *var2, NumericVar *result); static void ceil_var(NumericVar *var, NumericVar *result); static void floor_var(NumericVar *var, NumericVar *result); @@ -1906,7 +1906,7 @@ numeric_variance(PG_FUNCTION_ARGS) } else { - mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */ + mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */ div_dscale = select_div_scale(&vsumX2, &vNminus1); div_var(&vsumX2, &vNminus1, &vsumX); /* variance */ vsumX.dscale = div_dscale; @@ -1985,7 +1985,7 @@ numeric_stddev(PG_FUNCTION_ARGS) } else { - mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */ + mul_var(&vN, &vNminus1, &vNminus1); /* N * (N - 1) */ div_dscale = select_div_scale(&vsumX2, &vNminus1); div_var(&vsumX2, &vNminus1, &vsumX); /* variance */ vsumX.dscale = div_dscale; diff --git a/src/backend/utils/adt/numutils.c b/src/backend/utils/adt/numutils.c index f14c10b8f5..a88330cec1 100644 --- a/src/backend/utils/adt/numutils.c +++ b/src/backend/utils/adt/numutils.c @@ -11,7 +11,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.53 2002/08/27 20:54:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/numutils.c,v 1.54 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -63,8 +63,8 @@ pg_atoi(char *s, int size, int c) errno = 0; /* - * Some versions of strtol treat the empty string as an error, but some - * seem not to. Make an explicit test to be sure we catch it. + * Some versions of strtol treat the empty string as an error, but + * some seem not to. Make an explicit test to be sure we catch it. */ if (s == (char *) NULL) diff --git a/src/backend/utils/adt/oracle_compat.c b/src/backend/utils/adt/oracle_compat.c index e71604719f..48453c4ad6 100644 --- a/src/backend/utils/adt/oracle_compat.c +++ b/src/backend/utils/adt/oracle_compat.c @@ -9,7 +9,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.42 2002/08/29 07:22:27 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/oracle_compat.c,v 1.43 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -850,8 +850,8 @@ repeat(PG_FUNCTION_ARGS) /* Check for integer overflow */ if (slen != 0 && count != 0) { - int check = count * slen; - int check2 = check + VARHDRSZ; + int check = count * slen; + int check2 = check + VARHDRSZ; if ((check / slen) != count || check2 <= check) elog(ERROR, "Requested buffer is too large."); diff --git a/src/backend/utils/adt/pg_locale.c b/src/backend/utils/adt/pg_locale.c index 33a7a105ed..3b6114542b 100644 --- a/src/backend/utils/adt/pg_locale.c +++ b/src/backend/utils/adt/pg_locale.c @@ -2,7 +2,7 @@ * * PostgreSQL locale utilities * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.18 2002/08/09 22:52:04 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_locale.c,v 1.19 2002/09/04 20:31:28 momjian Exp $ * * Portions Copyright (c) 2002, PostgreSQL Global Development Group * @@ -20,7 +20,7 @@ * * The other categories, LC_MONETARY, LC_NUMERIC, and LC_TIME are also * settable at run-time. However, we don't actually set those locale - * categories permanently. This would have bizzare effects like no + * categories permanently. This would have bizzare effects like no * longer accepting standard floating-point literals in some locales. * Instead, we only set the locales briefly when needed, cache the * required information obtained from localeconv(), and set them back. @@ -44,10 +44,10 @@ static bool CurrentLocaleConvValid = false; /* GUC storage area */ -char *locale_messages; -char *locale_monetary; -char *locale_numeric; -char *locale_time; +char *locale_messages; +char *locale_monetary; +char *locale_numeric; +char *locale_time; /* GUC assign hooks */ @@ -60,7 +60,7 @@ char *locale_time; static const char * locale_xxx_assign(int category, const char *value, bool doit, bool interactive) { - char *save; + char *save; save = setlocale(category, NULL); if (!save) @@ -104,7 +104,10 @@ locale_time_assign(const char *value, bool doit, bool interactive) const char * locale_messages_assign(const char *value, bool doit, bool interactive) { - /* LC_MESSAGES category does not exist everywhere, but accept it anyway */ + /* + * LC_MESSAGES category does not exist everywhere, but accept it + * anyway + */ #ifdef LC_MESSAGES if (doit) { @@ -113,15 +116,15 @@ locale_messages_assign(const char *value, bool doit, bool interactive) } else { - char *save; + char *save; save = setlocale(LC_MESSAGES, NULL); if (!save) return NULL; - + if (!setlocale(LC_MESSAGES, value)) return NULL; - + setlocale(LC_MESSAGES, save); } #endif @@ -161,7 +164,7 @@ lc_collate_is_c(void) * itself.) */ static void -free_struct_lconv(struct lconv *s) +free_struct_lconv(struct lconv * s) { if (s == NULL) return; diff --git a/src/backend/utils/adt/pg_lzcompress.c b/src/backend/utils/adt/pg_lzcompress.c index 49886fea54..c16e59038e 100644 --- a/src/backend/utils/adt/pg_lzcompress.c +++ b/src/backend/utils/adt/pg_lzcompress.c @@ -1,7 +1,7 @@ /* ---------- * pg_lzcompress.c - * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.14 2001/11/17 06:09:30 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pg_lzcompress.c,v 1.15 2002/09/04 20:31:28 momjian Exp $ * * This is an implementation of LZ compression for PostgreSQL. * It uses a simple history table and generates 2-3 byte tags @@ -184,7 +184,7 @@ * Local definitions * ---------- */ -#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */ +#define PGLZ_HISTORY_LISTS 8192 /* must be power of 2 */ #define PGLZ_HISTORY_MASK (PGLZ_HISTORY_LISTS - 1) #define PGLZ_HISTORY_SIZE 4096 #define PGLZ_MAX_MATCH 273 @@ -202,7 +202,7 @@ */ typedef struct PGLZ_HistEntry { - struct PGLZ_HistEntry *next; /* links for my hash key's list */ + struct PGLZ_HistEntry *next; /* links for my hash key's list */ struct PGLZ_HistEntry *prev; int hindex; /* my current hash key */ char *pos; /* my input position */ @@ -418,8 +418,8 @@ pglz_find_match(PGLZ_HistEntry **hstart, char *input, char *end, * the best so far. And if we already have a match of 16 or more * bytes, it's worth the call overhead to use memcmp() to check if * this match is equal for the same size. After that we must - * fallback to character by character comparison to know the - * exact position where the diff occured. + * fallback to character by character comparison to know the exact + * position where the diff occured. */ thislen = 0; if (len >= 16) @@ -559,9 +559,8 @@ pglz_compress(char *source, int32 slen, PGLZ_Header *dest, PGLZ_Strategy *strate good_drop = 100; /* - * Initialize the history lists to empty. We do not need to zero - * the hist_entries[] array; its entries are initialized as they - * are used. + * Initialize the history lists to empty. We do not need to zero the + * hist_entries[] array; its entries are initialized as they are used. */ memset((void *) hist_start, 0, sizeof(hist_start)); diff --git a/src/backend/utils/adt/pseudotypes.c b/src/backend/utils/adt/pseudotypes.c index 63f585fe32..b93d738be1 100644 --- a/src/backend/utils/adt/pseudotypes.c +++ b/src/backend/utils/adt/pseudotypes.c @@ -6,7 +6,7 @@ * A pseudo-type isn't really a type and never has any operations, but * we do need to supply input and output functions to satisfy the links * in the pseudo-type's entry in pg_type. In most cases the functions - * just throw an error if invoked. (XXX the error messages here cover + * just throw an error if invoked. (XXX the error messages here cover * the most common case, but might be confusing in some contexts. Can * we do better?) * @@ -16,7 +16,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.3 2002/08/26 17:53:58 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/pseudotypes.c,v 1.4 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -127,7 +127,7 @@ anyarray_out(PG_FUNCTION_ARGS) * void_in - input routine for pseudo-type VOID. * * We allow this so that PL functions can return VOID without any special - * hack in the PL handler. Whatever value the PL thinks it's returning + * hack in the PL handler. Whatever value the PL thinks it's returning * will just be ignored. */ Datum diff --git a/src/backend/utils/adt/regexp.c b/src/backend/utils/adt/regexp.c index 69d00f1850..b64d6ede65 100644 --- a/src/backend/utils/adt/regexp.c +++ b/src/backend/utils/adt/regexp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.41 2002/06/20 20:29:38 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regexp.c,v 1.42 2002/09/04 20:31:28 momjian Exp $ * * Alistair Crooks added the code for the regex caching * agc - cached the regular expressions used - there's a good chance @@ -53,7 +53,7 @@ struct cached_re_str 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 */ -static int pg_lastrec = 0; +static int pg_lastrec = 0; /* attempt to compile `re' as an re, then match it against text */ /* cflags - flag to regcomp indicates case sensitivity */ @@ -70,9 +70,9 @@ RE_compile_and_execute(text *text_re, char *text, int cflags, re = DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(text_re))); - /* Find a previously compiled regular expression. - * Run the cache as a ring buffer, starting the search - * from the previous match if any. + /* + * Find a previously compiled regular expression. Run the cache as a + * ring buffer, starting the search from the previous match if any. */ i = pg_lastrec; while (i < rec) @@ -92,19 +92,16 @@ RE_compile_and_execute(text *text_re, char *text, int cflags, } i++; - /* If we were not at the first slot to start, - * then think about wrapping if necessary. + /* + * If we were not at the first slot to start, then think about + * wrapping if necessary. */ if (pg_lastrec != 0) { if (i >= rec) - { i = 0; - } else if (i == pg_lastrec) - { break; - } } } @@ -119,9 +116,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags, } } else - { oldest = rec++; - } /* if there was an old re, then de-allocate the space it used */ if (rev[oldest].cre_s != (char *) NULL) @@ -148,6 +143,7 @@ RE_compile_and_execute(text *text_re, char *text, int cflags, if (regcomp_result == 0) { pg_lastrec = oldest; + /* * use malloc/free for the cre_s field because the storage has to * persist across transactions @@ -329,10 +325,11 @@ textregexsubstr(PG_FUNCTION_ARGS) sterm = (char *) palloc(len + 1); memcpy(sterm, VARDATA(s), len); sterm[len] = '\0'; - /* We need the match info back from the pattern match - * to be able to actually extract the substring. - * It seems to be adequate to pass in a structure to return - * only one result. + + /* + * We need the match info back from the pattern match to be able to + * actually extract the substring. It seems to be adequate to pass in + * a structure to return only one result. */ match = RE_compile_and_execute(p, sterm, REG_EXTENDED, nmatch, &pmatch); pfree(sterm); @@ -342,8 +339,8 @@ textregexsubstr(PG_FUNCTION_ARGS) { return (DirectFunctionCall3(text_substr, PointerGetDatum(s), - Int32GetDatum(pmatch.rm_so+1), - Int32GetDatum(pmatch.rm_eo-pmatch.rm_so))); + Int32GetDatum(pmatch.rm_so + 1), + Int32GetDatum(pmatch.rm_eo - pmatch.rm_so))); } PG_RETURN_NULL(); diff --git a/src/backend/utils/adt/regproc.c b/src/backend/utils/adt/regproc.c index c39d176ece..22c93c431a 100644 --- a/src/backend/utils/adt/regproc.c +++ b/src/backend/utils/adt/regproc.c @@ -13,7 +13,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.74 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/regproc.c,v 1.75 2002/09/04 20:31:28 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,8 +38,8 @@ #include "utils/syscache.h" static void parseNameAndArgTypes(const char *string, const char *caller, - bool allowNone, - List **names, int *nargs, Oid *argtypes); + bool allowNone, + List **names, int *nargs, Oid *argtypes); /***************************************************************************** @@ -87,7 +87,7 @@ regprocin(PG_FUNCTION_ARGS) /* * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_proc for a unique match. This is needed for + * and just search pg_proc for a unique match. This is needed for * initializing other system catalogs (pg_namespace may not exist yet, * and certainly there are no schemas other than pg_catalog). */ @@ -96,7 +96,7 @@ regprocin(PG_FUNCTION_ARGS) int matches = 0; Relation hdesc; ScanKeyData skey[1]; - SysScanDesc sysscan; + SysScanDesc sysscan; HeapTuple tuple; ScanKeyEntryInitialize(&skey[0], 0x0, @@ -127,8 +127,8 @@ regprocin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it - * matches any pg_proc entries in the current search path. + * Normal case: parse the name into components and see if it matches + * any pg_proc entries in the current search path. */ names = stringToQualifiedNameList(pro_name_or_oid, "regprocin"); clist = FuncnameGetCandidates(names, -1); @@ -175,17 +175,15 @@ regprocout(PG_FUNCTION_ARGS) * output anyway.) */ if (IsBootstrapProcessingMode()) - { result = pstrdup(proname); - } else { char *nspname; FuncCandidateList clist; /* - * Would this proc be found (uniquely!) by regprocin? - * If not, qualify it. + * Would this proc be found (uniquely!) by regprocin? If not, + * qualify it. */ clist = FuncnameGetCandidates(makeList1(makeString(proname)), -1); if (clist != NULL && clist->next == NULL && @@ -250,10 +248,10 @@ regprocedurein(PG_FUNCTION_ARGS) } /* - * Else it's a name and arguments. Parse the name and arguments, - * look up potential matches in the current namespace search list, - * and scan to see which one exactly matches the given argument - * types. (There will not be more than one match.) + * Else it's a name and arguments. Parse the name and arguments, look + * up potential matches in the current namespace search list, and scan + * to see which one exactly matches the given argument types. (There + * will not be more than one match.) * * XXX at present, this code will not work in bootstrap mode, hence this * datatype cannot be used for any system column that needs to receive @@ -308,8 +306,8 @@ format_procedure(Oid procedure_oid) initStringInfo(&buf); /* - * Would this proc be found (given the right args) by regprocedurein? - * If not, we need to qualify it. + * Would this proc be found (given the right args) by + * regprocedurein? If not, we need to qualify it. */ if (FunctionIsVisible(procedure_oid)) nspname = NULL; @@ -320,7 +318,7 @@ format_procedure(Oid procedure_oid) quote_qualified_identifier(nspname, proname)); for (i = 0; i < nargs; i++) { - Oid thisargtype = procform->proargtypes[i]; + Oid thisargtype = procform->proargtypes[i]; if (i > 0) appendStringInfoChar(&buf, ','); @@ -401,7 +399,7 @@ regoperin(PG_FUNCTION_ARGS) /* * In bootstrap mode we assume the given name is not schema-qualified, - * and just search pg_operator for a unique match. This is needed for + * and just search pg_operator for a unique match. This is needed for * initializing other system catalogs (pg_namespace may not exist yet, * and certainly there are no schemas other than pg_catalog). */ @@ -410,7 +408,7 @@ regoperin(PG_FUNCTION_ARGS) int matches = 0; Relation hdesc; ScanKeyData skey[1]; - SysScanDesc sysscan; + SysScanDesc sysscan; HeapTuple tuple; ScanKeyEntryInitialize(&skey[0], 0x0, @@ -441,8 +439,8 @@ regoperin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it - * matches any pg_operator entries in the current search path. + * Normal case: parse the name into components and see if it matches + * any pg_operator entries in the current search path. */ names = stringToQualifiedNameList(opr_name_or_oid, "regoperin"); clist = OpernameGetCandidates(names, '\0'); @@ -489,16 +487,14 @@ regoperout(PG_FUNCTION_ARGS) * output anyway.) */ if (IsBootstrapProcessingMode()) - { result = pstrdup(oprname); - } else { FuncCandidateList clist; /* - * Would this oper be found (uniquely!) by regoperin? - * If not, qualify it. + * Would this oper be found (uniquely!) by regoperin? If not, + * qualify it. */ clist = OpernameGetCandidates(makeList1(makeString(oprname)), '\0'); @@ -511,7 +507,7 @@ regoperout(PG_FUNCTION_ARGS) nspname = get_namespace_name(operform->oprnamespace); nspname = quote_identifier(nspname); - result = (char *) palloc(strlen(nspname)+strlen(oprname)+2); + result = (char *) palloc(strlen(nspname) + strlen(oprname) + 2); sprintf(result, "%s.%s", nspname, oprname); } } @@ -520,7 +516,10 @@ regoperout(PG_FUNCTION_ARGS) } else { - /* If OID doesn't match any pg_operator entry, return it numerically */ + /* + * If OID doesn't match any pg_operator entry, return it + * numerically + */ result = (char *) palloc(NAMEDATALEN); snprintf(result, NAMEDATALEN, "%u", oprid); } @@ -570,10 +569,10 @@ regoperatorin(PG_FUNCTION_ARGS) } /* - * Else it's a name and arguments. Parse the name and arguments, - * look up potential matches in the current namespace search list, - * and scan to see which one exactly matches the given argument - * types. (There will not be more than one match.) + * Else it's a name and arguments. Parse the name and arguments, look + * up potential matches in the current namespace search list, and scan + * to see which one exactly matches the given argument types. (There + * will not be more than one match.) * * XXX at present, this code will not work in bootstrap mode, hence this * datatype cannot be used for any system column that needs to receive @@ -637,8 +636,8 @@ format_operator(Oid operator_oid) initStringInfo(&buf); /* - * Would this oper be found (given the right args) by regoperatorin? - * If not, we need to qualify it. + * Would this oper be found (given the right args) by + * regoperatorin? If not, we need to qualify it. */ if (!OperatorIsVisible(operator_oid)) { @@ -667,7 +666,10 @@ format_operator(Oid operator_oid) } else { - /* If OID doesn't match any pg_operator entry, return it numerically */ + /* + * If OID doesn't match any pg_operator entry, return it + * numerically + */ result = (char *) palloc(NAMEDATALEN); snprintf(result, NAMEDATALEN, "%u", operator_oid); } @@ -715,12 +717,12 @@ regclassin(PG_FUNCTION_ARGS) /* Numeric OID? */ if (class_name_or_oid[0] >= '0' && class_name_or_oid[0] <= '9' && - strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) + strspn(class_name_or_oid, "0123456789") == strlen(class_name_or_oid)) { Oid searchOid; searchOid = DatumGetObjectId(DirectFunctionCall1(oidin, - CStringGetDatum(class_name_or_oid))); + CStringGetDatum(class_name_or_oid))); result = GetSysCacheOid(RELOID, ObjectIdGetDatum(searchOid), 0, 0, 0); @@ -741,7 +743,7 @@ regclassin(PG_FUNCTION_ARGS) { Relation hdesc; ScanKeyData skey[1]; - SysScanDesc sysscan; + SysScanDesc sysscan; HeapTuple tuple; ScanKeyEntryInitialize(&skey[0], 0x0, @@ -767,8 +769,8 @@ regclassin(PG_FUNCTION_ARGS) } /* - * Normal case: parse the name into components and see if it - * matches any pg_class entries in the current search path. + * Normal case: parse the name into components and see if it matches + * any pg_class entries in the current search path. */ names = stringToQualifiedNameList(class_name_or_oid, "regclassin"); @@ -808,16 +810,14 @@ regclassout(PG_FUNCTION_ARGS) * output anyway.) */ if (IsBootstrapProcessingMode()) - { result = pstrdup(classname); - } else { char *nspname; /* - * Would this class be found by regclassin? - * If not, qualify it. + * Would this class be found by regclassin? If not, qualify + * it. */ if (RelationIsVisible(classid)) nspname = NULL; @@ -894,7 +894,7 @@ regtypein(PG_FUNCTION_ARGS) { Relation hdesc; ScanKeyData skey[1]; - SysScanDesc sysscan; + SysScanDesc sysscan; HeapTuple tuple; ScanKeyEntryInitialize(&skey[0], 0x0, @@ -920,8 +920,8 @@ regtypein(PG_FUNCTION_ARGS) } /* - * Normal case: invoke the full parser to deal with special cases - * such as array syntax. + * Normal case: invoke the full parser to deal with special cases such + * as array syntax. */ parseTypeString(typ_name_or_oid, &result, &typmod); @@ -964,9 +964,7 @@ regtypeout(PG_FUNCTION_ARGS) result = pstrdup(typname); } else - { result = format_type_be(typid); - } ReleaseSysCache(typetup); } @@ -1003,7 +1001,7 @@ stringToQualifiedNameList(const char *string, const char *caller) foreach(l, namelist) { - char *curname = (char *) lfirst(l); + char *curname = (char *) lfirst(l); result = lappend(result, makeString(pstrdup(curname))); } @@ -1020,7 +1018,7 @@ stringToQualifiedNameList(const char *string, const char *caller) /* * Given a C string, parse it into a qualified function or operator name - * followed by a parenthesized list of type names. Reduce the + * followed by a parenthesized list of type names. Reduce the * type names to an array of OIDs (returned into *nargs and *argtypes; * the argtypes array should be of size FUNC_MAX_ARGS). The function or * operator name is returned to *names as a List of Strings. diff --git a/src/backend/utils/adt/ri_triggers.c b/src/backend/utils/adt/ri_triggers.c index f6d56d0d55..d66fe4d95d 100644 --- a/src/backend/utils/adt/ri_triggers.c +++ b/src/backend/utils/adt/ri_triggers.c @@ -17,7 +17,7 @@ * * Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group * - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.41 2002/09/02 06:11:42 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ri_triggers.c,v 1.42 2002/09/04 20:31:28 momjian Exp $ * * ---------- */ @@ -131,9 +131,9 @@ static void ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, Relation fk_rel, Relation pk_rel, int argc, char **argv); static void ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id, - int32 constr_queryno, - Relation pk_rel, - int argc, char **argv); + int32 constr_queryno, + Relation pk_rel, + int argc, char **argv); static bool ri_KeysEqual(Relation rel, HeapTuple oldtup, HeapTuple newtup, RI_QueryKey *key, int pairidx); static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, @@ -141,8 +141,8 @@ static bool ri_AllKeysUnequal(Relation rel, HeapTuple oldtup, HeapTuple newtup, static bool ri_OneKeyEqual(Relation rel, int column, HeapTuple oldtup, HeapTuple newtup, RI_QueryKey *key, int pairidx); static bool ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue); -static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, - Oid tgoid, int match_type, int tgnargs, char **tgargs); +static bool ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, + Oid tgoid, int match_type, int tgnargs, char **tgargs); static void ri_InitHashTables(void); static void *ri_FetchPreparedPlan(RI_QueryKey *key); @@ -205,8 +205,8 @@ RI_FKey_check(PG_FUNCTION_ARGS) * Get the relation descriptors of the FK and PK tables and the new * tuple. * - * pk_rel is opened in RowShareLock mode since that's what our - * eventual SELECT FOR UPDATE will get on it. + * pk_rel is opened in RowShareLock mode since that's what our eventual + * SELECT FOR UPDATE will get on it. */ fk_rel = trigdata->tg_relation; pk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock); @@ -223,11 +223,13 @@ RI_FKey_check(PG_FUNCTION_ARGS) /* * We should not even consider checking the row if it is no longer - * valid since it was either deleted (doesn't matter) or updated - * (in which case it'll be checked with its final values). + * valid since it was either deleted (doesn't matter) or updated (in + * which case it'll be checked with its final values). */ - if (new_row) { - if (!HeapTupleSatisfiesItself(new_row->t_data)) { + if (new_row) + { + if (!HeapTupleSatisfiesItself(new_row->t_data)) + { heap_close(pk_rel, RowShareLock); return PointerGetDatum(NULL); } @@ -263,7 +265,7 @@ RI_FKey_check(PG_FUNCTION_ARGS) */ quoteRelationName(pkrelname, pk_rel); snprintf(querystr, sizeof(querystr), "SELECT 1 FROM ONLY %s x FOR UPDATE OF x", - pkrelname); + pkrelname); /* * Prepare, save and remember the new plan. @@ -418,9 +420,9 @@ RI_FKey_check(PG_FUNCTION_ARGS) for (i = 0; i < qkey.nkeypairs; i++) { quoteOneName(attname, - tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); + tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(fk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_FK_IDX]); @@ -521,32 +523,36 @@ RI_FKey_check_upd(PG_FUNCTION_ARGS) /* ---------- * ri_Check_Pk_Match * - * Check for matching value of old pk row in current state for + * Check for matching value of old pk row in current state for * noaction triggers. Returns false if no row was found and a fk row * could potentially be referencing this row, true otherwise. * ---------- */ static bool -ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs) { - void *qplan; +ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, int tgnargs, char **tgargs) +{ + void *qplan; RI_QueryKey qkey; - bool isnull; + bool isnull; Datum check_values[RI_MAX_NUMKEYS]; char check_nulls[RI_MAX_NUMKEYS + 1]; - int i; + int i; Oid save_uid; - bool result; + bool result; + save_uid = GetUserId(); ri_BuildQueryKeyPkCheck(&qkey, tgoid, - RI_PLAN_CHECK_LOOKUPPK, pk_rel, - tgnargs, tgargs); + RI_PLAN_CHECK_LOOKUPPK, pk_rel, + tgnargs, tgargs); switch (ri_NullCheck(pk_rel, old_row, &qkey, RI_KEYPAIR_PK_IDX)) { case RI_KEYS_ALL_NULL: + /* - * No check - nothing could have been referencing this row anyway. + * No check - nothing could have been referencing this row + * anyway. */ return true; @@ -560,10 +566,10 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, { case RI_MATCH_TYPE_FULL: case RI_MATCH_TYPE_UNSPECIFIED: - + /* - * MATCH <unspecified>/FULL - if ANY column is null, we - * can't be matching to this row already. + * MATCH <unspecified>/FULL - if ANY column is null, + * we can't be matching to this row already. */ return true; @@ -619,9 +625,9 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, for (i = 0; i < qkey.nkeypairs; i++) { quoteOneName(attname, - tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); + tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_PK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -644,7 +650,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, { check_values[i] = SPI_getbinval(old_row, pk_rel->rd_att, - qkey.keypair[i][RI_KEYPAIR_PK_IDX], + qkey.keypair[i][RI_KEYPAIR_PK_IDX], &isnull); if (isnull) check_nulls[i] = 'n'; @@ -664,7 +670,7 @@ ri_Check_Pk_Match(Relation pk_rel, HeapTuple old_row, Oid tgoid, int match_type, SetUserId(save_uid); - result = (SPI_processed!=0); + result = (SPI_processed != 0); if (SPI_finish() != SPI_OK_FINISH) elog(WARNING, "SPI_finish() failed in ri_Check_Pk_Match()"); @@ -736,8 +742,8 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) * Get the relation descriptors of the FK and PK tables and the old * tuple. * - * fk_rel is opened in RowShareLock mode since that's what our - * eventual SELECT FOR UPDATE will get on it. + * fk_rel is opened in RowShareLock mode since that's what our eventual + * SELECT FOR UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock); pk_rel = trigdata->tg_relation; @@ -745,10 +751,11 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]); if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid, - match_type, tgnargs, tgargs)) { - /* - * There's either another row, or no row could match this - * one. In either case, we don't need to do the check. + match_type, tgnargs, tgargs)) + { + /* + * There's either another row, or no row could match this one. In + * either case, we don't need to do the check. */ heap_close(fk_rel, RowShareLock); return PointerGetDatum(NULL); @@ -800,7 +807,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -823,7 +830,7 @@ RI_FKey_noaction_del(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -959,8 +966,8 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) * Get the relation descriptors of the FK and PK tables and the new * and old tuple. * - * fk_rel is opened in RowShareLock mode since that's what our - * eventual SELECT FOR UPDATE will get on it. + * fk_rel is opened in RowShareLock mode since that's what our eventual + * SELECT FOR UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock); pk_rel = trigdata->tg_relation; @@ -969,10 +976,11 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) match_type = ri_DetermineMatchType(tgargs[RI_MATCH_TYPE_ARGNO]); if (ri_Check_Pk_Match(pk_rel, old_row, trigdata->tg_trigger->tgoid, - match_type, tgnargs, tgargs)) { - /* - * There's either another row, or no row could match this - * one. In either case, we don't need to do the check. + match_type, tgnargs, tgargs)) + { + /* + * There's either another row, or no row could match this one. In + * either case, we don't need to do the check. */ heap_close(fk_rel, RowShareLock); return PointerGetDatum(NULL); @@ -1034,7 +1042,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1057,7 +1065,7 @@ RI_FKey_noaction_upd(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -1241,7 +1249,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1264,7 +1272,7 @@ RI_FKey_cascade_del(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -1455,7 +1463,7 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -1483,9 +1491,9 @@ RI_FKey_cascade_upd(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d", - qualsep, attname, j+1); + qualsep, attname, j + 1); querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, @@ -1628,8 +1636,8 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) * Get the relation descriptors of the FK and PK tables and the old * tuple. * - * fk_rel is opened in RowShareLock mode since that's what our - * eventual SELECT FOR UPDATE will get on it. + * fk_rel is opened in RowShareLock mode since that's what our eventual + * SELECT FOR UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock); pk_rel = trigdata->tg_relation; @@ -1682,7 +1690,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1705,7 +1713,7 @@ RI_FKey_restrict_del(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -1845,8 +1853,8 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) * Get the relation descriptors of the FK and PK tables and the new * and old tuple. * - * fk_rel is opened in RowShareLock mode since that's what our - * eventual SELECT FOR UPDATE will get on it. + * fk_rel is opened in RowShareLock mode since that's what our eventual + * SELECT FOR UPDATE will get on it. */ fk_rel = heap_open(trigdata->tg_trigger->tgconstrrelid, RowShareLock); pk_rel = trigdata->tg_relation; @@ -1910,7 +1918,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; const char *querysep; @@ -1933,7 +1941,7 @@ RI_FKey_restrict_upd(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), " %s %s = $%d", - querysep, attname, i+1); + querysep, attname, i + 1); querysep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -2121,7 +2129,7 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) if ((qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2149,9 +2157,9 @@ RI_FKey_setnull_del(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL", - querysep, attname); + querysep, attname); snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d", - qualsep, attname, i+1); + qualsep, attname, i + 1); querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, @@ -2365,7 +2373,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) (qplan = ri_FetchPreparedPlan(&qkey)) == NULL) { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2392,6 +2400,7 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) { quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); + /* * MATCH <unspecified> - only change columns * corresponding to changed columns in pk_rel's key @@ -2401,11 +2410,11 @@ RI_FKey_setnull_upd(PG_FUNCTION_ARGS) RI_KEYPAIR_PK_IDX)) { snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL", - querysep, attname); + querysep, attname); querysep = ","; } snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d", - qualsep, attname, i+1); + qualsep, attname, i + 1); qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -2592,7 +2601,7 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) */ { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2625,9 +2634,9 @@ RI_FKey_setdefault_del(PG_FUNCTION_ARGS) quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL", - querysep, attname); + querysep, attname); snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d", - qualsep, attname, i+1); + qualsep, attname, i + 1); querysep = ","; qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, @@ -2861,7 +2870,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) */ { char querystr[MAX_QUOTED_REL_NAME_LEN + 100 + - (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; + (MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS * 2]; char qualstr[(MAX_QUOTED_NAME_LEN + 32) * RI_MAX_NUMKEYS]; char fkrelname[MAX_QUOTED_REL_NAME_LEN]; char attname[MAX_QUOTED_NAME_LEN]; @@ -2893,6 +2902,7 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) { quoteOneName(attname, tgargs[RI_FIRST_ATTNAME_ARGNO + i * 2 + RI_KEYPAIR_FK_IDX]); + /* * MATCH <unspecified> - only change columns * corresponding to changed columns in pk_rel's key @@ -2902,11 +2912,11 @@ RI_FKey_setdefault_upd(PG_FUNCTION_ARGS) new_row, &qkey, RI_KEYPAIR_PK_IDX)) { snprintf(querystr + strlen(querystr), sizeof(querystr) - strlen(querystr), "%s %s = NULL", - querysep, attname); + querysep, attname); querysep = ","; } snprintf(qualstr + strlen(qualstr), sizeof(qualstr) - strlen(qualstr), " %s %s = $%d", - qualsep, attname, i+1); + qualsep, attname, i + 1); qualsep = "AND"; queryoids[i] = SPI_gettypeid(pk_rel->rd_att, qkey.keypair[i][RI_KEYPAIR_PK_IDX]); @@ -3245,8 +3255,8 @@ ri_BuildQueryKeyFull(RI_QueryKey *key, Oid constr_id, int32 constr_queryno, */ static void ri_BuildQueryKeyPkCheck(RI_QueryKey *key, Oid constr_id, int32 constr_queryno, - Relation pk_rel, - int argc, char **argv) + Relation pk_rel, + int argc, char **argv) { int i; int j; @@ -3588,7 +3598,7 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) typeid, typeid, true); if (!OidIsValid(opr_proc)) elog(ERROR, - "ri_AttributesEqual(): cannot find '=' operator for type %u", + "ri_AttributesEqual(): cannot find '=' operator for type %u", typeid); /* @@ -3616,4 +3626,3 @@ ri_AttributesEqual(Oid typeid, Datum oldvalue, Datum newvalue) return DatumGetBool(FunctionCall2(&(entry->oprfmgrinfo), oldvalue, newvalue)); } - diff --git a/src/backend/utils/adt/ruleutils.c b/src/backend/utils/adt/ruleutils.c index c7da14ad7e..740dde36dd 100644 --- a/src/backend/utils/adt/ruleutils.c +++ b/src/backend/utils/adt/ruleutils.c @@ -3,7 +3,7 @@ * back to source text * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.120 2002/08/31 22:10:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/ruleutils.c,v 1.121 2002/09/04 20:31:28 momjian Exp $ * * This software is copyrighted by Jan Wieck - Hamburg. * @@ -124,29 +124,29 @@ static char *query_getviewrule = "SELECT * FROM pg_catalog.pg_rewrite WHERE ev_c */ static text *pg_do_getviewdef(Oid viewoid); static void decompile_column_index_array(Datum column_index_array, Oid relId, - StringInfo buf); + StringInfo buf); static void make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc); static void make_viewdef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc); static void get_query_def(Query *query, StringInfo buf, List *parentnamespace, - TupleDesc resultDesc); + TupleDesc resultDesc); static void get_select_query_def(Query *query, deparse_context *context, - TupleDesc resultDesc); + TupleDesc resultDesc); static void get_insert_query_def(Query *query, deparse_context *context); static void get_update_query_def(Query *query, deparse_context *context); static void get_delete_query_def(Query *query, deparse_context *context); static void get_utility_query_def(Query *query, deparse_context *context); static void get_basic_select_query(Query *query, deparse_context *context, - TupleDesc resultDesc); + TupleDesc resultDesc); static void get_setop_query(Node *setOp, Query *query, - deparse_context *context, - TupleDesc resultDesc); + deparse_context *context, + TupleDesc resultDesc); static Node *get_rule_sortgroupclause(SortClause *srt, List *tlist, bool force_colno, deparse_context *context); static void get_names_for_var(Var *var, deparse_context *context, char **schemaname, char **refname, char **attname); static RangeTblEntry *find_rte_by_refname(const char *refname, - deparse_context *context); + deparse_context *context); static void get_rule_expr(Node *node, deparse_context *context); static void get_oper_expr(Expr *expr, deparse_context *context); static void get_func_expr(Expr *expr, deparse_context *context); @@ -159,7 +159,7 @@ static void get_from_clause(Query *query, deparse_context *context); static void get_from_clause_item(Node *jtnode, Query *query, deparse_context *context); static void get_from_clause_coldeflist(List *coldeflist, - deparse_context *context); + deparse_context *context); static void get_opclass_name(Oid opclass, Oid actual_datatype, StringInfo buf); static bool tleIsArrayAssign(TargetEntry *tle); @@ -284,7 +284,7 @@ pg_get_viewdef_name(PG_FUNCTION_ARGS) text *ruledef; viewrel = makeRangeVarFromNameList(textToQualifiedNameList(viewname, - "get_viewdef")); + "get_viewdef")); viewoid = RangeVarGetRelid(viewrel, false); ruledef = pg_do_getviewdef(viewoid); @@ -425,8 +425,8 @@ pg_get_indexdef(PG_FUNCTION_ARGS) amrec = (Form_pg_am) GETSTRUCT(ht_am); /* - * Start the index definition. Note that the index's name should never - * be schema-qualified, but the indexed rel's name may be. + * Start the index definition. Note that the index's name should + * never be schema-qualified, but the indexed rel's name may be. */ initStringInfo(&buf); appendStringInfo(&buf, "CREATE %sINDEX %s ON %s USING %s (", @@ -551,15 +551,15 @@ pg_get_indexdef(PG_FUNCTION_ARGS) Datum pg_get_constraintdef(PG_FUNCTION_ARGS) { - Oid constraintId = PG_GETARG_OID(0); - text *result; - StringInfoData buf; - int len; - Relation conDesc; - SysScanDesc conscan; - ScanKeyData skey[1]; - HeapTuple tup; - Form_pg_constraint conForm; + Oid constraintId = PG_GETARG_OID(0); + text *result; + StringInfoData buf; + int len; + Relation conDesc; + SysScanDesc conscan; + ScanKeyData skey[1]; + HeapTuple tup; + Form_pg_constraint conForm; /* * Fetch the pg_constraint row. There's no syscache for pg_constraint @@ -584,111 +584,111 @@ pg_get_constraintdef(PG_FUNCTION_ARGS) switch (conForm->contype) { case CONSTRAINT_FOREIGN: - { - Datum val; - bool isnull; - const char *string; + { + Datum val; + bool isnull; + const char *string; - /* Start off the constraint definition */ - appendStringInfo(&buf, "FOREIGN KEY ("); + /* Start off the constraint definition */ + appendStringInfo(&buf, "FOREIGN KEY ("); - /* Fetch and build referencing-column list */ - val = heap_getattr(tup, Anum_pg_constraint_conkey, - RelationGetDescr(conDesc), &isnull); - if (isnull) - elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u", - constraintId); + /* Fetch and build referencing-column list */ + val = heap_getattr(tup, Anum_pg_constraint_conkey, + RelationGetDescr(conDesc), &isnull); + if (isnull) + elog(ERROR, "pg_get_constraintdef: Null conkey for constraint %u", + constraintId); - decompile_column_index_array(val, conForm->conrelid, &buf); + decompile_column_index_array(val, conForm->conrelid, &buf); - /* add foreign relation name */ - appendStringInfo(&buf, ") REFERENCES %s(", + /* add foreign relation name */ + appendStringInfo(&buf, ") REFERENCES %s(", generate_relation_name(conForm->confrelid)); - /* Fetch and build referenced-column list */ - val = heap_getattr(tup, Anum_pg_constraint_confkey, - RelationGetDescr(conDesc), &isnull); - if (isnull) - elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u", - constraintId); + /* Fetch and build referenced-column list */ + val = heap_getattr(tup, Anum_pg_constraint_confkey, + RelationGetDescr(conDesc), &isnull); + if (isnull) + elog(ERROR, "pg_get_constraintdef: Null confkey for constraint %u", + constraintId); - decompile_column_index_array(val, conForm->confrelid, &buf); + decompile_column_index_array(val, conForm->confrelid, &buf); - appendStringInfo(&buf, ")"); + appendStringInfo(&buf, ")"); - /* Add match type */ - switch (conForm->confmatchtype) - { - case FKCONSTR_MATCH_FULL: - string = " MATCH FULL"; - break; - case FKCONSTR_MATCH_PARTIAL: - string = " MATCH PARTIAL"; - break; - case FKCONSTR_MATCH_UNSPECIFIED: - string = ""; - break; - default: - elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u", - conForm->confmatchtype, constraintId); - string = ""; /* keep compiler quiet */ - break; - } - appendStringInfo(&buf, "%s", string); + /* Add match type */ + switch (conForm->confmatchtype) + { + case FKCONSTR_MATCH_FULL: + string = " MATCH FULL"; + break; + case FKCONSTR_MATCH_PARTIAL: + string = " MATCH PARTIAL"; + break; + case FKCONSTR_MATCH_UNSPECIFIED: + string = ""; + break; + default: + elog(ERROR, "pg_get_constraintdef: Unknown confmatchtype '%c' for constraint %u", + conForm->confmatchtype, constraintId); + string = ""; /* keep compiler quiet */ + break; + } + appendStringInfo(&buf, "%s", string); - /* Add ON UPDATE and ON DELETE clauses */ - switch (conForm->confupdtype) - { - case FKCONSTR_ACTION_NOACTION: - string = "NO ACTION"; - break; - case FKCONSTR_ACTION_RESTRICT: - string = "RESTRICT"; - break; - case FKCONSTR_ACTION_CASCADE: - string = "CASCADE"; - break; - case FKCONSTR_ACTION_SETNULL: - string = "SET NULL"; - break; - case FKCONSTR_ACTION_SETDEFAULT: - string = "SET DEFAULT"; - break; - default: - elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u", - conForm->confupdtype, constraintId); - string = ""; /* keep compiler quiet */ - break; - } - appendStringInfo(&buf, " ON UPDATE %s", string); + /* Add ON UPDATE and ON DELETE clauses */ + switch (conForm->confupdtype) + { + case FKCONSTR_ACTION_NOACTION: + string = "NO ACTION"; + break; + case FKCONSTR_ACTION_RESTRICT: + string = "RESTRICT"; + break; + case FKCONSTR_ACTION_CASCADE: + string = "CASCADE"; + break; + case FKCONSTR_ACTION_SETNULL: + string = "SET NULL"; + break; + case FKCONSTR_ACTION_SETDEFAULT: + string = "SET DEFAULT"; + break; + default: + elog(ERROR, "pg_get_constraintdef: Unknown confupdtype '%c' for constraint %u", + conForm->confupdtype, constraintId); + string = ""; /* keep compiler quiet */ + break; + } + appendStringInfo(&buf, " ON UPDATE %s", string); - switch (conForm->confdeltype) - { - case FKCONSTR_ACTION_NOACTION: - string = "NO ACTION"; - break; - case FKCONSTR_ACTION_RESTRICT: - string = "RESTRICT"; - break; - case FKCONSTR_ACTION_CASCADE: - string = "CASCADE"; - break; - case FKCONSTR_ACTION_SETNULL: - string = "SET NULL"; - break; - case FKCONSTR_ACTION_SETDEFAULT: - string = "SET DEFAULT"; - break; - default: - elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u", - conForm->confdeltype, constraintId); - string = ""; /* keep compiler quiet */ - break; - } - appendStringInfo(&buf, " ON DELETE %s", string); + switch (conForm->confdeltype) + { + case FKCONSTR_ACTION_NOACTION: + string = "NO ACTION"; + break; + case FKCONSTR_ACTION_RESTRICT: + string = "RESTRICT"; + break; + case FKCONSTR_ACTION_CASCADE: + string = "CASCADE"; + break; + case FKCONSTR_ACTION_SETNULL: + string = "SET NULL"; + break; + case FKCONSTR_ACTION_SETDEFAULT: + string = "SET DEFAULT"; + break; + default: + elog(ERROR, "pg_get_constraintdef: Unknown confdeltype '%c' for constraint %u", + conForm->confdeltype, constraintId); + string = ""; /* keep compiler quiet */ + break; + } + appendStringInfo(&buf, " ON DELETE %s", string); - break; - } + break; + } /* * XXX Add more code here for other contypes @@ -735,7 +735,7 @@ decompile_column_index_array(Datum column_index_array, Oid relId, { char *colName; - colName = get_attname(relId, DatumGetInt16(keys[j])); + colName = get_attname(relId, DatumGetInt16(keys[j])); if (j == 0) appendStringInfo(buf, "%s", @@ -875,7 +875,7 @@ deparse_expression(Node *expr, List *dpcontext, bool forceprefix) * * Given the reference name (alias) and OID of a relation, build deparsing * context for an expression referencing only that relation (as varno 1, - * varlevelsup 0). This is sufficient for many uses of deparse_expression. + * varlevelsup 0). This is sufficient for many uses of deparse_expression. * ---------- */ List * @@ -972,7 +972,7 @@ deparse_context_for_subplan(const char *name, List *tlist, foreach(tl, tlist) { TargetEntry *tle = lfirst(tl); - Resdom *resdom = tle->resdom; + Resdom *resdom = tle->resdom; nattrs++; Assert(resdom->resno == nattrs); @@ -983,13 +983,13 @@ deparse_context_for_subplan(const char *name, List *tlist, } if (tle->expr && IsA(tle->expr, Var)) { - Var *var = (Var *) tle->expr; + Var *var = (Var *) tle->expr; /* varno/varattno won't be any good, but varnoold might be */ if (var->varnoold > 0 && var->varnoold <= rtablelength) { RangeTblEntry *varrte = rt_fetch(var->varnoold, rtable); - char *varname; + char *varname; varname = get_rte_attribute_name(varrte, var->varoattno); attrs = lappend(attrs, makeString(varname)); @@ -1001,7 +1001,7 @@ deparse_context_for_subplan(const char *name, List *tlist, attrs = lappend(attrs, makeString(pstrdup(buf))); } - rte->rtekind = RTE_SPECIAL; /* XXX */ + rte->rtekind = RTE_SPECIAL; /* XXX */ rte->relid = InvalidOid; rte->eref = makeAlias(name, attrs); rte->inh = false; @@ -1127,9 +1127,9 @@ make_ruledef(StringInfo buf, HeapTuple ruletup, TupleDesc rulettc) query = (Query *) lfirst(actions); /* - * If the action is INSERT...SELECT, OLD/NEW have been pushed - * down into the SELECT, and that's what we need to look at. - * (Ugly kluge ... try to fix this when we redesign querytrees.) + * If the action is INSERT...SELECT, OLD/NEW have been pushed down + * into the SELECT, and that's what we need to look at. (Ugly + * kluge ... try to fix this when we redesign querytrees.) */ query = getInsertSelectQuery(query, NULL); @@ -1434,13 +1434,13 @@ get_basic_select_query(Query *query, deparse_context *context, get_rule_expr(tle->expr, context); /* - * Figure out what the result column should be called. In the + * Figure out what the result column should be called. In the * context of a view, use the view's tuple descriptor (so as to - * pick up the effects of any column RENAME that's been done on the - * view). Otherwise, just use what we can find in the TLE. + * pick up the effects of any column RENAME that's been done on + * the view). Otherwise, just use what we can find in the TLE. */ if (resultDesc && colno <= resultDesc->natts) - colname = NameStr(resultDesc->attrs[colno-1]->attname); + colname = NameStr(resultDesc->attrs[colno - 1]->attname); else colname = tle->resdom->resname; @@ -1751,8 +1751,8 @@ get_utility_query_def(Query *query, deparse_context *context) NotifyStmt *stmt = (NotifyStmt *) query->utilityStmt; appendStringInfo(buf, "NOTIFY %s", - quote_qualified_identifier(stmt->relation->schemaname, - stmt->relation->relname)); + quote_qualified_identifier(stmt->relation->schemaname, + stmt->relation->relname)); } else elog(ERROR, "get_utility_query_def: unexpected statement type"); @@ -1762,7 +1762,7 @@ get_utility_query_def(Query *query, deparse_context *context) /* * Get the schemaname, refname and attname for a (possibly nonlocal) Var. * - * schemaname is usually returned as NULL. It will be non-null only if + * schemaname is usually returned as NULL. It will be non-null only if * use of the unqualified refname would find the wrong RTE. * * refname will be returned as NULL if the Var references an unnamed join. @@ -1813,9 +1813,10 @@ get_names_for_var(Var *var, deparse_context *context, if (rte->rtekind == RTE_RELATION) { /* - * It's possible that use of the bare refname would find another - * more-closely-nested RTE, or be ambiguous, in which case - * we need to specify the schemaname to avoid these errors. + * It's possible that use of the bare refname would find + * another more-closely-nested RTE, or be ambiguous, in which + * case we need to specify the schemaname to avoid these + * errors. */ if (find_rte_by_refname(rte->eref->aliasname, context) != rte) *schemaname = @@ -1864,7 +1865,7 @@ find_rte_by_refname(const char *refname, deparse_context *context) if (strcmp(rte->eref->aliasname, refname) == 0) { if (result) - return NULL; /* it's ambiguous */ + return NULL; /* it's ambiguous */ result = rte; } } @@ -1964,8 +1965,8 @@ get_rule_expr(Node *node, deparse_context *context) Assert(length(args) == 2); { /* binary operator */ - Node *arg1 = (Node *) lfirst(args); - Node *arg2 = (Node *) lsecond(args); + Node *arg1 = (Node *) lfirst(args); + Node *arg2 = (Node *) lsecond(args); get_rule_expr(arg1, context); appendStringInfo(buf, " IS DISTINCT FROM "); @@ -2007,10 +2008,11 @@ get_rule_expr(Node *node, deparse_context *context) break; case SUBPLAN_EXPR: + /* - * We cannot see an already-planned subplan in rule - * deparsing, only while EXPLAINing a query plan. - * For now, just punt. + * We cannot see an already-planned subplan in + * rule deparsing, only while EXPLAINing a query + * plan. For now, just punt. */ appendStringInfo(buf, "(subplan)"); break; @@ -2089,6 +2091,7 @@ get_rule_expr(Node *node, deparse_context *context) ReleaseSysCache(typetup); fieldname = get_relid_attribute_name(typrelid, fselect->fieldnum); + /* * If the argument is simple enough, we could emit * arg.fieldname, but most cases where FieldSelect is used @@ -2108,7 +2111,7 @@ get_rule_expr(Node *node, deparse_context *context) get_rule_expr(relabel->arg, context); appendStringInfo(buf, ")::%s", format_type_with_typemod(relabel->resulttype, - relabel->resulttypmod)); + relabel->resulttypmod)); } break; @@ -2246,8 +2249,8 @@ get_oper_expr(Expr *expr, deparse_context *context) if (length(args) == 2) { /* binary operator */ - Node *arg1 = (Node *) lfirst(args); - Node *arg2 = (Node *) lsecond(args); + Node *arg1 = (Node *) lfirst(args); + Node *arg2 = (Node *) lsecond(args); get_rule_expr(arg1, context); appendStringInfo(buf, " %s ", @@ -2332,9 +2335,9 @@ get_func_expr(Expr *expr, deparse_context *context) /* * Show typename with appropriate length decoration. Note that * since exprIsLengthCoercion succeeded, the function's output - * type is the right thing to report. Also note we don't need - * to quote the result of format_type_with_typemod: it takes - * care of double-quoting any identifier that needs it. + * type is the right thing to report. Also note we don't need to + * quote the result of format_type_with_typemod: it takes care of + * double-quoting any identifier that needs it. */ typdesc = format_type_with_typemod(rettype, coercedTypmod); appendStringInfo(buf, ")::%s", typdesc); @@ -2344,8 +2347,8 @@ get_func_expr(Expr *expr, deparse_context *context) } /* - * Normal function: display as proname(args). First we need to extract - * the argument datatypes. + * Normal function: display as proname(args). First we need to + * extract the argument datatypes. */ nargs = 0; foreach(l, expr->args) @@ -2354,7 +2357,7 @@ get_func_expr(Expr *expr, deparse_context *context) argtypes[nargs] = exprType((Node *) lfirst(l)); nargs++; } - + appendStringInfo(buf, "%s(", generate_function_name(funcoid, nargs, argtypes)); @@ -2378,7 +2381,7 @@ get_agg_expr(Aggref *aggref, deparse_context *context) Oid argtype = exprType(aggref->target); appendStringInfo(buf, "%s(%s", - generate_function_name(aggref->aggfnoid, 1, &argtype), + generate_function_name(aggref->aggfnoid, 1, &argtype), aggref->aggdistinct ? "DISTINCT " : ""); if (aggref->aggstar) appendStringInfo(buf, "*"); @@ -2438,8 +2441,8 @@ strip_type_coercion(Node *expr, Oid resultType) } /* See if function has is actually declared as a cast */ castTuple = SearchSysCache(CASTSOURCETARGET, - ObjectIdGetDatum(procStruct->proargtypes[0]), - ObjectIdGetDatum(procStruct->prorettype), + ObjectIdGetDatum(procStruct->proargtypes[0]), + ObjectIdGetDatum(procStruct->prorettype), 0, 0); if (!HeapTupleIsValid(castTuple)) { @@ -2519,11 +2522,11 @@ get_const_expr(Const *constval, deparse_context *context) if (constval->constisnull) { /* - * Always label the type of a NULL constant to prevent misdecisions - * about type when reparsing. + * Always label the type of a NULL constant to prevent + * misdecisions about type when reparsing. */ appendStringInfo(buf, "NULL::%s", - format_type_with_typemod(constval->consttype, -1)); + format_type_with_typemod(constval->consttype, -1)); return; } @@ -2549,23 +2552,23 @@ get_const_expr(Const *constval, deparse_context *context) case FLOAT4OID: case FLOAT8OID: case NUMERICOID: - { - /* - * These types are printed without quotes unless they - * contain values that aren't accepted by the scanner - * unquoted (e.g., 'NaN'). Note that strtod() and friends - * might accept NaN, so we can't use that to test. - * - * In reality we only need to defend against infinity and - * NaN, so we need not get too crazy about pattern - * matching here. - */ - if (strspn(extval, "0123456789 +-eE.") == strlen(extval)) - appendStringInfo(buf, extval); - else - appendStringInfo(buf, "'%s'", extval); - } - break; + { + /* + * These types are printed without quotes unless they + * contain values that aren't accepted by the scanner + * unquoted (e.g., 'NaN'). Note that strtod() and friends + * might accept NaN, so we can't use that to test. + * + * In reality we only need to defend against infinity and + * NaN, so we need not get too crazy about pattern + * matching here. + */ + if (strspn(extval, "0123456789 +-eE.") == strlen(extval)) + appendStringInfo(buf, extval); + else + appendStringInfo(buf, "'%s'", extval); + } + break; case BITOID: case VARBITOID: @@ -2573,13 +2576,14 @@ get_const_expr(Const *constval, deparse_context *context) break; case BOOLOID: - if (strcmp(extval, "t")==0) + if (strcmp(extval, "t") == 0) appendStringInfo(buf, "true"); else appendStringInfo(buf, "false"); break; default: + /* * We must quote any funny characters in the constant's * representation. XXX Any MULTIBYTE considerations here? @@ -2665,9 +2669,10 @@ get_sublink_expr(Node *node, deparse_context *context) /* * XXX we assume here that we can get away without qualifying the - * operator name. Since the name may imply multiple physical operators - * it's rather difficult to do otherwise --- in fact, if the operators - * are in different namespaces any attempt to qualify would surely fail. + * operator name. Since the name may imply multiple physical + * operators it's rather difficult to do otherwise --- in fact, if the + * operators are in different namespaces any attempt to qualify would + * surely fail. */ switch (sublink->subLinkType) { @@ -2812,13 +2817,13 @@ get_from_clause_item(Node *jtnode, Query *query, deparse_context *context) } } else if (rte->rtekind == RTE_RELATION && - strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0) + strcmp(rte->eref->aliasname, get_rel_name(rte->relid)) != 0) { /* - * Apparently the rel has been renamed since the rule was made. - * Emit a fake alias clause so that variable references will - * still work. This is not a 100% solution but should work in - * most reasonable situations. + * Apparently the rel has been renamed since the rule was + * made. Emit a fake alias clause so that variable references + * will still work. This is not a 100% solution but should + * work in most reasonable situations. */ appendStringInfo(buf, " %s", quote_identifier(rte->eref->aliasname)); @@ -2981,7 +2986,7 @@ get_opclass_name(Oid opclass, Oid actual_datatype, opcrec = (Form_pg_opclass) GETSTRUCT(ht_opc); if (actual_datatype != opcrec->opcintype || !opcrec->opcdefault) { - /* Okay, we need the opclass name. Do we need to qualify it? */ + /* Okay, we need the opclass name. Do we need to qualify it? */ opcname = NameStr(opcrec->opcname); if (OpclassIsVisible(opclass)) appendStringInfo(buf, " %s", quote_identifier(opcname)); @@ -3031,9 +3036,10 @@ const char * quote_identifier(const char *ident) { /* - * Can avoid quoting if ident starts with a lowercase letter or underscore - * and contains only lowercase letters, digits, and underscores, *and* is - * not any SQL keyword. Otherwise, supply quotes. + * Can avoid quoting if ident starts with a lowercase letter or + * underscore and contains only lowercase letters, digits, and + * underscores, *and* is not any SQL keyword. Otherwise, supply + * quotes. */ int nquotes = 0; bool safe; @@ -3187,8 +3193,8 @@ generate_function_name(Oid funcid, int nargs, Oid *argtypes) /* * The idea here is to schema-qualify only if the parser would fail to - * resolve the correct function given the unqualified func name - * with the specified argtypes. + * resolve the correct function given the unqualified func name with + * the specified argtypes. */ p_result = func_get_detail(makeList1(makeString(proname)), NIL, nargs, argtypes, @@ -3239,8 +3245,8 @@ generate_operator_name(Oid operid, Oid arg1, Oid arg2) /* * The idea here is to schema-qualify only if the parser would fail to - * resolve the correct operator given the unqualified op name - * with the specified argtypes. + * resolve the correct operator given the unqualified op name with the + * specified argtypes. */ switch (operform->oprkind) { diff --git a/src/backend/utils/adt/selfuncs.c b/src/backend/utils/adt/selfuncs.c index 44037b1a37..c5a7b33b67 100644 --- a/src/backend/utils/adt/selfuncs.c +++ b/src/backend/utils/adt/selfuncs.c @@ -15,7 +15,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.116 2002/09/03 21:45:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/selfuncs.c,v 1.117 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -855,9 +855,12 @@ patternsel(PG_FUNCTION_ARGS, Pattern_Type ptype) return 0.0; constval = ((Const *) other)->constvalue; - /* the right-hand const is type text or bytea for all supported operators */ + /* + * the right-hand const is type text or bytea for all supported + * operators + */ Assert(((Const *) other)->consttype == TEXTOID || - ((Const *) other)->consttype == BYTEAOID); + ((Const *) other)->consttype == BYTEAOID); /* divide pattern into fixed prefix and remainder */ patt = (Const *) other; @@ -1860,11 +1863,12 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max) get_typlenbyval(var->vartype, &typLen, &typByVal); /* - * If there is a histogram, grab the last or first value as appropriate. + * If there is a histogram, grab the last or first value as + * appropriate. * - * If there is a histogram that is sorted with some other operator - * than the one we want, fail --- this suggests that there is data - * we can't use. + * If there is a histogram that is sorted with some other operator than + * the one we want, fail --- this suggests that there is data we can't + * use. */ if (get_attstatsslot(statsTuple, var->vartype, var->vartypmod, STATISTIC_KIND_HISTOGRAM, sortop, @@ -1873,14 +1877,14 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max) { if (nvalues > 0) { - tmax = datumCopy(values[nvalues-1], typByVal, typLen); + tmax = datumCopy(values[nvalues - 1], typByVal, typLen); have_max = true; } free_attstatsslot(var->vartype, values, nvalues, NULL, 0); } else { - Oid rsortop = get_commutator(sortop); + Oid rsortop = get_commutator(sortop); if (OidIsValid(rsortop) && get_attstatsslot(statsTuple, var->vartype, var->vartypmod, @@ -1907,8 +1911,8 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max) } /* - * If we have most-common-values info, look for a large MCV. This - * is needed even if we also have a histogram, since the histogram + * If we have most-common-values info, look for a large MCV. This is + * needed even if we also have a histogram, since the histogram * excludes the MCVs. However, usually the MCVs will not be the * extreme values, so avoid unnecessary data copying. */ @@ -1917,7 +1921,7 @@ get_var_maximum(Query *root, Var *var, Oid sortop, Datum *max) &values, &nvalues, NULL, NULL)) { - bool large_mcv = false; + bool large_mcv = false; FmgrInfo opproc; fmgr_info(get_opcode(sortop), &opproc); @@ -2724,7 +2728,7 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, patt = DatumGetCString(DirectFunctionCall1(byteaout, patt_const->constvalue)); pattlen = toast_raw_datum_size(patt_const->constvalue) - VARHDRSZ; } - + prefix = match = palloc(pattlen + 1); match_pos = 0; @@ -2760,8 +2764,8 @@ like_fixed_prefix(Const *patt_const, bool case_insensitive, match[match_pos] = '\0'; rest = &patt[pos]; - *prefix_const = string_to_const(prefix, typeid); - *rest_const = string_to_const(rest, typeid); + *prefix_const = string_to_const(prefix, typeid); + *rest_const = string_to_const(rest, typeid); pfree(patt); pfree(match); @@ -2807,8 +2811,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, { rest = patt; - *prefix_const = NULL; - *rest_const = string_to_const(rest, typeid); + *prefix_const = NULL; + *rest_const = string_to_const(rest, typeid); return Pattern_Prefix_None; } @@ -2824,8 +2828,8 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, { rest = patt; - *prefix_const = NULL; - *rest_const = string_to_const(rest, typeid); + *prefix_const = NULL; + *rest_const = string_to_const(rest, typeid); return Pattern_Prefix_None; } @@ -2898,14 +2902,14 @@ regex_fixed_prefix(Const *patt_const, bool case_insensitive, { rest = &patt[pos + 1]; - *prefix_const = string_to_const(prefix, typeid); - *rest_const = string_to_const(rest, typeid); + *prefix_const = string_to_const(prefix, typeid); + *rest_const = string_to_const(rest, typeid); return Pattern_Prefix_Exact; /* pattern specifies exact match */ } - *prefix_const = string_to_const(prefix, typeid); - *rest_const = string_to_const(rest, typeid); + *prefix_const = string_to_const(prefix, typeid); + *rest_const = string_to_const(rest, typeid); pfree(patt); pfree(match); @@ -3279,7 +3283,7 @@ pattern_selectivity(Const *patt, Pattern_Type ptype) * we must be able to generate another string "fop" that is greater * than all strings "foobar" starting with "foo". Unfortunately, a * non-C locale may have arbitrary collation rules in which "fop" > - * "foo" is not sufficient to ensure "fop" > "foobar". Until we can + * "foo" is not sufficient to ensure "fop" > "foobar". Until we can * come up with a more bulletproof way of generating the upper-bound * string, the optimization is disabled in all non-C locales. * @@ -3356,8 +3360,8 @@ make_greater_string(const Const *str_const) (*lastchar)++; if (string_lessthan(str, workstr, datatype)) { - /* Success! */ - Const *workstr_const = string_to_const(workstr, datatype); + /* Success! */ + Const *workstr_const = string_to_const(workstr, datatype); pfree(str); pfree(workstr); @@ -3372,7 +3376,7 @@ make_greater_string(const Const *str_const) if (datatype != BYTEAOID && pg_database_encoding_max_length() > 1) len = pg_mbcliplen((const unsigned char *) workstr, len, len - 1); else - len -= - 1; + len -= -1; if (datatype != BYTEAOID) workstr[len] = '\0'; diff --git a/src/backend/utils/adt/sets.c b/src/backend/utils/adt/sets.c index 321b9c6855..3c4838c0fe 100644 --- a/src/backend/utils/adt/sets.c +++ b/src/backend/utils/adt/sets.c @@ -10,7 +10,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.53 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/Attic/sets.c,v 1.54 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -54,19 +54,19 @@ SetDefine(char *querystr, Oid elemType) char repl[Natts_pg_proc]; setoid = ProcedureCreate(procname, /* changed below, after oid known */ - PG_CATALOG_NAMESPACE, /* XXX wrong */ + PG_CATALOG_NAMESPACE, /* XXX wrong */ false, /* don't replace */ true, /* returnsSet */ elemType, /* returnType */ - SQLlanguageId, /* language */ + SQLlanguageId, /* language */ F_FMGR_SQL_VALIDATOR, querystr, /* prosrc */ fileName, /* probin */ false, /* not aggregate */ false, /* security invoker */ false, /* isStrict (irrelevant, no args) */ - PROVOLATILE_VOLATILE, /* assume unsafe */ - 0, /* parameterCount */ + PROVOLATILE_VOLATILE, /* assume unsafe */ + 0, /* parameterCount */ NULL); /* parameterTypes */ /* diff --git a/src/backend/utils/adt/tid.c b/src/backend/utils/adt/tid.c index d90c20adf9..4940008223 100644 --- a/src/backend/utils/adt/tid.c +++ b/src/backend/utils/adt/tid.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.35 2002/08/29 00:17:05 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/tid.c,v 1.36 2002/09/04 20:31:29 momjian Exp $ * * NOTES * input routine largely stolen from boxin(). @@ -154,14 +154,16 @@ setLastTid(const ItemPointer tid) * correspond to the CTID of a base relation. */ static Datum -currtid_for_view(Relation viewrel, ItemPointer tid) +currtid_for_view(Relation viewrel, ItemPointer tid) { TupleDesc att = RelationGetDescr(viewrel); - RuleLock *rulelock; - RewriteRule *rewrite; - int i, natts = att->natts, tididx = -1; + RuleLock *rulelock; + RewriteRule *rewrite; + int i, + natts = att->natts, + tididx = -1; - for (i = 0; i < natts ; i++) + for (i = 0; i < natts; i++) { if (strcasecmp(NameStr(att->attrs[i]->attname), "ctid") == 0) { @@ -179,7 +181,7 @@ currtid_for_view(Relation viewrel, ItemPointer tid) rewrite = rulelock->rules[i]; if (rewrite->event == CMD_SELECT) { - Query *query; + Query *query; TargetEntry *tle; if (length(rewrite->actions) != 1) @@ -188,8 +190,9 @@ currtid_for_view(Relation viewrel, ItemPointer tid) tle = (TargetEntry *) nth(tididx, query->targetList); if (tle && tle->expr && nodeTag(tle->expr) == T_Var) { - Var *var = (Var *) tle->expr; + Var *var = (Var *) tle->expr; RangeTblEntry *rte; + if (var->varno > 0 && var->varno < INNER && var->varattno == SelfItemPointerAttributeNumber) { rte = (RangeTblEntry *) nth(var->varno - 1, query->rtable); @@ -244,7 +247,7 @@ currtid_byrelname(PG_FUNCTION_ARGS) Relation rel; relrv = makeRangeVarFromNameList(textToQualifiedNameList(relname, - "currtid_byrelname")); + "currtid_byrelname")); rel = heap_openrv(relrv, AccessShareLock); if (rel->rd_rel->relkind == RELKIND_VIEW) return currtid_for_view(rel, tid); diff --git a/src/backend/utils/adt/timestamp.c b/src/backend/utils/adt/timestamp.c index a381fd47cd..bfdb7d06ef 100644 --- a/src/backend/utils/adt/timestamp.c +++ b/src/backend/utils/adt/timestamp.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.72 2002/09/03 22:55:54 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/timestamp.c,v 1.73 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -31,6 +31,7 @@ #ifdef HAVE_INT64_TIMESTAMP static int64 time2t(const int hour, const int min, const int sec, const fsec_t fsec); + #else static double time2t(const int hour, const int min, const int sec, const fsec_t fsec); #endif @@ -155,7 +156,7 @@ static void AdjustTimestampForTypmod(Timestamp *time, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP - static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION+1] = { + static const int64 TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = { INT64CONST(1000000), INT64CONST(100000), INT64CONST(10000), @@ -165,7 +166,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) INT64CONST(1) }; - static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = { + static const int64 TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = { INT64CONST(-500000), INT64CONST(-50000), INT64CONST(-5000), @@ -174,8 +175,9 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) INT64CONST(-5), INT64CONST(0) }; + #else - static const double TimestampScales[MAX_TIMESTAMP_PRECISION+1] = { + static const double TimestampScales[MAX_TIMESTAMP_PRECISION + 1] = { 1, 10, 100, @@ -185,7 +187,7 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) 1000000 }; - static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION+1] = { + static const double TimestampOffsets[MAX_TIMESTAMP_PRECISION + 1] = { 0.5, 0.05, 0.005, @@ -224,7 +226,10 @@ AdjustTimestampForTypmod(Timestamp *time, int32 typmod) } else { - /* Scale and truncate first, then add to help the rounding behavior */ + /* + * Scale and truncate first, then add to help the rounding + * behavior + */ *time = (rint((((double) *time) * TimestampScales[typmod]) + TimestampOffsets[typmod]) / TimestampScales[typmod]); } @@ -450,7 +455,7 @@ static void AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP - static const int64 IntervalScales[MAX_INTERVAL_PRECISION+1] = { + static const int64 IntervalScales[MAX_INTERVAL_PRECISION + 1] = { INT64CONST(1000000), INT64CONST(100000), INT64CONST(10000), @@ -460,7 +465,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) INT64CONST(1) }; - static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION+1] = { + static const int64 IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = { INT64CONST(-500000), INT64CONST(-50000), INT64CONST(-5000), @@ -469,8 +474,9 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) INT64CONST(-5), INT64CONST(0) }; + #else - static const double IntervalScales[MAX_INTERVAL_PRECISION+1] = { + static const double IntervalScales[MAX_INTERVAL_PRECISION + 1] = { 1, 10, 100, @@ -480,7 +486,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) 1000000 }; - static const double IntervalOffsets[MAX_INTERVAL_PRECISION+1] = { + static const double IntervalOffsets[MAX_INTERVAL_PRECISION + 1] = { 0.5, 0.05, 0.005, @@ -491,7 +497,8 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) }; #endif - /* Unspecified range and precision? Then not necessary to adjust. + /* + * Unspecified range and precision? Then not necessary to adjust. * Setting typmod to -1 is the convention for all types. */ if (typmod != -1) @@ -515,9 +522,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) } /* YEAR TO MONTH */ else if (range == (INTERVAL_MASK(YEAR) | INTERVAL_MASK(MONTH))) - { interval->time = 0; - } else if (range == INTERVAL_MASK(DAY)) { interval->month = 0; @@ -532,6 +537,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 day; + #else double day; #endif @@ -551,6 +557,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 hour; + #else double hour; #endif @@ -570,6 +577,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 minute; + #else double minute; #endif @@ -613,15 +621,14 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE) | INTERVAL_MASK(SECOND))) - { interval->month = 0; - } /* HOUR TO MINUTE */ else if (range == (INTERVAL_MASK(HOUR) | INTERVAL_MASK(MINUTE))) { #ifdef HAVE_INT64_TIMESTAMP int64 day; + #else double day; #endif @@ -644,6 +651,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 day; + #else double day; #endif @@ -662,6 +670,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) { #ifdef HAVE_INT64_TIMESTAMP int64 hour; + #else double hour; #endif @@ -706,7 +715,7 @@ AdjustIntervalForTypmod(Interval *interval, int32 typmod) else { interval->time = (rint((((double) interval->time) + IntervalOffsets[precision]) - * IntervalScales[precision]) / IntervalScales[precision]); + * IntervalScales[precision]) / IntervalScales[precision]); } #endif } @@ -756,6 +765,7 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP int64 time; + #else double time; #endif @@ -794,18 +804,19 @@ dt2time(Timestamp jd, int *hour, int *min, int *sec, fsec_t *fsec) * local time zone. If out of this range, leave as GMT. - tgl 97/05/27 */ int -timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn) +timestamp2tm(Timestamp dt, int *tzp, struct tm * tm, fsec_t *fsec, char **tzn) { #ifdef HAVE_INT64_TIMESTAMP - int date, - date0; - int64 time; + int date, + date0; + int64 time; + #else - double date, - date0; - double time; + double date, + date0; + double time; #endif - time_t utime; + time_t utime; #if defined(HAVE_TM_ZONE) || defined(HAVE_INT_TIMEZONE) struct tm *tx; @@ -880,7 +891,7 @@ timestamp2tm(Timestamp dt, int *tzp, struct tm *tm, fsec_t *fsec, char **tzn) { #ifdef HAVE_INT64_TIMESTAMP utime = ((dt / INT64CONST(1000000)) - + ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400))); + + ((date0 - date2j(1970, 1, 1)) * INT64CONST(86400))); #else utime = (dt + ((date0 - date2j(1970, 1, 1)) * 86400)); #endif @@ -963,8 +974,9 @@ int tm2timestamp(struct tm * tm, fsec_t fsec, int *tzp, Timestamp *result) { #ifdef HAVE_INT64_TIMESTAMP - int date; - int64 time; + int date; + int64 time; + #else double date, time; @@ -996,6 +1008,7 @@ interval2tm(Interval span, struct tm * tm, fsec_t *fsec) { #ifdef HAVE_INT64_TIMESTAMP int64 time; + #else double time; #endif @@ -1040,9 +1053,9 @@ tm2interval(struct tm * tm, fsec_t fsec, Interval *span) span->month = ((tm->tm_year * 12) + tm->tm_mon); #ifdef HAVE_INT64_TIMESTAMP span->time = ((((((((tm->tm_mday * INT64CONST(24)) - + tm->tm_hour) * INT64CONST(60)) - + tm->tm_min) * INT64CONST(60)) - + tm->tm_sec) * INT64CONST(1000000)) + fsec); + + tm->tm_hour) * INT64CONST(60)) + + tm->tm_min) * INT64CONST(60)) + + tm->tm_sec) * INT64CONST(1000000)) + fsec); #else span->time = ((((((tm->tm_mday * 24.0) + tm->tm_hour) * 60.0) @@ -1060,6 +1073,7 @@ time2t(const int hour, const int min, const int sec, const fsec_t fsec) { return ((((((hour * 60) + min) * 60) + sec) * INT64CONST(1000000)) + fsec); } /* time2t() */ + #else static double time2t(const int hour, const int min, const int sec, const fsec_t fsec) @@ -1226,6 +1240,7 @@ interval_cmp_internal(Interval *interval1, Interval *interval2) #ifdef HAVE_INT64_TIMESTAMP int64 span1, span2; + #else double span1, span2; @@ -1532,9 +1547,7 @@ timestamp_pl_span(PG_FUNCTION_ARGS) Timestamp result; if (TIMESTAMP_NOT_FINITE(timestamp)) - { result = timestamp; - } else { if (span->month != 0) @@ -1702,9 +1715,11 @@ interval_smaller(PG_FUNCTION_ARGS) Interval *interval1 = PG_GETARG_INTERVAL_P(0); Interval *interval2 = PG_GETARG_INTERVAL_P(1); Interval *result; + #ifdef HAVE_INT64_TIMESTAMP int64 span1, span2; + #else double span1, span2; @@ -1746,9 +1761,11 @@ interval_larger(PG_FUNCTION_ARGS) Interval *interval1 = PG_GETARG_INTERVAL_P(0); Interval *interval2 = PG_GETARG_INTERVAL_P(1); Interval *result; + #ifdef HAVE_INT64_TIMESTAMP int64 span1, span2; + #else double span1, span2; @@ -1828,8 +1845,10 @@ interval_mul(PG_FUNCTION_ARGS) Interval *span1 = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); Interval *result; + #ifdef HAVE_INT64_TIMESTAMP int64 months; + #else double months; #endif @@ -1868,6 +1887,7 @@ interval_div(PG_FUNCTION_ARGS) Interval *span = PG_GETARG_INTERVAL_P(0); float8 factor = PG_GETARG_FLOAT8(1); Interval *result; + #ifndef HAVE_INT64_TIMESTAMP double months; #endif @@ -1882,7 +1902,7 @@ interval_div(PG_FUNCTION_ARGS) result->time = (span->time / factor); /* evaluate fractional months as 30 days */ result->time += (((span->month - (result->month * factor)) - * INT64CONST(30) * INT64CONST(86400000000)) / factor); + * INT64CONST(30) * INT64CONST(86400000000)) / factor); #else months = (span->month / factor); result->month = rint(months); @@ -1928,8 +1948,8 @@ interval_accum(PG_FUNCTION_ARGS) * objects on machines where double requires 8-byte alignment. That * should be fixed, but in the meantime... * - * Note: must use DatumGetPointer here, not DatumGetIntervalP, - * else some compilers optimize into double-aligned load/store anyway. + * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some + * compilers optimize into double-aligned load/store anyway. */ memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval)); memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval)); @@ -1970,8 +1990,8 @@ interval_avg(PG_FUNCTION_ARGS) * objects on machines where double requires 8-byte alignment. That * should be fixed, but in the meantime... * - * Note: must use DatumGetPointer here, not DatumGetIntervalP, - * else some compilers optimize into double-aligned load/store anyway. + * Note: must use DatumGetPointer here, not DatumGetIntervalP, else some + * compilers optimize into double-aligned load/store anyway. */ memcpy((void *) &sumX, DatumGetPointer(transdatums[0]), sizeof(Interval)); memcpy((void *) &N, DatumGetPointer(transdatums[1]), sizeof(Interval)); @@ -3131,29 +3151,29 @@ interval_part(PG_FUNCTION_ARGS) { switch (val) { - case DTK_MICROSEC: + case DTK_MICROSEC: #ifdef HAVE_INT64_TIMESTAMP - result = ((tm->tm_sec * 1000000e0) + fsec); + result = ((tm->tm_sec * 1000000e0) + fsec); #else - result = (tm->tm_sec + fsec) * 1000000; + result = (tm->tm_sec + fsec) * 1000000; #endif - break; + break; - case DTK_MILLISEC: + case DTK_MILLISEC: #ifdef HAVE_INT64_TIMESTAMP - result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0)); + result = ((tm->tm_sec * 1000e0) + (fsec / 1000e0)); #else - result = (tm->tm_sec + fsec) * 1000; + result = (tm->tm_sec + fsec) * 1000; #endif - break; + break; - case DTK_SECOND: + case DTK_SECOND: #ifdef HAVE_INT64_TIMESTAMP - result = (tm->tm_sec + (fsec / 1000000e0)); + result = (tm->tm_sec + (fsec / 1000000e0)); #else - result = (tm->tm_sec + fsec); + result = (tm->tm_sec + fsec); #endif - break; + break; case DTK_MINUTE: result = tm->tm_min; @@ -3234,7 +3254,7 @@ interval_part(PG_FUNCTION_ARGS) /* timestamp_zone() * Encode timestamp type with specified time zone. * Returns timestamp with time zone, with the input - * rotated from local time to the specified zone. + * rotated from local time to the specified zone. */ Datum timestamp_zone(PG_FUNCTION_ARGS) diff --git a/src/backend/utils/adt/varbit.c b/src/backend/utils/adt/varbit.c index 97c3567f1a..f0c31a3961 100644 --- a/src/backend/utils/adt/varbit.c +++ b/src/backend/utils/adt/varbit.c @@ -9,7 +9,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.24 2002/08/26 17:53:59 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varbit.c,v 1.25 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1138,8 +1138,8 @@ bitfromint8(PG_FUNCTION_ARGS) VARBITLEN(result) = sizeof(a) * BITS_PER_BYTE; /* - * masks and shifts here are just too painful and we know that an int64 - * has got 8 bytes + * masks and shifts here are just too painful and we know that an + * int64 has got 8 bytes */ r = VARBITS(result); r[0] = (bits8) ((a >> (7 * BITS_PER_BYTE)) & BITMASK); diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c index 819e3122c3..780daf7565 100644 --- a/src/backend/utils/adt/varchar.c +++ b/src/backend/utils/adt/varchar.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.93 2002/09/03 21:45:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varchar.c,v 1.94 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -182,6 +182,7 @@ bpchar(PG_FUNCTION_ARGS) int charlen; /* number of charcters in the input string * + VARHDRSZ */ + len = VARSIZE(source); charlen = pg_mbstrlen_with_len(VARDATA(source), len - VARHDRSZ) + VARHDRSZ; diff --git a/src/backend/utils/adt/varlena.c b/src/backend/utils/adt/varlena.c index 12230a7065..e21e59e1be 100644 --- a/src/backend/utils/adt/varlena.c +++ b/src/backend/utils/adt/varlena.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.91 2002/09/03 21:45:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/adt/varlena.c,v 1.92 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -30,11 +30,11 @@ typedef struct varlena unknown; #define PG_GETARG_UNKNOWN_P(n) DatumGetUnknownP(PG_GETARG_DATUM(n)) #define PG_RETURN_UNKNOWN_P(x) PG_RETURN_POINTER(x) #define PG_TEXTARG_GET_STR(arg_) \ - DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_))) + DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(arg_))) #define PG_TEXT_GET_STR(textp_) \ - DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_))) + DatumGetCString(DirectFunctionCall1(textout, PointerGetDatum(textp_))) #define PG_STR_GET_TEXT(str_) \ - DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_))) + DatumGetTextP(DirectFunctionCall1(textin, CStringGetDatum(str_))) #define TEXTLEN(textp) \ text_length(PointerGetDatum(textp)) #define TEXTPOS(buf_text, from_sub_text) \ @@ -54,9 +54,9 @@ static int text_cmp(text *arg1, text *arg2); static int32 text_length(Datum str); static int32 text_position(Datum str, Datum search_str, int matchnum); static text *text_substring(Datum str, - int32 start, - int32 length, - bool length_not_specified); + int32 start, + int32 length, + bool length_not_specified); /***************************************************************************** @@ -266,7 +266,7 @@ Datum unknownin(PG_FUNCTION_ARGS) { char *inputStr = PG_GETARG_CSTRING(0); - unknown *result; + unknown *result; int len; len = strlen(inputStr) + VARHDRSZ; @@ -286,7 +286,7 @@ unknownin(PG_FUNCTION_ARGS) Datum unknownout(PG_FUNCTION_ARGS) { - unknown *t = PG_GETARG_UNKNOWN_P(0); + unknown *t = PG_GETARG_UNKNOWN_P(0); int len; char *result; @@ -330,12 +330,12 @@ text_length(Datum str) text *t = DatumGetTextP(str); PG_RETURN_INT32(pg_mbstrlen_with_len(VARDATA(t), - VARSIZE(t) - VARHDRSZ)); + VARSIZE(t) - VARHDRSZ)); } /* should never get here */ elog(ERROR, "Invalid backend encoding; encoding max length " - "is less than one."); + "is less than one."); /* not reached: suppress compiler warning */ return 0; @@ -425,7 +425,7 @@ textcat(PG_FUNCTION_ARGS) * behaviors conflicting with SQL92 to meet SQL92 (if E = S + L < S throw * error; if E < 1, return '', not entire string). Fixed MB related bug when * S > LC and < LC + 4 sometimes garbage characters are returned. - * - Joe Conway 2002-08-10 + * - Joe Conway 2002-08-10 */ Datum text_substr(PG_FUNCTION_ARGS) @@ -455,25 +455,26 @@ text_substr_no_len(PG_FUNCTION_ARGS) * This is broken out so it can be called directly by other string processing * functions. */ -static text* +static text * text_substring(Datum str, int32 start, int32 length, bool length_not_specified) { int32 eml = pg_database_encoding_max_length(); - int32 S = start; /* start position */ - int32 S1; /* adjusted start position */ - int32 L1; /* adjusted substring length */ + int32 S = start; /* start position */ + int32 S1; /* adjusted start position */ + int32 L1; /* adjusted substring length */ /* life is easy if the encoding max length is 1 */ if (eml == 1) { S1 = Max(S, 1); - if (length_not_specified) /* special case - get length to end of string */ + if (length_not_specified) /* special case - get length to + * end of string */ L1 = -1; else { /* end position */ - int E = S + length; + int E = S + length; /* * A negative value for L is the only way for the end position @@ -482,9 +483,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) if (E < S) elog(ERROR, "negative substring length not allowed"); - /* - * A zero or negative value for the end position can happen if the start - * was negative or one. SQL99 says to return a zero-length string. + /* + * A zero or negative value for the end position can happen if + * the start was negative or one. SQL99 says to return a + * zero-length string. */ if (E < 1) return PG_STR_GET_TEXT(""); @@ -492,11 +494,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) L1 = E - S1; } - /* - * If the start position is past the end of the string, - * SQL99 says to return a zero-length string -- - * PG_GETARG_TEXT_P_SLICE() will do that for us. - * Convert to zero-based starting position + /* + * If the start position is past the end of the string, SQL99 says + * to return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will + * do that for us. Convert to zero-based starting position */ return DatumGetTextPSlice(str, S1 - 1, L1); } @@ -504,13 +505,13 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) { /* * When encoding max length is > 1, we can't get LC without - * detoasting, so we'll grab a conservatively large slice - * now and go back later to do the right thing + * detoasting, so we'll grab a conservatively large slice now and + * go back later to do the right thing */ int32 slice_start; int32 slice_size; int32 slice_strlen; - text *slice; + text *slice; int32 E1; int32 i; char *p; @@ -518,23 +519,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) text *ret; /* - * if S is past the end of the string, the tuple toaster - * will return a zero-length string to us + * if S is past the end of the string, the tuple toaster will + * return a zero-length string to us */ S1 = Max(S, 1); /* - * We need to start at position zero because there is no - * way to know in advance which byte offset corresponds to - * the supplied start position. + * We need to start at position zero because there is no way to + * know in advance which byte offset corresponds to the supplied + * start position. */ slice_start = 0; - if (length_not_specified) /* special case - get length to end of string */ + if (length_not_specified) /* special case - get length to + * end of string */ slice_size = L1 = -1; else { - int E = S + length; + int E = S + length; /* * A negative value for L is the only way for the end position @@ -543,22 +545,24 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) if (E < S) elog(ERROR, "negative substring length not allowed"); - /* - * A zero or negative value for the end position can happen if the start - * was negative or one. SQL99 says to return a zero-length string. + /* + * A zero or negative value for the end position can happen if + * the start was negative or one. SQL99 says to return a + * zero-length string. */ if (E < 1) return PG_STR_GET_TEXT(""); /* - * if E is past the end of the string, the tuple toaster - * will truncate the length for us + * if E is past the end of the string, the tuple toaster will + * truncate the length for us */ L1 = E - S1; /* - * Total slice size in bytes can't be any longer than the start - * position plus substring length times the encoding max length. + * Total slice size in bytes can't be any longer than the + * start position plus substring length times the encoding max + * length. */ slice_size = (S1 + L1) * eml; } @@ -569,9 +573,10 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) return PG_STR_GET_TEXT(""); /* Now we can get the actual length of the slice in MB characters */ - slice_strlen = pg_mbstrlen_with_len (VARDATA(slice), VARSIZE(slice) - VARHDRSZ); + slice_strlen = pg_mbstrlen_with_len(VARDATA(slice), VARSIZE(slice) - VARHDRSZ); - /* Check that the start position wasn't > slice_strlen. If so, + /* + * Check that the start position wasn't > slice_strlen. If so, * SQL99 says to return a zero-length string. */ if (S1 > slice_strlen) @@ -579,16 +584,17 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) /* * Adjust L1 and E1 now that we know the slice string length. - * Again remember that S1 is one based, and slice_start is zero based. + * Again remember that S1 is one based, and slice_start is zero + * based. */ if (L1 > -1) - E1 = Min(S1 + L1 , slice_start + 1 + slice_strlen); + E1 = Min(S1 + L1, slice_start + 1 + slice_strlen); else E1 = slice_start + 1 + slice_strlen; /* - * Find the start position in the slice; - * remember S1 is not zero based + * Find the start position in the slice; remember S1 is not zero + * based */ p = VARDATA(slice); for (i = 0; i < S1 - 1; i++) @@ -598,8 +604,8 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) s = p; /* - * Count the actual bytes used by the substring of - * the requested length. + * Count the actual bytes used by the substring of the requested + * length. */ for (i = S1; i < E1; i++) p += pg_mblen(p); @@ -612,7 +618,7 @@ text_substring(Datum str, int32 start, int32 length, bool length_not_specified) } else elog(ERROR, "Invalid backend encoding; encoding max length " - "is less than one."); + "is less than one."); /* not reached: suppress compiler warning */ return PG_STR_GET_TEXT(""); @@ -650,8 +656,8 @@ text_position(Datum str, Datum search_str, int matchnum) len1, len2; - if(matchnum == 0) - return 0; /* result for 0th match */ + if (matchnum == 0) + return 0; /* result for 0th match */ if (VARSIZE(t2) <= VARHDRSZ) PG_RETURN_INT32(1); /* result for empty pattern */ @@ -662,10 +668,10 @@ text_position(Datum str, Datum search_str, int matchnum) /* no use in searching str past point where search_str will fit */ px = (len1 - len2); - if (eml == 1) /* simple case - single byte encoding */ + if (eml == 1) /* simple case - single byte encoding */ { - char *p1, - *p2; + char *p1, + *p2; p1 = VARDATA(t1); p2 = VARDATA(t2); @@ -683,7 +689,7 @@ text_position(Datum str, Datum search_str, int matchnum) p1++; } } - else if (eml > 1) /* not as simple - multibyte encoding */ + else if (eml > 1) /* not as simple - multibyte encoding */ { pg_wchar *p1, *p2, @@ -715,7 +721,7 @@ text_position(Datum str, Datum search_str, int matchnum) } else elog(ERROR, "Invalid backend encoding; encoding max length " - "is less than one."); + "is less than one."); PG_RETURN_INT32(pos); } @@ -734,10 +740,10 @@ varstr_cmp(char *arg1, int len1, char *arg2, int len2) *a2p; /* - * Unfortunately, there is no strncoll(), so in the non-C locale - * case we have to do some memory copying. This turns out to be - * significantly slower, so we optimize the case where LC_COLLATE - * is C. + * Unfortunately, there is no strncoll(), so in the non-C locale case + * we have to do some memory copying. This turns out to be + * significantly slower, so we optimize the case where LC_COLLATE is + * C. */ if (!lc_collate_is_c()) { @@ -990,7 +996,7 @@ byteacat(PG_FUNCTION_ARGS) } #define PG_STR_GET_BYTEA(str_) \ - DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_))) + DatumGetByteaP(DirectFunctionCall1(byteain, CStringGetDatum(str_))) /* * bytea_substr() * Return a substring starting at the specified position. @@ -1009,36 +1015,37 @@ byteacat(PG_FUNCTION_ARGS) Datum bytea_substr(PG_FUNCTION_ARGS) { - int S = PG_GETARG_INT32(1); /* start position */ - int S1; /* adjusted start position */ - int L1; /* adjusted substring length */ + int S = PG_GETARG_INT32(1); /* start position */ + int S1; /* adjusted start position */ + int L1; /* adjusted substring length */ S1 = Max(S, 1); if (fcinfo->nargs == 2) { /* - * Not passed a length - PG_GETARG_BYTEA_P_SLICE() - * grabs everything to the end of the string if we pass it - * a negative value for length. + * Not passed a length - PG_GETARG_BYTEA_P_SLICE() grabs + * everything to the end of the string if we pass it a negative + * value for length. */ L1 = -1; } else { /* end position */ - int E = S + PG_GETARG_INT32(2); + int E = S + PG_GETARG_INT32(2); /* - * A negative value for L is the only way for the end position - * to be before the start. SQL99 says to throw an error. + * A negative value for L is the only way for the end position to + * be before the start. SQL99 says to throw an error. */ if (E < S) elog(ERROR, "negative substring length not allowed"); - /* - * A zero or negative value for the end position can happen if the start - * was negative or one. SQL99 says to return a zero-length string. + /* + * A zero or negative value for the end position can happen if the + * start was negative or one. SQL99 says to return a zero-length + * string. */ if (E < 1) PG_RETURN_BYTEA_P(PG_STR_GET_BYTEA("")); @@ -1046,13 +1053,12 @@ bytea_substr(PG_FUNCTION_ARGS) L1 = E - S1; } - /* - * If the start position is past the end of the string, - * SQL99 says to return a zero-length string -- - * PG_GETARG_TEXT_P_SLICE() will do that for us. - * Convert to zero-based starting position + /* + * If the start position is past the end of the string, SQL99 says to + * return a zero-length string -- PG_GETARG_TEXT_P_SLICE() will do + * that for us. Convert to zero-based starting position */ - PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE (0, S1 - 1, L1)); + PG_RETURN_BYTEA_P(PG_GETARG_BYTEA_P_SLICE(0, S1 - 1, L1)); } /* @@ -1343,7 +1349,7 @@ textToQualifiedNameList(text *textval, const char *caller) /* Convert to C string (handles possible detoasting). */ /* Note we rely on being able to modify rawname below. */ rawname = DatumGetCString(DirectFunctionCall1(textout, - PointerGetDatum(textval))); + PointerGetDatum(textval))); if (!SplitIdentifierString(rawname, '.', &namelist)) elog(ERROR, "%s: invalid name syntax", caller); @@ -1353,7 +1359,7 @@ textToQualifiedNameList(text *textval, const char *caller) foreach(l, namelist) { - char *curname = (char *) lfirst(l); + char *curname = (char *) lfirst(l); result = lappend(result, makeString(pstrdup(curname))); } @@ -1368,15 +1374,15 @@ textToQualifiedNameList(text *textval, const char *caller) * SplitIdentifierString --- parse a string containing identifiers * * This is the guts of textToQualifiedNameList, and is exported for use in - * other situations such as parsing GUC variables. In the GUC case, it's + * other situations such as parsing GUC variables. In the GUC case, it's * important to avoid memory leaks, so the API is designed to minimize the * amount of stuff that needs to be allocated and freed. * * Inputs: - * rawstring: the input string; must be overwritable! On return, it's + * rawstring: the input string; must be overwritable! On return, it's * been modified to contain the separated identifiers. * separator: the separator punctuation expected between identifiers - * (typically '.' or ','). Whitespace may also appear around + * (typically '.' or ','). Whitespace may also appear around * identifiers. * Outputs: * namelist: filled with a palloc'd list of pointers to identifiers within @@ -1417,11 +1423,11 @@ SplitIdentifierString(char *rawstring, char separator, { endp = strchr(nextp + 1, '\"'); if (endp == NULL) - return false; /* mismatched quotes */ + return false; /* mismatched quotes */ if (endp[1] != '\"') break; /* found end of quoted name */ /* Collapse adjacent quotes into one quote, and look again */ - memmove(endp, endp+1, strlen(endp)); + memmove(endp, endp + 1, strlen(endp)); nextp = endp; } /* endp now points at the terminating quote */ @@ -1435,8 +1441,8 @@ SplitIdentifierString(char *rawstring, char separator, !isspace((unsigned char) *nextp)) { /* - * It's important that this match the identifier downcasing - * code used by backend/parser/scan.l. + * It's important that this match the identifier + * downcasing code used by backend/parser/scan.l. */ if (isupper((unsigned char) *nextp)) *nextp = tolower((unsigned char) *nextp); @@ -1647,24 +1653,24 @@ byteacmp(PG_FUNCTION_ARGS) * replace_text * replace all occurences of 'old_sub_str' in 'orig_str' * with 'new_sub_str' to form 'new_str' - * + * * returns 'orig_str' if 'old_sub_str' == '' or 'orig_str' == '' - * otherwise returns 'new_str' + * otherwise returns 'new_str' */ Datum replace_text(PG_FUNCTION_ARGS) { - text *left_text; - text *right_text; - text *buf_text; - text *ret_text; + text *left_text; + text *right_text; + text *buf_text; + text *ret_text; int curr_posn; - text *src_text = PG_GETARG_TEXT_P(0); + text *src_text = PG_GETARG_TEXT_P(0); int src_text_len = TEXTLEN(src_text); - text *from_sub_text = PG_GETARG_TEXT_P(1); + text *from_sub_text = PG_GETARG_TEXT_P(1); int from_sub_text_len = TEXTLEN(from_sub_text); - text *to_sub_text = PG_GETARG_TEXT_P(2); - char *to_sub_str = PG_TEXT_GET_STR(to_sub_text); + text *to_sub_text = PG_GETARG_TEXT_P(2); + char *to_sub_str = PG_TEXT_GET_STR(to_sub_text); StringInfo str = makeStringInfo(); if (src_text_len == 0 || from_sub_text_len == 0) @@ -1713,7 +1719,7 @@ split_text(PG_FUNCTION_ARGS) int fldnum = PG_GETARG_INT32(2); int start_posn = 0; int end_posn = 0; - text *result_text; + text *result_text; /* return empty string for empty input string */ if (inputstring_len < 1) @@ -1722,9 +1728,11 @@ split_text(PG_FUNCTION_ARGS) /* empty field separator */ if (fldsep_len < 1) { - if (fldnum == 1) /* first field - just return the input string */ + if (fldnum == 1) /* first field - just return the input + * string */ PG_RETURN_TEXT_P(inputstring); - else /* otherwise return an empty string */ + else +/* otherwise return an empty string */ PG_RETURN_TEXT_P(PG_STR_GET_TEXT("")); } @@ -1733,17 +1741,19 @@ split_text(PG_FUNCTION_ARGS) elog(ERROR, "field position must be > 0"); start_posn = text_position(PointerGetDatum(inputstring), - PointerGetDatum(fldsep), - fldnum - 1); + PointerGetDatum(fldsep), + fldnum - 1); end_posn = text_position(PointerGetDatum(inputstring), - PointerGetDatum(fldsep), - fldnum); + PointerGetDatum(fldsep), + fldnum); if ((start_posn == 0) && (end_posn == 0)) /* fldsep not found */ { - if (fldnum == 1) /* first field - just return the input string */ + if (fldnum == 1) /* first field - just return the input + * string */ PG_RETURN_TEXT_P(inputstring); - else /* otherwise return an empty string */ + else +/* otherwise return an empty string */ PG_RETURN_TEXT_P(PG_STR_GET_TEXT("")); } else if ((start_posn != 0) && (end_posn == 0)) @@ -1774,11 +1784,11 @@ split_text(PG_FUNCTION_ARGS) Datum to_hex32(PG_FUNCTION_ARGS) { - static char digits[] = "0123456789abcdef"; - char buf[32]; /* bigger than needed, but reasonable */ - char *ptr; - text *result_text; - int32 value = PG_GETARG_INT32(0); + static char digits[] = "0123456789abcdef"; + char buf[32]; /* bigger than needed, but reasonable */ + char *ptr; + text *result_text; + int32 value = PG_GETARG_INT32(0); ptr = buf + sizeof(buf) - 1; *ptr = '\0'; @@ -1800,11 +1810,11 @@ to_hex32(PG_FUNCTION_ARGS) Datum to_hex64(PG_FUNCTION_ARGS) { - static char digits[] = "0123456789abcdef"; - char buf[32]; /* bigger than needed, but reasonable */ - char *ptr; - text *result_text; - int64 value = PG_GETARG_INT64(0); + static char digits[] = "0123456789abcdef"; + char buf[32]; /* bigger than needed, but reasonable */ + char *ptr; + text *result_text; + int64 value = PG_GETARG_INT64(0); ptr = buf + sizeof(buf) - 1; *ptr = '\0'; @@ -1818,4 +1828,3 @@ to_hex64(PG_FUNCTION_ARGS) result_text = PG_STR_GET_TEXT(ptr); PG_RETURN_TEXT_P(result_text); } - diff --git a/src/backend/utils/cache/catcache.c b/src/backend/utils/cache/catcache.c index 5703bf1653..c84abb87a1 100644 --- a/src/backend/utils/cache/catcache.c +++ b/src/backend/utils/cache/catcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.98 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/catcache.c,v 1.99 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -34,7 +34,7 @@ #include "utils/syscache.h" -/* #define CACHEDEBUG */ /* turns DEBUG elogs on */ + /* #define CACHEDEBUG */ /* turns DEBUG elogs on */ /* * Constants related to size of the catcache. @@ -102,6 +102,7 @@ static uint32 CatalogCacheComputeHashValue(CatCache *cache, int nkeys, ScanKey cur_skey); static uint32 CatalogCacheComputeTupleHashValue(CatCache *cache, HeapTuple tuple); + #ifdef CATCACHE_STATS static void CatCachePrintStats(void); #endif @@ -109,8 +110,8 @@ static void CatCacheRemoveCTup(CatCache *cache, CatCTup *ct); static void CatCacheRemoveCList(CatCache *cache, CatCList *cl); static void CatalogCacheInitializeCache(CatCache *cache); static CatCTup *CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, - uint32 hashValue, Index hashIndex, - bool negative); + uint32 hashValue, Index hashIndex, + bool negative); static HeapTuple build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys); @@ -325,8 +326,7 @@ CatCachePrintStats(void) cc_lsearches, cc_lhits); } - -#endif /* CATCACHE_STATS */ +#endif /* CATCACHE_STATS */ /* @@ -372,7 +372,7 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl) Assert(cl->my_cache == cache); /* delink from member tuples */ - for (i = cl->n_members; --i >= 0; ) + for (i = cl->n_members; --i >= 0;) { CatCTup *ct = cl->members[i]; @@ -397,11 +397,11 @@ CatCacheRemoveCList(CatCache *cache, CatCList *cl) * item pointer. Positive entries are deleted if they match the item * pointer. Negative entries must be deleted if they match the hash * value (since we do not have the exact key of the tuple that's being - * inserted). But this should only rarely result in loss of a cache + * inserted). But this should only rarely result in loss of a cache * entry that could have been kept. * * Note that it's not very relevant whether the tuple identified by - * the item pointer is being inserted or deleted. We don't expect to + * the item pointer is being inserted or deleted. We don't expect to * find matching positive entries in the one case, and we don't expect * to find matching negative entries in the other; but we will do the * right things in any case. @@ -435,8 +435,8 @@ CatalogCacheIdInvalidate(int cacheId, /* * We don't bother to check whether the cache has finished - * initialization yet; if not, there will be no entries in it - * so no problem. + * initialization yet; if not, there will be no entries in it so + * no problem. */ /* @@ -819,7 +819,7 @@ InitCatCache(int id, cp->id = id; cp->cc_relname = relname; cp->cc_indname = indname; - cp->cc_reloid = InvalidOid; /* temporary */ + cp->cc_reloid = InvalidOid; /* temporary */ cp->cc_relisshared = false; /* temporary */ cp->cc_tupdesc = (TupleDesc) NULL; cp->cc_reloidattr = reloidattr; @@ -1015,8 +1015,8 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey) { /* * Since the OIDs of indexes aren't hardwired, it's painful to - * figure out which is which. Just force all pg_index searches - * to be heap scans while building the relcaches. + * figure out which is which. Just force all pg_index searches to + * be heap scans while building the relcaches. */ if (!criticalRelcachesBuilt) return false; @@ -1037,7 +1037,7 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey) if (!criticalRelcachesBuilt) { /* Looking for an OID comparison function? */ - Oid lookup_oid = DatumGetObjectId(cur_skey[0].sk_argument); + Oid lookup_oid = DatumGetObjectId(cur_skey[0].sk_argument); if (lookup_oid >= MIN_OIDCMP && lookup_oid <= MAX_OIDCMP) return false; @@ -1055,7 +1055,7 @@ IndexScanOK(CatCache *cache, ScanKey cur_skey) * if necessary (on the first access to a particular cache). * * The result is NULL if not found, or a pointer to a HeapTuple in - * the cache. The caller must not modify the tuple, and must call + * the cache. The caller must not modify the tuple, and must call * ReleaseCatCache() when done with it. * * The search key values should be expressed as Datums of the key columns' @@ -1077,7 +1077,7 @@ SearchCatCache(CatCache *cache, Dlelem *elt; CatCTup *ct; Relation relation; - SysScanDesc scandesc; + SysScanDesc scandesc; HeapTuple ntp; /* @@ -1134,18 +1134,18 @@ SearchCatCache(CatCache *cache, continue; /* - * we found a match in the cache: move it to the front of the global - * LRU list. We also move it to the front of the list for its - * hashbucket, in order to speed subsequent searches. (The most - * frequently accessed elements in any hashbucket will tend to be - * near the front of the hashbucket's list.) + * we found a match in the cache: move it to the front of the + * global LRU list. We also move it to the front of the list for + * its hashbucket, in order to speed subsequent searches. (The + * most frequently accessed elements in any hashbucket will tend + * to be near the front of the hashbucket's list.) */ DLMoveToFront(&ct->lrulist_elem); DLMoveToFront(&ct->cache_elem); /* - * If it's a positive entry, bump its refcount and return it. - * If it's negative, we can report failure to the caller. + * If it's a positive entry, bump its refcount and return it. If + * it's negative, we can report failure to the caller. */ if (!ct->negative) { @@ -1175,8 +1175,8 @@ SearchCatCache(CatCache *cache, /* * Tuple was not found in cache, so we have to try to retrieve it - * directly from the relation. If found, we will add it to the - * cache; if not found, we will add a negative cache entry instead. + * directly from the relation. If found, we will add it to the cache; + * if not found, we will add a negative cache entry instead. * * NOTE: it is possible for recursive cache lookups to occur while * reading the relation --- for example, due to shared-cache-inval @@ -1213,8 +1213,8 @@ SearchCatCache(CatCache *cache, /* * If tuple was not found, we need to build a negative cache entry - * containing a fake tuple. The fake tuple has the correct key columns, - * but nulls everywhere else. + * containing a fake tuple. The fake tuple has the correct key + * columns, but nulls everywhere else. */ if (ct == NULL) { @@ -1307,7 +1307,7 @@ SearchCatCacheList(CatCache *cache, List *ctlist; int nmembers; Relation relation; - SysScanDesc scandesc; + SysScanDesc scandesc; bool ordered; HeapTuple ntp; MemoryContext oldcxt; @@ -1336,8 +1336,8 @@ SearchCatCacheList(CatCache *cache, /* * compute a hash value of the given keys for faster search. We don't - * presently divide the CatCList items into buckets, but this still lets - * us skip non-matching items quickly most of the time. + * presently divide the CatCList items into buckets, but this still + * lets us skip non-matching items quickly most of the time. */ lHashValue = CatalogCacheComputeHashValue(cache, nkeys, cur_skey); @@ -1373,11 +1373,11 @@ SearchCatCacheList(CatCache *cache, /* * we found a matching list: move each of its members to the front - * of the global LRU list. Also move the list itself to the front - * of the cache's list-of-lists, to speed subsequent searches. - * (We do not move the members to the fronts of their hashbucket + * of the global LRU list. Also move the list itself to the front + * of the cache's list-of-lists, to speed subsequent searches. (We + * do not move the members to the fronts of their hashbucket * lists, however, since there's no point in that unless they are - * searched for individually.) Also bump the members' refcounts. + * searched for individually.) Also bump the members' refcounts. */ for (i = 0; i < cl->n_members; i++) { @@ -1400,9 +1400,9 @@ SearchCatCacheList(CatCache *cache, } /* - * List was not found in cache, so we have to build it by reading - * the relation. For each matching tuple found in the relation, - * use an existing cache entry if possible, else build a new one. + * List was not found in cache, so we have to build it by reading the + * relation. For each matching tuple found in the relation, use an + * existing cache entry if possible, else build a new one. */ relation = heap_open(cache->cc_reloid, AccessShareLock); @@ -1438,17 +1438,17 @@ SearchCatCacheList(CatCache *cache, ct = (CatCTup *) DLE_VAL(elt); if (ct->dead || ct->negative) - continue; /* ignore dead and negative entries */ + continue; /* ignore dead and negative entries */ if (ct->hash_value != hashValue) - continue; /* quickly skip entry if wrong hash val */ + continue; /* quickly skip entry if wrong hash val */ if (!ItemPointerEquals(&(ct->tuple.t_self), &(ntp->t_self))) - continue; /* not same tuple */ + continue; /* not same tuple */ /* - * Found a match, but can't use it if it belongs to another list - * already + * Found a match, but can't use it if it belongs to another + * list already */ if (ct->c_list) continue; @@ -1498,7 +1498,7 @@ SearchCatCacheList(CatCache *cache, cl->hash_value = lHashValue; cl->n_members = nmembers; /* The list is backwards because we built it with lcons */ - for (i = nmembers; --i >= 0; ) + for (i = nmembers; --i >= 0;) { cl->members[i] = ct = (CatCTup *) lfirst(ctlist); Assert(ct->c_list == NULL); @@ -1531,7 +1531,7 @@ ReleaseCatCacheList(CatCList *list) Assert(list->cl_magic == CL_MAGIC); Assert(list->refcount > 0); - for (i = list->n_members; --i >= 0; ) + for (i = list->n_members; --i >= 0;) { CatCTup *ct = list->members[i]; @@ -1558,7 +1558,7 @@ ReleaseCatCacheList(CatCList *list) /* * CatalogCacheCreateEntry * Create a new CatCTup entry, copying the given HeapTuple and other - * supplied data into it. The new entry is given refcount 1. + * supplied data into it. The new entry is given refcount 1. */ static CatCTup * CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, @@ -1568,7 +1568,8 @@ CatalogCacheCreateEntry(CatCache *cache, HeapTuple ntp, MemoryContext oldcxt; /* - * Allocate CatCTup header in cache memory, and copy the tuple there too. + * Allocate CatCTup header in cache memory, and copy the tuple there + * too. */ oldcxt = MemoryContextSwitchTo(CacheMemoryContext); ct = (CatCTup *) palloc(sizeof(CatCTup)); @@ -1655,27 +1656,26 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) for (i = 0; i < nkeys; i++) { - int attindex = cache->cc_key[i]; - Datum keyval = skeys[i].sk_argument; + int attindex = cache->cc_key[i]; + Datum keyval = skeys[i].sk_argument; if (attindex > 0) { /* - * Here we must be careful in case the caller passed a - * C string where a NAME is wanted: convert the given - * argument to a correctly padded NAME. Otherwise the - * memcpy() done in heap_formtuple could fall off the - * end of memory. + * Here we must be careful in case the caller passed a C + * string where a NAME is wanted: convert the given argument + * to a correctly padded NAME. Otherwise the memcpy() done in + * heap_formtuple could fall off the end of memory. */ if (cache->cc_isname[i]) { - Name newval = &tempNames[i]; + Name newval = &tempNames[i]; namestrcpy(newval, DatumGetCString(keyval)); keyval = NameGetDatum(newval); } - values[attindex-1] = keyval; - nulls[attindex-1] = ' '; + values[attindex - 1] = keyval; + nulls[attindex - 1] = ' '; } else { @@ -1727,7 +1727,7 @@ build_dummy_tuple(CatCache *cache, int nkeys, ScanKey skeys) void PrepareToInvalidateCacheTuple(Relation relation, HeapTuple tuple, - void (*function) (int, uint32, ItemPointer, Oid)) + void (*function) (int, uint32, ItemPointer, Oid)) { CatCache *ccp; Oid reloid; diff --git a/src/backend/utils/cache/inval.c b/src/backend/utils/cache/inval.c index d64f5bf0b5..6aa5ab62f2 100644 --- a/src/backend/utils/cache/inval.c +++ b/src/backend/utils/cache/inval.c @@ -10,7 +10,7 @@ * ie, until the next CommandCounterIncrement() or transaction commit. * (See utils/time/tqual.c, and note that system catalogs are generally * scanned under SnapshotNow rules by the system, or plain user snapshots - * for user queries.) At the command boundary, the old tuple stops + * for user queries.) At the command boundary, the old tuple stops * being valid and the new version, if any, becomes valid. Therefore, * we cannot simply flush a tuple from the system caches during heap_update() * or heap_delete(). The tuple is still good at that point; what's more, @@ -29,12 +29,12 @@ * * If we successfully complete the transaction, we have to broadcast all * these invalidation events to other backends (via the SI message queue) - * so that they can flush obsolete entries from their caches. Note we have + * so that they can flush obsolete entries from their caches. Note we have * to record the transaction commit before sending SI messages, otherwise * the other backends won't see our updated tuples as good. * * In short, we need to remember until xact end every insert or delete - * of a tuple that might be in the system caches. Updates are treated as + * of a tuple that might be in the system caches. Updates are treated as * two events, delete + insert, for simplicity. (There are cases where * it'd be possible to record just one event, but we don't currently try.) * @@ -74,7 +74,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.54 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/inval.c,v 1.55 2002/09/04 20:31:29 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -129,7 +129,7 @@ static InvalidationListHeader CurrentCmdInvalidMsgs; /* head of previous-commands event list */ static InvalidationListHeader PriorCmdInvalidMsgs; -static bool RelcacheInitFileInval; /* init file must be invalidated? */ +static bool RelcacheInitFileInval; /* init file must be invalidated? */ /* * Dynamically-registered callback functions. Current implementation @@ -395,6 +395,7 @@ RegisterRelcacheInvalidation(Oid dbId, Oid relId) { AddRelcacheInvalidationMessage(&CurrentCmdInvalidMsgs, dbId, relId); + /* * If the relation being invalidated is one of those cached in the * relcache init file, mark that we need to zap that file at commit. @@ -505,10 +506,11 @@ PrepareForTupleInvalidation(Relation relation, HeapTuple tuple, */ if (!IsSystemRelation(relation)) return; - /* - * TOAST tuples can likewise be ignored here. - * Note that TOAST tables are considered system relations - * so they are not filtered by the above test. + + /* + * TOAST tuples can likewise be ignored here. Note that TOAST tables + * are considered system relations so they are not filtered by the + * above test. */ if (IsToastRelation(relation)) return; @@ -573,12 +575,12 @@ AcceptInvalidationMessages(void) * If isCommit, we must send out the messages in our PriorCmdInvalidMsgs list * to the shared invalidation message queue. Note that these will be read * not only by other backends, but also by our own backend at the next - * transaction start (via AcceptInvalidationMessages). This means that + * transaction start (via AcceptInvalidationMessages). This means that * we can skip immediate local processing of anything that's still in * CurrentCmdInvalidMsgs, and just send that list out too. * * If not isCommit, we are aborting, and must locally process the messages - * in PriorCmdInvalidMsgs. No messages need be sent to other backends, + * in PriorCmdInvalidMsgs. No messages need be sent to other backends, * since they'll not have seen our changed tuples anyway. We can forget * about CurrentCmdInvalidMsgs too, since those changes haven't touched * the caches yet. @@ -596,9 +598,9 @@ AtEOXactInvalidationMessages(bool isCommit) if (isCommit) { /* - * Relcache init file invalidation requires processing both - * before and after we send the SI messages. However, we need - * not do anything unless we committed. + * Relcache init file invalidation requires processing both before + * and after we send the SI messages. However, we need not do + * anything unless we committed. */ if (RelcacheInitFileInval) RelationCacheInitFileInvalidate(true); @@ -694,7 +696,7 @@ CacheInvalidateRelcache(Oid relationId) * * NOTE: currently, the OID argument to the callback routine is not * provided for syscache callbacks; the routine doesn't really get any - * useful info as to exactly what changed. It should treat every call + * useful info as to exactly what changed. It should treat every call * as a "cache flush" request. */ void diff --git a/src/backend/utils/cache/lsyscache.c b/src/backend/utils/cache/lsyscache.c index 4054b2920e..2672ed3aad 100644 --- a/src/backend/utils/cache/lsyscache.c +++ b/src/backend/utils/cache/lsyscache.c @@ -7,7 +7,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.82 2002/08/31 22:10:47 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/lsyscache.c,v 1.83 2002/09/04 20:31:30 momjian Exp $ * * NOTES * Eventually, the index information should go through here, too. @@ -349,7 +349,7 @@ op_mergejoinable(Oid opno, Oid ltype, Oid rtype, Oid *leftOp, Oid *rightOp) * * Returns the cross-type comparison operators (ltype "<" rtype and * ltype ">" rtype) for an operator previously determined to be - * mergejoinable. Optionally, fetches the regproc ids of these + * mergejoinable. Optionally, fetches the regproc ids of these * operators, as well as their operator OIDs. */ void @@ -651,7 +651,7 @@ get_relname_relid(const char *relname, Oid relnamespace) Oid get_system_catalog_relid(const char *catname) { - Oid relid; + Oid relid; relid = GetSysCacheOid(RELNAMENSP, PointerGetDatum(catname), @@ -737,7 +737,7 @@ get_rel_namespace(Oid relid) if (HeapTupleIsValid(tp)) { Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); - Oid result; + Oid result; result = reltup->relnamespace; ReleaseSysCache(tp); @@ -766,7 +766,7 @@ get_rel_type_id(Oid relid) if (HeapTupleIsValid(tp)) { Form_pg_class reltup = (Form_pg_class) GETSTRUCT(tp); - Oid result; + Oid result; result = reltup->reltype; ReleaseSysCache(tp); @@ -1105,8 +1105,8 @@ getBaseTypeMod(Oid typid, int32 typmod) /* * The typmod applied to a domain should always be -1. * - * We substitute the domain's typmod as we switch attention to - * the base type. + * We substitute the domain's typmod as we switch attention to the + * base type. */ Assert(typmod < 0); diff --git a/src/backend/utils/cache/relcache.c b/src/backend/utils/cache/relcache.c index 1b33371e90..a0eeff11dd 100644 --- a/src/backend/utils/cache/relcache.c +++ b/src/backend/utils/cache/relcache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.174 2002/09/02 02:47:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/relcache.c,v 1.175 2002/09/04 20:31:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -81,7 +81,7 @@ static FormData_pg_attribute Desc_pg_type[Natts_pg_type] = {Schema_pg_type}; * Relations are looked up two ways, by OID and by name, * thus there are two hash tables for referencing them. * - * The OID index covers all relcache entries. The name index + * The OID index covers all relcache entries. The name index * covers *only* system relations (only those in PG_CATALOG_NAMESPACE). */ static HTAB *RelationIdCache; @@ -98,7 +98,7 @@ static HTAB *RelationNodeCache; * This flag is false until we have prepared the critical relcache entries * that are needed to do indexscans on the tables read by relcache building. */ -bool criticalRelcachesBuilt = false; +bool criticalRelcachesBuilt = false; /* * This flag is set if we discover that we need to write a new relcache @@ -108,7 +108,7 @@ static bool needNewCacheFile = false; /* * This counter counts relcache inval events received since backend startup - * (but only for rels that are actually in cache). Presently, we use it only + * (but only for rels that are actually in cache). Presently, we use it only * to detect whether data about to be written by write_relcache_init_file() * might already be obsolete. */ @@ -260,8 +260,8 @@ typedef struct opclasscacheent StrategyNumber numStrats; /* max # of strategies (from pg_am) */ StrategyNumber numSupport; /* max # of support procs (from pg_am) */ Oid *operatorOids; /* strategy operators' OIDs */ - RegProcedure *operatorProcs; /* strategy operators' procs */ - RegProcedure *supportProcs; /* support procs */ + RegProcedure *operatorProcs; /* strategy operators' procs */ + RegProcedure *supportProcs; /* support procs */ } OpClassCacheEnt; static HTAB *OpClassCache = NULL; @@ -292,15 +292,15 @@ static void AttrDefaultFetch(Relation relation); static void CheckConstraintFetch(Relation relation); static List *insert_ordered_oid(List *list, Oid datum); static void IndexSupportInitialize(Form_pg_index iform, - IndexStrategy indexStrategy, - Oid *indexOperator, - RegProcedure *indexSupport, - StrategyNumber maxStrategyNumber, - StrategyNumber maxSupportNumber, - AttrNumber maxAttributeNumber); + IndexStrategy indexStrategy, + Oid *indexOperator, + RegProcedure *indexSupport, + StrategyNumber maxStrategyNumber, + StrategyNumber maxSupportNumber, + AttrNumber maxAttributeNumber); static OpClassCacheEnt *LookupOpclassInfo(Oid operatorClassOid, - StrategyNumber numStrats, - StrategyNumber numSupport); + StrategyNumber numStrats, + StrategyNumber numSupport); /* @@ -345,7 +345,7 @@ ScanPgRelation(RelationBuildDescInfo buildinfo) ScanKeyEntryInitialize(&key[1], 0, Anum_pg_class_relnamespace, F_OIDEQ, - ObjectIdGetDatum(PG_CATALOG_NAMESPACE)); + ObjectIdGetDatum(PG_CATALOG_NAMESPACE)); nkeys = 2; indexRelname = ClassNameNspIndex; break; @@ -356,9 +356,9 @@ ScanPgRelation(RelationBuildDescInfo buildinfo) } /* - * Open pg_class and fetch a tuple. Force heap scan if we haven't - * yet built the critical relcache entries (this includes initdb - * and startup without a pg_internal.init file). + * Open pg_class and fetch a tuple. Force heap scan if we haven't yet + * built the critical relcache entries (this includes initdb and + * startup without a pg_internal.init file). */ pg_class_desc = heap_openr(RelationRelationName, AccessShareLock); pg_class_scan = systable_beginscan(pg_class_desc, indexRelname, @@ -481,9 +481,9 @@ RelationBuildTupleDesc(RelationBuildDescInfo buildinfo, Int16GetDatum(0)); /* - * Open pg_attribute and begin a scan. Force heap scan if we haven't - * yet built the critical relcache entries (this includes initdb - * and startup without a pg_internal.init file). + * Open pg_attribute and begin a scan. Force heap scan if we haven't + * yet built the critical relcache entries (this includes initdb and + * startup without a pg_internal.init file). */ pg_attribute_desc = heap_openr(AttributeRelationName, AccessShareLock); pg_attribute_scan = systable_beginscan(pg_attribute_desc, @@ -653,8 +653,8 @@ RelationBuildRuleLock(Relation relation) relation->rd_rulescxt = rulescxt; /* - * allocate an array to hold the rewrite rules (the array is extended if - * necessary) + * allocate an array to hold the rewrite rules (the array is extended + * if necessary) */ maxlocks = 4; rules = (RewriteRule **) @@ -672,14 +672,14 @@ RelationBuildRuleLock(Relation relation) /* * open pg_rewrite and begin a scan * - * Note: since we scan the rules using RewriteRelRulenameIndex, - * we will be reading the rules in name order, except possibly - * during emergency-recovery operations (ie, IsIgnoringSystemIndexes). - * This in turn ensures that rules will be fired in name order. + * Note: since we scan the rules using RewriteRelRulenameIndex, we will + * be reading the rules in name order, except possibly during + * emergency-recovery operations (ie, IsIgnoringSystemIndexes). This + * in turn ensures that rules will be fired in name order. */ rewrite_desc = heap_openr(RewriteRelationName, AccessShareLock); rewrite_tupdesc = RelationGetDescr(rewrite_desc); - rewrite_scan = systable_beginscan(rewrite_desc, + rewrite_scan = systable_beginscan(rewrite_desc, RewriteRelRulenameIndex, true, SnapshotNow, 1, &key); @@ -723,7 +723,7 @@ RelationBuildRuleLock(Relation relation) &isnull); Assert(!isnull); rule_evqual_str = DatumGetCString(DirectFunctionCall1(textout, - rule_evqual)); + rule_evqual)); oldcxt = MemoryContextSwitchTo(rulescxt); rule->qual = (Node *) stringToNode(rule_evqual_str); MemoryContextSwitchTo(oldcxt); @@ -767,9 +767,9 @@ equalRuleLocks(RuleLock *rlock1, RuleLock *rlock2) int i; /* - * As of 7.3 we assume the rule ordering is repeatable, - * because RelationBuildRuleLock should read 'em in a - * consistent order. So just compare corresponding slots. + * As of 7.3 we assume the rule ordering is repeatable, because + * RelationBuildRuleLock should read 'em in a consistent order. So + * just compare corresponding slots. */ if (rlock1 != NULL) { @@ -860,9 +860,10 @@ RelationBuildDesc(RelationBuildDescInfo buildinfo, RelationSetReferenceCount(relation, 1); /* - * normal relations are not nailed into the cache; nor can a pre-existing - * relation be new. It could be temp though. (Actually, it could be new - * too, but it's okay to forget that fact if forced to flush the entry.) + * normal relations are not nailed into the cache; nor can a + * pre-existing relation be new. It could be temp though. (Actually, + * it could be new too, but it's okay to forget that fact if forced to + * flush the entry.) */ relation->rd_isnailed = false; relation->rd_isnew = false; @@ -950,8 +951,8 @@ RelationInitIndexAccessInfo(Relation relation) uint16 amsupport; /* - * Make a copy of the pg_index entry for the index. Note that this - * is a variable-length tuple. + * Make a copy of the pg_index entry for the index. Note that this is + * a variable-length tuple. */ tuple = SearchSysCache(INDEXRELID, ObjectIdGetDatum(RelationGetRelid(relation)), @@ -1116,6 +1117,7 @@ IndexSupportInitialize(Form_pg_index iform, MemSet(mapentry, 0, sizeof(*mapentry)); mapentry->sk_flags = 0; mapentry->sk_procedure = opcentry->operatorProcs[strategy]; + /* * Mark mapentry->sk_func invalid, until and unless * someone sets it up. @@ -1387,7 +1389,7 @@ formrdesc(const char *relationName, /* * It's important to distinguish between shared and non-shared * relations, even at bootstrap time, to make sure we know where they - * are stored. At present, all relations that formrdesc is used for + * are stored. At present, all relations that formrdesc is used for * are not shared. */ relation->rd_rel->relisshared = false; @@ -1401,12 +1403,12 @@ formrdesc(const char *relationName, /* * initialize attribute tuple form * - * Unlike the case with the relation tuple, this data had better be - * right because it will never be replaced. The input values must be + * Unlike the case with the relation tuple, this data had better be right + * because it will never be replaced. The input values must be * correctly defined by macros in src/include/catalog/ headers. */ relation->rd_att = CreateTemplateTupleDesc(natts, - relation->rd_rel->relhasoids); + relation->rd_rel->relhasoids); /* * initialize tuple desc info @@ -1799,10 +1801,11 @@ RelationClearRelation(Relation relation, bool rebuild) FreeTriggerDesc(old_trigdesc); /* - * Update rd_nblocks. This is kind of expensive, but I think we must - * do it in case relation has been truncated... we definitely must - * do it if the rel is new or temp, since RelationGetNumberOfBlocks - * will subsequently assume that the block count is correct. + * Update rd_nblocks. This is kind of expensive, but I think we + * must do it in case relation has been truncated... we definitely + * must do it if the rel is new or temp, since + * RelationGetNumberOfBlocks will subsequently assume that the + * block count is correct. */ RelationUpdateNumberOfBlocks(relation); } @@ -1971,12 +1974,13 @@ AtEOXact_RelationCache(bool commit) /* * Is it a relation created in the current transaction? * - * During commit, reset the flag to false, since we are now out of the - * creating transaction. During abort, simply delete the relcache - * entry --- it isn't interesting any longer. (NOTE: if we have - * forgotten the isnew state of a new relation due to a forced cache - * flush, the entry will get deleted anyway by shared-cache-inval - * processing of the aborted pg_class insertion.) + * During commit, reset the flag to false, since we are now out of + * the creating transaction. During abort, simply delete the + * relcache entry --- it isn't interesting any longer. (NOTE: if + * we have forgotten the isnew state of a new relation due to a + * forced cache flush, the entry will get deleted anyway by + * shared-cache-inval processing of the aborted pg_class + * insertion.) */ if (relation->rd_isnew) { @@ -1991,18 +1995,18 @@ AtEOXact_RelationCache(bool commit) /* * During transaction abort, we must also reset relcache entry ref - * counts to their normal not-in-a-transaction state. A ref count may - * be too high because some routine was exited by elog() between - * incrementing and decrementing the count. + * counts to their normal not-in-a-transaction state. A ref count + * may be too high because some routine was exited by elog() + * between incrementing and decrementing the count. * - * During commit, we should not have to do this, but it's still useful - * to check that the counts are correct to catch missed relcache - * closes. + * During commit, we should not have to do this, but it's still + * useful to check that the counts are correct to catch missed + * relcache closes. * * In bootstrap mode, do NOT reset the refcnt nor complain that it's * nonzero --- the bootstrap code expects relations to stay open - * across start/commit transaction calls. (That seems bogus, but it's - * not worth fixing.) + * across start/commit transaction calls. (That seems bogus, but + * it's not worth fixing.) */ expected_refcnt = relation->rd_isnailed ? 1 : 0; @@ -2083,10 +2087,10 @@ RelationBuildLocalRelation(const char *relname, /* * create a new tuple descriptor from the one passed in. We do this * partly to copy it into the cache context, and partly because the - * new relation can't have any defaults or constraints yet; they - * have to be added in later steps, because they require additions - * to multiple system catalogs. We can copy attnotnull constraints - * here, however. + * new relation can't have any defaults or constraints yet; they have + * to be added in later steps, because they require additions to + * multiple system catalogs. We can copy attnotnull constraints here, + * however. */ rel->rd_att = CreateTupleDescCopy(tupDesc); for (i = 0; i < natts; i++) @@ -2184,12 +2188,12 @@ RelationCacheInitialize(void) &ctl, HASH_ELEM | HASH_FUNCTION); /* - * Try to load the relcache cache file. If successful, we're done - * for now. Otherwise, initialize the cache with pre-made descriptors - * for the critical "nailed-in" system catalogs. + * Try to load the relcache cache file. If successful, we're done for + * now. Otherwise, initialize the cache with pre-made descriptors for + * the critical "nailed-in" system catalogs. */ if (IsBootstrapProcessingMode() || - ! load_relcache_init_file()) + !load_relcache_init_file()) { formrdesc(RelationRelationName, Natts_pg_class, Desc_pg_class); @@ -2228,22 +2232,23 @@ RelationCacheInitializePhase2(void) * If we didn't get the critical system indexes loaded into relcache, * do so now. These are critical because the catcache depends on them * for catcache fetches that are done during relcache load. Thus, we - * have an infinite-recursion problem. We can break the recursion - * by doing heapscans instead of indexscans at certain key spots. - * To avoid hobbling performance, we only want to do that until we - * have the critical indexes loaded into relcache. Thus, the flag - * criticalRelcachesBuilt is used to decide whether to do heapscan - * or indexscan at the key spots, and we set it true after we've loaded + * have an infinite-recursion problem. We can break the recursion by + * doing heapscans instead of indexscans at certain key spots. To + * avoid hobbling performance, we only want to do that until we have + * the critical indexes loaded into relcache. Thus, the flag + * criticalRelcachesBuilt is used to decide whether to do heapscan or + * indexscan at the key spots, and we set it true after we've loaded * the critical indexes. * * The critical indexes are marked as "nailed in cache", partly to make * it easy for load_relcache_init_file to count them, but mainly * because we cannot flush and rebuild them once we've set - * criticalRelcachesBuilt to true. (NOTE: perhaps it would be possible - * to reload them by temporarily setting criticalRelcachesBuilt to - * false again. For now, though, we just nail 'em in.) + * criticalRelcachesBuilt to true. (NOTE: perhaps it would be + * possible to reload them by temporarily setting + * criticalRelcachesBuilt to false again. For now, though, we just + * nail 'em in.) */ - if (! criticalRelcachesBuilt) + if (!criticalRelcachesBuilt) { RelationBuildDescInfo buildinfo; Relation ird; @@ -2265,7 +2270,7 @@ RelationCacheInitializePhase2(void) LOAD_CRIT_INDEX(AccessMethodProcedureIndex); LOAD_CRIT_INDEX(OperatorOidIndex); -#define NUM_CRITICAL_INDEXES 7 /* fix if you change list above */ +#define NUM_CRITICAL_INDEXES 7 /* fix if you change list above */ criticalRelcachesBuilt = true; } @@ -2273,10 +2278,10 @@ RelationCacheInitializePhase2(void) /* * Now, scan all the relcache entries and update anything that might * be wrong in the results from formrdesc or the relcache cache file. - * If we faked up relcache entries using formrdesc, then read - * the real pg_class rows and replace the fake entries with them. - * Also, if any of the relcache entries have rules or triggers, - * load that info the hard way since it isn't recorded in the cache file. + * If we faked up relcache entries using formrdesc, then read the real + * pg_class rows and replace the fake entries with them. Also, if any + * of the relcache entries have rules or triggers, load that info the + * hard way since it isn't recorded in the cache file. */ hash_seq_init(&status, RelationIdCache); @@ -2293,12 +2298,13 @@ RelationCacheInitializePhase2(void) Form_pg_class relp; htup = SearchSysCache(RELOID, - ObjectIdGetDatum(RelationGetRelid(relation)), + ObjectIdGetDatum(RelationGetRelid(relation)), 0, 0, 0); if (!HeapTupleIsValid(htup)) elog(FATAL, "RelationCacheInitializePhase2: no pg_class entry for %s", RelationGetRelationName(relation)); relp = (Form_pg_class) GETSTRUCT(htup); + /* * Copy tuple to relation->rd_rel. (See notes in * AllocateRelationDesc()) @@ -2335,11 +2341,11 @@ RelationCacheInitializePhase3(void) if (needNewCacheFile) { /* - * Force all the catcaches to finish initializing and thereby - * open the catalogs and indexes they use. This will preload - * the relcache with entries for all the most important system - * catalogs and indexes, so that the init file will be most - * useful for future backends. + * Force all the catcaches to finish initializing and thereby open + * the catalogs and indexes they use. This will preload the + * relcache with entries for all the most important system + * catalogs and indexes, so that the init file will be most useful + * for future backends. */ InitCatalogCachePhase2(); @@ -2509,7 +2515,7 @@ CheckConstraintFetch(Relation relation) RelationGetRelationName(relation)); check[found].ccname = MemoryContextStrdup(CacheMemoryContext, - NameStr(conform->conname)); + NameStr(conform->conname)); /* Grab and test conbin is actually set */ val = fastgetattr(htup, @@ -2559,7 +2565,7 @@ List * RelationGetIndexList(Relation relation) { Relation indrel; - SysScanDesc indscan; + SysScanDesc indscan; ScanKeyData skey; HeapTuple htup; List *result; @@ -2724,7 +2730,7 @@ load_relcache_init_file(void) nailed_rels = nailed_indexes = 0; initFileRelationIds = NIL; - for (relno = 0; ; relno++) + for (relno = 0;; relno++) { Size len; size_t nread; @@ -2820,9 +2826,9 @@ load_relcache_init_file(void) */ indexcxt = AllocSetContextCreate(CacheMemoryContext, RelationGetRelationName(rel), - 0, /* minsize */ - 512, /* initsize */ - 1024); /* maxsize */ + 0, /* minsize */ + 512, /* initsize */ + 1024); /* maxsize */ rel->rd_indexcxt = indexcxt; /* next, read the index strategy map */ @@ -2883,8 +2889,9 @@ load_relcache_init_file(void) /* * Rules and triggers are not saved (mainly because the internal * format is complex and subject to change). They must be rebuilt - * if needed by RelationCacheInitializePhase2. This is not expected - * to be a big performance hit since few system catalogs have such. + * if needed by RelationCacheInitializePhase2. This is not + * expected to be a big performance hit since few system catalogs + * have such. */ rel->rd_rules = NULL; rel->rd_rulescxt = NULL; @@ -2917,8 +2924,8 @@ load_relcache_init_file(void) } /* - * We reached the end of the init file without apparent problem. - * Did we get the right number of nailed items? (This is a useful + * We reached the end of the init file without apparent problem. Did + * we get the right number of nailed items? (This is a useful * crosscheck in case the set of critical rels or indexes changes.) */ if (nailed_rels != NUM_CRITICAL_RELS || @@ -2945,9 +2952,9 @@ load_relcache_init_file(void) return true; /* - * init file is broken, so do it the hard way. We don't bother - * trying to free the clutter we just allocated; it's not in the - * relcache so it won't hurt. + * init file is broken, so do it the hard way. We don't bother trying + * to free the clutter we just allocated; it's not in the relcache so + * it won't hurt. */ read_failed: pfree(rels); @@ -3052,7 +3059,7 @@ write_relcache_init_file(void) * afresh using the syscache, and write that. */ tuple = SearchSysCache(INDEXRELID, - ObjectIdGetDatum(RelationGetRelid(rel)), + ObjectIdGetDatum(RelationGetRelid(rel)), 0, 0, 0); if (!HeapTupleIsValid(tuple)) elog(ERROR, "write_relcache_init_file: no pg_index entry for index %u", @@ -3109,14 +3116,14 @@ write_relcache_init_file(void) /* * Now we have to check whether the data we've so painstakingly - * accumulated is already obsolete due to someone else's just-committed - * catalog changes. If so, we just delete the temp file and leave it - * to the next backend to try again. (Our own relcache entries will be - * updated by SI message processing, but we can't be sure whether what - * we wrote out was up-to-date.) + * accumulated is already obsolete due to someone else's + * just-committed catalog changes. If so, we just delete the temp + * file and leave it to the next backend to try again. (Our own + * relcache entries will be updated by SI message processing, but we + * can't be sure whether what we wrote out was up-to-date.) * - * This mustn't run concurrently with RelationCacheInitFileInvalidate, - * so grab a serialization lock for the duration. + * This mustn't run concurrently with RelationCacheInitFileInvalidate, so + * grab a serialization lock for the duration. */ LWLockAcquire(RelCacheInitLock, LW_EXCLUSIVE); @@ -3140,9 +3147,10 @@ write_relcache_init_file(void) if (rename(tempfilename, finalfilename) < 0) { elog(WARNING, "Cannot rename init file %s to %s: %m\n\tContinuing anyway, but there's something wrong.", tempfilename, finalfilename); + /* - * If we fail, try to clean up the useless temp file; don't bother - * to complain if this fails too. + * If we fail, try to clean up the useless temp file; don't + * bother to complain if this fails too. */ unlink(tempfilename); } @@ -3206,13 +3214,13 @@ RelationCacheInitFileInvalidate(bool beforeSend) else { /* - * We need to interlock this against write_relcache_init_file, - * to guard against possibility that someone renames a new-but- + * We need to interlock this against write_relcache_init_file, to + * guard against possibility that someone renames a new-but- * already-obsolete init file into place just after we unlink. * With the interlock, it's certain that write_relcache_init_file - * will notice our SI inval message before renaming into place, - * or else that we will execute second and successfully unlink - * the file. + * will notice our SI inval message before renaming into place, or + * else that we will execute second and successfully unlink the + * file. */ LWLockAcquire(RelCacheInitLock, LW_EXCLUSIVE); unlink(initfilename); diff --git a/src/backend/utils/cache/syscache.c b/src/backend/utils/cache/syscache.c index 357829bee5..3eca49ba8a 100644 --- a/src/backend/utils/cache/syscache.c +++ b/src/backend/utils/cache/syscache.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.86 2002/08/05 03:29:17 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/cache/syscache.c,v 1.87 2002/09/04 20:31:30 momjian Exp $ * * NOTES * These routines allow the parser/planner/executor to perform @@ -174,7 +174,7 @@ static const struct cachedesc cacheinfo[] = { 0 }}, { - CastRelationName, /* CASTSOURCETARGET */ + CastRelationName, /* CASTSOURCETARGET */ CastSourceTargetIndex, 0, 2, @@ -204,7 +204,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {ConversionRelationName, /* CONDEFAULT */ + {ConversionRelationName, /* CONDEFAULT */ ConversionDefaultIndex, 0, 4, @@ -214,7 +214,7 @@ static const struct cachedesc cacheinfo[] = { Anum_pg_conversion_contoencoding, ObjectIdAttributeNumber, }}, - {ConversionRelationName, /* CONNAMENSP */ + {ConversionRelationName, /* CONNAMENSP */ ConversionNameNspIndex, 0, 2, @@ -224,7 +224,7 @@ static const struct cachedesc cacheinfo[] = { 0, 0 }}, - {ConversionRelationName, /* CONOID */ + {ConversionRelationName, /* CONOID */ ConversionOidIndex, 0, 1, @@ -436,7 +436,8 @@ static const struct cachedesc cacheinfo[] = { }} }; -static CatCache *SysCache[lengthof(cacheinfo)]; +static CatCache *SysCache[ + lengthof(cacheinfo)]; static int SysCacheSize = lengthof(cacheinfo); static bool CacheInitialized = false; @@ -501,9 +502,7 @@ InitCatalogCachePhase2(void) Assert(CacheInitialized); for (cacheId = 0; cacheId < SysCacheSize; cacheId++) - { InitCatCachePhase2(SysCache[cacheId]); - } } @@ -531,7 +530,7 @@ SearchSysCache(int cacheId, Datum key4) { if (cacheId < 0 || cacheId >= SysCacheSize || - ! PointerIsValid(SysCache[cacheId])) + !PointerIsValid(SysCache[cacheId])) elog(ERROR, "SearchSysCache: Bad cache id %d", cacheId); return SearchCatCache(SysCache[cacheId], key1, key2, key3, key4); @@ -731,7 +730,7 @@ SearchSysCacheList(int cacheId, int nkeys, Datum key1, Datum key2, Datum key3, Datum key4) { if (cacheId < 0 || cacheId >= SysCacheSize || - ! PointerIsValid(SysCache[cacheId])) + !PointerIsValid(SysCache[cacheId])) elog(ERROR, "SearchSysCacheList: Bad cache id %d", cacheId); return SearchCatCacheList(SysCache[cacheId], nkeys, diff --git a/src/backend/utils/error/assert.c b/src/backend/utils/error/assert.c index 81fe83c4b4..f03dbf5c2f 100644 --- a/src/backend/utils/error/assert.c +++ b/src/backend/utils/error/assert.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.22 2002/08/10 20:29:18 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/assert.c,v 1.23 2002/09/04 20:31:30 momjian Exp $ * * NOTE * This should eventually work with elog() @@ -31,9 +31,7 @@ ExceptionalCondition(char *conditionName, if (!PointerIsValid(conditionName) || !PointerIsValid(fileName) || !PointerIsValid(errorType)) - { fprintf(stderr, "TRAP: ExceptionalCondition: bad arguments\n"); - } else { fprintf(stderr, "TRAP: %s(\"%s\", File: \"%s\", Line: %d)\n", diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 9258dd9fbc..f730fb9527 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.102 2002/09/02 05:42:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/error/elog.c,v 1.103 2002/09/04 20:31:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -91,6 +91,7 @@ void elog(int lev, const char *fmt,...) { va_list ap; + /* * The expanded format and final output message are dynamically * allocated if necessary, but not if they fit in the "reasonable @@ -103,22 +104,22 @@ elog(int lev, const char *fmt,...) * Note that we use malloc() not palloc() because we want to retain * control if we run out of memory. palloc() would recursively call * elog(ERROR), which would be all right except if we are working on a - * FATAL or PANIC error. We'd lose track of the fatal condition - * and report a mere ERROR to outer loop, which would be a Bad Thing. - * So, we substitute an appropriate message in-place, without - * downgrading the level if it's above ERROR. + * FATAL or PANIC error. We'd lose track of the fatal condition and + * report a mere ERROR to outer loop, which would be a Bad Thing. So, + * we substitute an appropriate message in-place, without downgrading + * the level if it's above ERROR. */ char fmt_fixedbuf[128]; char msg_fixedbuf[256]; char *fmt_buf = fmt_fixedbuf; char *msg_buf = msg_fixedbuf; - char copylineno_buf[32]; /* for COPY line numbers */ + char copylineno_buf[32]; /* for COPY line numbers */ const char *errorstr; const char *prefix; const char *cp; char *bp; size_t space_needed; - size_t timestamp_size; /* prefix len for timestamp+pid */ + size_t timestamp_size; /* prefix len for timestamp+pid */ bool output_to_server = false; bool output_to_client = false; @@ -206,13 +207,13 @@ elog(int lev, const char *fmt,...) * calculation simple, we only allow one %m. */ space_needed = timestamp_size + strlen(prefix) + - strlen(fmt) + strlen(errorstr) + 1; + strlen(fmt) + strlen(errorstr) + 1; if (copy_lineno) { /* - * Prints the failure line of the COPY. Wow, what a hack! bjm - * Translator: Error message will be truncated at 31 characters. + * Prints the failure line of the COPY. Wow, what a hack! bjm + * Translator: Error message will be truncated at 31 characters. */ snprintf(copylineno_buf, 32, gettext("copy: line %d, "), copy_lineno); space_needed += strlen(copylineno_buf); @@ -427,13 +428,14 @@ elog(int lev, const char *fmt,...) if (msg_buf != msg_fixedbuf) free(msg_buf); - /* If the user wants this elog() generating query logged, - * do so. We only want to log if the query has been - * written to debug_query_string. Also, avoid infinite loops. + /* + * If the user wants this elog() generating query logged, do so. We + * only want to log if the query has been written to + * debug_query_string. Also, avoid infinite loops. */ - if(lev != LOG && lev >= log_min_error_statement && debug_query_string) - elog(LOG,"statement: %s",debug_query_string); + if (lev != LOG && lev >= log_min_error_statement && debug_query_string) + elog(LOG, "statement: %s", debug_query_string); /* * Perform error recovery action as specified by lev. @@ -445,7 +447,8 @@ elog(int lev, const char *fmt,...) /* * If we just reported a startup failure, the client will - * disconnect on receiving it, so don't send any more to the client. + * disconnect on receiving it, so don't send any more to the + * client. */ if (!Warn_restart_ready && whereToSendOutput == Remote) whereToSendOutput = None; @@ -506,7 +509,7 @@ elog(int lev, const char *fmt,...) proc_exit(2); } - /* We reach here if lev <= WARNING. OK to return to caller. */ + /* We reach here if lev <= WARNING. OK to return to caller. */ } @@ -744,8 +747,8 @@ send_message_to_frontend(int type, const char *msg) AssertArg(type <= ERROR); pq_beginmessage(&buf); - pq_sendbyte(&buf, type != ERROR ? 'N' : 'E'); /* N is INFO, NOTICE, - * or WARNING */ + pq_sendbyte(&buf, type != ERROR ? 'N' : 'E'); /* N is INFO, NOTICE, or + * WARNING */ pq_sendstring(&buf, msg); pq_endmessage(&buf); @@ -835,6 +838,3 @@ elog_message_prefix(int lev) Assert(prefix != NULL); return prefix; } - - - diff --git a/src/backend/utils/fmgr/fmgr.c b/src/backend/utils/fmgr/fmgr.c index 7e3204c5c0..c0cef75e8c 100644 --- a/src/backend/utils/fmgr/fmgr.c +++ b/src/backend/utils/fmgr/fmgr.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.61 2002/08/13 17:22:08 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/fmgr.c,v 1.62 2002/09/04 20:31:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,7 +58,7 @@ typedef struct static void fmgr_info_cxt_security(Oid functionId, FmgrInfo *finfo, MemoryContext mcxt, - bool ignore_security); + bool ignore_security); static void fmgr_info_C_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple); static void fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple); static Datum fmgr_oldstyle(PG_FUNCTION_ARGS); @@ -339,8 +339,8 @@ fmgr_info_other_lang(Oid functionId, FmgrInfo *finfo, HeapTuple procedureTuple) /* * If lookup of the PL handler function produced nonnull fn_extra, - * complain --- it must be an oldstyle function! We no longer - * support oldstyle PL handlers. + * complain --- it must be an oldstyle function! We no longer support + * oldstyle PL handlers. */ if (plfinfo.fn_extra != NULL) elog(ERROR, "fmgr_info: language %u has old-style handler", diff --git a/src/backend/utils/fmgr/funcapi.c b/src/backend/utils/fmgr/funcapi.c index 0df872cf92..95975653a6 100644 --- a/src/backend/utils/fmgr/funcapi.c +++ b/src/backend/utils/fmgr/funcapi.c @@ -7,7 +7,7 @@ * Copyright (c) 2002, PostgreSQL Global Development Group * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.5 2002/08/30 19:56:49 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/fmgr/funcapi.c,v 1.6 2002/09/04 20:31:30 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -62,7 +62,8 @@ init_MultiFuncCall(PG_FUNCTION_ARGS) */ fcinfo->flinfo->fn_extra = retval; } - else /* second and subsequent calls */ + else +/* second and subsequent calls */ { elog(ERROR, "init_MultiFuncCall may not be called more than once"); @@ -75,7 +76,7 @@ init_MultiFuncCall(PG_FUNCTION_ARGS) /* * per_MultiFuncCall - * + * * Do Multi-function per-call setup */ FuncCallContext * @@ -87,8 +88,8 @@ per_MultiFuncCall(PG_FUNCTION_ARGS) * Clear the TupleTableSlot, if present. This is for safety's sake: * the Slot will be in a long-lived context (it better be, if the * FuncCallContext is pointing to it), but in most usage patterns the - * tuples stored in it will be in the function's per-tuple context. - * So at the beginning of each call, the Slot will hold a dangling + * tuples stored in it will be in the function's per-tuple context. So + * at the beginning of each call, the Slot will hold a dangling * pointer to an already-recycled tuple. We clear it out here. (See * also the definition of TupleGetDatum() in funcapi.h!) */ @@ -109,8 +110,8 @@ end_MultiFuncCall(PG_FUNCTION_ARGS, FuncCallContext *funcctx) fcinfo->flinfo->fn_extra = NULL; /* - * Caller is responsible to free up memory for individual - * struct elements other than att_in_funcinfo and elements. + * Caller is responsible to free up memory for individual struct + * elements other than att_in_funcinfo and elements. */ if (funcctx->attinmeta != NULL) pfree(funcctx->attinmeta); diff --git a/src/backend/utils/init/findbe.c b/src/backend/utils/init/findbe.c index 6c9698da48..3c5e04055a 100644 --- a/src/backend/utils/init/findbe.c +++ b/src/backend/utils/init/findbe.c @@ -7,7 +7,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.29 2002/09/02 02:47:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/Attic/findbe.c,v 1.30 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -115,7 +115,7 @@ ValidateBinary(char *path) is_x = buf.st_mode & S_IXGRP; if (!(is_r && is_x)) elog(DEBUG2, "ValidateBinary: \"%s\" is not group read/execute", - path); + path); return is_x ? (is_r ? 0 : -2) : -1; } } @@ -123,7 +123,7 @@ ValidateBinary(char *path) is_x = buf.st_mode & S_IXOTH; if (!(is_r && is_x)) elog(DEBUG2, "ValidateBinary: \"%s\" is not other read/execute", - path); + path); return is_x ? (is_r ? 0 : -2) : -1; } @@ -207,7 +207,7 @@ FindExec(char *full_path, const char *argv0, const char *binary_name) case 0: /* found ok */ strncpy(full_path, buf, MAXPGPATH); elog(DEBUG1, "FindExec: found \"%s\" using PATH", - full_path); + full_path); free(path); return 0; case -1: /* wasn't even a candidate, keep looking */ diff --git a/src/backend/utils/init/globals.c b/src/backend/utils/init/globals.c index 51a729c49c..91c3ba0146 100644 --- a/src/backend/utils/init/globals.c +++ b/src/backend/utils/init/globals.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.66 2002/08/12 00:36:11 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/globals.c,v 1.67 2002/09/04 20:31:31 momjian Exp $ * * NOTES * Globals used all over the place should be declared here and not @@ -39,6 +39,7 @@ struct Port *MyProcPort; long MyCancelKey; char *DataDir = NULL; + /* * The PGDATA directory user says to use, or defaults to via environment * variable. NULL if no option given and no environment variable set diff --git a/src/backend/utils/init/miscinit.c b/src/backend/utils/init/miscinit.c index df67988bed..f41706862f 100644 --- a/src/backend/utils/init/miscinit.c +++ b/src/backend/utils/init/miscinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.95 2002/09/02 02:47:05 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/miscinit.c,v 1.96 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -176,8 +176,8 @@ SetDataDir(const char *dir) * generating funny-looking paths to individual files. */ newlen = strlen(new); - if (newlen > 1 && new[newlen-1] == '/') - new[newlen-1] = '\0'; + if (newlen > 1 && new[newlen - 1] == '/') + new[newlen - 1] = '\0'; if (DataDir) free(DataDir); @@ -470,7 +470,6 @@ GetCharSetByHost(char *TableName, int host, const char *DataDir) pfree(ChArray[i]); } } - #endif /* CYR_RECODE */ @@ -561,22 +560,22 @@ InitializeSessionUserId(const char *username) AuthenticatedUserId = usesysid; AuthenticatedUserIsSuperuser = ((Form_pg_shadow) GETSTRUCT(userTup))->usesuper; - SetSessionUserId(usesysid); /* sets CurrentUserId too */ + SetSessionUserId(usesysid); /* sets CurrentUserId too */ /* Record username as a config option too */ SetConfigOption("session_authorization", username, PGC_BACKEND, PGC_S_OVERRIDE); /* - * Set up user-specific configuration variables. This is a good - * place to do it so we don't have to read pg_shadow twice during - * session startup. + * Set up user-specific configuration variables. This is a good place + * to do it so we don't have to read pg_shadow twice during session + * startup. */ datum = SysCacheGetAttr(SHADOWNAME, userTup, Anum_pg_shadow_useconfig, &isnull); if (!isnull) { - ArrayType *a = DatumGetArrayTypeP(datum); + ArrayType *a = DatumGetArrayTypeP(datum); ProcessGUCArray(a, PGC_S_USER); } @@ -952,7 +951,7 @@ RecordSharedMemoryInLockFile(unsigned long id1, unsigned long id2) ptr++; /* - * Append key information. Format to try to keep it the same length + * Append key information. Format to try to keep it the same length * always (trailing junk won't hurt, but might confuse humans). */ sprintf(ptr, "%9lu %9lu\n", id1, id2); diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index 7de6eb2595..ee4abdff88 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.115 2002/09/03 21:45:42 petere Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/init/postinit.c,v 1.116 2002/09/04 20:31:31 momjian Exp $ * * *------------------------------------------------------------------------- @@ -124,13 +124,14 @@ ReverifyMyDatabase(const char *name) name); /* - * OK, we're golden. Only other to-do item is to save the - * encoding info out of the pg_database tuple. + * OK, we're golden. Only other to-do item is to save the encoding + * info out of the pg_database tuple. */ SetDatabaseEncoding(dbform->encoding); /* If we have no other source of client_encoding, use server encoding */ SetConfigOption("client_encoding", GetDatabaseEncodingName(), PGC_BACKEND, PGC_S_DEFAULT); + /* * Set up database-specific configuration variables. */ @@ -143,7 +144,7 @@ ReverifyMyDatabase(const char *name) RelationGetDescr(pgdbrel), &isnull); if (!isnull) { - ArrayType *a = DatumGetArrayTypeP(datum); + ArrayType *a = DatumGetArrayTypeP(datum); ProcessGUCArray(a, PGC_S_DATABASE); } @@ -277,8 +278,8 @@ InitPostgres(const char *dbname, const char *username) */ /* - * Set up my per-backend PGPROC struct in shared memory. (We need to - * know MyDatabaseId before we can do this, since it's entered into + * Set up my per-backend PGPROC struct in shared memory. (We need + * to know MyDatabaseId before we can do this, since it's entered into * the PGPROC struct.) */ InitProcess(); @@ -304,9 +305,9 @@ InitPostgres(const char *dbname, const char *username) AmiTransactionOverride(bootstrap); /* - * Initialize the relation descriptor cache. This must create - * at least the minimum set of "nailed-in" cache entries. No - * catalog access happens here. + * Initialize the relation descriptor cache. This must create at + * least the minimum set of "nailed-in" cache entries. No catalog + * access happens here. */ RelationCacheInitialize(); @@ -367,25 +368,26 @@ InitPostgres(const char *dbname, const char *username) ReverifyMyDatabase(dbname); /* - * Final phase of relation cache startup: write a new cache file - * if necessary. This is done after ReverifyMyDatabase to avoid - * writing a cache file into a dead database. + * Final phase of relation cache startup: write a new cache file if + * necessary. This is done after ReverifyMyDatabase to avoid writing + * a cache file into a dead database. */ RelationCacheInitializePhase3(); /* - * Initialize various default states that can't be set up until - * we've selected the active user and done ReverifyMyDatabase. + * Initialize various default states that can't be set up until we've + * selected the active user and done ReverifyMyDatabase. */ /* set default namespace search path */ InitializeSearchPath(); /* - * Set up process-exit callback to do pre-shutdown cleanup. This should - * be last because we want shmem_exit to call this routine before the exit - * callbacks that are registered by buffer manager, lock manager, etc. - * We need to run this code before we close down database access! + * Set up process-exit callback to do pre-shutdown cleanup. This + * should be last because we want shmem_exit to call this routine + * before the exit callbacks that are registered by buffer manager, + * lock manager, etc. We need to run this code before we close down + * database access! */ on_shmem_exit(ShutdownPostgres, 0); @@ -395,10 +397,11 @@ InitPostgres(const char *dbname, const char *username) /* * Check a normal user hasn't connected to a superuser reserved slot. - * Do this here since we need the user information and that only happens - * after we've started bringing the shared memory online. So we wait - * until we've registered exit handlers and potentially shut an open - * transaction down for an as safety conscious rejection as possible. + * Do this here since we need the user information and that only + * happens after we've started bringing the shared memory online. So + * we wait until we've registered exit handlers and potentially shut + * an open transaction down for an as safety conscious rejection as + * possible. */ if (CountEmptyBackendSlots() < ReservedBackends && !superuser()) elog(ERROR, "Non-superuser connection limit exceeded"); diff --git a/src/backend/utils/mb/conv.c b/src/backend/utils/mb/conv.c index 98b6b27db8..a41f9abe9d 100644 --- a/src/backend/utils/mb/conv.c +++ b/src/backend/utils/mb/conv.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.42 2002/08/14 02:45:10 ishii Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conv.c,v 1.43 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,11 +52,12 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len) len--; *p++ = c1; } - else if(c1 >= 0x81 && c1 <= 0xfe) + else if (c1 >= 0x81 && c1 <= 0xfe) { c2 = *gb18030++; - - if(c2 >= 0x30 && c2 <= 0x69){ + + if (c2 >= 0x30 && c2 <= 0x69) + { len -= 4; *p++ = c1; *p++ = c2; @@ -64,13 +65,15 @@ gb180302mic(unsigned char *gb18030, unsigned char *p, int len) *p++ = *gb18030++; *p++ = *gb18030++; } - else if ((c2 >=0x40 && c2 <= 0x7e) ||(c2 >=0x80 && c2 <= 0xfe)){ + else if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe)) + { len -= 2; *p++ = c1; *p++ = c2; *p++ = *gb18030++; } - else{ /*throw the strange code*/ + else + { /* throw the strange code */ len--; } } @@ -92,39 +95,40 @@ mic2gb18030(unsigned char *mic, unsigned char *p, int len) { len -= pg_mic_mblen(mic++); - if (c1 <= 0x7f) /*ASCII*/ - { + if (c1 <= 0x7f) /* ASCII */ *p++ = c1; - } else if (c1 >= 0x81 && c1 <= 0xfe) - { + { c2 = *mic++; - - if((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe)){ + + if ((c2 >= 0x40 && c2 <= 0x7e) || (c2 >= 0x80 && c2 <= 0xfe)) + { *p++ = c1; *p++ = c2; } - else if(c2 >= 0x30 && c2 <= 0x39){ + else if (c2 >= 0x30 && c2 <= 0x39) + { *p++ = c1; *p++ = c2; *p++ = *mic++; *p++ = *mic++; - } - else{ + } + else + { mic--; pg_print_bogus_char(&mic, &p); mic--; pg_print_bogus_char(&mic, &p); - } + } } - else{ + else + { mic--; pg_print_bogus_char(&mic, &p); } } *p = '\0'; } - #endif /* @@ -387,7 +391,7 @@ UtfToLocal(unsigned char *utf, unsigned char *iso, */ void LocalToUtf(unsigned char *iso, unsigned char *utf, - pg_local_to_utf *map, int size, int encoding, int len) + pg_local_to_utf *map, int size, int encoding, int len) { unsigned int iiso; int l; diff --git a/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c b/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c index 2c827e8990..4f3199e889 100644 --- a/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/ascii_and_mic/ascii_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ ascii_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -53,7 +53,7 @@ mic_to_ascii(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII); diff --git a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c index a870deec87..7d4b8f423c 100644 --- a/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/cyrillic_and_mic/cyrillic_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -79,12 +79,12 @@ static void mic2win1251(unsigned char *mic, unsigned char *p, int len); static void alt2mic(unsigned char *l, unsigned char *p, int len); static void mic2alt(unsigned char *mic, unsigned char *p, int len); -Datum +Datum koi8r_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_KOI8R); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -95,12 +95,12 @@ koi8r_to_mic(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum mic_to_koi8r(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_KOI8R); @@ -116,7 +116,7 @@ iso_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -132,7 +132,7 @@ mic_to_iso(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_ISO_8859_5); @@ -148,7 +148,7 @@ win1251_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN1251); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -164,7 +164,7 @@ mic_to_win1251(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_WIN1251); @@ -180,7 +180,7 @@ alt_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_ALT); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -196,7 +196,7 @@ mic_to_alt(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_ALT); @@ -212,7 +212,7 @@ koi8r_to_win1251(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_KOI8R); @@ -227,12 +227,12 @@ koi8r_to_win1251(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum win1251_to_koi8r(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_WIN1251); @@ -252,7 +252,7 @@ koi8r_to_alt(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_KOI8R); @@ -267,12 +267,12 @@ koi8r_to_alt(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum alt_to_koi8r(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ALT); @@ -287,12 +287,12 @@ alt_to_koi8r(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum alt_to_win1251(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ALT); @@ -307,12 +307,12 @@ alt_to_win1251(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum win1251_to_alt(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_WIN1251); @@ -327,12 +327,12 @@ win1251_to_alt(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum iso_to_koi8r(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5); @@ -347,12 +347,12 @@ iso_to_koi8r(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum koi8r_to_iso(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_KOI8R); @@ -367,12 +367,12 @@ koi8r_to_iso(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum iso_to_win1251(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5); @@ -387,12 +387,12 @@ iso_to_win1251(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum win1251_to_iso(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_WIN1251); @@ -407,12 +407,12 @@ win1251_to_iso(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum iso_to_alt(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ISO_8859_5); @@ -427,12 +427,12 @@ iso_to_alt(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum alt_to_iso(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_ALT); @@ -627,4 +627,3 @@ mic2alt(unsigned char *mic, unsigned char *p, int len) mic2latin_with_table(mic, p, len, LC_KOI8_R, koi2alt); } - diff --git a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c index c443aa8a23..bddaddf3d0 100644 --- a/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_cn_and_mic/euc_cn_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ euc_cn_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_CN); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -56,7 +56,7 @@ mic_to_euc_cn(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_EUC_CN); diff --git a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c index cc98298986..6ba2407b75 100644 --- a/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_jp_and_sjis/euc_jp_and_sjis.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -64,7 +64,7 @@ euc_jp_to_sjis(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_EUC_JP); @@ -84,7 +84,7 @@ sjis_to_euc_jp(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_SJIS); @@ -104,7 +104,7 @@ euc_jp_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_JP); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -120,7 +120,7 @@ mic_to_euc_jp(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_EUC_JP); @@ -136,7 +136,7 @@ sjis_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_SJIS); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -152,7 +152,7 @@ mic_to_sjis(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_SJIS); diff --git a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c index 43e69f7a07..c850cfa2be 100644 --- a/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_kr_and_mic/euc_kr_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -40,7 +40,7 @@ euc_kr_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_KR); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -56,7 +56,7 @@ mic_to_euc_kr(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_EUC_KR); @@ -122,4 +122,3 @@ mic2euc_kr(unsigned char *mic, unsigned char *p, int len) } *p = '\0'; } - diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c index 4e1844c2d5..ad509670d4 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/big5.c @@ -7,7 +7,7 @@ * * 1999/1/15 Tatsuo Ishii * - * $Id: big5.c,v 1.1 2002/07/16 09:25:05 ishii Exp $ + * $Id: big5.c,v 1.2 2002/09/04 20:31:31 momjian Exp $ */ /* can be used in either frontend or backend */ @@ -19,7 +19,7 @@ typedef struct { unsigned short code, peer; -} codes_t; +} codes_t; /* map Big5 Level 1 to CNS 11643-1992 Plane 1 */ static codes_t big5Level1ToCnsPlane1[25] = { /* range */ @@ -205,7 +205,7 @@ static unsigned short b2c3[][2] = { }; static unsigned short BinarySearchRange - (codes_t *array, int high, unsigned short code) + (codes_t * array, int high, unsigned short code) { int low, mid, diff --git a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c index 112bdc1a4a..a4e1a007d9 100644 --- a/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c +++ b/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/euc_tw_and_big5/euc_tw_and_big5.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -52,7 +52,7 @@ euc_tw_to_big5(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_EUC_TW); @@ -72,7 +72,7 @@ big5_to_euc_tw(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_BIG5); @@ -92,7 +92,7 @@ euc_tw_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_TW); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -108,7 +108,7 @@ mic_to_euc_tw(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_EUC_TW); @@ -124,7 +124,7 @@ big5_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_BIG5); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -140,7 +140,7 @@ mic_to_big5(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_BIG5); diff --git a/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c b/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c index f3a6476d4c..31227761dd 100644 --- a/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c +++ b/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.2 2002/08/22 00:01:44 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin2_and_win1250/latin2_and_win1250.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,12 +47,12 @@ static void mic2latin2(unsigned char *mic, unsigned char *p, int len); static void win12502mic(unsigned char *l, unsigned char *p, int len); static void mic2win1250(unsigned char *mic, unsigned char *p, int len); -Datum +Datum latin2_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_LATIN2); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -63,12 +63,12 @@ latin2_to_mic(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum mic_to_latin2(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_LATIN2); @@ -84,7 +84,7 @@ win1250_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN1250); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -100,7 +100,7 @@ mic_to_win1250(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_WIN1250); @@ -116,7 +116,7 @@ latin2_to_win1250(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_LATIN2); @@ -136,7 +136,7 @@ win1250_to_latin2(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned char *buf; Assert(PG_GETARG_INT32(0) == PG_WIN1250); diff --git a/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c b/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c index e6122f49ae..d08470d5d0 100644 --- a/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c +++ b/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/latin_and_mic/latin_and_mic.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -47,12 +47,12 @@ static void mic2latin3(unsigned char *mic, unsigned char *p, int len); static void latin42mic(unsigned char *l, unsigned char *p, int len); static void mic2latin4(unsigned char *mic, unsigned char *p, int len); -Datum +Datum latin1_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_LATIN1); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -63,12 +63,12 @@ latin1_to_mic(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum mic_to_latin1(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_LATIN1); @@ -79,12 +79,12 @@ mic_to_latin1(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum latin3_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_LATIN3); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -95,12 +95,12 @@ latin3_to_mic(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum mic_to_latin3(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_LATIN3); @@ -111,12 +111,12 @@ mic_to_latin3(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum +Datum latin4_to_mic(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_LATIN4); Assert(PG_GETARG_INT32(1) == PG_MULE_INTERNAL); @@ -127,11 +127,12 @@ latin4_to_mic(PG_FUNCTION_ARGS) PG_RETURN_INT32(0); } -Datum mic_to_latin4(PG_FUNCTION_ARGS) +Datum +mic_to_latin4(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_MULE_INTERNAL); Assert(PG_GETARG_INT32(1) == PG_LATIN4); @@ -172,4 +173,3 @@ mic2latin4(unsigned char *mic, unsigned char *p, int len) { mic2latin(mic, p, len, LC_ISO8859_4); } - diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c b/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c index 581cebbb5d..71448e3280 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_ascii/utf8_and_ascii.c,v 1.3 2002/09/04 20:31:31 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ ascii_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_SQL_ASCII); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -53,7 +53,7 @@ utf8_to_ascii(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_SQL_ASCII); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c index 7b6c16ac30..f2adecb2fe 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_big5/utf8_and_big5.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ big5_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_BIG5); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -55,7 +55,7 @@ utf8_to_big5(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_BIG5); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c index 3135d15033..31693a14f6 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_cyrillic/utf8_and_cyrillic.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -51,14 +51,14 @@ utf8_to_koi8r(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_KOI8R); Assert(len > 0); - UtfToLocal(src, dest, ULmap_KOI8R, - sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmap_KOI8R, + sizeof(ULmap_KOI8R) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -68,14 +68,14 @@ koi8r_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_KOI8R); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); - LocalToUtf(src, dest, LUmapKOI8R, - sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len); + LocalToUtf(src, dest, LUmapKOI8R, + sizeof(LUmapKOI8R) / sizeof(pg_local_to_utf), PG_KOI8R, len); PG_RETURN_INT32(0); } @@ -85,14 +85,14 @@ utf8_to_win1251(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_WIN1251); Assert(len > 0); - UtfToLocal(src, dest, ULmap_WIN1251, - sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmap_WIN1251, + sizeof(ULmap_WIN1251) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -102,14 +102,14 @@ win1251_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN1251); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); - LocalToUtf(src, dest, LUmapWIN1251, - sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len); + LocalToUtf(src, dest, LUmapWIN1251, + sizeof(LUmapWIN1251) / sizeof(pg_local_to_utf), PG_WIN1251, len); PG_RETURN_INT32(0); } @@ -119,14 +119,14 @@ utf8_to_alt(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_ALT); Assert(len > 0); - UtfToLocal(src, dest, ULmap_ALT, - sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmap_ALT, + sizeof(ULmap_ALT) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -136,14 +136,14 @@ alt_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_ALT); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); - LocalToUtf(src, dest, LUmapALT, - sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len); + LocalToUtf(src, dest, LUmapALT, + sizeof(LUmapALT) / sizeof(pg_local_to_utf), PG_ALT, len); PG_RETURN_INT32(0); } diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c index b021301194..cfedb309ea 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_cn/utf8_and_euc_cn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ euc_cn_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_CN); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapEUC_CN, - sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len); + sizeof(LUmapEUC_CN) / sizeof(pg_local_to_utf), PG_EUC_CN, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_euc_cn(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_EUC_CN); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c index d71af15131..7ea81cd897 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_jp/utf8_and_euc_jp.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ euc_jp_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_JP); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapEUC_JP, - sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len); + sizeof(LUmapEUC_JP) / sizeof(pg_local_to_utf), PG_EUC_JP, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_euc_jp(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_EUC_JP); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c index 7833950010..6700b738a2 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_kr/utf8_and_euc_kr.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ euc_kr_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_KR); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapEUC_KR, - sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len); + sizeof(LUmapEUC_KR) / sizeof(pg_local_to_utf), PG_EUC_KR, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_euc_kr(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_EUC_KR); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c index 7a8bff0cb5..b094cf145b 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_euc_tw/utf8_and_euc_tw.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ euc_tw_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_EUC_TW); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapEUC_TW, - sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len); + sizeof(LUmapEUC_TW) / sizeof(pg_local_to_utf), PG_EUC_TW, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_euc_tw(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_EUC_TW); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c index 034651501e..bc293a4305 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gb18030/utf8_and_gb18030.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ gb18030_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_GB18030); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapGB18030, - sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len); + sizeof(LUmapGB18030) / sizeof(pg_local_to_utf), PG_GB18030, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_gb18030(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_GB18030); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c index a6ec76c9ee..94392a4ba8 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_gbk/utf8_and_gbk.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ gbk_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_GBK); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -55,7 +55,7 @@ utf8_to_gbk(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_GBK); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c index 6c373bfa51..f8d331e853 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859/utf8_and_iso8859.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -58,78 +58,79 @@ extern Datum utf8_to_iso8859(PG_FUNCTION_ARGS); * ---------- */ -typedef struct { - pg_enc encoding; - pg_local_to_utf *map1; /* to UTF-8 map name */ - pg_utf_to_local *map2; /* from UTF-8 map name */ - int size1; /* size of map1 */ - int size2; /* size of map2 */ -} pg_conv_map; +typedef struct +{ + pg_enc encoding; + pg_local_to_utf *map1; /* to UTF-8 map name */ + pg_utf_to_local *map2; /* from UTF-8 map name */ + int size1; /* size of map1 */ + int size2; /* size of map2 */ +} pg_conv_map; static pg_conv_map maps[] = { - {PG_SQL_ASCII}, /* SQL/ASCII */ - {PG_EUC_JP}, /* EUC for Japanese */ - {PG_EUC_CN}, /* EUC for Chinese */ - {PG_EUC_KR}, /* EUC for Korean */ - {PG_EUC_TW}, /* EUC for Taiwan */ - {PG_JOHAB}, /* EUC for Korean JOHAB */ - {PG_UTF8}, /* Unicode UTF-8 */ - {PG_MULE_INTERNAL}, /* Mule internal code */ - {PG_LATIN1}, /* ISO-8859-1 Latin 1 */ + {PG_SQL_ASCII}, /* SQL/ASCII */ + {PG_EUC_JP}, /* EUC for Japanese */ + {PG_EUC_CN}, /* EUC for Chinese */ + {PG_EUC_KR}, /* EUC for Korean */ + {PG_EUC_TW}, /* EUC for Taiwan */ + {PG_JOHAB}, /* EUC for Korean JOHAB */ + {PG_UTF8}, /* Unicode UTF-8 */ + {PG_MULE_INTERNAL}, /* Mule internal code */ + {PG_LATIN1}, /* ISO-8859-1 Latin 1 */ {PG_LATIN2, LUmapISO8859_2, ULmapISO8859_2, - sizeof(LUmapISO8859_2)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_2)/sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */ + sizeof(LUmapISO8859_2) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_2) / sizeof(pg_utf_to_local)}, /* ISO-8859-2 Latin 2 */ {PG_LATIN3, LUmapISO8859_3, ULmapISO8859_3, - sizeof(LUmapISO8859_3)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_3)/sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */ + sizeof(LUmapISO8859_3) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_3) / sizeof(pg_utf_to_local)}, /* ISO-8859-3 Latin 3 */ {PG_LATIN4, LUmapISO8859_4, ULmapISO8859_4, - sizeof(LUmapISO8859_4)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_4)/sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */ + sizeof(LUmapISO8859_4) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_4) / sizeof(pg_utf_to_local)}, /* ISO-8859-4 Latin 4 */ {PG_LATIN5, LUmapISO8859_9, ULmapISO8859_9, - sizeof(LUmapISO8859_9)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_9)/sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */ + sizeof(LUmapISO8859_9) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_9) / sizeof(pg_utf_to_local)}, /* ISO-8859-9 Latin 5 */ {PG_LATIN6, LUmapISO8859_10, ULmapISO8859_10, - sizeof(LUmapISO8859_10)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_10)/sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */ + sizeof(LUmapISO8859_10) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_10) / sizeof(pg_utf_to_local)}, /* ISO-8859-10 Latin 6 */ {PG_LATIN7, LUmapISO8859_13, ULmapISO8859_13, - sizeof(LUmapISO8859_13)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_13)/sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */ + sizeof(LUmapISO8859_13) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_13) / sizeof(pg_utf_to_local)}, /* ISO-8859-13 Latin 7 */ {PG_LATIN8, LUmapISO8859_14, ULmapISO8859_14, - sizeof(LUmapISO8859_14)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_14)/sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */ + sizeof(LUmapISO8859_14) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_14) / sizeof(pg_utf_to_local)}, /* ISO-8859-14 Latin 8 */ {PG_LATIN9, LUmapISO8859_2, ULmapISO8859_2, - sizeof(LUmapISO8859_15)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_15)/sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */ + sizeof(LUmapISO8859_15) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_15) / sizeof(pg_utf_to_local)}, /* ISO-8859-15 Latin 9 */ {PG_LATIN10, LUmapISO8859_16, ULmapISO8859_16, - sizeof(LUmapISO8859_16)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_16)/sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */ - {PG_WIN1256}, /* windows-1256 */ + sizeof(LUmapISO8859_16) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_16) / sizeof(pg_utf_to_local)}, /* ISO-8859-16 Latin 10 */ + {PG_WIN1256}, /* windows-1256 */ {PG_TCVN}, /* TCVN (Windows-1258) */ {PG_WIN874}, /* windows-874 */ {PG_KOI8R}, /* KOI8-R */ {PG_WIN1251}, /* windows-1251 (was: WIN) */ {PG_ALT}, /* (MS-DOS CP866) */ {PG_ISO_8859_5, LUmapISO8859_5, ULmapISO8859_5, - sizeof(LUmapISO8859_5)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_5)/sizeof(pg_utf_to_local)}, /* ISO-8859-5 */ + sizeof(LUmapISO8859_5) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_5) / sizeof(pg_utf_to_local)}, /* ISO-8859-5 */ {PG_ISO_8859_6, LUmapISO8859_6, ULmapISO8859_6, - sizeof(LUmapISO8859_6)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_6)/sizeof(pg_utf_to_local)}, /* ISO-8859-6 */ + sizeof(LUmapISO8859_6) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_6) / sizeof(pg_utf_to_local)}, /* ISO-8859-6 */ {PG_ISO_8859_7, LUmapISO8859_7, ULmapISO8859_7, - sizeof(LUmapISO8859_7)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_7)/sizeof(pg_utf_to_local)}, /* ISO-8859-7 */ + sizeof(LUmapISO8859_7) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_7) / sizeof(pg_utf_to_local)}, /* ISO-8859-7 */ {PG_ISO_8859_8, LUmapISO8859_8, ULmapISO8859_8, - sizeof(LUmapISO8859_8)/sizeof(pg_local_to_utf), - sizeof(ULmapISO8859_8)/sizeof(pg_utf_to_local)}, /* ISO-8859-8 */ + sizeof(LUmapISO8859_8) / sizeof(pg_local_to_utf), + sizeof(ULmapISO8859_8) / sizeof(pg_utf_to_local)}, /* ISO-8859-8 */ }; - + Datum iso8859_to_utf8(PG_FUNCTION_ARGS) { - int encoding = PG_GETARG_INT32(0); + int encoding = PG_GETARG_INT32(0); unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); @@ -142,10 +143,10 @@ iso8859_to_utf8(PG_FUNCTION_ARGS) Datum utf8_to_iso8859(PG_FUNCTION_ARGS) { - int encoding = PG_GETARG_INT32(1); + int encoding = PG_GETARG_INT32(1); unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(len > 0); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c index e66de79ba1..03302345d8 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_iso8859_1/utf8_and_iso8859_1.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -37,7 +37,7 @@ iso8859_1_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned short c; Assert(PG_GETARG_INT32(0) == PG_LATIN1); @@ -64,7 +64,7 @@ utf8_to_iso8859_1(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); unsigned short c, c1, c2; diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c index 4dbd33fdd0..c385922bfc 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_johab/utf8_and_johab.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,14 +38,14 @@ johab_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_JOHAB); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapJOHAB, - sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len); + sizeof(LUmapJOHAB) / sizeof(pg_local_to_utf), PG_JOHAB, len); PG_RETURN_INT32(0); } @@ -55,7 +55,7 @@ utf8_to_johab(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_JOHAB); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c index a460768f21..e42822e3e9 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_sjis/utf8_and_sjis.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ sjis_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_SJIS); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -55,7 +55,7 @@ utf8_to_sjis(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_SJIS); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/utf8_and_tcvn.c b/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/utf8_and_tcvn.c index 6847458df4..a6b47d8e1a 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/utf8_and_tcvn.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/utf8_and_tcvn.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_tcvn/Attic/utf8_and_tcvn.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ tcvn_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_TCVN); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -55,7 +55,7 @@ utf8_to_tcvn(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_TCVN); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c index d30f3de3a3..afd3c68990 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_uhc/utf8_and_uhc.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -38,7 +38,7 @@ uhc_to_utf8(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UHC); Assert(PG_GETARG_INT32(1) == PG_UTF8); @@ -55,7 +55,7 @@ utf8_to_uhc(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_UHC); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c index 6b32fe78e2..eab60c2115 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1250/utf8_and_win1250.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1250/Attic/utf8_and_win1250.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,14 +39,14 @@ utf_to_win1250(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_WIN1250); Assert(len > 0); - UtfToLocal(src, dest, ULmapWIN1250, - sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmapWIN1250, + sizeof(ULmapWIN1250) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -56,7 +56,7 @@ win1250_to_utf(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN1250); Assert(PG_GETARG_INT32(1) == PG_UTF8); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c index 4014330b0a..073e11ee26 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win1256/utf8_and_win1256.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win1256/Attic/utf8_and_win1256.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,14 +39,14 @@ utf_to_win1256(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_WIN1256); Assert(len > 0); - UtfToLocal(src, dest, ULmapWIN1256, - sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmapWIN1256, + sizeof(ULmapWIN1256) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -56,7 +56,7 @@ win1256_to_utf(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN1256); Assert(PG_GETARG_INT32(1) == PG_UTF8); diff --git a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c index 9192db3ccf..38a3f2b5a6 100644 --- a/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c +++ b/src/backend/utils/mb/conversion_procs/utf8_and_win874/utf8_and_win874.c @@ -6,7 +6,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.2 2002/08/22 00:01:45 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mb/conversion_procs/utf8_and_win874/Attic/utf8_and_win874.c,v 1.3 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -39,14 +39,14 @@ utf_to_win874(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_UTF8); Assert(PG_GETARG_INT32(1) == PG_WIN874); Assert(len > 0); - UtfToLocal(src, dest, ULmapWIN874, - sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len); + UtfToLocal(src, dest, ULmapWIN874, + sizeof(ULmapWIN874) / sizeof(pg_utf_to_local), len); PG_RETURN_INT32(0); } @@ -56,14 +56,14 @@ win874_to_utf(PG_FUNCTION_ARGS) { unsigned char *src = PG_GETARG_CSTRING(2); unsigned char *dest = PG_GETARG_CSTRING(3); - int len = PG_GETARG_INT32(4); + int len = PG_GETARG_INT32(4); Assert(PG_GETARG_INT32(0) == PG_WIN874); Assert(PG_GETARG_INT32(1) == PG_UTF8); Assert(len > 0); LocalToUtf(src, dest, LUmapWIN874, - sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len); + sizeof(LUmapWIN874) / sizeof(pg_local_to_utf), PG_WIN874, len); PG_RETURN_INT32(0); } diff --git a/src/backend/utils/mb/encnames.c b/src/backend/utils/mb/encnames.c index 8c00038304..af8629955d 100644 --- a/src/backend/utils/mb/encnames.c +++ b/src/backend/utils/mb/encnames.c @@ -2,7 +2,7 @@ * Encoding names and routines for work with it. All * in this file is shared bedween FE and BE. * - * $Id: encnames.c,v 1.9 2002/09/03 21:45:43 petere Exp $ + * $Id: encnames.c,v 1.10 2002/09/04 20:31:31 momjian Exp $ */ #ifdef FRONTEND #include "postgres_fe.h" @@ -55,12 +55,12 @@ pg_encname pg_encname_tbl[] = * for Japanese, stdandard OSF */ { "euckr", PG_EUC_KR - }, /* EUC-KR; Extended Unix Code for - * Korean , KS X 1001 standard */ + }, /* EUC-KR; Extended Unix Code for Korean , + * KS X 1001 standard */ { "euctw", PG_EUC_TW }, /* EUC-TW; Extended Unix Code for - + * * traditional Chinese */ { "gb18030", PG_GB18030 @@ -171,7 +171,7 @@ pg_encname pg_encname_tbl[] = "tcvn", PG_TCVN }, /* TCVN; Vietnamese TCVN-5712 */ { - "tcvn5712",PG_TCVN + "tcvn5712", PG_TCVN }, /* alias for TCVN */ { "uhc", PG_UHC diff --git a/src/backend/utils/mb/mbutils.c b/src/backend/utils/mb/mbutils.c index 24f3d4486a..dfcad8e18e 100644 --- a/src/backend/utils/mb/mbutils.c +++ b/src/backend/utils/mb/mbutils.c @@ -3,7 +3,7 @@ * client encoding and server internal encoding. * (currently mule internal code (mic) is used) * Tatsuo Ishii - * $Id: mbutils.c,v 1.34 2002/09/03 21:45:43 petere Exp $ + * $Id: mbutils.c,v 1.35 2002/09/04 20:31:31 momjian Exp $ */ #include "postgres.h" #include "access/xact.h" @@ -27,15 +27,15 @@ static pg_enc2name *DatabaseEncoding = &pg_enc2name_tbl[PG_SQL_ASCII]; * allocated in TopMemoryContext so that it survives outside * transactions. See SetClientEncoding() for more details. */ -static FmgrInfo *ToServerConvPorc = NULL; -static FmgrInfo *ToClientConvPorc = NULL; +static FmgrInfo *ToServerConvPorc = NULL; +static FmgrInfo *ToClientConvPorc = NULL; /* Internal functions */ static unsigned char * -perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server); + perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server); static int -cliplen(const unsigned char *str, int len, int limit); + cliplen(const unsigned char *str, int len, int limit); /* * Set the client encoding and save fmgrinfo for the converion @@ -46,9 +46,10 @@ int SetClientEncoding(int encoding, bool doit) { int current_server_encoding; - Oid to_server_proc, to_client_proc; - FmgrInfo *to_server = NULL; - FmgrInfo *to_client = NULL; + Oid to_server_proc, + to_client_proc; + FmgrInfo *to_server = NULL; + FmgrInfo *to_client = NULL; MemoryContext oldcontext; current_server_encoding = GetDatabaseEncoding(); @@ -57,15 +58,15 @@ SetClientEncoding(int encoding, bool doit) return (-1); if (current_server_encoding == encoding || - (current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII)) + (current_server_encoding == PG_SQL_ASCII || encoding == PG_SQL_ASCII)) { ClientEncoding = &pg_enc2name_tbl[encoding]; return 0; } - /* XXX We cannot use FindDefaultConversionProc() while in - * bootstrap or initprocessing mode since namespace functions will - * not work. + /* + * XXX We cannot use FindDefaultConversionProc() while in bootstrap or + * initprocessing mode since namespace functions will not work. */ if (IsTransactionState()) { @@ -76,8 +77,8 @@ SetClientEncoding(int encoding, bool doit) return -1; /* - * load the fmgr info into TopMemoryContext so that it - * survives outside transaction. + * load the fmgr info into TopMemoryContext so that it survives + * outside transaction. */ oldcontext = MemoryContextSwitchTo(TopMemoryContext); to_server = palloc(sizeof(FmgrInfo)); @@ -94,7 +95,7 @@ SetClientEncoding(int encoding, bool doit) { ClientEncoding = &pg_enc2name_tbl[encoding]; - if(ToServerConvPorc != NULL) + if (ToServerConvPorc != NULL) { if (ToServerConvPorc->fn_extra) pfree(ToServerConvPorc->fn_extra); @@ -102,7 +103,7 @@ SetClientEncoding(int encoding, bool doit) } ToServerConvPorc = to_server; - if(ToClientConvPorc != NULL) + if (ToClientConvPorc != NULL) { if (ToClientConvPorc->fn_extra) pfree(ToClientConvPorc->fn_extra); @@ -152,11 +153,11 @@ pg_do_encoding_conversion(unsigned char *src, int len, int src_encoding, int dest_encoding) { unsigned char *result; - Oid proc; + Oid proc; if (!IsTransactionState()) return src; - + if (src_encoding == dest_encoding) return src; @@ -171,13 +172,14 @@ pg_do_encoding_conversion(unsigned char *src, int len, return src; } - /* XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise - * we are going into inifinite loop! So we have to make sure that - * the function exists before calling OidFunctionCall. + /* + * XXX we shoud avoid throwing errors in OidFuctionCall. Otherwise we + * are going into inifinite loop! So we have to make sure that the + * function exists before calling OidFunctionCall. */ if (!SearchSysCacheExists(PROCOID, - ObjectIdGetDatum(proc), - 0, 0, 0)) + ObjectIdGetDatum(proc), + 0, 0, 0)) { elog(LOG, "default conversion proc %u for %s to %s not found in pg_proc", proc, @@ -204,17 +206,17 @@ pg_do_encoding_conversion(unsigned char *src, int len, Datum pg_convert(PG_FUNCTION_ARGS) { - Datum string = PG_GETARG_DATUM(0); - Datum dest_encoding_name = PG_GETARG_DATUM(1); - Datum src_encoding_name = DirectFunctionCall1( - namein, CStringGetDatum(DatabaseEncoding->name)); - Datum result; + Datum string = PG_GETARG_DATUM(0); + Datum dest_encoding_name = PG_GETARG_DATUM(1); + Datum src_encoding_name = DirectFunctionCall1( + namein, CStringGetDatum(DatabaseEncoding->name)); + Datum result; result = DirectFunctionCall3( - pg_convert2, string, src_encoding_name, dest_encoding_name); + pg_convert2, string, src_encoding_name, dest_encoding_name); /* free memory allocated by namein */ - pfree((void *)src_encoding_name); + pfree((void *) src_encoding_name); PG_RETURN_TEXT_P(result); } @@ -235,7 +237,7 @@ pg_convert2(PG_FUNCTION_ARGS) unsigned char *result; text *retval; unsigned char *str; - int len; + int len; if (src_encoding < 0) elog(ERROR, "Invalid source encoding name %s", src_encoding_name); @@ -252,9 +254,11 @@ pg_convert2(PG_FUNCTION_ARGS) if (result == NULL) elog(ERROR, "Encoding conversion failed"); - /* build text data type structre. we cannot use textin() here, - since textin assumes that input string encoding is same as - database encoding. */ + /* + * build text data type structre. we cannot use textin() here, since + * textin assumes that input string encoding is same as database + * encoding. + */ len = strlen(result) + VARHDRSZ; retval = palloc(len); VARATT_SIZEP(retval) = len; @@ -262,7 +266,7 @@ pg_convert2(PG_FUNCTION_ARGS) if (result != str) pfree(result); - pfree(str); + pfree(str); /* free memory if allocated by the toaster */ PG_FREE_IF_COPY(string, 0); @@ -301,18 +305,19 @@ pg_server_to_client(unsigned char *s, int len) } /* - * Perform default encoding conversion using cached FmgrInfo. Since - * this function does not access database at all, it is safe to call - * outside transactions. Explicit setting client encoding required - * before calling this function. Otherwise no conversion is - * performed. + * Perform default encoding conversion using cached FmgrInfo. Since + * this function does not access database at all, it is safe to call + * outside transactions. Explicit setting client encoding required + * before calling this function. Otherwise no conversion is + * performed. */ static unsigned char * perform_default_encoding_conversion(unsigned char *src, int len, bool is_client_to_server) { unsigned char *result; - int src_encoding, dest_encoding; - FmgrInfo *flinfo; + int src_encoding, + dest_encoding; + FmgrInfo *flinfo; if (is_client_to_server) { @@ -376,7 +381,7 @@ pg_mbstrlen(const unsigned char *mbstr) /* optimization for single byte encoding */ if (pg_database_encoding_max_length() == 1) - return strlen((char *)mbstr); + return strlen((char *) mbstr); while (*mbstr) { @@ -506,9 +511,9 @@ pg_client_encoding(PG_FUNCTION_ARGS) } static int -cliplen(const unsigned char *str, int len, int limit) +cliplen(const unsigned char *str, int len, int limit) { - int l = 0; + int l = 0; const unsigned char *s; for (s = str; *s; s++, l++) diff --git a/src/backend/utils/mb/wchar.c b/src/backend/utils/mb/wchar.c index 50d90f30d6..eeee9a6836 100644 --- a/src/backend/utils/mb/wchar.c +++ b/src/backend/utils/mb/wchar.c @@ -1,7 +1,7 @@ /* * conversion functions between pg_wchar and multibyte streams. * Tatsuo Ishii - * $Id: wchar.c,v 1.29 2002/09/03 21:45:43 petere Exp $ + * $Id: wchar.c,v 1.30 2002/09/04 20:31:31 momjian Exp $ * * WIN1250 client encoding updated by Pavel Behal * @@ -511,30 +511,31 @@ pg_uhc_mblen(const unsigned char *s) } /* - * * GB18030 - * * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp> - * */ + * * GB18030 + * * Added by Bill Huang <bhuang@redhat.com>,<bill_huanghb@ybb.ne.jp> + * */ static int pg_gb18030_mblen(const unsigned char *s) { - int len; - if (*s <= 0x7f) - { /* ASCII */ - len = 1; - } - else - { - if((*(s+1) >= 0x40 && *(s+1) <= 0x7e)|| (*(s+1) >= 0x80 && *(s+1) <= 0xfe)) - len = 2; - else if(*(s+1) >= 0x30 && *(s+1) <= 0x39) - len = 4; - else - len = 2; - } - return (len); + int len; + + if (*s <= 0x7f) + { /* ASCII */ + len = 1; + } + else + { + if ((*(s + 1) >= 0x40 && *(s + 1) <= 0x7e) || (*(s + 1) >= 0x80 && *(s + 1) <= 0xfe)) + len = 2; + else if (*(s + 1) >= 0x30 && *(s + 1) <= 0x39) + len = 4; + else + len = 2; + } + return (len); } - + pg_wchar_tbl pg_wchar_table[] = { {pg_ascii2wchar_with_len, pg_ascii_mblen, 1}, /* 0; PG_SQL_ASCII */ {pg_eucjp2wchar_with_len, pg_eucjp_mblen, 3}, /* 1; PG_EUC_JP */ @@ -543,7 +544,7 @@ pg_wchar_tbl pg_wchar_table[] = { {pg_euctw2wchar_with_len, pg_euctw_mblen, 3}, /* 4; PG_EUC_TW */ {pg_johab2wchar_with_len, pg_johab_mblen, 3}, /* 5; PG_JOHAB */ {pg_utf2wchar_with_len, pg_utf_mblen, 3}, /* 6; PG_UNICODE */ - {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */ + {pg_mule2wchar_with_len, pg_mule_mblen, 3}, /* 7; PG_MULE_INTERNAL */ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 8; PG_LATIN1 */ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 9; PG_LATIN2 */ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 10; PG_LATIN3 */ @@ -569,7 +570,7 @@ pg_wchar_tbl pg_wchar_table[] = { {0, pg_gbk_mblen, 2}, /* 30; PG_GBK */ {0, pg_uhc_mblen, 2}, /* 31; PG_UHC */ {pg_latin12wchar_with_len, pg_latin1_mblen, 1}, /* 32; PG_WIN1250 */ - {0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */ + {0, pg_gb18030_mblen, 2} /* 33; PG_GB18030 */ }; /* returns the byte length of a word for mule internal code */ diff --git a/src/backend/utils/misc/database.c b/src/backend/utils/misc/database.c index fd80b23bb8..3769f350fd 100644 --- a/src/backend/utils/misc/database.c +++ b/src/backend/utils/misc/database.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.52 2002/07/20 05:16:59 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/Attic/database.c,v 1.53 2002/09/04 20:31:32 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -223,7 +223,7 @@ GetRawDatabaseInfo(const char *name, Oid *db_id, char *path) *db_id = HeapTupleGetOid(&tup); pathlen = VARSIZE(&(tup_db->datpath)) - VARHDRSZ; if (pathlen < 0) - pathlen = 0; /* pure paranoia */ + pathlen = 0; /* pure paranoia */ if (pathlen >= MAXPGPATH) pathlen = MAXPGPATH - 1; /* more paranoia */ strncpy(path, VARDATA(&(tup_db->datpath)), pathlen); diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c index a1c2f24b77..7df703e60a 100644 --- a/src/backend/utils/misc/guc.c +++ b/src/backend/utils/misc/guc.c @@ -5,7 +5,7 @@ * command, configuration file, and command line options. * See src/backend/utils/misc/README for more information. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.92 2002/09/02 05:42:54 momjian Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/guc.c,v 1.93 2002/09/04 20:31:33 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * Written by Peter Eisentraut <peter_e@gmx.net>. @@ -68,11 +68,11 @@ extern char *Syslog_facility; extern char *Syslog_ident; static const char *assign_facility(const char *facility, - bool doit, bool interactive); + bool doit, bool interactive); #endif static const char *assign_msglvl(int *var, const char *newval, - bool doit, bool interactive); + bool doit, bool interactive); /* * Debugging options @@ -90,8 +90,8 @@ bool Debug_pretty_print = false; bool Show_parser_stats = false; bool Show_planner_stats = false; bool Show_executor_stats = false; -bool Show_statement_stats = false; /* this is sort of all three above - * together */ +bool Show_statement_stats = false; /* this is sort of all + * three above together */ bool Show_btree_build_stats = false; bool Explain_pretty_print = true; @@ -103,16 +103,16 @@ bool Australian_timezones = false; bool Password_encryption = true; int log_min_error_statement; -char *log_min_error_statement_str = NULL; +char *log_min_error_statement_str = NULL; const char log_min_error_statement_str_default[] = "error"; -int server_min_messages; -char *server_min_messages_str = NULL; -const char server_min_messages_str_default[] = "notice"; +int server_min_messages; +char *server_min_messages_str = NULL; +const char server_min_messages_str_default[] = "notice"; -int client_min_messages; -char *client_min_messages_str = NULL; -const char client_min_messages_str_default[] = "notice"; +int client_min_messages; +char *client_min_messages_str = NULL; +const char client_min_messages_str_default[] = "notice"; #ifndef PG_KRB_SRVTAB @@ -134,7 +134,7 @@ static char *timezone_string; static char *XactIsoLevel_string; static const char *assign_defaultxactisolevel(const char *newval, - bool doit, bool interactive); + bool doit, bool interactive); /* @@ -161,20 +161,20 @@ struct config_generic enum config_type vartype; /* type of variable (set only at startup) */ int status; /* status bits, see below */ GucSource reset_source; /* source of the reset_value */ - GucSource session_source; /* source of the session_value */ - GucSource tentative_source; /* source of the tentative_value */ + GucSource session_source; /* source of the session_value */ + GucSource tentative_source; /* source of the tentative_value */ GucSource source; /* source of the current actual value */ }; /* bit values in flags field */ -#define GUC_LIST_INPUT 0x0001 /* input can be list format */ -#define GUC_LIST_QUOTE 0x0002 /* double-quote list elements */ -#define GUC_NO_SHOW_ALL 0x0004 /* exclude from SHOW ALL */ -#define GUC_NO_RESET_ALL 0x0008 /* exclude from RESET ALL */ +#define GUC_LIST_INPUT 0x0001 /* input can be list format */ +#define GUC_LIST_QUOTE 0x0002 /* double-quote list elements */ +#define GUC_NO_SHOW_ALL 0x0004 /* exclude from SHOW ALL */ +#define GUC_NO_RESET_ALL 0x0008 /* exclude from RESET ALL */ /* bit values in status field */ -#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */ -#define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */ +#define GUC_HAVE_TENTATIVE 0x0001 /* tentative value is defined */ +#define GUC_HAVE_LOCAL 0x0002 /* a SET LOCAL has been executed */ /* GUC records for specific variable types */ @@ -309,213 +309,213 @@ static struct config_bool ConfigureNamesBool[] = { { - { "enable_seqscan", PGC_USERSET }, &enable_seqscan, + {"enable_seqscan", PGC_USERSET}, &enable_seqscan, true, NULL, NULL }, { - { "enable_indexscan", PGC_USERSET }, &enable_indexscan, + {"enable_indexscan", PGC_USERSET}, &enable_indexscan, true, NULL, NULL }, { - { "enable_tidscan", PGC_USERSET }, &enable_tidscan, + {"enable_tidscan", PGC_USERSET}, &enable_tidscan, true, NULL, NULL }, { - { "enable_sort", PGC_USERSET }, &enable_sort, + {"enable_sort", PGC_USERSET}, &enable_sort, true, NULL, NULL }, { - { "enable_nestloop", PGC_USERSET }, &enable_nestloop, + {"enable_nestloop", PGC_USERSET}, &enable_nestloop, true, NULL, NULL }, { - { "enable_mergejoin", PGC_USERSET }, &enable_mergejoin, + {"enable_mergejoin", PGC_USERSET}, &enable_mergejoin, true, NULL, NULL }, { - { "enable_hashjoin", PGC_USERSET }, &enable_hashjoin, + {"enable_hashjoin", PGC_USERSET}, &enable_hashjoin, true, NULL, NULL }, { - { "geqo", PGC_USERSET }, &enable_geqo, + {"geqo", PGC_USERSET}, &enable_geqo, true, NULL, NULL }, { - { "tcpip_socket", PGC_POSTMASTER }, &NetServer, + {"tcpip_socket", PGC_POSTMASTER}, &NetServer, false, NULL, NULL }, { - { "ssl", PGC_POSTMASTER }, &EnableSSL, + {"ssl", PGC_POSTMASTER}, &EnableSSL, false, NULL, NULL }, { - { "fsync", PGC_SIGHUP }, &enableFsync, + {"fsync", PGC_SIGHUP}, &enableFsync, true, NULL, NULL }, { - { "silent_mode", PGC_POSTMASTER }, &SilentMode, + {"silent_mode", PGC_POSTMASTER}, &SilentMode, false, NULL, NULL }, { - { "log_connections", PGC_BACKEND }, &Log_connections, + {"log_connections", PGC_BACKEND}, &Log_connections, false, NULL, NULL }, { - { "log_timestamp", PGC_SIGHUP }, &Log_timestamp, + {"log_timestamp", PGC_SIGHUP}, &Log_timestamp, false, NULL, NULL }, { - { "log_pid", PGC_SIGHUP }, &Log_pid, + {"log_pid", PGC_SIGHUP}, &Log_pid, false, NULL, NULL }, #ifdef USE_ASSERT_CHECKING { - { "debug_assertions", PGC_USERSET }, &assert_enabled, + {"debug_assertions", PGC_USERSET}, &assert_enabled, true, NULL, NULL }, #endif { - { "log_statement", PGC_USERSET }, &Log_statement, + {"log_statement", PGC_USERSET}, &Log_statement, false, NULL, NULL }, { - { "log_duration", PGC_USERSET }, &Log_duration, + {"log_duration", PGC_USERSET}, &Log_duration, false, NULL, NULL }, { - { "debug_print_parse", PGC_USERSET }, &Debug_print_parse, + {"debug_print_parse", PGC_USERSET}, &Debug_print_parse, false, NULL, NULL }, { - { "debug_print_rewritten", PGC_USERSET }, &Debug_print_rewritten, + {"debug_print_rewritten", PGC_USERSET}, &Debug_print_rewritten, false, NULL, NULL }, { - { "debug_print_plan", PGC_USERSET }, &Debug_print_plan, + {"debug_print_plan", PGC_USERSET}, &Debug_print_plan, false, NULL, NULL }, { - { "debug_pretty_print", PGC_USERSET }, &Debug_pretty_print, + {"debug_pretty_print", PGC_USERSET}, &Debug_pretty_print, false, NULL, NULL }, { - { "show_parser_stats", PGC_USERSET }, &Show_parser_stats, + {"show_parser_stats", PGC_USERSET}, &Show_parser_stats, false, NULL, NULL }, { - { "show_planner_stats", PGC_USERSET }, &Show_planner_stats, + {"show_planner_stats", PGC_USERSET}, &Show_planner_stats, false, NULL, NULL }, { - { "show_executor_stats", PGC_USERSET }, &Show_executor_stats, + {"show_executor_stats", PGC_USERSET}, &Show_executor_stats, false, NULL, NULL }, { - { "show_statement_stats", PGC_USERSET }, &Show_statement_stats, + {"show_statement_stats", PGC_USERSET}, &Show_statement_stats, false, NULL, NULL }, #ifdef BTREE_BUILD_STATS { - { "show_btree_build_stats", PGC_SUSET }, &Show_btree_build_stats, + {"show_btree_build_stats", PGC_SUSET}, &Show_btree_build_stats, false, NULL, NULL }, #endif { - { "explain_pretty_print", PGC_USERSET }, &Explain_pretty_print, + {"explain_pretty_print", PGC_USERSET}, &Explain_pretty_print, true, NULL, NULL }, { - { "stats_start_collector", PGC_POSTMASTER }, &pgstat_collect_startcollector, + {"stats_start_collector", PGC_POSTMASTER}, &pgstat_collect_startcollector, true, NULL, NULL }, { - { "stats_reset_on_server_start", PGC_POSTMASTER }, &pgstat_collect_resetonpmstart, + {"stats_reset_on_server_start", PGC_POSTMASTER}, &pgstat_collect_resetonpmstart, true, NULL, NULL }, { - { "stats_command_string", PGC_SUSET }, &pgstat_collect_querystring, + {"stats_command_string", PGC_SUSET}, &pgstat_collect_querystring, false, NULL, NULL }, { - { "stats_row_level", PGC_SUSET }, &pgstat_collect_tuplelevel, + {"stats_row_level", PGC_SUSET}, &pgstat_collect_tuplelevel, false, NULL, NULL }, { - { "stats_block_level", PGC_SUSET }, &pgstat_collect_blocklevel, + {"stats_block_level", PGC_SUSET}, &pgstat_collect_blocklevel, false, NULL, NULL }, { - { "trace_notify", PGC_USERSET }, &Trace_notify, + {"trace_notify", PGC_USERSET}, &Trace_notify, false, NULL, NULL }, #ifdef LOCK_DEBUG { - { "trace_locks", PGC_SUSET }, &Trace_locks, + {"trace_locks", PGC_SUSET}, &Trace_locks, false, NULL, NULL }, { - { "trace_userlocks", PGC_SUSET }, &Trace_userlocks, + {"trace_userlocks", PGC_SUSET}, &Trace_userlocks, false, NULL, NULL }, { - { "trace_lwlocks", PGC_SUSET }, &Trace_lwlocks, + {"trace_lwlocks", PGC_SUSET}, &Trace_lwlocks, false, NULL, NULL }, { - { "debug_deadlocks", PGC_SUSET }, &Debug_deadlocks, + {"debug_deadlocks", PGC_SUSET}, &Debug_deadlocks, false, NULL, NULL }, #endif { - { "hostname_lookup", PGC_SIGHUP }, &HostnameLookup, + {"hostname_lookup", PGC_SIGHUP}, &HostnameLookup, false, NULL, NULL }, { - { "show_source_port", PGC_SIGHUP }, &ShowPortNumber, + {"show_source_port", PGC_SIGHUP}, &ShowPortNumber, false, NULL, NULL }, { - { "sql_inheritance", PGC_USERSET }, &SQL_inheritance, + {"sql_inheritance", PGC_USERSET}, &SQL_inheritance, true, NULL, NULL }, { - { "australian_timezones", PGC_USERSET }, &Australian_timezones, + {"australian_timezones", PGC_USERSET}, &Australian_timezones, false, ClearDateCache, NULL }, { - { "fixbtree", PGC_POSTMASTER }, &FixBTree, + {"fixbtree", PGC_POSTMASTER}, &FixBTree, true, NULL, NULL }, { - { "password_encryption", PGC_USERSET }, &Password_encryption, + {"password_encryption", PGC_USERSET}, &Password_encryption, true, NULL, NULL }, { - { "transform_null_equals", PGC_USERSET }, &Transform_null_equals, + {"transform_null_equals", PGC_USERSET}, &Transform_null_equals, false, NULL, NULL }, { - { "db_user_namespace", PGC_SIGHUP }, &Db_user_namespace, + {"db_user_namespace", PGC_SIGHUP}, &Db_user_namespace, false, NULL, NULL }, { - { "autocommit", PGC_USERSET }, &autocommit, + {"autocommit", PGC_USERSET}, &autocommit, true, NULL, NULL }, { - { NULL, 0 }, NULL, false, NULL, NULL + {NULL, 0}, NULL, false, NULL, NULL } }; @@ -524,38 +524,38 @@ static struct config_int ConfigureNamesInt[] = { { - { "default_statistics_target", PGC_USERSET }, &default_statistics_target, + {"default_statistics_target", PGC_USERSET}, &default_statistics_target, 10, 1, 1000, NULL, NULL }, { - { "geqo_threshold", PGC_USERSET }, &geqo_rels, + {"geqo_threshold", PGC_USERSET}, &geqo_rels, DEFAULT_GEQO_RELS, 2, INT_MAX, NULL, NULL }, { - { "geqo_pool_size", PGC_USERSET }, &Geqo_pool_size, + {"geqo_pool_size", PGC_USERSET}, &Geqo_pool_size, DEFAULT_GEQO_POOL_SIZE, 0, MAX_GEQO_POOL_SIZE, NULL, NULL }, { - { "geqo_effort", PGC_USERSET }, &Geqo_effort, + {"geqo_effort", PGC_USERSET}, &Geqo_effort, 1, 1, INT_MAX, NULL, NULL }, { - { "geqo_generations", PGC_USERSET }, &Geqo_generations, + {"geqo_generations", PGC_USERSET}, &Geqo_generations, 0, 0, INT_MAX, NULL, NULL }, { - { "geqo_random_seed", PGC_USERSET }, &Geqo_random_seed, + {"geqo_random_seed", PGC_USERSET}, &Geqo_random_seed, -1, INT_MIN, INT_MAX, NULL, NULL }, { - { "deadlock_timeout", PGC_POSTMASTER }, &DeadlockTimeout, + {"deadlock_timeout", PGC_POSTMASTER}, &DeadlockTimeout, 1000, 0, INT_MAX, NULL, NULL }, #ifdef HAVE_SYSLOG { - { "syslog", PGC_SIGHUP }, &Use_syslog, + {"syslog", PGC_SIGHUP}, &Use_syslog, 0, 0, 2, NULL, NULL }, #endif @@ -568,121 +568,121 @@ static struct config_int * backends number. */ { - { "max_connections", PGC_POSTMASTER }, &MaxBackends, + {"max_connections", PGC_POSTMASTER}, &MaxBackends, DEF_MAXBACKENDS, 1, INT_MAX, NULL, NULL }, { - { "superuser_reserved_connections", PGC_POSTMASTER }, &ReservedBackends, + {"superuser_reserved_connections", PGC_POSTMASTER}, &ReservedBackends, 2, 0, INT_MAX, NULL, NULL }, { - { "shared_buffers", PGC_POSTMASTER }, &NBuffers, + {"shared_buffers", PGC_POSTMASTER}, &NBuffers, DEF_NBUFFERS, 16, INT_MAX, NULL, NULL }, { - { "port", PGC_POSTMASTER }, &PostPortNumber, + {"port", PGC_POSTMASTER}, &PostPortNumber, DEF_PGPORT, 1, 65535, NULL, NULL }, { - { "unix_socket_permissions", PGC_POSTMASTER }, &Unix_socket_permissions, + {"unix_socket_permissions", PGC_POSTMASTER}, &Unix_socket_permissions, 0777, 0000, 0777, NULL, NULL }, { - { "sort_mem", PGC_USERSET }, &SortMem, + {"sort_mem", PGC_USERSET}, &SortMem, 1024, 8 * BLCKSZ / 1024, INT_MAX, NULL, NULL }, { - { "vacuum_mem", PGC_USERSET }, &VacuumMem, + {"vacuum_mem", PGC_USERSET}, &VacuumMem, 8192, 1024, INT_MAX, NULL, NULL }, { - { "max_files_per_process", PGC_BACKEND }, &max_files_per_process, + {"max_files_per_process", PGC_BACKEND}, &max_files_per_process, 1000, 25, INT_MAX, NULL, NULL }, #ifdef LOCK_DEBUG { - { "trace_lock_oidmin", PGC_SUSET }, &Trace_lock_oidmin, + {"trace_lock_oidmin", PGC_SUSET}, &Trace_lock_oidmin, BootstrapObjectIdData, 1, INT_MAX, NULL, NULL }, { - { "trace_lock_table", PGC_SUSET }, &Trace_lock_table, + {"trace_lock_table", PGC_SUSET}, &Trace_lock_table, 0, 0, INT_MAX, NULL, NULL }, #endif { - { "max_expr_depth", PGC_USERSET }, &max_expr_depth, + {"max_expr_depth", PGC_USERSET}, &max_expr_depth, DEFAULT_MAX_EXPR_DEPTH, 10, INT_MAX, NULL, NULL }, { - { "statement_timeout", PGC_USERSET }, &StatementTimeout, + {"statement_timeout", PGC_USERSET}, &StatementTimeout, 0, 0, INT_MAX, NULL, NULL }, { - { "max_fsm_relations", PGC_POSTMASTER }, &MaxFSMRelations, + {"max_fsm_relations", PGC_POSTMASTER}, &MaxFSMRelations, 100, 10, INT_MAX, NULL, NULL }, { - { "max_fsm_pages", PGC_POSTMASTER }, &MaxFSMPages, + {"max_fsm_pages", PGC_POSTMASTER}, &MaxFSMPages, 10000, 1000, INT_MAX, NULL, NULL }, { - { "max_locks_per_transaction", PGC_POSTMASTER }, &max_locks_per_xact, + {"max_locks_per_transaction", PGC_POSTMASTER}, &max_locks_per_xact, 64, 10, INT_MAX, NULL, NULL }, { - { "authentication_timeout", PGC_SIGHUP }, &AuthenticationTimeout, + {"authentication_timeout", PGC_SIGHUP}, &AuthenticationTimeout, 60, 1, 600, NULL, NULL }, { - { "pre_auth_delay", PGC_SIGHUP }, &PreAuthDelay, + {"pre_auth_delay", PGC_SIGHUP}, &PreAuthDelay, 0, 0, 60, NULL, NULL }, { - { "checkpoint_segments", PGC_SIGHUP }, &CheckPointSegments, + {"checkpoint_segments", PGC_SIGHUP}, &CheckPointSegments, 3, 1, INT_MAX, NULL, NULL }, { - { "checkpoint_timeout", PGC_SIGHUP }, &CheckPointTimeout, + {"checkpoint_timeout", PGC_SIGHUP}, &CheckPointTimeout, 300, 30, 3600, NULL, NULL }, { - { "wal_buffers", PGC_POSTMASTER }, &XLOGbuffers, + {"wal_buffers", PGC_POSTMASTER}, &XLOGbuffers, 8, 4, INT_MAX, NULL, NULL }, { - { "wal_debug", PGC_SUSET }, &XLOG_DEBUG, + {"wal_debug", PGC_SUSET}, &XLOG_DEBUG, 0, 0, 16, NULL, NULL }, { - { "commit_delay", PGC_USERSET }, &CommitDelay, + {"commit_delay", PGC_USERSET}, &CommitDelay, 0, 0, 100000, NULL, NULL }, { - { "commit_siblings", PGC_USERSET }, &CommitSiblings, + {"commit_siblings", PGC_USERSET}, &CommitSiblings, 5, 1, 1000, NULL, NULL }, { - { NULL, 0 }, NULL, 0, 0, 0, NULL, NULL + {NULL, 0}, NULL, 0, 0, 0, NULL, NULL } }; @@ -691,40 +691,40 @@ static struct config_real ConfigureNamesReal[] = { { - { "effective_cache_size", PGC_USERSET }, &effective_cache_size, + {"effective_cache_size", PGC_USERSET}, &effective_cache_size, DEFAULT_EFFECTIVE_CACHE_SIZE, 0, DBL_MAX, NULL, NULL }, { - { "random_page_cost", PGC_USERSET }, &random_page_cost, + {"random_page_cost", PGC_USERSET}, &random_page_cost, DEFAULT_RANDOM_PAGE_COST, 0, DBL_MAX, NULL, NULL }, { - { "cpu_tuple_cost", PGC_USERSET }, &cpu_tuple_cost, + {"cpu_tuple_cost", PGC_USERSET}, &cpu_tuple_cost, DEFAULT_CPU_TUPLE_COST, 0, DBL_MAX, NULL, NULL }, { - { "cpu_index_tuple_cost", PGC_USERSET }, &cpu_index_tuple_cost, + {"cpu_index_tuple_cost", PGC_USERSET}, &cpu_index_tuple_cost, DEFAULT_CPU_INDEX_TUPLE_COST, 0, DBL_MAX, NULL, NULL }, { - { "cpu_operator_cost", PGC_USERSET }, &cpu_operator_cost, + {"cpu_operator_cost", PGC_USERSET}, &cpu_operator_cost, DEFAULT_CPU_OPERATOR_COST, 0, DBL_MAX, NULL, NULL }, { - { "geqo_selection_bias", PGC_USERSET }, &Geqo_selection_bias, + {"geqo_selection_bias", PGC_USERSET}, &Geqo_selection_bias, DEFAULT_GEQO_SELECTION_BIAS, MIN_GEQO_SELECTION_BIAS, MAX_GEQO_SELECTION_BIAS, NULL, NULL }, { - { "seed", PGC_USERSET, GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL }, + {"seed", PGC_USERSET, GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL}, &phony_random_seed, 0.5, 0.0, 1.0, assign_random_seed, show_random_seed }, { - { NULL, 0 }, NULL, 0.0, 0.0, 0.0, NULL, NULL + {NULL, 0}, NULL, 0.0, 0.0, 0.0, NULL, NULL } }; @@ -733,126 +733,126 @@ static struct config_string ConfigureNamesString[] = { { - { "client_encoding", PGC_USERSET }, &client_encoding_string, + {"client_encoding", PGC_USERSET}, &client_encoding_string, "SQL_ASCII", assign_client_encoding, NULL }, { - { "client_min_messages", PGC_USERSET }, &client_min_messages_str, + {"client_min_messages", PGC_USERSET}, &client_min_messages_str, client_min_messages_str_default, assign_client_min_messages, NULL }, { - { "log_min_error_statement", PGC_USERSET }, &log_min_error_statement_str, + {"log_min_error_statement", PGC_USERSET}, &log_min_error_statement_str, log_min_error_statement_str_default, assign_min_error_statement, NULL }, { - { "DateStyle", PGC_USERSET, GUC_LIST_INPUT }, &datestyle_string, + {"DateStyle", PGC_USERSET, GUC_LIST_INPUT}, &datestyle_string, "ISO, US", assign_datestyle, show_datestyle }, { - { "default_transaction_isolation", PGC_USERSET }, &default_iso_level_string, + {"default_transaction_isolation", PGC_USERSET}, &default_iso_level_string, "read committed", assign_defaultxactisolevel, NULL }, { - { "dynamic_library_path", PGC_SUSET }, &Dynamic_library_path, + {"dynamic_library_path", PGC_SUSET}, &Dynamic_library_path, "$libdir", NULL, NULL }, { - { "krb_server_keyfile", PGC_POSTMASTER }, &pg_krb_server_keyfile, + {"krb_server_keyfile", PGC_POSTMASTER}, &pg_krb_server_keyfile, PG_KRB_SRVTAB, NULL, NULL }, { - { "lc_messages", PGC_SUSET }, &locale_messages, + {"lc_messages", PGC_SUSET}, &locale_messages, "", locale_messages_assign, NULL }, { - { "lc_monetary", PGC_USERSET }, &locale_monetary, + {"lc_monetary", PGC_USERSET}, &locale_monetary, "", locale_monetary_assign, NULL }, { - { "lc_numeric", PGC_USERSET }, &locale_numeric, + {"lc_numeric", PGC_USERSET}, &locale_numeric, "", locale_numeric_assign, NULL }, { - { "lc_time", PGC_USERSET }, &locale_time, + {"lc_time", PGC_USERSET}, &locale_time, "", locale_time_assign, NULL }, { - { "search_path", PGC_USERSET, GUC_LIST_INPUT | GUC_LIST_QUOTE }, + {"search_path", PGC_USERSET, GUC_LIST_INPUT | GUC_LIST_QUOTE}, &namespace_search_path, "$user,public", assign_search_path, NULL }, { - { "server_encoding", PGC_USERSET }, &server_encoding_string, + {"server_encoding", PGC_USERSET}, &server_encoding_string, "SQL_ASCII", assign_server_encoding, show_server_encoding }, { - { "server_min_messages", PGC_USERSET }, &server_min_messages_str, + {"server_min_messages", PGC_USERSET}, &server_min_messages_str, server_min_messages_str_default, assign_server_min_messages, NULL }, { - { "session_authorization", PGC_USERSET, GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL }, + {"session_authorization", PGC_USERSET, GUC_NO_SHOW_ALL | GUC_NO_RESET_ALL}, &session_authorization_string, NULL, assign_session_authorization, show_session_authorization }, #ifdef HAVE_SYSLOG { - { "syslog_facility", PGC_POSTMASTER }, &Syslog_facility, + {"syslog_facility", PGC_POSTMASTER}, &Syslog_facility, "LOCAL0", assign_facility, NULL }, { - { "syslog_ident", PGC_POSTMASTER }, &Syslog_ident, + {"syslog_ident", PGC_POSTMASTER}, &Syslog_ident, "postgres", NULL, NULL }, #endif { - { "TimeZone", PGC_USERSET }, &timezone_string, + {"TimeZone", PGC_USERSET}, &timezone_string, "UNKNOWN", assign_timezone, show_timezone }, { - { "TRANSACTION ISOLATION LEVEL", PGC_USERSET, GUC_NO_RESET_ALL }, + {"TRANSACTION ISOLATION LEVEL", PGC_USERSET, GUC_NO_RESET_ALL}, &XactIsoLevel_string, NULL, assign_XactIsoLevel, show_XactIsoLevel }, { - { "unix_socket_group", PGC_POSTMASTER }, &Unix_socket_group, + {"unix_socket_group", PGC_POSTMASTER}, &Unix_socket_group, "", NULL, NULL }, { - { "unix_socket_directory", PGC_POSTMASTER }, &UnixSocketDir, + {"unix_socket_directory", PGC_POSTMASTER}, &UnixSocketDir, "", NULL, NULL }, { - { "virtual_host", PGC_POSTMASTER }, &VirtualHost, + {"virtual_host", PGC_POSTMASTER}, &VirtualHost, "", NULL, NULL }, { - { "wal_sync_method", PGC_SIGHUP }, &XLOG_sync_method, + {"wal_sync_method", PGC_SIGHUP}, &XLOG_sync_method, XLOG_sync_method_default, assign_xlog_sync_method, NULL }, { - { NULL, 0 }, NULL, NULL, NULL, NULL + {NULL, 0}, NULL, NULL, NULL, NULL } }; @@ -863,19 +863,19 @@ static struct config_string * Actual lookup of variables is done through this single, sorted array. */ static struct config_generic **guc_variables; -static int num_guc_variables; +static int num_guc_variables; static bool guc_dirty; /* TRUE if need to do commit/abort work */ -static char *guc_string_workspace; /* for avoiding memory leaks */ +static char *guc_string_workspace; /* for avoiding memory leaks */ -static int guc_var_compare(const void *a, const void *b); -static char *_ShowOption(struct config_generic *record); +static int guc_var_compare(const void *a, const void *b); +static char *_ShowOption(struct config_generic * record); /* - * Build the sorted array. This is split out so that it could be + * Build the sorted array. This is split out so that it could be * re-executed after startup (eg, we could allow loadable modules to * add vars, and then we'd need to re-sort). */ @@ -927,16 +927,16 @@ build_guc_variables(void) num_vars = 0; for (i = 0; ConfigureNamesBool[i].gen.name; i++) - guc_vars[num_vars++] = & ConfigureNamesBool[i].gen; + guc_vars[num_vars++] = &ConfigureNamesBool[i].gen; for (i = 0; ConfigureNamesInt[i].gen.name; i++) - guc_vars[num_vars++] = & ConfigureNamesInt[i].gen; + guc_vars[num_vars++] = &ConfigureNamesInt[i].gen; for (i = 0; ConfigureNamesReal[i].gen.name; i++) - guc_vars[num_vars++] = & ConfigureNamesReal[i].gen; + guc_vars[num_vars++] = &ConfigureNamesReal[i].gen; for (i = 0; ConfigureNamesString[i].gen.name; i++) - guc_vars[num_vars++] = & ConfigureNamesString[i].gen; + guc_vars[num_vars++] = &ConfigureNamesString[i].gen; qsort((void *) guc_vars, num_vars, sizeof(struct config_generic *), guc_var_compare); @@ -964,11 +964,11 @@ find_option(const char *name) * by equating const char ** with struct config_generic *, we are * assuming the name field is first in config_generic. */ - res = (struct config_generic**) bsearch((void *) &key, - (void *) guc_variables, - num_guc_variables, - sizeof(struct config_generic *), - guc_var_compare); + res = (struct config_generic **) bsearch((void *) &key, + (void *) guc_variables, + num_guc_variables, + sizeof(struct config_generic *), + guc_var_compare); if (res) return *res; return NULL; @@ -1048,88 +1048,92 @@ InitializeGUCOptions(void) switch (gconf->vartype) { case PGC_BOOL: - { - struct config_bool *conf = (struct config_bool *) gconf; + { + struct config_bool *conf = (struct config_bool *) gconf; - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, false)) - fprintf(stderr, "Failed to initialize %s to %d\n", - conf->gen.name, (int) conf->reset_val); - *conf->variable = conf->reset_val; - conf->session_val = conf->reset_val; - break; - } + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, false)) + fprintf(stderr, "Failed to initialize %s to %d\n", + conf->gen.name, (int) conf->reset_val); + *conf->variable = conf->reset_val; + conf->session_val = conf->reset_val; + break; + } case PGC_INT: - { - struct config_int *conf = (struct config_int *) gconf; + { + struct config_int *conf = (struct config_int *) gconf; - Assert(conf->reset_val >= conf->min); - Assert(conf->reset_val <= conf->max); - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, false)) - fprintf(stderr, "Failed to initialize %s to %d\n", - conf->gen.name, conf->reset_val); - *conf->variable = conf->reset_val; - conf->session_val = conf->reset_val; - break; - } + Assert(conf->reset_val >= conf->min); + Assert(conf->reset_val <= conf->max); + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, false)) + fprintf(stderr, "Failed to initialize %s to %d\n", + conf->gen.name, conf->reset_val); + *conf->variable = conf->reset_val; + conf->session_val = conf->reset_val; + break; + } case PGC_REAL: - { - struct config_real *conf = (struct config_real *) gconf; - - Assert(conf->reset_val >= conf->min); - Assert(conf->reset_val <= conf->max); - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, false)) - fprintf(stderr, "Failed to initialize %s to %g\n", - conf->gen.name, conf->reset_val); - *conf->variable = conf->reset_val; - conf->session_val = conf->reset_val; - break; - } - case PGC_STRING: - { - struct config_string *conf = (struct config_string *) gconf; - char *str; - - *conf->variable = NULL; - conf->reset_val = NULL; - conf->session_val = NULL; - conf->tentative_val = NULL; - - if (conf->boot_val == NULL) { - /* Cannot set value yet */ + struct config_real *conf = (struct config_real *) gconf; + + Assert(conf->reset_val >= conf->min); + Assert(conf->reset_val <= conf->max); + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, false)) + fprintf(stderr, "Failed to initialize %s to %g\n", + conf->gen.name, conf->reset_val); + *conf->variable = conf->reset_val; + conf->session_val = conf->reset_val; break; } - - str = strdup(conf->boot_val); - if (str == NULL) - elog(PANIC, "out of memory"); - conf->reset_val = str; - - if (conf->assign_hook) + case PGC_STRING: { - const char *newstr; + struct config_string *conf = (struct config_string *) gconf; + char *str; + + *conf->variable = NULL; + conf->reset_val = NULL; + conf->session_val = NULL; + conf->tentative_val = NULL; - newstr = (*conf->assign_hook) (str, true, false); - if (newstr == NULL) + if (conf->boot_val == NULL) { - fprintf(stderr, "Failed to initialize %s to '%s'\n", - conf->gen.name, str); + /* Cannot set value yet */ + break; } - else if (newstr != str) + + str = strdup(conf->boot_val); + if (str == NULL) + elog(PANIC, "out of memory"); + conf->reset_val = str; + + if (conf->assign_hook) { - free(str); - /* See notes in set_config_option about casting */ - str = (char *) newstr; - conf->reset_val = str; + const char *newstr; + + newstr = (*conf->assign_hook) (str, true, false); + if (newstr == NULL) + { + fprintf(stderr, "Failed to initialize %s to '%s'\n", + conf->gen.name, str); + } + else if (newstr != str) + { + free(str); + + /* + * See notes in set_config_option about + * casting + */ + str = (char *) newstr; + conf->reset_val = str; + } } + *conf->variable = str; + conf->session_val = str; + break; } - *conf->variable = str; - conf->session_val = str; - break; - } } } @@ -1146,7 +1150,7 @@ InitializeGUCOptions(void) /* * For historical reasons, some GUC parameters can receive defaults - * from environment variables. Process those settings. + * from environment variables. Process those settings. */ env = getenv("PGPORT"); @@ -1192,86 +1196,89 @@ ResetAllOptions(void) switch (gconf->vartype) { case PGC_BOOL: - { - struct config_bool *conf = (struct config_bool *) gconf; + { + struct config_bool *conf = (struct config_bool *) gconf; - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, true)) - elog(ERROR, "Failed to reset %s", conf->gen.name); - *conf->variable = conf->reset_val; - conf->tentative_val = conf->reset_val; - conf->gen.source = conf->gen.reset_source; - conf->gen.tentative_source = conf->gen.reset_source; - conf->gen.status |= GUC_HAVE_TENTATIVE; - guc_dirty = true; - break; - } + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, true)) + elog(ERROR, "Failed to reset %s", conf->gen.name); + *conf->variable = conf->reset_val; + conf->tentative_val = conf->reset_val; + conf->gen.source = conf->gen.reset_source; + conf->gen.tentative_source = conf->gen.reset_source; + conf->gen.status |= GUC_HAVE_TENTATIVE; + guc_dirty = true; + break; + } case PGC_INT: - { - struct config_int *conf = (struct config_int *) gconf; + { + struct config_int *conf = (struct config_int *) gconf; - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, true)) - elog(ERROR, "Failed to reset %s", conf->gen.name); - *conf->variable = conf->reset_val; - conf->tentative_val = conf->reset_val; - conf->gen.source = conf->gen.reset_source; - conf->gen.tentative_source = conf->gen.reset_source; - conf->gen.status |= GUC_HAVE_TENTATIVE; - guc_dirty = true; - break; - } + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, true)) + elog(ERROR, "Failed to reset %s", conf->gen.name); + *conf->variable = conf->reset_val; + conf->tentative_val = conf->reset_val; + conf->gen.source = conf->gen.reset_source; + conf->gen.tentative_source = conf->gen.reset_source; + conf->gen.status |= GUC_HAVE_TENTATIVE; + guc_dirty = true; + break; + } case PGC_REAL: - { - struct config_real *conf = (struct config_real *) gconf; - - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->reset_val, true, true)) - elog(ERROR, "Failed to reset %s", conf->gen.name); - *conf->variable = conf->reset_val; - conf->tentative_val = conf->reset_val; - conf->gen.source = conf->gen.reset_source; - conf->gen.tentative_source = conf->gen.reset_source; - conf->gen.status |= GUC_HAVE_TENTATIVE; - guc_dirty = true; - break; - } - case PGC_STRING: - { - struct config_string *conf = (struct config_string *) gconf; - char *str; - - if (conf->reset_val == NULL) { - /* Nothing to reset to, as yet; so do nothing */ + struct config_real *conf = (struct config_real *) gconf; + + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->reset_val, true, true)) + elog(ERROR, "Failed to reset %s", conf->gen.name); + *conf->variable = conf->reset_val; + conf->tentative_val = conf->reset_val; + conf->gen.source = conf->gen.reset_source; + conf->gen.tentative_source = conf->gen.reset_source; + conf->gen.status |= GUC_HAVE_TENTATIVE; + guc_dirty = true; break; } + case PGC_STRING: + { + struct config_string *conf = (struct config_string *) gconf; + char *str; - /* We need not strdup here */ - str = conf->reset_val; + if (conf->reset_val == NULL) + { + /* Nothing to reset to, as yet; so do nothing */ + break; + } - if (conf->assign_hook) - { - const char *newstr; + /* We need not strdup here */ + str = conf->reset_val; - newstr = (*conf->assign_hook) (str, true, true); - if (newstr == NULL) - elog(ERROR, "Failed to reset %s", conf->gen.name); - else if (newstr != str) + if (conf->assign_hook) { - /* See notes in set_config_option about casting */ - str = (char *) newstr; + const char *newstr; + + newstr = (*conf->assign_hook) (str, true, true); + if (newstr == NULL) + elog(ERROR, "Failed to reset %s", conf->gen.name); + else if (newstr != str) + { + /* + * See notes in set_config_option about + * casting + */ + str = (char *) newstr; + } } - } - SET_STRING_VARIABLE(conf, str); - SET_STRING_TENTATIVE_VAL(conf, str); - conf->gen.source = conf->gen.reset_source; - conf->gen.tentative_source = conf->gen.reset_source; - conf->gen.status |= GUC_HAVE_TENTATIVE; - guc_dirty = true; - break; - } + SET_STRING_VARIABLE(conf, str); + SET_STRING_TENTATIVE_VAL(conf, str); + conf->gen.source = conf->gen.reset_source; + conf->gen.tentative_source = conf->gen.reset_source; + conf->gen.status |= GUC_HAVE_TENTATIVE; + guc_dirty = true; + break; + } } } } @@ -1307,111 +1314,112 @@ AtEOXact_GUC(bool isCommit) switch (gconf->vartype) { case PGC_BOOL: - { - struct config_bool *conf = (struct config_bool *) gconf; - - if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) { - conf->session_val = conf->tentative_val; - conf->gen.session_source = conf->gen.tentative_source; - } + struct config_bool *conf = (struct config_bool *) gconf; - if (*conf->variable != conf->session_val) - { - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->session_val, - true, false)) - elog(LOG, "Failed to commit %s", conf->gen.name); - *conf->variable = conf->session_val; + if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) + { + conf->session_val = conf->tentative_val; + conf->gen.session_source = conf->gen.tentative_source; + } + + if (*conf->variable != conf->session_val) + { + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->session_val, + true, false)) + elog(LOG, "Failed to commit %s", conf->gen.name); + *conf->variable = conf->session_val; + } + conf->gen.source = conf->gen.session_source; + conf->gen.status = 0; + break; } - conf->gen.source = conf->gen.session_source; - conf->gen.status = 0; - break; - } case PGC_INT: - { - struct config_int *conf = (struct config_int *) gconf; - - if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) { - conf->session_val = conf->tentative_val; - conf->gen.session_source = conf->gen.tentative_source; - } + struct config_int *conf = (struct config_int *) gconf; - if (*conf->variable != conf->session_val) - { - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->session_val, - true, false)) - elog(LOG, "Failed to commit %s", conf->gen.name); - *conf->variable = conf->session_val; + if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) + { + conf->session_val = conf->tentative_val; + conf->gen.session_source = conf->gen.tentative_source; + } + + if (*conf->variable != conf->session_val) + { + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->session_val, + true, false)) + elog(LOG, "Failed to commit %s", conf->gen.name); + *conf->variable = conf->session_val; + } + conf->gen.source = conf->gen.session_source; + conf->gen.status = 0; + break; } - conf->gen.source = conf->gen.session_source; - conf->gen.status = 0; - break; - } case PGC_REAL: - { - struct config_real *conf = (struct config_real *) gconf; - - if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) { - conf->session_val = conf->tentative_val; - conf->gen.session_source = conf->gen.tentative_source; - } + struct config_real *conf = (struct config_real *) gconf; - if (*conf->variable != conf->session_val) - { - if (conf->assign_hook) - if (!(*conf->assign_hook) (conf->session_val, - true, false)) - elog(LOG, "Failed to commit %s", conf->gen.name); - *conf->variable = conf->session_val; - } - conf->gen.source = conf->gen.session_source; - conf->gen.status = 0; - break; - } - case PGC_STRING: - { - struct config_string *conf = (struct config_string *) gconf; + if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) + { + conf->session_val = conf->tentative_val; + conf->gen.session_source = conf->gen.tentative_source; + } - if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) - { - SET_STRING_SESSION_VAL(conf, conf->tentative_val); - conf->gen.session_source = conf->gen.tentative_source; - conf->tentative_val = NULL; /* transfer ownership */ + if (*conf->variable != conf->session_val) + { + if (conf->assign_hook) + if (!(*conf->assign_hook) (conf->session_val, + true, false)) + elog(LOG, "Failed to commit %s", conf->gen.name); + *conf->variable = conf->session_val; + } + conf->gen.source = conf->gen.session_source; + conf->gen.status = 0; + break; } - else + case PGC_STRING: { - SET_STRING_TENTATIVE_VAL(conf, NULL); - } + struct config_string *conf = (struct config_string *) gconf; - if (*conf->variable != conf->session_val) - { - char *str = conf->session_val; + if (isCommit && (conf->gen.status & GUC_HAVE_TENTATIVE)) + { + SET_STRING_SESSION_VAL(conf, conf->tentative_val); + conf->gen.session_source = conf->gen.tentative_source; + conf->tentative_val = NULL; /* transfer ownership */ + } + else + SET_STRING_TENTATIVE_VAL(conf, NULL); - if (conf->assign_hook) + if (*conf->variable != conf->session_val) { - const char *newstr; + char *str = conf->session_val; - newstr = (*conf->assign_hook) (str, true, false); - if (newstr == NULL) - elog(LOG, "Failed to commit %s", conf->gen.name); - else if (newstr != str) + if (conf->assign_hook) { - /* See notes in set_config_option about casting */ - str = (char *) newstr; - SET_STRING_SESSION_VAL(conf, str); + const char *newstr; + + newstr = (*conf->assign_hook) (str, true, false); + if (newstr == NULL) + elog(LOG, "Failed to commit %s", conf->gen.name); + else if (newstr != str) + { + /* + * See notes in set_config_option about + * casting + */ + str = (char *) newstr; + SET_STRING_SESSION_VAL(conf, str); + } } - } - SET_STRING_VARIABLE(conf, str); + SET_STRING_VARIABLE(conf, str); + } + conf->gen.source = conf->gen.session_source; + conf->gen.status = 0; + break; } - conf->gen.source = conf->gen.session_source; - conf->gen.status = 0; - break; - } } } @@ -1644,18 +1652,20 @@ set_config_option(const char *name, const char *value, /* Should we report errors interactively? */ interactive = (source >= PGC_S_SESSION); + /* - * Should we set reset/session values? (If so, the behavior is not + * Should we set reset/session values? (If so, the behavior is not * transactional.) */ makeDefault = DoIt && (source <= PGC_S_OVERRIDE) && (value != NULL); /* * Ignore attempted set if overridden by previously processed setting. - * However, if DoIt is false then plow ahead anyway since we are trying - * to find out if the value is potentially good, not actually use it. - * Also keep going if makeDefault is true, since we may want to set - * the reset/session values even if we can't set the variable itself. + * However, if DoIt is false then plow ahead anyway since we are + * trying to find out if the value is potentially good, not actually + * use it. Also keep going if makeDefault is true, since we may want + * to set the reset/session values even if we can't set the variable + * itself. */ if (record->source > source) { @@ -1897,8 +1907,8 @@ set_config_option(const char *name, const char *value, { /* * We could possibly avoid strdup here, but easier to - * make this case work the same as the normal assignment - * case. + * make this case work the same as the normal + * assignment case. */ newval = strdup(conf->reset_val); if (newval == NULL) @@ -1924,7 +1934,7 @@ set_config_option(const char *name, const char *value, if (conf->assign_hook) { - const char *hookresult; + const char *hookresult; hookresult = (*conf->assign_hook) (newval, DoIt, interactive); @@ -1939,13 +1949,15 @@ set_config_option(const char *name, const char *value, else if (hookresult != newval) { free(newval); + /* - * Having to cast away const here is annoying, but the - * alternative is to declare assign_hooks as returning - * char*, which would mean they'd have to cast away - * const, or as both taking and returning char*, which - * doesn't seem attractive either --- we don't want - * them to scribble on the passed str. + * Having to cast away const here is annoying, but + * the alternative is to declare assign_hooks as + * returning char*, which would mean they'd have + * to cast away const, or as both taking and + * returning char*, which doesn't seem attractive + * either --- we don't want them to scribble on + * the passed str. */ newval = (char *) hookresult; } @@ -1992,9 +2004,7 @@ set_config_option(const char *name, const char *value, } } else - { free(newval); - } break; } } @@ -2006,7 +2016,7 @@ set_config_option(const char *name, const char *value, /* * Set a config option to the given value. See also set_config_option, - * this is just the wrapper to be called from outside GUC. NB: this + * this is just the wrapper to be called from outside GUC. NB: this * is used only for non-transactional operations. */ void @@ -2109,7 +2119,7 @@ flatten_set_variable_args(const char *name, List *args) struct config_generic *record; int flags; StringInfoData buf; - List *l; + List *l; /* Fast path if just DEFAULT */ if (args == NIL) @@ -2157,27 +2167,27 @@ flatten_set_variable_args(const char *name, List *args) * Coerce to interval and back to normalize the value * and account for any typmod. */ - Datum interval; - char *intervalout; + Datum interval; + char *intervalout; interval = DirectFunctionCall3(interval_in, CStringGetDatum(val), ObjectIdGetDatum(InvalidOid), - Int32GetDatum(arg->typename->typmod)); + Int32GetDatum(arg->typename->typmod)); intervalout = DatumGetCString(DirectFunctionCall3(interval_out, interval, - ObjectIdGetDatum(InvalidOid), - Int32GetDatum(-1))); + ObjectIdGetDatum(InvalidOid), + Int32GetDatum(-1))); appendStringInfo(&buf, "INTERVAL '%s'", intervalout); } else { /* - * Plain string literal or identifier. For quote mode, - * quote it if it's not a vanilla identifier. + * Plain string literal or identifier. For quote + * mode, quote it if it's not a vanilla identifier. */ if (flags & GUC_LIST_QUOTE) appendStringInfo(&buf, "%s", quote_identifier(val)); @@ -2218,11 +2228,11 @@ SetPGVariable(const char *name, List *args, bool is_local) Datum set_config_by_name(PG_FUNCTION_ARGS) { - char *name; - char *value; - char *new_value; - bool is_local; - text *result_text; + char *name; + char *value; + char *new_value; + bool is_local; + text *result_text; if (PG_ARGISNULL(0)) elog(ERROR, "SET variable name is required"); @@ -2237,8 +2247,8 @@ set_config_by_name(PG_FUNCTION_ARGS) value = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(1))); /* - * Get the desired state of is_local. Default to false - * if provided value is NULL + * Get the desired state of is_local. Default to false if provided + * value is NULL */ if (PG_ARGISNULL(2)) is_local = false; @@ -2300,10 +2310,10 @@ void ShowGUCConfigOption(const char *name) { TupOutputState *tstate; - TupleDesc tupdesc; - CommandDest dest = whereToSendOutput; - const char *varname; - char *value; + TupleDesc tupdesc; + CommandDest dest = whereToSendOutput; + const char *varname; + char *value; /* Get the value and canonical spelling of name */ value = GetConfigOptionByName(name, &varname); @@ -2330,9 +2340,9 @@ ShowAllGUCConfig(void) { int i; TupOutputState *tstate; - TupleDesc tupdesc; - CommandDest dest = whereToSendOutput; - char *values[2]; + TupleDesc tupdesc; + CommandDest dest = whereToSendOutput; + char *values[2]; /* need a tuple descriptor representing two TEXT columns */ tupdesc = CreateTemplateTupleDesc(2, false); @@ -2424,9 +2434,9 @@ GetNumConfigOptions(void) Datum show_config_by_name(PG_FUNCTION_ARGS) { - char *varname; - char *varval; - text *result_text; + char *varname; + char *varval; + text *result_text; /* Get the GUC variable name */ varname = DatumGetCString(DirectFunctionCall1(textout, PG_GETARG_DATUM(0))); @@ -2448,21 +2458,24 @@ show_config_by_name(PG_FUNCTION_ARGS) Datum show_all_settings(PG_FUNCTION_ARGS) { - FuncCallContext *funcctx; - TupleDesc tupdesc; - int call_cntr; - int max_calls; - TupleTableSlot *slot; - AttInMetadata *attinmeta; - MemoryContext oldcontext; + FuncCallContext *funcctx; + TupleDesc tupdesc; + int call_cntr; + int max_calls; + TupleTableSlot *slot; + AttInMetadata *attinmeta; + MemoryContext oldcontext; /* stuff done only on the first call of the function */ - if(SRF_IS_FIRSTCALL()) - { + if (SRF_IS_FIRSTCALL()) + { /* create a function context for cross-call persistence */ - funcctx = SRF_FIRSTCALL_INIT(); + funcctx = SRF_FIRSTCALL_INIT(); - /* switch to memory context appropriate for multiple function calls */ + /* + * switch to memory context appropriate for multiple function + * calls + */ oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx); /* need a tuple descriptor representing two TEXT columns */ @@ -2479,8 +2492,8 @@ show_all_settings(PG_FUNCTION_ARGS) funcctx->slot = slot; /* - * Generate attribute metadata needed later to produce tuples from raw - * C strings + * Generate attribute metadata needed later to produce tuples from + * raw C strings */ attinmeta = TupleDescGetAttInMetadata(tupdesc); funcctx->attinmeta = attinmeta; @@ -2489,18 +2502,18 @@ show_all_settings(PG_FUNCTION_ARGS) funcctx->max_calls = GetNumConfigOptions(); MemoryContextSwitchTo(oldcontext); - } + } /* stuff done on every call of the function */ - funcctx = SRF_PERCALL_SETUP(); + funcctx = SRF_PERCALL_SETUP(); call_cntr = funcctx->call_cntr; max_calls = funcctx->max_calls; slot = funcctx->slot; attinmeta = funcctx->attinmeta; - if (call_cntr < max_calls) /* do when there is more left to send */ - { + if (call_cntr < max_calls) /* do when there is more left to send */ + { char *values[2]; char *varname; char *varval; @@ -2527,14 +2540,14 @@ show_all_settings(PG_FUNCTION_ARGS) /* make sure we haven't gone too far now */ if (call_cntr >= max_calls) - SRF_RETURN_DONE(funcctx); + SRF_RETURN_DONE(funcctx); } } while (noshow); /* - * Prepare a values array for storage in our slot. - * This should be an array of C strings which will - * be processed later by the appropriate "in" functions. + * Prepare a values array for storage in our slot. This should be + * an array of C strings which will be processed later by the + * appropriate "in" functions. */ values[0] = varname; values[1] = varval; @@ -2549,16 +2562,15 @@ show_all_settings(PG_FUNCTION_ARGS) if (varval != NULL) pfree(varval); - SRF_RETURN_NEXT(funcctx, result); - } - else /* do when there is no more left */ - { - SRF_RETURN_DONE(funcctx); - } + SRF_RETURN_NEXT(funcctx, result); + } + else +/* do when there is no more left */ + SRF_RETURN_DONE(funcctx); } static char * -_ShowOption(struct config_generic *record) +_ShowOption(struct config_generic * record) { char buffer[256]; const char *val; @@ -2699,7 +2711,6 @@ assign_facility(const char *facility, bool doit, bool interactive) return facility; return NULL; } - #endif @@ -2707,9 +2718,15 @@ static const char * assign_defaultxactisolevel(const char *newval, bool doit, bool interactive) { if (strcasecmp(newval, "serializable") == 0) - { if (doit) DefaultXactIsoLevel = XACT_SERIALIZABLE; } + { + if (doit) + DefaultXactIsoLevel = XACT_SERIALIZABLE; + } else if (strcasecmp(newval, "read committed") == 0) - { if (doit) DefaultXactIsoLevel = XACT_READ_COMMITTED; } + { + if (doit) + DefaultXactIsoLevel = XACT_READ_COMMITTED; + } else return NULL; return newval; @@ -2723,7 +2740,7 @@ assign_defaultxactisolevel(const char *newval, bool doit, bool interactive) void ProcessGUCArray(ArrayType *array, GucSource source) { - int i; + int i; Assert(array != NULL); Assert(ARR_ELEMTYPE(array) == TEXTOID); @@ -2740,10 +2757,10 @@ ProcessGUCArray(ArrayType *array, GucSource source) char *value; d = array_ref(array, 1, &i, - -1 /*varlenarray*/, - -1 /*TEXT's typlen*/, - false /*TEXT's typbyval*/, - 'i' /*TEXT's typalign*/, + -1 /* varlenarray */ , + -1 /* TEXT's typlen */ , + false /* TEXT's typbyval */ , + 'i' /* TEXT's typalign */ , &isnull); if (isnull) @@ -2760,8 +2777,8 @@ ProcessGUCArray(ArrayType *array, GucSource source) } /* - * We process all these options at SUSET level. We assume that the - * right to insert an option into pg_database or pg_shadow was + * We process all these options at SUSET level. We assume that + * the right to insert an option into pg_database or pg_shadow was * checked when it was inserted. */ SetConfigOption(name, value, PGC_SUSET, source); @@ -2795,15 +2812,15 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) if (array) { - int index; - bool isnull; - int i; + int index; + bool isnull; + int i; Assert(ARR_ELEMTYPE(array) == TEXTOID); Assert(ARR_NDIM(array) == 1); Assert(ARR_LBOUND(array)[0] == 1); - index = ARR_DIMS(array)[0] + 1; /* add after end */ + index = ARR_DIMS(array)[0] + 1; /* add after end */ for (i = 1; i <= ARR_DIMS(array)[0]; i++) { @@ -2811,15 +2828,15 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) char *current; d = array_ref(array, 1, &i, - -1 /*varlenarray*/, - -1 /*TEXT's typlen*/, - false /*TEXT's typbyval*/, - 'i' /*TEXT's typalign*/, + -1 /* varlenarray */ , + -1 /* TEXT's typlen */ , + false /* TEXT's typbyval */ , + 'i' /* TEXT's typalign */ , &isnull); if (isnull) continue; current = DatumGetCString(DirectFunctionCall1(textout, d)); - if (strncmp(current, newval, strlen(name) + 1)==0) + if (strncmp(current, newval, strlen(name) + 1) == 0) { index = i; break; @@ -2829,10 +2846,10 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) isnull = false; a = array_set(array, 1, &index, datum, - -1 /*varlenarray*/, - -1 /*TEXT's typlen*/, - false /*TEXT's typbyval*/, - 'i' /*TEXT's typalign*/, + -1 /* varlenarray */ , + -1 /* TEXT's typlen */ , + false /* TEXT's typbyval */ , + 'i' /* TEXT's typalign */ , &isnull); } else @@ -2848,9 +2865,9 @@ GUCArrayAdd(ArrayType *array, const char *name, const char *value) ArrayType * GUCArrayDelete(ArrayType *array, const char *name) { - ArrayType *newarray; - int i; - int index; + ArrayType *newarray; + int i; + int index; Assert(name); Assert(array); @@ -2872,26 +2889,26 @@ GUCArrayDelete(ArrayType *array, const char *name) bool isnull; d = array_ref(array, 1, &i, - -1 /*varlenarray*/, - -1 /*TEXT's typlen*/, - false /*TEXT's typbyval*/, - 'i' /*TEXT's typalign*/, + -1 /* varlenarray */ , + -1 /* TEXT's typlen */ , + false /* TEXT's typbyval */ , + 'i' /* TEXT's typalign */ , &isnull); if (isnull) continue; val = DatumGetCString(DirectFunctionCall1(textout, d)); - if (strncmp(val, name, strlen(name))==0 + if (strncmp(val, name, strlen(name)) == 0 && val[strlen(name)] == '=') continue; isnull = false; newarray = array_set(newarray, 1, &index, d, - -1 /*varlenarray*/, - -1 /*TEXT's typlen*/, - false /*TEXT's typbyval*/, - 'i' /*TEXT's typalign*/, + -1 /* varlenarray */ , + -1 /* TEXT's typlen */ , + false /* TEXT's typbyval */ , + 'i' /* TEXT's typalign */ , &isnull); index++; } @@ -2903,49 +2920,81 @@ const char * assign_server_min_messages(const char *newval, bool doit, bool interactive) { - return(assign_msglvl(&server_min_messages,newval,doit,interactive)); + return (assign_msglvl(&server_min_messages, newval, doit, interactive)); } const char * assign_client_min_messages(const char *newval, bool doit, bool interactive) { - return(assign_msglvl(&client_min_messages,newval,doit,interactive)); + return (assign_msglvl(&client_min_messages, newval, doit, interactive)); } const char * assign_min_error_statement(const char *newval, bool doit, bool interactive) { - return(assign_msglvl(&log_min_error_statement,newval,doit,interactive)); + return (assign_msglvl(&log_min_error_statement, newval, doit, interactive)); } static const char * assign_msglvl(int *var, const char *newval, bool doit, bool interactive) { if (strcasecmp(newval, "debug") == 0) - { if (doit) (*var) = DEBUG1; } + { + if (doit) + (*var) = DEBUG1; + } else if (strcasecmp(newval, "debug5") == 0) - { if (doit) (*var) = DEBUG5; } + { + if (doit) + (*var) = DEBUG5; + } else if (strcasecmp(newval, "debug4") == 0) - { if (doit) (*var) = DEBUG4; } + { + if (doit) + (*var) = DEBUG4; + } else if (strcasecmp(newval, "debug3") == 0) - { if (doit) (*var) = DEBUG3; } + { + if (doit) + (*var) = DEBUG3; + } else if (strcasecmp(newval, "debug2") == 0) - { if (doit) (*var) = DEBUG2; } + { + if (doit) + (*var) = DEBUG2; + } else if (strcasecmp(newval, "debug1") == 0) - { if (doit) (*var) = DEBUG1; } + { + if (doit) + (*var) = DEBUG1; + } else if (strcasecmp(newval, "log") == 0) - { if (doit) (*var) = LOG; } + { + if (doit) + (*var) = LOG; + } else if (strcasecmp(newval, "info") == 0) - { if (doit) (*var) = INFO; } + { + if (doit) + (*var) = INFO; + } else if (strcasecmp(newval, "notice") == 0) - { if (doit) (*var) = NOTICE; } + { + if (doit) + (*var) = NOTICE; + } else if (strcasecmp(newval, "warning") == 0) - { if (doit) (*var) = WARNING; } + { + if (doit) + (*var) = WARNING; + } else if (strcasecmp(newval, "error") == 0) - { if (doit) (*var) = ERROR; } + { + if (doit) + (*var) = ERROR; + } else return NULL; /* fail */ return newval; /* OK */ } - diff --git a/src/backend/utils/misc/ps_status.c b/src/backend/utils/misc/ps_status.c index c6e335561f..a87d620703 100644 --- a/src/backend/utils/misc/ps_status.c +++ b/src/backend/utils/misc/ps_status.c @@ -5,7 +5,7 @@ * to contain some useful information. Mechanism differs wildly across * platforms. * - * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.12 2001/12/21 15:22:09 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/misc/ps_status.c,v 1.13 2002/09/04 20:31:33 momjian Exp $ * * Copyright 2000 by PostgreSQL Global Development Group * various details abducted from various places @@ -265,7 +265,7 @@ set_ps_display(const char *activity) #ifdef PS_USE_CLOBBER_ARGV { - int buflen; + int buflen; /* pad unused memory */ buflen = strlen(ps_buffer); diff --git a/src/backend/utils/mmgr/aset.c b/src/backend/utils/mmgr/aset.c index 9cfcabbc9f..bafe9153e8 100644 --- a/src/backend/utils/mmgr/aset.c +++ b/src/backend/utils/mmgr/aset.c @@ -11,7 +11,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.47 2002/08/12 00:36:12 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/mmgr/aset.c,v 1.48 2002/09/04 20:31:33 momjian Exp $ * * NOTE: * This is a new (Feb. 05, 1999) implementation of the allocation set @@ -206,6 +206,7 @@ static void AllocSetReset(MemoryContext context); static void AllocSetDelete(MemoryContext context); static Size AllocSetGetChunkSpace(MemoryContext context, void *pointer); static void AllocSetStats(MemoryContext context); + #ifdef MEMORY_CONTEXT_CHECKING static void AllocSetCheck(MemoryContext context); #endif @@ -223,7 +224,7 @@ static MemoryContextMethods AllocSetMethods = { AllocSetGetChunkSpace, AllocSetStats #ifdef MEMORY_CONTEXT_CHECKING - , AllocSetCheck + ,AllocSetCheck #endif }; diff --git a/src/backend/utils/sort/tuplesort.c b/src/backend/utils/sort/tuplesort.c index 53ea0fa75b..6dfbd95bf1 100644 --- a/src/backend/utils/sort/tuplesort.c +++ b/src/backend/utils/sort/tuplesort.c @@ -78,7 +78,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.26 2002/08/24 15:00:46 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/sort/tuplesort.c,v 1.27 2002/09/04 20:31:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -1854,8 +1854,8 @@ comparetup_index(Tuplesortstate *state, const void *a, const void *b) * otherwise the sort algorithm wouldn't have checked whether one must * appear before the other. * - * Some rather brain-dead implementations of qsort will sometimes - * call the comparison routine to compare a value to itself. (At this + * Some rather brain-dead implementations of qsort will sometimes call + * the comparison routine to compare a value to itself. (At this * writing only QNX 4 is known to do such silly things.) Don't raise * a bogus error in that case. */ diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c index 0cc88167da..f5314526b8 100644 --- a/src/backend/utils/time/tqual.c +++ b/src/backend/utils/time/tqual.c @@ -6,7 +6,7 @@ * NOTE: all the HeapTupleSatisfies routines will update the tuple's * "hint" status bits if we see that the inserting or deleting transaction * has now committed or aborted. The caller is responsible for noticing any - * change in t_infomask and scheduling a disk write if so. Note that the + * change in t_infomask and scheduling a disk write if so. Note that the * caller must hold at least a shared buffer context lock on the buffer * containing the tuple. (VACUUM FULL assumes it's sufficient to have * exclusive lock on the containing relation, instead.) @@ -16,7 +16,7 @@ * Portions Copyright (c) 1994, Regents of the University of California * * IDENTIFICATION - * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.59 2002/09/02 01:05:06 tgl Exp $ + * $Header: /cvsroot/pgsql/src/backend/utils/time/tqual.c,v 1.60 2002/09/04 20:31:33 momjian Exp $ * *------------------------------------------------------------------------- */ @@ -309,7 +309,7 @@ HeapTupleSatisfiesNow(HeapTupleHeader tuple) * This is a simplified version that only checks for VACUUM moving conditions. * It's appropriate for TOAST usage because TOAST really doesn't want to do * its own time qual checks; if you can see the main table row that contains - * a TOAST reference, you should be able to see the TOASTed value. However, + * a TOAST reference, you should be able to see the TOASTed value. However, * vacuuming a TOAST table is independent of the main table, and in case such * a vacuum fails partway through, we'd better do this much checking. * @@ -412,7 +412,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid) return HeapTupleInvisible; /* inserted after scan * started */ - if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ + if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid */ return HeapTupleMayBeUpdated; Assert(TransactionIdIsCurrentTransactionId(HeapTupleHeaderGetXmax(tuple))); @@ -430,7 +430,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid) else if (!TransactionIdDidCommit(HeapTupleHeaderGetXmin(tuple))) { if (TransactionIdDidAbort(HeapTupleHeaderGetXmin(tuple))) - tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ + tuple->t_infomask |= HEAP_XMIN_INVALID; /* aborted */ return HeapTupleInvisible; } else @@ -439,7 +439,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htuple, CommandId curcid) /* by here, the inserting transaction has committed */ - if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */ + if (tuple->t_infomask & HEAP_XMAX_INVALID) /* xid invalid or aborted */ return HeapTupleMayBeUpdated; if (tuple->t_infomask & HEAP_XMAX_COMMITTED) @@ -701,7 +701,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) * when... */ if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmin(tuple), - snapshot->xmin)) + snapshot->xmin)) { uint32 i; @@ -712,7 +712,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) for (i = 0; i < snapshot->xcnt; i++) { if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple), - snapshot->xip[i])) + snapshot->xip[i])) return false; } } @@ -752,7 +752,7 @@ HeapTupleSatisfiesSnapshot(HeapTupleHeader tuple, Snapshot snapshot) uint32 i; if (TransactionIdFollowsOrEquals(HeapTupleHeaderGetXmax(tuple), - snapshot->xmax)) + snapshot->xmax)) return true; for (i = 0; i < snapshot->xcnt; i++) { @@ -867,7 +867,8 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) return HEAPTUPLE_LIVE; if (TransactionIdDidCommit(HeapTupleHeaderGetXmax(tuple))) tuple->t_infomask |= HEAP_XMAX_COMMITTED; - else /* it's either aborted or crashed */ + else +/* it's either aborted or crashed */ tuple->t_infomask |= HEAP_XMAX_INVALID; } return HEAPTUPLE_LIVE; @@ -902,7 +903,7 @@ HeapTupleSatisfiesVacuum(HeapTupleHeader tuple, TransactionId OldestXmin) */ if (TransactionIdEquals(HeapTupleHeaderGetXmin(tuple), - HeapTupleHeaderGetXmax(tuple))) + HeapTupleHeaderGetXmax(tuple))) { /* * inserter also deleted it, so it was never visible to anyone |